1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_netemul_test__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct CounterConnectToProtocolRequest {
16 pub protocol_name: String,
17 pub request: fidl::Channel,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21 for CounterConnectToProtocolRequest
22{
23}
24
25#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct CounterOpenInNamespaceRequest {
27 pub path: String,
28 pub flags: fidl_fuchsia_io::Flags,
29 pub request: fidl::Channel,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
33 for CounterOpenInNamespaceRequest
34{
35}
36
37#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
38pub struct CounterMarker;
39
40impl fidl::endpoints::ProtocolMarker for CounterMarker {
41 type Proxy = CounterProxy;
42 type RequestStream = CounterRequestStream;
43 #[cfg(target_os = "fuchsia")]
44 type SynchronousProxy = CounterSynchronousProxy;
45
46 const DEBUG_NAME: &'static str = "fuchsia.netemul.test.Counter";
47}
48impl fidl::endpoints::DiscoverableProtocolMarker for CounterMarker {}
49pub type CounterTryOpenDirectoryResult = Result<(), i32>;
50
51pub trait CounterProxyInterface: Send + Sync {
52 type IncrementResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
53 fn r#increment(&self) -> Self::IncrementResponseFut;
54 fn r#connect_to_protocol(
55 &self,
56 protocol_name: &str,
57 request: fidl::Channel,
58 ) -> Result<(), fidl::Error>;
59 fn r#open_in_namespace(
60 &self,
61 path: &str,
62 flags: fidl_fuchsia_io::Flags,
63 request: fidl::Channel,
64 ) -> Result<(), fidl::Error>;
65 type TryOpenDirectoryResponseFut: std::future::Future<Output = Result<CounterTryOpenDirectoryResult, fidl::Error>>
66 + Send;
67 fn r#try_open_directory(&self, path: &str) -> Self::TryOpenDirectoryResponseFut;
68 type SetAbortOnShutdownResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
69 fn r#set_abort_on_shutdown(&self, abort: bool) -> Self::SetAbortOnShutdownResponseFut;
70}
71#[derive(Debug)]
72#[cfg(target_os = "fuchsia")]
73pub struct CounterSynchronousProxy {
74 client: fidl::client::sync::Client,
75}
76
77#[cfg(target_os = "fuchsia")]
78impl fidl::endpoints::SynchronousProxy for CounterSynchronousProxy {
79 type Proxy = CounterProxy;
80 type Protocol = CounterMarker;
81
82 fn from_channel(inner: fidl::Channel) -> Self {
83 Self::new(inner)
84 }
85
86 fn into_channel(self) -> fidl::Channel {
87 self.client.into_channel()
88 }
89
90 fn as_channel(&self) -> &fidl::Channel {
91 self.client.as_channel()
92 }
93}
94
95#[cfg(target_os = "fuchsia")]
96impl CounterSynchronousProxy {
97 pub fn new(channel: fidl::Channel) -> Self {
98 let protocol_name = <CounterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
99 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
100 }
101
102 pub fn into_channel(self) -> fidl::Channel {
103 self.client.into_channel()
104 }
105
106 pub fn wait_for_event(
109 &self,
110 deadline: zx::MonotonicInstant,
111 ) -> Result<CounterEvent, fidl::Error> {
112 CounterEvent::decode(self.client.wait_for_event(deadline)?)
113 }
114
115 pub fn r#increment(&self, ___deadline: zx::MonotonicInstant) -> Result<u32, fidl::Error> {
117 let _response =
118 self.client.send_query::<fidl::encoding::EmptyPayload, CounterIncrementResponse>(
119 (),
120 0x60cf610cd915d7a9,
121 fidl::encoding::DynamicFlags::empty(),
122 ___deadline,
123 )?;
124 Ok(_response.value)
125 }
126
127 pub fn r#connect_to_protocol(
130 &self,
131 mut protocol_name: &str,
132 mut request: fidl::Channel,
133 ) -> Result<(), fidl::Error> {
134 self.client.send::<CounterConnectToProtocolRequest>(
135 (protocol_name, request),
136 0x75ea8d3a0e7a4f68,
137 fidl::encoding::DynamicFlags::empty(),
138 )
139 }
140
141 pub fn r#open_in_namespace(
152 &self,
153 mut path: &str,
154 mut flags: fidl_fuchsia_io::Flags,
155 mut request: fidl::Channel,
156 ) -> Result<(), fidl::Error> {
157 self.client.send::<CounterOpenInNamespaceRequest>(
158 (path, flags, request),
159 0x393b5808935aee83,
160 fidl::encoding::DynamicFlags::empty(),
161 )
162 }
163
164 pub fn r#try_open_directory(
170 &self,
171 mut path: &str,
172 ___deadline: zx::MonotonicInstant,
173 ) -> Result<CounterTryOpenDirectoryResult, fidl::Error> {
174 let _response = self.client.send_query::<
175 CounterTryOpenDirectoryRequest,
176 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
177 >(
178 (path,),
179 0x37310702b1c8b863,
180 fidl::encoding::DynamicFlags::empty(),
181 ___deadline,
182 )?;
183 Ok(_response.map(|x| x))
184 }
185
186 pub fn r#set_abort_on_shutdown(
191 &self,
192 mut abort: bool,
193 ___deadline: zx::MonotonicInstant,
194 ) -> Result<(), fidl::Error> {
195 let _response = self
196 .client
197 .send_query::<CounterSetAbortOnShutdownRequest, fidl::encoding::EmptyPayload>(
198 (abort,),
199 0x1d9c7aac19741829,
200 fidl::encoding::DynamicFlags::empty(),
201 ___deadline,
202 )?;
203 Ok(_response)
204 }
205}
206
207#[cfg(target_os = "fuchsia")]
208impl From<CounterSynchronousProxy> for zx::Handle {
209 fn from(value: CounterSynchronousProxy) -> Self {
210 value.into_channel().into()
211 }
212}
213
214#[cfg(target_os = "fuchsia")]
215impl From<fidl::Channel> for CounterSynchronousProxy {
216 fn from(value: fidl::Channel) -> Self {
217 Self::new(value)
218 }
219}
220
221#[cfg(target_os = "fuchsia")]
222impl fidl::endpoints::FromClient for CounterSynchronousProxy {
223 type Protocol = CounterMarker;
224
225 fn from_client(value: fidl::endpoints::ClientEnd<CounterMarker>) -> Self {
226 Self::new(value.into_channel())
227 }
228}
229
230#[derive(Debug, Clone)]
231pub struct CounterProxy {
232 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
233}
234
235impl fidl::endpoints::Proxy for CounterProxy {
236 type Protocol = CounterMarker;
237
238 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
239 Self::new(inner)
240 }
241
242 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
243 self.client.into_channel().map_err(|client| Self { client })
244 }
245
246 fn as_channel(&self) -> &::fidl::AsyncChannel {
247 self.client.as_channel()
248 }
249}
250
251impl CounterProxy {
252 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
254 let protocol_name = <CounterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
255 Self { client: fidl::client::Client::new(channel, protocol_name) }
256 }
257
258 pub fn take_event_stream(&self) -> CounterEventStream {
264 CounterEventStream { event_receiver: self.client.take_event_receiver() }
265 }
266
267 pub fn r#increment(
269 &self,
270 ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
271 CounterProxyInterface::r#increment(self)
272 }
273
274 pub fn r#connect_to_protocol(
277 &self,
278 mut protocol_name: &str,
279 mut request: fidl::Channel,
280 ) -> Result<(), fidl::Error> {
281 CounterProxyInterface::r#connect_to_protocol(self, protocol_name, request)
282 }
283
284 pub fn r#open_in_namespace(
295 &self,
296 mut path: &str,
297 mut flags: fidl_fuchsia_io::Flags,
298 mut request: fidl::Channel,
299 ) -> Result<(), fidl::Error> {
300 CounterProxyInterface::r#open_in_namespace(self, path, flags, request)
301 }
302
303 pub fn r#try_open_directory(
309 &self,
310 mut path: &str,
311 ) -> fidl::client::QueryResponseFut<
312 CounterTryOpenDirectoryResult,
313 fidl::encoding::DefaultFuchsiaResourceDialect,
314 > {
315 CounterProxyInterface::r#try_open_directory(self, path)
316 }
317
318 pub fn r#set_abort_on_shutdown(
323 &self,
324 mut abort: bool,
325 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
326 CounterProxyInterface::r#set_abort_on_shutdown(self, abort)
327 }
328}
329
330impl CounterProxyInterface for CounterProxy {
331 type IncrementResponseFut =
332 fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
333 fn r#increment(&self) -> Self::IncrementResponseFut {
334 fn _decode(
335 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
336 ) -> Result<u32, fidl::Error> {
337 let _response = fidl::client::decode_transaction_body::<
338 CounterIncrementResponse,
339 fidl::encoding::DefaultFuchsiaResourceDialect,
340 0x60cf610cd915d7a9,
341 >(_buf?)?;
342 Ok(_response.value)
343 }
344 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
345 (),
346 0x60cf610cd915d7a9,
347 fidl::encoding::DynamicFlags::empty(),
348 _decode,
349 )
350 }
351
352 fn r#connect_to_protocol(
353 &self,
354 mut protocol_name: &str,
355 mut request: fidl::Channel,
356 ) -> Result<(), fidl::Error> {
357 self.client.send::<CounterConnectToProtocolRequest>(
358 (protocol_name, request),
359 0x75ea8d3a0e7a4f68,
360 fidl::encoding::DynamicFlags::empty(),
361 )
362 }
363
364 fn r#open_in_namespace(
365 &self,
366 mut path: &str,
367 mut flags: fidl_fuchsia_io::Flags,
368 mut request: fidl::Channel,
369 ) -> Result<(), fidl::Error> {
370 self.client.send::<CounterOpenInNamespaceRequest>(
371 (path, flags, request),
372 0x393b5808935aee83,
373 fidl::encoding::DynamicFlags::empty(),
374 )
375 }
376
377 type TryOpenDirectoryResponseFut = fidl::client::QueryResponseFut<
378 CounterTryOpenDirectoryResult,
379 fidl::encoding::DefaultFuchsiaResourceDialect,
380 >;
381 fn r#try_open_directory(&self, mut path: &str) -> Self::TryOpenDirectoryResponseFut {
382 fn _decode(
383 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
384 ) -> Result<CounterTryOpenDirectoryResult, fidl::Error> {
385 let _response = fidl::client::decode_transaction_body::<
386 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
387 fidl::encoding::DefaultFuchsiaResourceDialect,
388 0x37310702b1c8b863,
389 >(_buf?)?;
390 Ok(_response.map(|x| x))
391 }
392 self.client
393 .send_query_and_decode::<CounterTryOpenDirectoryRequest, CounterTryOpenDirectoryResult>(
394 (path,),
395 0x37310702b1c8b863,
396 fidl::encoding::DynamicFlags::empty(),
397 _decode,
398 )
399 }
400
401 type SetAbortOnShutdownResponseFut =
402 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
403 fn r#set_abort_on_shutdown(&self, mut abort: bool) -> Self::SetAbortOnShutdownResponseFut {
404 fn _decode(
405 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
406 ) -> Result<(), fidl::Error> {
407 let _response = fidl::client::decode_transaction_body::<
408 fidl::encoding::EmptyPayload,
409 fidl::encoding::DefaultFuchsiaResourceDialect,
410 0x1d9c7aac19741829,
411 >(_buf?)?;
412 Ok(_response)
413 }
414 self.client.send_query_and_decode::<CounterSetAbortOnShutdownRequest, ()>(
415 (abort,),
416 0x1d9c7aac19741829,
417 fidl::encoding::DynamicFlags::empty(),
418 _decode,
419 )
420 }
421}
422
423pub struct CounterEventStream {
424 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
425}
426
427impl std::marker::Unpin for CounterEventStream {}
428
429impl futures::stream::FusedStream for CounterEventStream {
430 fn is_terminated(&self) -> bool {
431 self.event_receiver.is_terminated()
432 }
433}
434
435impl futures::Stream for CounterEventStream {
436 type Item = Result<CounterEvent, fidl::Error>;
437
438 fn poll_next(
439 mut self: std::pin::Pin<&mut Self>,
440 cx: &mut std::task::Context<'_>,
441 ) -> std::task::Poll<Option<Self::Item>> {
442 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
443 &mut self.event_receiver,
444 cx
445 )?) {
446 Some(buf) => std::task::Poll::Ready(Some(CounterEvent::decode(buf))),
447 None => std::task::Poll::Ready(None),
448 }
449 }
450}
451
452#[derive(Debug)]
453pub enum CounterEvent {}
454
455impl CounterEvent {
456 fn decode(
458 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
459 ) -> Result<CounterEvent, fidl::Error> {
460 let (bytes, _handles) = buf.split_mut();
461 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
462 debug_assert_eq!(tx_header.tx_id, 0);
463 match tx_header.ordinal {
464 _ => Err(fidl::Error::UnknownOrdinal {
465 ordinal: tx_header.ordinal,
466 protocol_name: <CounterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
467 }),
468 }
469 }
470}
471
472pub struct CounterRequestStream {
474 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
475 is_terminated: bool,
476}
477
478impl std::marker::Unpin for CounterRequestStream {}
479
480impl futures::stream::FusedStream for CounterRequestStream {
481 fn is_terminated(&self) -> bool {
482 self.is_terminated
483 }
484}
485
486impl fidl::endpoints::RequestStream for CounterRequestStream {
487 type Protocol = CounterMarker;
488 type ControlHandle = CounterControlHandle;
489
490 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
491 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
492 }
493
494 fn control_handle(&self) -> Self::ControlHandle {
495 CounterControlHandle { inner: self.inner.clone() }
496 }
497
498 fn into_inner(
499 self,
500 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
501 {
502 (self.inner, self.is_terminated)
503 }
504
505 fn from_inner(
506 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
507 is_terminated: bool,
508 ) -> Self {
509 Self { inner, is_terminated }
510 }
511}
512
513impl futures::Stream for CounterRequestStream {
514 type Item = Result<CounterRequest, fidl::Error>;
515
516 fn poll_next(
517 mut self: std::pin::Pin<&mut Self>,
518 cx: &mut std::task::Context<'_>,
519 ) -> std::task::Poll<Option<Self::Item>> {
520 let this = &mut *self;
521 if this.inner.check_shutdown(cx) {
522 this.is_terminated = true;
523 return std::task::Poll::Ready(None);
524 }
525 if this.is_terminated {
526 panic!("polled CounterRequestStream after completion");
527 }
528 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
529 |bytes, handles| {
530 match this.inner.channel().read_etc(cx, bytes, handles) {
531 std::task::Poll::Ready(Ok(())) => {}
532 std::task::Poll::Pending => return std::task::Poll::Pending,
533 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
534 this.is_terminated = true;
535 return std::task::Poll::Ready(None);
536 }
537 std::task::Poll::Ready(Err(e)) => {
538 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
539 e.into(),
540 ))))
541 }
542 }
543
544 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
546
547 std::task::Poll::Ready(Some(match header.ordinal {
548 0x60cf610cd915d7a9 => {
549 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
550 let mut req = fidl::new_empty!(
551 fidl::encoding::EmptyPayload,
552 fidl::encoding::DefaultFuchsiaResourceDialect
553 );
554 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
555 let control_handle = CounterControlHandle { inner: this.inner.clone() };
556 Ok(CounterRequest::Increment {
557 responder: CounterIncrementResponder {
558 control_handle: std::mem::ManuallyDrop::new(control_handle),
559 tx_id: header.tx_id,
560 },
561 })
562 }
563 0x75ea8d3a0e7a4f68 => {
564 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
565 let mut req = fidl::new_empty!(
566 CounterConnectToProtocolRequest,
567 fidl::encoding::DefaultFuchsiaResourceDialect
568 );
569 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CounterConnectToProtocolRequest>(&header, _body_bytes, handles, &mut req)?;
570 let control_handle = CounterControlHandle { inner: this.inner.clone() };
571 Ok(CounterRequest::ConnectToProtocol {
572 protocol_name: req.protocol_name,
573 request: req.request,
574
575 control_handle,
576 })
577 }
578 0x393b5808935aee83 => {
579 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
580 let mut req = fidl::new_empty!(
581 CounterOpenInNamespaceRequest,
582 fidl::encoding::DefaultFuchsiaResourceDialect
583 );
584 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CounterOpenInNamespaceRequest>(&header, _body_bytes, handles, &mut req)?;
585 let control_handle = CounterControlHandle { inner: this.inner.clone() };
586 Ok(CounterRequest::OpenInNamespace {
587 path: req.path,
588 flags: req.flags,
589 request: req.request,
590
591 control_handle,
592 })
593 }
594 0x37310702b1c8b863 => {
595 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
596 let mut req = fidl::new_empty!(
597 CounterTryOpenDirectoryRequest,
598 fidl::encoding::DefaultFuchsiaResourceDialect
599 );
600 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CounterTryOpenDirectoryRequest>(&header, _body_bytes, handles, &mut req)?;
601 let control_handle = CounterControlHandle { inner: this.inner.clone() };
602 Ok(CounterRequest::TryOpenDirectory {
603 path: req.path,
604
605 responder: CounterTryOpenDirectoryResponder {
606 control_handle: std::mem::ManuallyDrop::new(control_handle),
607 tx_id: header.tx_id,
608 },
609 })
610 }
611 0x1d9c7aac19741829 => {
612 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
613 let mut req = fidl::new_empty!(
614 CounterSetAbortOnShutdownRequest,
615 fidl::encoding::DefaultFuchsiaResourceDialect
616 );
617 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CounterSetAbortOnShutdownRequest>(&header, _body_bytes, handles, &mut req)?;
618 let control_handle = CounterControlHandle { inner: this.inner.clone() };
619 Ok(CounterRequest::SetAbortOnShutdown {
620 abort: req.abort,
621
622 responder: CounterSetAbortOnShutdownResponder {
623 control_handle: std::mem::ManuallyDrop::new(control_handle),
624 tx_id: header.tx_id,
625 },
626 })
627 }
628 _ => Err(fidl::Error::UnknownOrdinal {
629 ordinal: header.ordinal,
630 protocol_name:
631 <CounterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
632 }),
633 }))
634 },
635 )
636 }
637}
638
639#[derive(Debug)]
641pub enum CounterRequest {
642 Increment { responder: CounterIncrementResponder },
644 ConnectToProtocol {
647 protocol_name: String,
648 request: fidl::Channel,
649 control_handle: CounterControlHandle,
650 },
651 OpenInNamespace {
662 path: String,
663 flags: fidl_fuchsia_io::Flags,
664 request: fidl::Channel,
665 control_handle: CounterControlHandle,
666 },
667 TryOpenDirectory { path: String, responder: CounterTryOpenDirectoryResponder },
673 SetAbortOnShutdown { abort: bool, responder: CounterSetAbortOnShutdownResponder },
678}
679
680impl CounterRequest {
681 #[allow(irrefutable_let_patterns)]
682 pub fn into_increment(self) -> Option<(CounterIncrementResponder)> {
683 if let CounterRequest::Increment { responder } = self {
684 Some((responder))
685 } else {
686 None
687 }
688 }
689
690 #[allow(irrefutable_let_patterns)]
691 pub fn into_connect_to_protocol(self) -> Option<(String, fidl::Channel, CounterControlHandle)> {
692 if let CounterRequest::ConnectToProtocol { protocol_name, request, control_handle } = self {
693 Some((protocol_name, request, control_handle))
694 } else {
695 None
696 }
697 }
698
699 #[allow(irrefutable_let_patterns)]
700 pub fn into_open_in_namespace(
701 self,
702 ) -> Option<(String, fidl_fuchsia_io::Flags, fidl::Channel, CounterControlHandle)> {
703 if let CounterRequest::OpenInNamespace { path, flags, request, control_handle } = self {
704 Some((path, flags, request, control_handle))
705 } else {
706 None
707 }
708 }
709
710 #[allow(irrefutable_let_patterns)]
711 pub fn into_try_open_directory(self) -> Option<(String, CounterTryOpenDirectoryResponder)> {
712 if let CounterRequest::TryOpenDirectory { path, responder } = self {
713 Some((path, responder))
714 } else {
715 None
716 }
717 }
718
719 #[allow(irrefutable_let_patterns)]
720 pub fn into_set_abort_on_shutdown(self) -> Option<(bool, CounterSetAbortOnShutdownResponder)> {
721 if let CounterRequest::SetAbortOnShutdown { abort, responder } = self {
722 Some((abort, responder))
723 } else {
724 None
725 }
726 }
727
728 pub fn method_name(&self) -> &'static str {
730 match *self {
731 CounterRequest::Increment { .. } => "increment",
732 CounterRequest::ConnectToProtocol { .. } => "connect_to_protocol",
733 CounterRequest::OpenInNamespace { .. } => "open_in_namespace",
734 CounterRequest::TryOpenDirectory { .. } => "try_open_directory",
735 CounterRequest::SetAbortOnShutdown { .. } => "set_abort_on_shutdown",
736 }
737 }
738}
739
740#[derive(Debug, Clone)]
741pub struct CounterControlHandle {
742 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
743}
744
745impl fidl::endpoints::ControlHandle for CounterControlHandle {
746 fn shutdown(&self) {
747 self.inner.shutdown()
748 }
749 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
750 self.inner.shutdown_with_epitaph(status)
751 }
752
753 fn is_closed(&self) -> bool {
754 self.inner.channel().is_closed()
755 }
756 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
757 self.inner.channel().on_closed()
758 }
759
760 #[cfg(target_os = "fuchsia")]
761 fn signal_peer(
762 &self,
763 clear_mask: zx::Signals,
764 set_mask: zx::Signals,
765 ) -> Result<(), zx_status::Status> {
766 use fidl::Peered;
767 self.inner.channel().signal_peer(clear_mask, set_mask)
768 }
769}
770
771impl CounterControlHandle {}
772
773#[must_use = "FIDL methods require a response to be sent"]
774#[derive(Debug)]
775pub struct CounterIncrementResponder {
776 control_handle: std::mem::ManuallyDrop<CounterControlHandle>,
777 tx_id: u32,
778}
779
780impl std::ops::Drop for CounterIncrementResponder {
784 fn drop(&mut self) {
785 self.control_handle.shutdown();
786 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
788 }
789}
790
791impl fidl::endpoints::Responder for CounterIncrementResponder {
792 type ControlHandle = CounterControlHandle;
793
794 fn control_handle(&self) -> &CounterControlHandle {
795 &self.control_handle
796 }
797
798 fn drop_without_shutdown(mut self) {
799 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
801 std::mem::forget(self);
803 }
804}
805
806impl CounterIncrementResponder {
807 pub fn send(self, mut value: u32) -> Result<(), fidl::Error> {
811 let _result = self.send_raw(value);
812 if _result.is_err() {
813 self.control_handle.shutdown();
814 }
815 self.drop_without_shutdown();
816 _result
817 }
818
819 pub fn send_no_shutdown_on_err(self, mut value: u32) -> Result<(), fidl::Error> {
821 let _result = self.send_raw(value);
822 self.drop_without_shutdown();
823 _result
824 }
825
826 fn send_raw(&self, mut value: u32) -> Result<(), fidl::Error> {
827 self.control_handle.inner.send::<CounterIncrementResponse>(
828 (value,),
829 self.tx_id,
830 0x60cf610cd915d7a9,
831 fidl::encoding::DynamicFlags::empty(),
832 )
833 }
834}
835
836#[must_use = "FIDL methods require a response to be sent"]
837#[derive(Debug)]
838pub struct CounterTryOpenDirectoryResponder {
839 control_handle: std::mem::ManuallyDrop<CounterControlHandle>,
840 tx_id: u32,
841}
842
843impl std::ops::Drop for CounterTryOpenDirectoryResponder {
847 fn drop(&mut self) {
848 self.control_handle.shutdown();
849 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
851 }
852}
853
854impl fidl::endpoints::Responder for CounterTryOpenDirectoryResponder {
855 type ControlHandle = CounterControlHandle;
856
857 fn control_handle(&self) -> &CounterControlHandle {
858 &self.control_handle
859 }
860
861 fn drop_without_shutdown(mut self) {
862 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
864 std::mem::forget(self);
866 }
867}
868
869impl CounterTryOpenDirectoryResponder {
870 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
874 let _result = self.send_raw(result);
875 if _result.is_err() {
876 self.control_handle.shutdown();
877 }
878 self.drop_without_shutdown();
879 _result
880 }
881
882 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
884 let _result = self.send_raw(result);
885 self.drop_without_shutdown();
886 _result
887 }
888
889 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
890 self.control_handle
891 .inner
892 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
893 result,
894 self.tx_id,
895 0x37310702b1c8b863,
896 fidl::encoding::DynamicFlags::empty(),
897 )
898 }
899}
900
901#[must_use = "FIDL methods require a response to be sent"]
902#[derive(Debug)]
903pub struct CounterSetAbortOnShutdownResponder {
904 control_handle: std::mem::ManuallyDrop<CounterControlHandle>,
905 tx_id: u32,
906}
907
908impl std::ops::Drop for CounterSetAbortOnShutdownResponder {
912 fn drop(&mut self) {
913 self.control_handle.shutdown();
914 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
916 }
917}
918
919impl fidl::endpoints::Responder for CounterSetAbortOnShutdownResponder {
920 type ControlHandle = CounterControlHandle;
921
922 fn control_handle(&self) -> &CounterControlHandle {
923 &self.control_handle
924 }
925
926 fn drop_without_shutdown(mut self) {
927 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
929 std::mem::forget(self);
931 }
932}
933
934impl CounterSetAbortOnShutdownResponder {
935 pub fn send(self) -> Result<(), fidl::Error> {
939 let _result = self.send_raw();
940 if _result.is_err() {
941 self.control_handle.shutdown();
942 }
943 self.drop_without_shutdown();
944 _result
945 }
946
947 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
949 let _result = self.send_raw();
950 self.drop_without_shutdown();
951 _result
952 }
953
954 fn send_raw(&self) -> Result<(), fidl::Error> {
955 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
956 (),
957 self.tx_id,
958 0x1d9c7aac19741829,
959 fidl::encoding::DynamicFlags::empty(),
960 )
961 }
962}
963
964mod internal {
965 use super::*;
966
967 impl fidl::encoding::ResourceTypeMarker for CounterConnectToProtocolRequest {
968 type Borrowed<'a> = &'a mut Self;
969 fn take_or_borrow<'a>(
970 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
971 ) -> Self::Borrowed<'a> {
972 value
973 }
974 }
975
976 unsafe impl fidl::encoding::TypeMarker for CounterConnectToProtocolRequest {
977 type Owned = Self;
978
979 #[inline(always)]
980 fn inline_align(_context: fidl::encoding::Context) -> usize {
981 8
982 }
983
984 #[inline(always)]
985 fn inline_size(_context: fidl::encoding::Context) -> usize {
986 24
987 }
988 }
989
990 unsafe impl
991 fidl::encoding::Encode<
992 CounterConnectToProtocolRequest,
993 fidl::encoding::DefaultFuchsiaResourceDialect,
994 > for &mut CounterConnectToProtocolRequest
995 {
996 #[inline]
997 unsafe fn encode(
998 self,
999 encoder: &mut fidl::encoding::Encoder<
1000 '_,
1001 fidl::encoding::DefaultFuchsiaResourceDialect,
1002 >,
1003 offset: usize,
1004 _depth: fidl::encoding::Depth,
1005 ) -> fidl::Result<()> {
1006 encoder.debug_check_bounds::<CounterConnectToProtocolRequest>(offset);
1007 fidl::encoding::Encode::<
1009 CounterConnectToProtocolRequest,
1010 fidl::encoding::DefaultFuchsiaResourceDialect,
1011 >::encode(
1012 (
1013 <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1014 &self.protocol_name,
1015 ),
1016 <fidl::encoding::HandleType<
1017 fidl::Channel,
1018 { fidl::ObjectType::CHANNEL.into_raw() },
1019 2147483648,
1020 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1021 &mut self.request
1022 ),
1023 ),
1024 encoder,
1025 offset,
1026 _depth,
1027 )
1028 }
1029 }
1030 unsafe impl<
1031 T0: fidl::encoding::Encode<
1032 fidl::encoding::BoundedString<255>,
1033 fidl::encoding::DefaultFuchsiaResourceDialect,
1034 >,
1035 T1: fidl::encoding::Encode<
1036 fidl::encoding::HandleType<
1037 fidl::Channel,
1038 { fidl::ObjectType::CHANNEL.into_raw() },
1039 2147483648,
1040 >,
1041 fidl::encoding::DefaultFuchsiaResourceDialect,
1042 >,
1043 >
1044 fidl::encoding::Encode<
1045 CounterConnectToProtocolRequest,
1046 fidl::encoding::DefaultFuchsiaResourceDialect,
1047 > for (T0, T1)
1048 {
1049 #[inline]
1050 unsafe fn encode(
1051 self,
1052 encoder: &mut fidl::encoding::Encoder<
1053 '_,
1054 fidl::encoding::DefaultFuchsiaResourceDialect,
1055 >,
1056 offset: usize,
1057 depth: fidl::encoding::Depth,
1058 ) -> fidl::Result<()> {
1059 encoder.debug_check_bounds::<CounterConnectToProtocolRequest>(offset);
1060 unsafe {
1063 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1064 (ptr as *mut u64).write_unaligned(0);
1065 }
1066 self.0.encode(encoder, offset + 0, depth)?;
1068 self.1.encode(encoder, offset + 16, depth)?;
1069 Ok(())
1070 }
1071 }
1072
1073 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1074 for CounterConnectToProtocolRequest
1075 {
1076 #[inline(always)]
1077 fn new_empty() -> Self {
1078 Self {
1079 protocol_name: fidl::new_empty!(
1080 fidl::encoding::BoundedString<255>,
1081 fidl::encoding::DefaultFuchsiaResourceDialect
1082 ),
1083 request: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1084 }
1085 }
1086
1087 #[inline]
1088 unsafe fn decode(
1089 &mut self,
1090 decoder: &mut fidl::encoding::Decoder<
1091 '_,
1092 fidl::encoding::DefaultFuchsiaResourceDialect,
1093 >,
1094 offset: usize,
1095 _depth: fidl::encoding::Depth,
1096 ) -> fidl::Result<()> {
1097 decoder.debug_check_bounds::<Self>(offset);
1098 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1100 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1101 let mask = 0xffffffff00000000u64;
1102 let maskedval = padval & mask;
1103 if maskedval != 0 {
1104 return Err(fidl::Error::NonZeroPadding {
1105 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1106 });
1107 }
1108 fidl::decode!(
1109 fidl::encoding::BoundedString<255>,
1110 fidl::encoding::DefaultFuchsiaResourceDialect,
1111 &mut self.protocol_name,
1112 decoder,
1113 offset + 0,
1114 _depth
1115 )?;
1116 fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.request, decoder, offset + 16, _depth)?;
1117 Ok(())
1118 }
1119 }
1120
1121 impl fidl::encoding::ResourceTypeMarker for CounterOpenInNamespaceRequest {
1122 type Borrowed<'a> = &'a mut Self;
1123 fn take_or_borrow<'a>(
1124 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1125 ) -> Self::Borrowed<'a> {
1126 value
1127 }
1128 }
1129
1130 unsafe impl fidl::encoding::TypeMarker for CounterOpenInNamespaceRequest {
1131 type Owned = Self;
1132
1133 #[inline(always)]
1134 fn inline_align(_context: fidl::encoding::Context) -> usize {
1135 8
1136 }
1137
1138 #[inline(always)]
1139 fn inline_size(_context: fidl::encoding::Context) -> usize {
1140 32
1141 }
1142 }
1143
1144 unsafe impl
1145 fidl::encoding::Encode<
1146 CounterOpenInNamespaceRequest,
1147 fidl::encoding::DefaultFuchsiaResourceDialect,
1148 > for &mut CounterOpenInNamespaceRequest
1149 {
1150 #[inline]
1151 unsafe fn encode(
1152 self,
1153 encoder: &mut fidl::encoding::Encoder<
1154 '_,
1155 fidl::encoding::DefaultFuchsiaResourceDialect,
1156 >,
1157 offset: usize,
1158 _depth: fidl::encoding::Depth,
1159 ) -> fidl::Result<()> {
1160 encoder.debug_check_bounds::<CounterOpenInNamespaceRequest>(offset);
1161 fidl::encoding::Encode::<CounterOpenInNamespaceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1163 (
1164 <fidl::encoding::BoundedString<4095> as fidl::encoding::ValueTypeMarker>::borrow(&self.path),
1165 <fidl_fuchsia_io::Flags as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
1166 <fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.request),
1167 ),
1168 encoder, offset, _depth
1169 )
1170 }
1171 }
1172 unsafe impl<
1173 T0: fidl::encoding::Encode<
1174 fidl::encoding::BoundedString<4095>,
1175 fidl::encoding::DefaultFuchsiaResourceDialect,
1176 >,
1177 T1: fidl::encoding::Encode<
1178 fidl_fuchsia_io::Flags,
1179 fidl::encoding::DefaultFuchsiaResourceDialect,
1180 >,
1181 T2: fidl::encoding::Encode<
1182 fidl::encoding::HandleType<
1183 fidl::Channel,
1184 { fidl::ObjectType::CHANNEL.into_raw() },
1185 2147483648,
1186 >,
1187 fidl::encoding::DefaultFuchsiaResourceDialect,
1188 >,
1189 >
1190 fidl::encoding::Encode<
1191 CounterOpenInNamespaceRequest,
1192 fidl::encoding::DefaultFuchsiaResourceDialect,
1193 > for (T0, T1, T2)
1194 {
1195 #[inline]
1196 unsafe fn encode(
1197 self,
1198 encoder: &mut fidl::encoding::Encoder<
1199 '_,
1200 fidl::encoding::DefaultFuchsiaResourceDialect,
1201 >,
1202 offset: usize,
1203 depth: fidl::encoding::Depth,
1204 ) -> fidl::Result<()> {
1205 encoder.debug_check_bounds::<CounterOpenInNamespaceRequest>(offset);
1206 unsafe {
1209 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
1210 (ptr as *mut u64).write_unaligned(0);
1211 }
1212 self.0.encode(encoder, offset + 0, depth)?;
1214 self.1.encode(encoder, offset + 16, depth)?;
1215 self.2.encode(encoder, offset + 24, depth)?;
1216 Ok(())
1217 }
1218 }
1219
1220 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1221 for CounterOpenInNamespaceRequest
1222 {
1223 #[inline(always)]
1224 fn new_empty() -> Self {
1225 Self {
1226 path: fidl::new_empty!(
1227 fidl::encoding::BoundedString<4095>,
1228 fidl::encoding::DefaultFuchsiaResourceDialect
1229 ),
1230 flags: fidl::new_empty!(
1231 fidl_fuchsia_io::Flags,
1232 fidl::encoding::DefaultFuchsiaResourceDialect
1233 ),
1234 request: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1235 }
1236 }
1237
1238 #[inline]
1239 unsafe fn decode(
1240 &mut self,
1241 decoder: &mut fidl::encoding::Decoder<
1242 '_,
1243 fidl::encoding::DefaultFuchsiaResourceDialect,
1244 >,
1245 offset: usize,
1246 _depth: fidl::encoding::Depth,
1247 ) -> fidl::Result<()> {
1248 decoder.debug_check_bounds::<Self>(offset);
1249 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
1251 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1252 let mask = 0xffffffff00000000u64;
1253 let maskedval = padval & mask;
1254 if maskedval != 0 {
1255 return Err(fidl::Error::NonZeroPadding {
1256 padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
1257 });
1258 }
1259 fidl::decode!(
1260 fidl::encoding::BoundedString<4095>,
1261 fidl::encoding::DefaultFuchsiaResourceDialect,
1262 &mut self.path,
1263 decoder,
1264 offset + 0,
1265 _depth
1266 )?;
1267 fidl::decode!(
1268 fidl_fuchsia_io::Flags,
1269 fidl::encoding::DefaultFuchsiaResourceDialect,
1270 &mut self.flags,
1271 decoder,
1272 offset + 16,
1273 _depth
1274 )?;
1275 fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.request, decoder, offset + 24, _depth)?;
1276 Ok(())
1277 }
1278 }
1279}