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::NullableHandle {
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 { Some((responder)) } else { None }
684 }
685
686 #[allow(irrefutable_let_patterns)]
687 pub fn into_connect_to_protocol(self) -> Option<(String, fidl::Channel, CounterControlHandle)> {
688 if let CounterRequest::ConnectToProtocol { protocol_name, request, control_handle } = self {
689 Some((protocol_name, request, control_handle))
690 } else {
691 None
692 }
693 }
694
695 #[allow(irrefutable_let_patterns)]
696 pub fn into_open_in_namespace(
697 self,
698 ) -> Option<(String, fidl_fuchsia_io::Flags, fidl::Channel, CounterControlHandle)> {
699 if let CounterRequest::OpenInNamespace { path, flags, request, control_handle } = self {
700 Some((path, flags, request, control_handle))
701 } else {
702 None
703 }
704 }
705
706 #[allow(irrefutable_let_patterns)]
707 pub fn into_try_open_directory(self) -> Option<(String, CounterTryOpenDirectoryResponder)> {
708 if let CounterRequest::TryOpenDirectory { path, responder } = self {
709 Some((path, responder))
710 } else {
711 None
712 }
713 }
714
715 #[allow(irrefutable_let_patterns)]
716 pub fn into_set_abort_on_shutdown(self) -> Option<(bool, CounterSetAbortOnShutdownResponder)> {
717 if let CounterRequest::SetAbortOnShutdown { abort, responder } = self {
718 Some((abort, responder))
719 } else {
720 None
721 }
722 }
723
724 pub fn method_name(&self) -> &'static str {
726 match *self {
727 CounterRequest::Increment { .. } => "increment",
728 CounterRequest::ConnectToProtocol { .. } => "connect_to_protocol",
729 CounterRequest::OpenInNamespace { .. } => "open_in_namespace",
730 CounterRequest::TryOpenDirectory { .. } => "try_open_directory",
731 CounterRequest::SetAbortOnShutdown { .. } => "set_abort_on_shutdown",
732 }
733 }
734}
735
736#[derive(Debug, Clone)]
737pub struct CounterControlHandle {
738 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
739}
740
741impl fidl::endpoints::ControlHandle for CounterControlHandle {
742 fn shutdown(&self) {
743 self.inner.shutdown()
744 }
745
746 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
747 self.inner.shutdown_with_epitaph(status)
748 }
749
750 fn is_closed(&self) -> bool {
751 self.inner.channel().is_closed()
752 }
753 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
754 self.inner.channel().on_closed()
755 }
756
757 #[cfg(target_os = "fuchsia")]
758 fn signal_peer(
759 &self,
760 clear_mask: zx::Signals,
761 set_mask: zx::Signals,
762 ) -> Result<(), zx_status::Status> {
763 use fidl::Peered;
764 self.inner.channel().signal_peer(clear_mask, set_mask)
765 }
766}
767
768impl CounterControlHandle {}
769
770#[must_use = "FIDL methods require a response to be sent"]
771#[derive(Debug)]
772pub struct CounterIncrementResponder {
773 control_handle: std::mem::ManuallyDrop<CounterControlHandle>,
774 tx_id: u32,
775}
776
777impl std::ops::Drop for CounterIncrementResponder {
781 fn drop(&mut self) {
782 self.control_handle.shutdown();
783 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
785 }
786}
787
788impl fidl::endpoints::Responder for CounterIncrementResponder {
789 type ControlHandle = CounterControlHandle;
790
791 fn control_handle(&self) -> &CounterControlHandle {
792 &self.control_handle
793 }
794
795 fn drop_without_shutdown(mut self) {
796 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
798 std::mem::forget(self);
800 }
801}
802
803impl CounterIncrementResponder {
804 pub fn send(self, mut value: u32) -> Result<(), fidl::Error> {
808 let _result = self.send_raw(value);
809 if _result.is_err() {
810 self.control_handle.shutdown();
811 }
812 self.drop_without_shutdown();
813 _result
814 }
815
816 pub fn send_no_shutdown_on_err(self, mut value: u32) -> Result<(), fidl::Error> {
818 let _result = self.send_raw(value);
819 self.drop_without_shutdown();
820 _result
821 }
822
823 fn send_raw(&self, mut value: u32) -> Result<(), fidl::Error> {
824 self.control_handle.inner.send::<CounterIncrementResponse>(
825 (value,),
826 self.tx_id,
827 0x60cf610cd915d7a9,
828 fidl::encoding::DynamicFlags::empty(),
829 )
830 }
831}
832
833#[must_use = "FIDL methods require a response to be sent"]
834#[derive(Debug)]
835pub struct CounterTryOpenDirectoryResponder {
836 control_handle: std::mem::ManuallyDrop<CounterControlHandle>,
837 tx_id: u32,
838}
839
840impl std::ops::Drop for CounterTryOpenDirectoryResponder {
844 fn drop(&mut self) {
845 self.control_handle.shutdown();
846 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
848 }
849}
850
851impl fidl::endpoints::Responder for CounterTryOpenDirectoryResponder {
852 type ControlHandle = CounterControlHandle;
853
854 fn control_handle(&self) -> &CounterControlHandle {
855 &self.control_handle
856 }
857
858 fn drop_without_shutdown(mut self) {
859 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
861 std::mem::forget(self);
863 }
864}
865
866impl CounterTryOpenDirectoryResponder {
867 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
871 let _result = self.send_raw(result);
872 if _result.is_err() {
873 self.control_handle.shutdown();
874 }
875 self.drop_without_shutdown();
876 _result
877 }
878
879 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
881 let _result = self.send_raw(result);
882 self.drop_without_shutdown();
883 _result
884 }
885
886 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
887 self.control_handle
888 .inner
889 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
890 result,
891 self.tx_id,
892 0x37310702b1c8b863,
893 fidl::encoding::DynamicFlags::empty(),
894 )
895 }
896}
897
898#[must_use = "FIDL methods require a response to be sent"]
899#[derive(Debug)]
900pub struct CounterSetAbortOnShutdownResponder {
901 control_handle: std::mem::ManuallyDrop<CounterControlHandle>,
902 tx_id: u32,
903}
904
905impl std::ops::Drop for CounterSetAbortOnShutdownResponder {
909 fn drop(&mut self) {
910 self.control_handle.shutdown();
911 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
913 }
914}
915
916impl fidl::endpoints::Responder for CounterSetAbortOnShutdownResponder {
917 type ControlHandle = CounterControlHandle;
918
919 fn control_handle(&self) -> &CounterControlHandle {
920 &self.control_handle
921 }
922
923 fn drop_without_shutdown(mut self) {
924 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
926 std::mem::forget(self);
928 }
929}
930
931impl CounterSetAbortOnShutdownResponder {
932 pub fn send(self) -> Result<(), fidl::Error> {
936 let _result = self.send_raw();
937 if _result.is_err() {
938 self.control_handle.shutdown();
939 }
940 self.drop_without_shutdown();
941 _result
942 }
943
944 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
946 let _result = self.send_raw();
947 self.drop_without_shutdown();
948 _result
949 }
950
951 fn send_raw(&self) -> Result<(), fidl::Error> {
952 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
953 (),
954 self.tx_id,
955 0x1d9c7aac19741829,
956 fidl::encoding::DynamicFlags::empty(),
957 )
958 }
959}
960
961mod internal {
962 use super::*;
963
964 impl fidl::encoding::ResourceTypeMarker for CounterConnectToProtocolRequest {
965 type Borrowed<'a> = &'a mut Self;
966 fn take_or_borrow<'a>(
967 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
968 ) -> Self::Borrowed<'a> {
969 value
970 }
971 }
972
973 unsafe impl fidl::encoding::TypeMarker for CounterConnectToProtocolRequest {
974 type Owned = Self;
975
976 #[inline(always)]
977 fn inline_align(_context: fidl::encoding::Context) -> usize {
978 8
979 }
980
981 #[inline(always)]
982 fn inline_size(_context: fidl::encoding::Context) -> usize {
983 24
984 }
985 }
986
987 unsafe impl
988 fidl::encoding::Encode<
989 CounterConnectToProtocolRequest,
990 fidl::encoding::DefaultFuchsiaResourceDialect,
991 > for &mut CounterConnectToProtocolRequest
992 {
993 #[inline]
994 unsafe fn encode(
995 self,
996 encoder: &mut fidl::encoding::Encoder<
997 '_,
998 fidl::encoding::DefaultFuchsiaResourceDialect,
999 >,
1000 offset: usize,
1001 _depth: fidl::encoding::Depth,
1002 ) -> fidl::Result<()> {
1003 encoder.debug_check_bounds::<CounterConnectToProtocolRequest>(offset);
1004 fidl::encoding::Encode::<
1006 CounterConnectToProtocolRequest,
1007 fidl::encoding::DefaultFuchsiaResourceDialect,
1008 >::encode(
1009 (
1010 <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1011 &self.protocol_name,
1012 ),
1013 <fidl::encoding::HandleType<
1014 fidl::Channel,
1015 { fidl::ObjectType::CHANNEL.into_raw() },
1016 2147483648,
1017 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1018 &mut self.request
1019 ),
1020 ),
1021 encoder,
1022 offset,
1023 _depth,
1024 )
1025 }
1026 }
1027 unsafe impl<
1028 T0: fidl::encoding::Encode<
1029 fidl::encoding::BoundedString<255>,
1030 fidl::encoding::DefaultFuchsiaResourceDialect,
1031 >,
1032 T1: fidl::encoding::Encode<
1033 fidl::encoding::HandleType<
1034 fidl::Channel,
1035 { fidl::ObjectType::CHANNEL.into_raw() },
1036 2147483648,
1037 >,
1038 fidl::encoding::DefaultFuchsiaResourceDialect,
1039 >,
1040 >
1041 fidl::encoding::Encode<
1042 CounterConnectToProtocolRequest,
1043 fidl::encoding::DefaultFuchsiaResourceDialect,
1044 > for (T0, T1)
1045 {
1046 #[inline]
1047 unsafe fn encode(
1048 self,
1049 encoder: &mut fidl::encoding::Encoder<
1050 '_,
1051 fidl::encoding::DefaultFuchsiaResourceDialect,
1052 >,
1053 offset: usize,
1054 depth: fidl::encoding::Depth,
1055 ) -> fidl::Result<()> {
1056 encoder.debug_check_bounds::<CounterConnectToProtocolRequest>(offset);
1057 unsafe {
1060 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1061 (ptr as *mut u64).write_unaligned(0);
1062 }
1063 self.0.encode(encoder, offset + 0, depth)?;
1065 self.1.encode(encoder, offset + 16, depth)?;
1066 Ok(())
1067 }
1068 }
1069
1070 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1071 for CounterConnectToProtocolRequest
1072 {
1073 #[inline(always)]
1074 fn new_empty() -> Self {
1075 Self {
1076 protocol_name: fidl::new_empty!(
1077 fidl::encoding::BoundedString<255>,
1078 fidl::encoding::DefaultFuchsiaResourceDialect
1079 ),
1080 request: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1081 }
1082 }
1083
1084 #[inline]
1085 unsafe fn decode(
1086 &mut self,
1087 decoder: &mut fidl::encoding::Decoder<
1088 '_,
1089 fidl::encoding::DefaultFuchsiaResourceDialect,
1090 >,
1091 offset: usize,
1092 _depth: fidl::encoding::Depth,
1093 ) -> fidl::Result<()> {
1094 decoder.debug_check_bounds::<Self>(offset);
1095 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1097 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1098 let mask = 0xffffffff00000000u64;
1099 let maskedval = padval & mask;
1100 if maskedval != 0 {
1101 return Err(fidl::Error::NonZeroPadding {
1102 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1103 });
1104 }
1105 fidl::decode!(
1106 fidl::encoding::BoundedString<255>,
1107 fidl::encoding::DefaultFuchsiaResourceDialect,
1108 &mut self.protocol_name,
1109 decoder,
1110 offset + 0,
1111 _depth
1112 )?;
1113 fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.request, decoder, offset + 16, _depth)?;
1114 Ok(())
1115 }
1116 }
1117
1118 impl fidl::encoding::ResourceTypeMarker for CounterOpenInNamespaceRequest {
1119 type Borrowed<'a> = &'a mut Self;
1120 fn take_or_borrow<'a>(
1121 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1122 ) -> Self::Borrowed<'a> {
1123 value
1124 }
1125 }
1126
1127 unsafe impl fidl::encoding::TypeMarker for CounterOpenInNamespaceRequest {
1128 type Owned = Self;
1129
1130 #[inline(always)]
1131 fn inline_align(_context: fidl::encoding::Context) -> usize {
1132 8
1133 }
1134
1135 #[inline(always)]
1136 fn inline_size(_context: fidl::encoding::Context) -> usize {
1137 32
1138 }
1139 }
1140
1141 unsafe impl
1142 fidl::encoding::Encode<
1143 CounterOpenInNamespaceRequest,
1144 fidl::encoding::DefaultFuchsiaResourceDialect,
1145 > for &mut CounterOpenInNamespaceRequest
1146 {
1147 #[inline]
1148 unsafe fn encode(
1149 self,
1150 encoder: &mut fidl::encoding::Encoder<
1151 '_,
1152 fidl::encoding::DefaultFuchsiaResourceDialect,
1153 >,
1154 offset: usize,
1155 _depth: fidl::encoding::Depth,
1156 ) -> fidl::Result<()> {
1157 encoder.debug_check_bounds::<CounterOpenInNamespaceRequest>(offset);
1158 fidl::encoding::Encode::<CounterOpenInNamespaceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1160 (
1161 <fidl::encoding::BoundedString<4095> as fidl::encoding::ValueTypeMarker>::borrow(&self.path),
1162 <fidl_fuchsia_io::Flags as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
1163 <fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.request),
1164 ),
1165 encoder, offset, _depth
1166 )
1167 }
1168 }
1169 unsafe impl<
1170 T0: fidl::encoding::Encode<
1171 fidl::encoding::BoundedString<4095>,
1172 fidl::encoding::DefaultFuchsiaResourceDialect,
1173 >,
1174 T1: fidl::encoding::Encode<
1175 fidl_fuchsia_io::Flags,
1176 fidl::encoding::DefaultFuchsiaResourceDialect,
1177 >,
1178 T2: fidl::encoding::Encode<
1179 fidl::encoding::HandleType<
1180 fidl::Channel,
1181 { fidl::ObjectType::CHANNEL.into_raw() },
1182 2147483648,
1183 >,
1184 fidl::encoding::DefaultFuchsiaResourceDialect,
1185 >,
1186 >
1187 fidl::encoding::Encode<
1188 CounterOpenInNamespaceRequest,
1189 fidl::encoding::DefaultFuchsiaResourceDialect,
1190 > for (T0, T1, T2)
1191 {
1192 #[inline]
1193 unsafe fn encode(
1194 self,
1195 encoder: &mut fidl::encoding::Encoder<
1196 '_,
1197 fidl::encoding::DefaultFuchsiaResourceDialect,
1198 >,
1199 offset: usize,
1200 depth: fidl::encoding::Depth,
1201 ) -> fidl::Result<()> {
1202 encoder.debug_check_bounds::<CounterOpenInNamespaceRequest>(offset);
1203 unsafe {
1206 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
1207 (ptr as *mut u64).write_unaligned(0);
1208 }
1209 self.0.encode(encoder, offset + 0, depth)?;
1211 self.1.encode(encoder, offset + 16, depth)?;
1212 self.2.encode(encoder, offset + 24, depth)?;
1213 Ok(())
1214 }
1215 }
1216
1217 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1218 for CounterOpenInNamespaceRequest
1219 {
1220 #[inline(always)]
1221 fn new_empty() -> Self {
1222 Self {
1223 path: fidl::new_empty!(
1224 fidl::encoding::BoundedString<4095>,
1225 fidl::encoding::DefaultFuchsiaResourceDialect
1226 ),
1227 flags: fidl::new_empty!(
1228 fidl_fuchsia_io::Flags,
1229 fidl::encoding::DefaultFuchsiaResourceDialect
1230 ),
1231 request: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1232 }
1233 }
1234
1235 #[inline]
1236 unsafe fn decode(
1237 &mut self,
1238 decoder: &mut fidl::encoding::Decoder<
1239 '_,
1240 fidl::encoding::DefaultFuchsiaResourceDialect,
1241 >,
1242 offset: usize,
1243 _depth: fidl::encoding::Depth,
1244 ) -> fidl::Result<()> {
1245 decoder.debug_check_bounds::<Self>(offset);
1246 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
1248 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1249 let mask = 0xffffffff00000000u64;
1250 let maskedval = padval & mask;
1251 if maskedval != 0 {
1252 return Err(fidl::Error::NonZeroPadding {
1253 padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
1254 });
1255 }
1256 fidl::decode!(
1257 fidl::encoding::BoundedString<4095>,
1258 fidl::encoding::DefaultFuchsiaResourceDialect,
1259 &mut self.path,
1260 decoder,
1261 offset + 0,
1262 _depth
1263 )?;
1264 fidl::decode!(
1265 fidl_fuchsia_io::Flags,
1266 fidl::encoding::DefaultFuchsiaResourceDialect,
1267 &mut self.flags,
1268 decoder,
1269 offset + 16,
1270 _depth
1271 )?;
1272 fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.request, decoder, offset + 24, _depth)?;
1273 Ok(())
1274 }
1275 }
1276}