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_examples_inspect__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct FizzBuzzMarker;
16
17impl fidl::endpoints::ProtocolMarker for FizzBuzzMarker {
18 type Proxy = FizzBuzzProxy;
19 type RequestStream = FizzBuzzRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = FizzBuzzSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.examples.inspect.FizzBuzz";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for FizzBuzzMarker {}
26
27pub trait FizzBuzzProxyInterface: Send + Sync {
28 type ExecuteResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
29 fn r#execute(&self, count: u32) -> Self::ExecuteResponseFut;
30}
31#[derive(Debug)]
32#[cfg(target_os = "fuchsia")]
33pub struct FizzBuzzSynchronousProxy {
34 client: fidl::client::sync::Client,
35}
36
37#[cfg(target_os = "fuchsia")]
38impl fidl::endpoints::SynchronousProxy for FizzBuzzSynchronousProxy {
39 type Proxy = FizzBuzzProxy;
40 type Protocol = FizzBuzzMarker;
41
42 fn from_channel(inner: fidl::Channel) -> Self {
43 Self::new(inner)
44 }
45
46 fn into_channel(self) -> fidl::Channel {
47 self.client.into_channel()
48 }
49
50 fn as_channel(&self) -> &fidl::Channel {
51 self.client.as_channel()
52 }
53}
54
55#[cfg(target_os = "fuchsia")]
56impl FizzBuzzSynchronousProxy {
57 pub fn new(channel: fidl::Channel) -> Self {
58 let protocol_name = <FizzBuzzMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
59 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
60 }
61
62 pub fn into_channel(self) -> fidl::Channel {
63 self.client.into_channel()
64 }
65
66 pub fn wait_for_event(
69 &self,
70 deadline: zx::MonotonicInstant,
71 ) -> Result<FizzBuzzEvent, fidl::Error> {
72 FizzBuzzEvent::decode(self.client.wait_for_event(deadline)?)
73 }
74
75 pub fn r#execute(
76 &self,
77 mut count: u32,
78 ___deadline: zx::MonotonicInstant,
79 ) -> Result<String, fidl::Error> {
80 let _response = self.client.send_query::<FizzBuzzExecuteRequest, FizzBuzzExecuteResponse>(
81 (count,),
82 0x207cbeb002df3833,
83 fidl::encoding::DynamicFlags::empty(),
84 ___deadline,
85 )?;
86 Ok(_response.response)
87 }
88}
89
90#[cfg(target_os = "fuchsia")]
91impl From<FizzBuzzSynchronousProxy> for zx::NullableHandle {
92 fn from(value: FizzBuzzSynchronousProxy) -> Self {
93 value.into_channel().into()
94 }
95}
96
97#[cfg(target_os = "fuchsia")]
98impl From<fidl::Channel> for FizzBuzzSynchronousProxy {
99 fn from(value: fidl::Channel) -> Self {
100 Self::new(value)
101 }
102}
103
104#[cfg(target_os = "fuchsia")]
105impl fidl::endpoints::FromClient for FizzBuzzSynchronousProxy {
106 type Protocol = FizzBuzzMarker;
107
108 fn from_client(value: fidl::endpoints::ClientEnd<FizzBuzzMarker>) -> Self {
109 Self::new(value.into_channel())
110 }
111}
112
113#[derive(Debug, Clone)]
114pub struct FizzBuzzProxy {
115 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
116}
117
118impl fidl::endpoints::Proxy for FizzBuzzProxy {
119 type Protocol = FizzBuzzMarker;
120
121 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
122 Self::new(inner)
123 }
124
125 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
126 self.client.into_channel().map_err(|client| Self { client })
127 }
128
129 fn as_channel(&self) -> &::fidl::AsyncChannel {
130 self.client.as_channel()
131 }
132}
133
134impl FizzBuzzProxy {
135 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
137 let protocol_name = <FizzBuzzMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
138 Self { client: fidl::client::Client::new(channel, protocol_name) }
139 }
140
141 pub fn take_event_stream(&self) -> FizzBuzzEventStream {
147 FizzBuzzEventStream { event_receiver: self.client.take_event_receiver() }
148 }
149
150 pub fn r#execute(
151 &self,
152 mut count: u32,
153 ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
154 FizzBuzzProxyInterface::r#execute(self, count)
155 }
156}
157
158impl FizzBuzzProxyInterface for FizzBuzzProxy {
159 type ExecuteResponseFut =
160 fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
161 fn r#execute(&self, mut count: u32) -> Self::ExecuteResponseFut {
162 fn _decode(
163 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
164 ) -> Result<String, fidl::Error> {
165 let _response = fidl::client::decode_transaction_body::<
166 FizzBuzzExecuteResponse,
167 fidl::encoding::DefaultFuchsiaResourceDialect,
168 0x207cbeb002df3833,
169 >(_buf?)?;
170 Ok(_response.response)
171 }
172 self.client.send_query_and_decode::<FizzBuzzExecuteRequest, String>(
173 (count,),
174 0x207cbeb002df3833,
175 fidl::encoding::DynamicFlags::empty(),
176 _decode,
177 )
178 }
179}
180
181pub struct FizzBuzzEventStream {
182 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
183}
184
185impl std::marker::Unpin for FizzBuzzEventStream {}
186
187impl futures::stream::FusedStream for FizzBuzzEventStream {
188 fn is_terminated(&self) -> bool {
189 self.event_receiver.is_terminated()
190 }
191}
192
193impl futures::Stream for FizzBuzzEventStream {
194 type Item = Result<FizzBuzzEvent, fidl::Error>;
195
196 fn poll_next(
197 mut self: std::pin::Pin<&mut Self>,
198 cx: &mut std::task::Context<'_>,
199 ) -> std::task::Poll<Option<Self::Item>> {
200 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
201 &mut self.event_receiver,
202 cx
203 )?) {
204 Some(buf) => std::task::Poll::Ready(Some(FizzBuzzEvent::decode(buf))),
205 None => std::task::Poll::Ready(None),
206 }
207 }
208}
209
210#[derive(Debug)]
211pub enum FizzBuzzEvent {}
212
213impl FizzBuzzEvent {
214 fn decode(
216 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
217 ) -> Result<FizzBuzzEvent, fidl::Error> {
218 let (bytes, _handles) = buf.split_mut();
219 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
220 debug_assert_eq!(tx_header.tx_id, 0);
221 match tx_header.ordinal {
222 _ => Err(fidl::Error::UnknownOrdinal {
223 ordinal: tx_header.ordinal,
224 protocol_name: <FizzBuzzMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
225 }),
226 }
227 }
228}
229
230pub struct FizzBuzzRequestStream {
232 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
233 is_terminated: bool,
234}
235
236impl std::marker::Unpin for FizzBuzzRequestStream {}
237
238impl futures::stream::FusedStream for FizzBuzzRequestStream {
239 fn is_terminated(&self) -> bool {
240 self.is_terminated
241 }
242}
243
244impl fidl::endpoints::RequestStream for FizzBuzzRequestStream {
245 type Protocol = FizzBuzzMarker;
246 type ControlHandle = FizzBuzzControlHandle;
247
248 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
249 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
250 }
251
252 fn control_handle(&self) -> Self::ControlHandle {
253 FizzBuzzControlHandle { inner: self.inner.clone() }
254 }
255
256 fn into_inner(
257 self,
258 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
259 {
260 (self.inner, self.is_terminated)
261 }
262
263 fn from_inner(
264 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
265 is_terminated: bool,
266 ) -> Self {
267 Self { inner, is_terminated }
268 }
269}
270
271impl futures::Stream for FizzBuzzRequestStream {
272 type Item = Result<FizzBuzzRequest, fidl::Error>;
273
274 fn poll_next(
275 mut self: std::pin::Pin<&mut Self>,
276 cx: &mut std::task::Context<'_>,
277 ) -> std::task::Poll<Option<Self::Item>> {
278 let this = &mut *self;
279 if this.inner.check_shutdown(cx) {
280 this.is_terminated = true;
281 return std::task::Poll::Ready(None);
282 }
283 if this.is_terminated {
284 panic!("polled FizzBuzzRequestStream after completion");
285 }
286 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
287 |bytes, handles| {
288 match this.inner.channel().read_etc(cx, bytes, handles) {
289 std::task::Poll::Ready(Ok(())) => {}
290 std::task::Poll::Pending => return std::task::Poll::Pending,
291 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
292 this.is_terminated = true;
293 return std::task::Poll::Ready(None);
294 }
295 std::task::Poll::Ready(Err(e)) => {
296 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
297 e.into(),
298 ))));
299 }
300 }
301
302 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
304
305 std::task::Poll::Ready(Some(match header.ordinal {
306 0x207cbeb002df3833 => {
307 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
308 let mut req = fidl::new_empty!(
309 FizzBuzzExecuteRequest,
310 fidl::encoding::DefaultFuchsiaResourceDialect
311 );
312 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FizzBuzzExecuteRequest>(&header, _body_bytes, handles, &mut req)?;
313 let control_handle = FizzBuzzControlHandle { inner: this.inner.clone() };
314 Ok(FizzBuzzRequest::Execute {
315 count: req.count,
316
317 responder: FizzBuzzExecuteResponder {
318 control_handle: std::mem::ManuallyDrop::new(control_handle),
319 tx_id: header.tx_id,
320 },
321 })
322 }
323 _ => Err(fidl::Error::UnknownOrdinal {
324 ordinal: header.ordinal,
325 protocol_name:
326 <FizzBuzzMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
327 }),
328 }))
329 },
330 )
331 }
332}
333
334#[derive(Debug)]
335pub enum FizzBuzzRequest {
336 Execute { count: u32, responder: FizzBuzzExecuteResponder },
337}
338
339impl FizzBuzzRequest {
340 #[allow(irrefutable_let_patterns)]
341 pub fn into_execute(self) -> Option<(u32, FizzBuzzExecuteResponder)> {
342 if let FizzBuzzRequest::Execute { count, responder } = self {
343 Some((count, responder))
344 } else {
345 None
346 }
347 }
348
349 pub fn method_name(&self) -> &'static str {
351 match *self {
352 FizzBuzzRequest::Execute { .. } => "execute",
353 }
354 }
355}
356
357#[derive(Debug, Clone)]
358pub struct FizzBuzzControlHandle {
359 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
360}
361
362impl fidl::endpoints::ControlHandle for FizzBuzzControlHandle {
363 fn shutdown(&self) {
364 self.inner.shutdown()
365 }
366
367 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
368 self.inner.shutdown_with_epitaph(status)
369 }
370
371 fn is_closed(&self) -> bool {
372 self.inner.channel().is_closed()
373 }
374 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
375 self.inner.channel().on_closed()
376 }
377
378 #[cfg(target_os = "fuchsia")]
379 fn signal_peer(
380 &self,
381 clear_mask: zx::Signals,
382 set_mask: zx::Signals,
383 ) -> Result<(), zx_status::Status> {
384 use fidl::Peered;
385 self.inner.channel().signal_peer(clear_mask, set_mask)
386 }
387}
388
389impl FizzBuzzControlHandle {}
390
391#[must_use = "FIDL methods require a response to be sent"]
392#[derive(Debug)]
393pub struct FizzBuzzExecuteResponder {
394 control_handle: std::mem::ManuallyDrop<FizzBuzzControlHandle>,
395 tx_id: u32,
396}
397
398impl std::ops::Drop for FizzBuzzExecuteResponder {
402 fn drop(&mut self) {
403 self.control_handle.shutdown();
404 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
406 }
407}
408
409impl fidl::endpoints::Responder for FizzBuzzExecuteResponder {
410 type ControlHandle = FizzBuzzControlHandle;
411
412 fn control_handle(&self) -> &FizzBuzzControlHandle {
413 &self.control_handle
414 }
415
416 fn drop_without_shutdown(mut self) {
417 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
419 std::mem::forget(self);
421 }
422}
423
424impl FizzBuzzExecuteResponder {
425 pub fn send(self, mut response: &str) -> Result<(), fidl::Error> {
429 let _result = self.send_raw(response);
430 if _result.is_err() {
431 self.control_handle.shutdown();
432 }
433 self.drop_without_shutdown();
434 _result
435 }
436
437 pub fn send_no_shutdown_on_err(self, mut response: &str) -> Result<(), fidl::Error> {
439 let _result = self.send_raw(response);
440 self.drop_without_shutdown();
441 _result
442 }
443
444 fn send_raw(&self, mut response: &str) -> Result<(), fidl::Error> {
445 self.control_handle.inner.send::<FizzBuzzExecuteResponse>(
446 (response,),
447 self.tx_id,
448 0x207cbeb002df3833,
449 fidl::encoding::DynamicFlags::empty(),
450 )
451 }
452}
453
454#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
455pub struct ReverserMarker;
456
457impl fidl::endpoints::ProtocolMarker for ReverserMarker {
458 type Proxy = ReverserProxy;
459 type RequestStream = ReverserRequestStream;
460 #[cfg(target_os = "fuchsia")]
461 type SynchronousProxy = ReverserSynchronousProxy;
462
463 const DEBUG_NAME: &'static str = "fuchsia.examples.inspect.Reverser";
464}
465impl fidl::endpoints::DiscoverableProtocolMarker for ReverserMarker {}
466
467pub trait ReverserProxyInterface: Send + Sync {
468 type ReverseResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
469 fn r#reverse(&self, input: &str) -> Self::ReverseResponseFut;
470}
471#[derive(Debug)]
472#[cfg(target_os = "fuchsia")]
473pub struct ReverserSynchronousProxy {
474 client: fidl::client::sync::Client,
475}
476
477#[cfg(target_os = "fuchsia")]
478impl fidl::endpoints::SynchronousProxy for ReverserSynchronousProxy {
479 type Proxy = ReverserProxy;
480 type Protocol = ReverserMarker;
481
482 fn from_channel(inner: fidl::Channel) -> Self {
483 Self::new(inner)
484 }
485
486 fn into_channel(self) -> fidl::Channel {
487 self.client.into_channel()
488 }
489
490 fn as_channel(&self) -> &fidl::Channel {
491 self.client.as_channel()
492 }
493}
494
495#[cfg(target_os = "fuchsia")]
496impl ReverserSynchronousProxy {
497 pub fn new(channel: fidl::Channel) -> Self {
498 let protocol_name = <ReverserMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
499 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
500 }
501
502 pub fn into_channel(self) -> fidl::Channel {
503 self.client.into_channel()
504 }
505
506 pub fn wait_for_event(
509 &self,
510 deadline: zx::MonotonicInstant,
511 ) -> Result<ReverserEvent, fidl::Error> {
512 ReverserEvent::decode(self.client.wait_for_event(deadline)?)
513 }
514
515 pub fn r#reverse(
516 &self,
517 mut input: &str,
518 ___deadline: zx::MonotonicInstant,
519 ) -> Result<String, fidl::Error> {
520 let _response = self.client.send_query::<ReverserReverseRequest, ReverserReverseResponse>(
521 (input,),
522 0x481eccb3af87ff3e,
523 fidl::encoding::DynamicFlags::empty(),
524 ___deadline,
525 )?;
526 Ok(_response.response)
527 }
528}
529
530#[cfg(target_os = "fuchsia")]
531impl From<ReverserSynchronousProxy> for zx::NullableHandle {
532 fn from(value: ReverserSynchronousProxy) -> Self {
533 value.into_channel().into()
534 }
535}
536
537#[cfg(target_os = "fuchsia")]
538impl From<fidl::Channel> for ReverserSynchronousProxy {
539 fn from(value: fidl::Channel) -> Self {
540 Self::new(value)
541 }
542}
543
544#[cfg(target_os = "fuchsia")]
545impl fidl::endpoints::FromClient for ReverserSynchronousProxy {
546 type Protocol = ReverserMarker;
547
548 fn from_client(value: fidl::endpoints::ClientEnd<ReverserMarker>) -> Self {
549 Self::new(value.into_channel())
550 }
551}
552
553#[derive(Debug, Clone)]
554pub struct ReverserProxy {
555 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
556}
557
558impl fidl::endpoints::Proxy for ReverserProxy {
559 type Protocol = ReverserMarker;
560
561 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
562 Self::new(inner)
563 }
564
565 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
566 self.client.into_channel().map_err(|client| Self { client })
567 }
568
569 fn as_channel(&self) -> &::fidl::AsyncChannel {
570 self.client.as_channel()
571 }
572}
573
574impl ReverserProxy {
575 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
577 let protocol_name = <ReverserMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
578 Self { client: fidl::client::Client::new(channel, protocol_name) }
579 }
580
581 pub fn take_event_stream(&self) -> ReverserEventStream {
587 ReverserEventStream { event_receiver: self.client.take_event_receiver() }
588 }
589
590 pub fn r#reverse(
591 &self,
592 mut input: &str,
593 ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
594 ReverserProxyInterface::r#reverse(self, input)
595 }
596}
597
598impl ReverserProxyInterface for ReverserProxy {
599 type ReverseResponseFut =
600 fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
601 fn r#reverse(&self, mut input: &str) -> Self::ReverseResponseFut {
602 fn _decode(
603 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
604 ) -> Result<String, fidl::Error> {
605 let _response = fidl::client::decode_transaction_body::<
606 ReverserReverseResponse,
607 fidl::encoding::DefaultFuchsiaResourceDialect,
608 0x481eccb3af87ff3e,
609 >(_buf?)?;
610 Ok(_response.response)
611 }
612 self.client.send_query_and_decode::<ReverserReverseRequest, String>(
613 (input,),
614 0x481eccb3af87ff3e,
615 fidl::encoding::DynamicFlags::empty(),
616 _decode,
617 )
618 }
619}
620
621pub struct ReverserEventStream {
622 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
623}
624
625impl std::marker::Unpin for ReverserEventStream {}
626
627impl futures::stream::FusedStream for ReverserEventStream {
628 fn is_terminated(&self) -> bool {
629 self.event_receiver.is_terminated()
630 }
631}
632
633impl futures::Stream for ReverserEventStream {
634 type Item = Result<ReverserEvent, fidl::Error>;
635
636 fn poll_next(
637 mut self: std::pin::Pin<&mut Self>,
638 cx: &mut std::task::Context<'_>,
639 ) -> std::task::Poll<Option<Self::Item>> {
640 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
641 &mut self.event_receiver,
642 cx
643 )?) {
644 Some(buf) => std::task::Poll::Ready(Some(ReverserEvent::decode(buf))),
645 None => std::task::Poll::Ready(None),
646 }
647 }
648}
649
650#[derive(Debug)]
651pub enum ReverserEvent {}
652
653impl ReverserEvent {
654 fn decode(
656 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
657 ) -> Result<ReverserEvent, fidl::Error> {
658 let (bytes, _handles) = buf.split_mut();
659 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
660 debug_assert_eq!(tx_header.tx_id, 0);
661 match tx_header.ordinal {
662 _ => Err(fidl::Error::UnknownOrdinal {
663 ordinal: tx_header.ordinal,
664 protocol_name: <ReverserMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
665 }),
666 }
667 }
668}
669
670pub struct ReverserRequestStream {
672 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
673 is_terminated: bool,
674}
675
676impl std::marker::Unpin for ReverserRequestStream {}
677
678impl futures::stream::FusedStream for ReverserRequestStream {
679 fn is_terminated(&self) -> bool {
680 self.is_terminated
681 }
682}
683
684impl fidl::endpoints::RequestStream for ReverserRequestStream {
685 type Protocol = ReverserMarker;
686 type ControlHandle = ReverserControlHandle;
687
688 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
689 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
690 }
691
692 fn control_handle(&self) -> Self::ControlHandle {
693 ReverserControlHandle { inner: self.inner.clone() }
694 }
695
696 fn into_inner(
697 self,
698 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
699 {
700 (self.inner, self.is_terminated)
701 }
702
703 fn from_inner(
704 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
705 is_terminated: bool,
706 ) -> Self {
707 Self { inner, is_terminated }
708 }
709}
710
711impl futures::Stream for ReverserRequestStream {
712 type Item = Result<ReverserRequest, fidl::Error>;
713
714 fn poll_next(
715 mut self: std::pin::Pin<&mut Self>,
716 cx: &mut std::task::Context<'_>,
717 ) -> std::task::Poll<Option<Self::Item>> {
718 let this = &mut *self;
719 if this.inner.check_shutdown(cx) {
720 this.is_terminated = true;
721 return std::task::Poll::Ready(None);
722 }
723 if this.is_terminated {
724 panic!("polled ReverserRequestStream after completion");
725 }
726 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
727 |bytes, handles| {
728 match this.inner.channel().read_etc(cx, bytes, handles) {
729 std::task::Poll::Ready(Ok(())) => {}
730 std::task::Poll::Pending => return std::task::Poll::Pending,
731 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
732 this.is_terminated = true;
733 return std::task::Poll::Ready(None);
734 }
735 std::task::Poll::Ready(Err(e)) => {
736 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
737 e.into(),
738 ))));
739 }
740 }
741
742 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
744
745 std::task::Poll::Ready(Some(match header.ordinal {
746 0x481eccb3af87ff3e => {
747 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
748 let mut req = fidl::new_empty!(
749 ReverserReverseRequest,
750 fidl::encoding::DefaultFuchsiaResourceDialect
751 );
752 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ReverserReverseRequest>(&header, _body_bytes, handles, &mut req)?;
753 let control_handle = ReverserControlHandle { inner: this.inner.clone() };
754 Ok(ReverserRequest::Reverse {
755 input: req.input,
756
757 responder: ReverserReverseResponder {
758 control_handle: std::mem::ManuallyDrop::new(control_handle),
759 tx_id: header.tx_id,
760 },
761 })
762 }
763 _ => Err(fidl::Error::UnknownOrdinal {
764 ordinal: header.ordinal,
765 protocol_name:
766 <ReverserMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
767 }),
768 }))
769 },
770 )
771 }
772}
773
774#[derive(Debug)]
775pub enum ReverserRequest {
776 Reverse { input: String, responder: ReverserReverseResponder },
777}
778
779impl ReverserRequest {
780 #[allow(irrefutable_let_patterns)]
781 pub fn into_reverse(self) -> Option<(String, ReverserReverseResponder)> {
782 if let ReverserRequest::Reverse { input, responder } = self {
783 Some((input, responder))
784 } else {
785 None
786 }
787 }
788
789 pub fn method_name(&self) -> &'static str {
791 match *self {
792 ReverserRequest::Reverse { .. } => "reverse",
793 }
794 }
795}
796
797#[derive(Debug, Clone)]
798pub struct ReverserControlHandle {
799 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
800}
801
802impl fidl::endpoints::ControlHandle for ReverserControlHandle {
803 fn shutdown(&self) {
804 self.inner.shutdown()
805 }
806
807 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
808 self.inner.shutdown_with_epitaph(status)
809 }
810
811 fn is_closed(&self) -> bool {
812 self.inner.channel().is_closed()
813 }
814 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
815 self.inner.channel().on_closed()
816 }
817
818 #[cfg(target_os = "fuchsia")]
819 fn signal_peer(
820 &self,
821 clear_mask: zx::Signals,
822 set_mask: zx::Signals,
823 ) -> Result<(), zx_status::Status> {
824 use fidl::Peered;
825 self.inner.channel().signal_peer(clear_mask, set_mask)
826 }
827}
828
829impl ReverserControlHandle {}
830
831#[must_use = "FIDL methods require a response to be sent"]
832#[derive(Debug)]
833pub struct ReverserReverseResponder {
834 control_handle: std::mem::ManuallyDrop<ReverserControlHandle>,
835 tx_id: u32,
836}
837
838impl std::ops::Drop for ReverserReverseResponder {
842 fn drop(&mut self) {
843 self.control_handle.shutdown();
844 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
846 }
847}
848
849impl fidl::endpoints::Responder for ReverserReverseResponder {
850 type ControlHandle = ReverserControlHandle;
851
852 fn control_handle(&self) -> &ReverserControlHandle {
853 &self.control_handle
854 }
855
856 fn drop_without_shutdown(mut self) {
857 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
859 std::mem::forget(self);
861 }
862}
863
864impl ReverserReverseResponder {
865 pub fn send(self, mut response: &str) -> Result<(), fidl::Error> {
869 let _result = self.send_raw(response);
870 if _result.is_err() {
871 self.control_handle.shutdown();
872 }
873 self.drop_without_shutdown();
874 _result
875 }
876
877 pub fn send_no_shutdown_on_err(self, mut response: &str) -> Result<(), fidl::Error> {
879 let _result = self.send_raw(response);
880 self.drop_without_shutdown();
881 _result
882 }
883
884 fn send_raw(&self, mut response: &str) -> Result<(), fidl::Error> {
885 self.control_handle.inner.send::<ReverserReverseResponse>(
886 (response,),
887 self.tx_id,
888 0x481eccb3af87ff3e,
889 fidl::encoding::DynamicFlags::empty(),
890 )
891 }
892}
893
894mod internal {
895 use super::*;
896}