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