fidl_fuchsia_example_power/
fidl_fuchsia_example_power.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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_example_power__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct MessageSourceReceiveMessagesRequest {
16    pub socket: fidl::Socket,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for MessageSourceReceiveMessagesRequest
21{
22}
23
24#[derive(Debug, Default, PartialEq)]
25pub struct LeaseBaton {
26    pub lease: Option<fidl::EventPair>,
27    pub msg_index: Option<u64>,
28    #[doc(hidden)]
29    pub __source_breaking: fidl::marker::SourceBreaking,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for LeaseBaton {}
33
34#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
35pub struct CounterMarker;
36
37impl fidl::endpoints::ProtocolMarker for CounterMarker {
38    type Proxy = CounterProxy;
39    type RequestStream = CounterRequestStream;
40    #[cfg(target_os = "fuchsia")]
41    type SynchronousProxy = CounterSynchronousProxy;
42
43    const DEBUG_NAME: &'static str = "fuchsia.example.power.Counter";
44}
45impl fidl::endpoints::DiscoverableProtocolMarker for CounterMarker {}
46
47pub trait CounterProxyInterface: Send + Sync {
48    type GetResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
49    fn r#get(&self) -> Self::GetResponseFut;
50}
51#[derive(Debug)]
52#[cfg(target_os = "fuchsia")]
53pub struct CounterSynchronousProxy {
54    client: fidl::client::sync::Client,
55}
56
57#[cfg(target_os = "fuchsia")]
58impl fidl::endpoints::SynchronousProxy for CounterSynchronousProxy {
59    type Proxy = CounterProxy;
60    type Protocol = CounterMarker;
61
62    fn from_channel(inner: fidl::Channel) -> Self {
63        Self::new(inner)
64    }
65
66    fn into_channel(self) -> fidl::Channel {
67        self.client.into_channel()
68    }
69
70    fn as_channel(&self) -> &fidl::Channel {
71        self.client.as_channel()
72    }
73}
74
75#[cfg(target_os = "fuchsia")]
76impl CounterSynchronousProxy {
77    pub fn new(channel: fidl::Channel) -> Self {
78        let protocol_name = <CounterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
79        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
80    }
81
82    pub fn into_channel(self) -> fidl::Channel {
83        self.client.into_channel()
84    }
85
86    /// Waits until an event arrives and returns it. It is safe for other
87    /// threads to make concurrent requests while waiting for an event.
88    pub fn wait_for_event(
89        &self,
90        deadline: zx::MonotonicInstant,
91    ) -> Result<CounterEvent, fidl::Error> {
92        CounterEvent::decode(self.client.wait_for_event(deadline)?)
93    }
94
95    pub fn r#get(&self, ___deadline: zx::MonotonicInstant) -> Result<u64, fidl::Error> {
96        let _response =
97            self.client.send_query::<fidl::encoding::EmptyPayload, CounterGetResponse>(
98                (),
99                0x3944f6d91c5b8ad8,
100                fidl::encoding::DynamicFlags::empty(),
101                ___deadline,
102            )?;
103        Ok(_response.count)
104    }
105}
106
107#[cfg(target_os = "fuchsia")]
108impl From<CounterSynchronousProxy> for zx::NullableHandle {
109    fn from(value: CounterSynchronousProxy) -> Self {
110        value.into_channel().into()
111    }
112}
113
114#[cfg(target_os = "fuchsia")]
115impl From<fidl::Channel> for CounterSynchronousProxy {
116    fn from(value: fidl::Channel) -> Self {
117        Self::new(value)
118    }
119}
120
121#[cfg(target_os = "fuchsia")]
122impl fidl::endpoints::FromClient for CounterSynchronousProxy {
123    type Protocol = CounterMarker;
124
125    fn from_client(value: fidl::endpoints::ClientEnd<CounterMarker>) -> Self {
126        Self::new(value.into_channel())
127    }
128}
129
130#[derive(Debug, Clone)]
131pub struct CounterProxy {
132    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
133}
134
135impl fidl::endpoints::Proxy for CounterProxy {
136    type Protocol = CounterMarker;
137
138    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
139        Self::new(inner)
140    }
141
142    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
143        self.client.into_channel().map_err(|client| Self { client })
144    }
145
146    fn as_channel(&self) -> &::fidl::AsyncChannel {
147        self.client.as_channel()
148    }
149}
150
151impl CounterProxy {
152    /// Create a new Proxy for fuchsia.example.power/Counter.
153    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
154        let protocol_name = <CounterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
155        Self { client: fidl::client::Client::new(channel, protocol_name) }
156    }
157
158    /// Get a Stream of events from the remote end of the protocol.
159    ///
160    /// # Panics
161    ///
162    /// Panics if the event stream was already taken.
163    pub fn take_event_stream(&self) -> CounterEventStream {
164        CounterEventStream { event_receiver: self.client.take_event_receiver() }
165    }
166
167    pub fn r#get(
168        &self,
169    ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
170        CounterProxyInterface::r#get(self)
171    }
172}
173
174impl CounterProxyInterface for CounterProxy {
175    type GetResponseFut =
176        fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
177    fn r#get(&self) -> Self::GetResponseFut {
178        fn _decode(
179            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
180        ) -> Result<u64, fidl::Error> {
181            let _response = fidl::client::decode_transaction_body::<
182                CounterGetResponse,
183                fidl::encoding::DefaultFuchsiaResourceDialect,
184                0x3944f6d91c5b8ad8,
185            >(_buf?)?;
186            Ok(_response.count)
187        }
188        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u64>(
189            (),
190            0x3944f6d91c5b8ad8,
191            fidl::encoding::DynamicFlags::empty(),
192            _decode,
193        )
194    }
195}
196
197pub struct CounterEventStream {
198    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
199}
200
201impl std::marker::Unpin for CounterEventStream {}
202
203impl futures::stream::FusedStream for CounterEventStream {
204    fn is_terminated(&self) -> bool {
205        self.event_receiver.is_terminated()
206    }
207}
208
209impl futures::Stream for CounterEventStream {
210    type Item = Result<CounterEvent, fidl::Error>;
211
212    fn poll_next(
213        mut self: std::pin::Pin<&mut Self>,
214        cx: &mut std::task::Context<'_>,
215    ) -> std::task::Poll<Option<Self::Item>> {
216        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
217            &mut self.event_receiver,
218            cx
219        )?) {
220            Some(buf) => std::task::Poll::Ready(Some(CounterEvent::decode(buf))),
221            None => std::task::Poll::Ready(None),
222        }
223    }
224}
225
226#[derive(Debug)]
227pub enum CounterEvent {}
228
229impl CounterEvent {
230    /// Decodes a message buffer as a [`CounterEvent`].
231    fn decode(
232        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
233    ) -> Result<CounterEvent, fidl::Error> {
234        let (bytes, _handles) = buf.split_mut();
235        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
236        debug_assert_eq!(tx_header.tx_id, 0);
237        match tx_header.ordinal {
238            _ => Err(fidl::Error::UnknownOrdinal {
239                ordinal: tx_header.ordinal,
240                protocol_name: <CounterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
241            }),
242        }
243    }
244}
245
246/// A Stream of incoming requests for fuchsia.example.power/Counter.
247pub struct CounterRequestStream {
248    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
249    is_terminated: bool,
250}
251
252impl std::marker::Unpin for CounterRequestStream {}
253
254impl futures::stream::FusedStream for CounterRequestStream {
255    fn is_terminated(&self) -> bool {
256        self.is_terminated
257    }
258}
259
260impl fidl::endpoints::RequestStream for CounterRequestStream {
261    type Protocol = CounterMarker;
262    type ControlHandle = CounterControlHandle;
263
264    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
265        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
266    }
267
268    fn control_handle(&self) -> Self::ControlHandle {
269        CounterControlHandle { inner: self.inner.clone() }
270    }
271
272    fn into_inner(
273        self,
274    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
275    {
276        (self.inner, self.is_terminated)
277    }
278
279    fn from_inner(
280        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
281        is_terminated: bool,
282    ) -> Self {
283        Self { inner, is_terminated }
284    }
285}
286
287impl futures::Stream for CounterRequestStream {
288    type Item = Result<CounterRequest, fidl::Error>;
289
290    fn poll_next(
291        mut self: std::pin::Pin<&mut Self>,
292        cx: &mut std::task::Context<'_>,
293    ) -> std::task::Poll<Option<Self::Item>> {
294        let this = &mut *self;
295        if this.inner.check_shutdown(cx) {
296            this.is_terminated = true;
297            return std::task::Poll::Ready(None);
298        }
299        if this.is_terminated {
300            panic!("polled CounterRequestStream after completion");
301        }
302        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
303            |bytes, handles| {
304                match this.inner.channel().read_etc(cx, bytes, handles) {
305                    std::task::Poll::Ready(Ok(())) => {}
306                    std::task::Poll::Pending => return std::task::Poll::Pending,
307                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
308                        this.is_terminated = true;
309                        return std::task::Poll::Ready(None);
310                    }
311                    std::task::Poll::Ready(Err(e)) => {
312                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
313                            e.into(),
314                        ))));
315                    }
316                }
317
318                // A message has been received from the channel
319                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
320
321                std::task::Poll::Ready(Some(match header.ordinal {
322                    0x3944f6d91c5b8ad8 => {
323                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
324                        let mut req = fidl::new_empty!(
325                            fidl::encoding::EmptyPayload,
326                            fidl::encoding::DefaultFuchsiaResourceDialect
327                        );
328                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
329                        let control_handle = CounterControlHandle { inner: this.inner.clone() };
330                        Ok(CounterRequest::Get {
331                            responder: CounterGetResponder {
332                                control_handle: std::mem::ManuallyDrop::new(control_handle),
333                                tx_id: header.tx_id,
334                            },
335                        })
336                    }
337                    _ => Err(fidl::Error::UnknownOrdinal {
338                        ordinal: header.ordinal,
339                        protocol_name:
340                            <CounterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
341                    }),
342                }))
343            },
344        )
345    }
346}
347
348#[derive(Debug)]
349pub enum CounterRequest {
350    Get { responder: CounterGetResponder },
351}
352
353impl CounterRequest {
354    #[allow(irrefutable_let_patterns)]
355    pub fn into_get(self) -> Option<(CounterGetResponder)> {
356        if let CounterRequest::Get { responder } = self { Some((responder)) } else { None }
357    }
358
359    /// Name of the method defined in FIDL
360    pub fn method_name(&self) -> &'static str {
361        match *self {
362            CounterRequest::Get { .. } => "get",
363        }
364    }
365}
366
367#[derive(Debug, Clone)]
368pub struct CounterControlHandle {
369    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
370}
371
372impl fidl::endpoints::ControlHandle for CounterControlHandle {
373    fn shutdown(&self) {
374        self.inner.shutdown()
375    }
376
377    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
378        self.inner.shutdown_with_epitaph(status)
379    }
380
381    fn is_closed(&self) -> bool {
382        self.inner.channel().is_closed()
383    }
384    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
385        self.inner.channel().on_closed()
386    }
387
388    #[cfg(target_os = "fuchsia")]
389    fn signal_peer(
390        &self,
391        clear_mask: zx::Signals,
392        set_mask: zx::Signals,
393    ) -> Result<(), zx_status::Status> {
394        use fidl::Peered;
395        self.inner.channel().signal_peer(clear_mask, set_mask)
396    }
397}
398
399impl CounterControlHandle {}
400
401#[must_use = "FIDL methods require a response to be sent"]
402#[derive(Debug)]
403pub struct CounterGetResponder {
404    control_handle: std::mem::ManuallyDrop<CounterControlHandle>,
405    tx_id: u32,
406}
407
408/// Set the the channel to be shutdown (see [`CounterControlHandle::shutdown`])
409/// if the responder is dropped without sending a response, so that the client
410/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
411impl std::ops::Drop for CounterGetResponder {
412    fn drop(&mut self) {
413        self.control_handle.shutdown();
414        // Safety: drops once, never accessed again
415        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
416    }
417}
418
419impl fidl::endpoints::Responder for CounterGetResponder {
420    type ControlHandle = CounterControlHandle;
421
422    fn control_handle(&self) -> &CounterControlHandle {
423        &self.control_handle
424    }
425
426    fn drop_without_shutdown(mut self) {
427        // Safety: drops once, never accessed again due to mem::forget
428        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
429        // Prevent Drop from running (which would shut down the channel)
430        std::mem::forget(self);
431    }
432}
433
434impl CounterGetResponder {
435    /// Sends a response to the FIDL transaction.
436    ///
437    /// Sets the channel to shutdown if an error occurs.
438    pub fn send(self, mut count: u64) -> Result<(), fidl::Error> {
439        let _result = self.send_raw(count);
440        if _result.is_err() {
441            self.control_handle.shutdown();
442        }
443        self.drop_without_shutdown();
444        _result
445    }
446
447    /// Similar to "send" but does not shutdown the channel if an error occurs.
448    pub fn send_no_shutdown_on_err(self, mut count: u64) -> Result<(), fidl::Error> {
449        let _result = self.send_raw(count);
450        self.drop_without_shutdown();
451        _result
452    }
453
454    fn send_raw(&self, mut count: u64) -> Result<(), fidl::Error> {
455        self.control_handle.inner.send::<CounterGetResponse>(
456            (count,),
457            self.tx_id,
458            0x3944f6d91c5b8ad8,
459            fidl::encoding::DynamicFlags::empty(),
460        )
461    }
462}
463
464#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
465pub struct FrameControlMarker;
466
467impl fidl::endpoints::ProtocolMarker for FrameControlMarker {
468    type Proxy = FrameControlProxy;
469    type RequestStream = FrameControlRequestStream;
470    #[cfg(target_os = "fuchsia")]
471    type SynchronousProxy = FrameControlSynchronousProxy;
472
473    const DEBUG_NAME: &'static str = "fuchsia.example.power.FrameControl";
474}
475impl fidl::endpoints::DiscoverableProtocolMarker for FrameControlMarker {}
476
477pub trait FrameControlProxyInterface: Send + Sync {
478    type StartFrameResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
479    fn r#start_frame(
480        &self,
481        duration_ms: u16,
482        rate_change_offset_ms: u16,
483    ) -> Self::StartFrameResponseFut;
484}
485#[derive(Debug)]
486#[cfg(target_os = "fuchsia")]
487pub struct FrameControlSynchronousProxy {
488    client: fidl::client::sync::Client,
489}
490
491#[cfg(target_os = "fuchsia")]
492impl fidl::endpoints::SynchronousProxy for FrameControlSynchronousProxy {
493    type Proxy = FrameControlProxy;
494    type Protocol = FrameControlMarker;
495
496    fn from_channel(inner: fidl::Channel) -> Self {
497        Self::new(inner)
498    }
499
500    fn into_channel(self) -> fidl::Channel {
501        self.client.into_channel()
502    }
503
504    fn as_channel(&self) -> &fidl::Channel {
505        self.client.as_channel()
506    }
507}
508
509#[cfg(target_os = "fuchsia")]
510impl FrameControlSynchronousProxy {
511    pub fn new(channel: fidl::Channel) -> Self {
512        let protocol_name = <FrameControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
513        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
514    }
515
516    pub fn into_channel(self) -> fidl::Channel {
517        self.client.into_channel()
518    }
519
520    /// Waits until an event arrives and returns it. It is safe for other
521    /// threads to make concurrent requests while waiting for an event.
522    pub fn wait_for_event(
523        &self,
524        deadline: zx::MonotonicInstant,
525    ) -> Result<FrameControlEvent, fidl::Error> {
526        FrameControlEvent::decode(self.client.wait_for_event(deadline)?)
527    }
528
529    pub fn r#start_frame(
530        &self,
531        mut duration_ms: u16,
532        mut rate_change_offset_ms: u16,
533        ___deadline: zx::MonotonicInstant,
534    ) -> Result<(), fidl::Error> {
535        let _response =
536            self.client.send_query::<FrameControlStartFrameRequest, fidl::encoding::EmptyPayload>(
537                (duration_ms, rate_change_offset_ms),
538                0x187c1cc46de29b5e,
539                fidl::encoding::DynamicFlags::empty(),
540                ___deadline,
541            )?;
542        Ok(_response)
543    }
544}
545
546#[cfg(target_os = "fuchsia")]
547impl From<FrameControlSynchronousProxy> for zx::NullableHandle {
548    fn from(value: FrameControlSynchronousProxy) -> Self {
549        value.into_channel().into()
550    }
551}
552
553#[cfg(target_os = "fuchsia")]
554impl From<fidl::Channel> for FrameControlSynchronousProxy {
555    fn from(value: fidl::Channel) -> Self {
556        Self::new(value)
557    }
558}
559
560#[cfg(target_os = "fuchsia")]
561impl fidl::endpoints::FromClient for FrameControlSynchronousProxy {
562    type Protocol = FrameControlMarker;
563
564    fn from_client(value: fidl::endpoints::ClientEnd<FrameControlMarker>) -> Self {
565        Self::new(value.into_channel())
566    }
567}
568
569#[derive(Debug, Clone)]
570pub struct FrameControlProxy {
571    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
572}
573
574impl fidl::endpoints::Proxy for FrameControlProxy {
575    type Protocol = FrameControlMarker;
576
577    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
578        Self::new(inner)
579    }
580
581    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
582        self.client.into_channel().map_err(|client| Self { client })
583    }
584
585    fn as_channel(&self) -> &::fidl::AsyncChannel {
586        self.client.as_channel()
587    }
588}
589
590impl FrameControlProxy {
591    /// Create a new Proxy for fuchsia.example.power/FrameControl.
592    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
593        let protocol_name = <FrameControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
594        Self { client: fidl::client::Client::new(channel, protocol_name) }
595    }
596
597    /// Get a Stream of events from the remote end of the protocol.
598    ///
599    /// # Panics
600    ///
601    /// Panics if the event stream was already taken.
602    pub fn take_event_stream(&self) -> FrameControlEventStream {
603        FrameControlEventStream { event_receiver: self.client.take_event_receiver() }
604    }
605
606    pub fn r#start_frame(
607        &self,
608        mut duration_ms: u16,
609        mut rate_change_offset_ms: u16,
610    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
611        FrameControlProxyInterface::r#start_frame(self, duration_ms, rate_change_offset_ms)
612    }
613}
614
615impl FrameControlProxyInterface for FrameControlProxy {
616    type StartFrameResponseFut =
617        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
618    fn r#start_frame(
619        &self,
620        mut duration_ms: u16,
621        mut rate_change_offset_ms: u16,
622    ) -> Self::StartFrameResponseFut {
623        fn _decode(
624            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
625        ) -> Result<(), fidl::Error> {
626            let _response = fidl::client::decode_transaction_body::<
627                fidl::encoding::EmptyPayload,
628                fidl::encoding::DefaultFuchsiaResourceDialect,
629                0x187c1cc46de29b5e,
630            >(_buf?)?;
631            Ok(_response)
632        }
633        self.client.send_query_and_decode::<FrameControlStartFrameRequest, ()>(
634            (duration_ms, rate_change_offset_ms),
635            0x187c1cc46de29b5e,
636            fidl::encoding::DynamicFlags::empty(),
637            _decode,
638        )
639    }
640}
641
642pub struct FrameControlEventStream {
643    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
644}
645
646impl std::marker::Unpin for FrameControlEventStream {}
647
648impl futures::stream::FusedStream for FrameControlEventStream {
649    fn is_terminated(&self) -> bool {
650        self.event_receiver.is_terminated()
651    }
652}
653
654impl futures::Stream for FrameControlEventStream {
655    type Item = Result<FrameControlEvent, fidl::Error>;
656
657    fn poll_next(
658        mut self: std::pin::Pin<&mut Self>,
659        cx: &mut std::task::Context<'_>,
660    ) -> std::task::Poll<Option<Self::Item>> {
661        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
662            &mut self.event_receiver,
663            cx
664        )?) {
665            Some(buf) => std::task::Poll::Ready(Some(FrameControlEvent::decode(buf))),
666            None => std::task::Poll::Ready(None),
667        }
668    }
669}
670
671#[derive(Debug)]
672pub enum FrameControlEvent {}
673
674impl FrameControlEvent {
675    /// Decodes a message buffer as a [`FrameControlEvent`].
676    fn decode(
677        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
678    ) -> Result<FrameControlEvent, fidl::Error> {
679        let (bytes, _handles) = buf.split_mut();
680        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
681        debug_assert_eq!(tx_header.tx_id, 0);
682        match tx_header.ordinal {
683            _ => Err(fidl::Error::UnknownOrdinal {
684                ordinal: tx_header.ordinal,
685                protocol_name: <FrameControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
686            }),
687        }
688    }
689}
690
691/// A Stream of incoming requests for fuchsia.example.power/FrameControl.
692pub struct FrameControlRequestStream {
693    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
694    is_terminated: bool,
695}
696
697impl std::marker::Unpin for FrameControlRequestStream {}
698
699impl futures::stream::FusedStream for FrameControlRequestStream {
700    fn is_terminated(&self) -> bool {
701        self.is_terminated
702    }
703}
704
705impl fidl::endpoints::RequestStream for FrameControlRequestStream {
706    type Protocol = FrameControlMarker;
707    type ControlHandle = FrameControlControlHandle;
708
709    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
710        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
711    }
712
713    fn control_handle(&self) -> Self::ControlHandle {
714        FrameControlControlHandle { inner: self.inner.clone() }
715    }
716
717    fn into_inner(
718        self,
719    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
720    {
721        (self.inner, self.is_terminated)
722    }
723
724    fn from_inner(
725        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
726        is_terminated: bool,
727    ) -> Self {
728        Self { inner, is_terminated }
729    }
730}
731
732impl futures::Stream for FrameControlRequestStream {
733    type Item = Result<FrameControlRequest, fidl::Error>;
734
735    fn poll_next(
736        mut self: std::pin::Pin<&mut Self>,
737        cx: &mut std::task::Context<'_>,
738    ) -> std::task::Poll<Option<Self::Item>> {
739        let this = &mut *self;
740        if this.inner.check_shutdown(cx) {
741            this.is_terminated = true;
742            return std::task::Poll::Ready(None);
743        }
744        if this.is_terminated {
745            panic!("polled FrameControlRequestStream after completion");
746        }
747        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
748            |bytes, handles| {
749                match this.inner.channel().read_etc(cx, bytes, handles) {
750                    std::task::Poll::Ready(Ok(())) => {}
751                    std::task::Poll::Pending => return std::task::Poll::Pending,
752                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
753                        this.is_terminated = true;
754                        return std::task::Poll::Ready(None);
755                    }
756                    std::task::Poll::Ready(Err(e)) => {
757                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
758                            e.into(),
759                        ))));
760                    }
761                }
762
763                // A message has been received from the channel
764                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
765
766                std::task::Poll::Ready(Some(match header.ordinal {
767                    0x187c1cc46de29b5e => {
768                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
769                        let mut req = fidl::new_empty!(
770                            FrameControlStartFrameRequest,
771                            fidl::encoding::DefaultFuchsiaResourceDialect
772                        );
773                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FrameControlStartFrameRequest>(&header, _body_bytes, handles, &mut req)?;
774                        let control_handle =
775                            FrameControlControlHandle { inner: this.inner.clone() };
776                        Ok(FrameControlRequest::StartFrame {
777                            duration_ms: req.duration_ms,
778                            rate_change_offset_ms: req.rate_change_offset_ms,
779
780                            responder: FrameControlStartFrameResponder {
781                                control_handle: std::mem::ManuallyDrop::new(control_handle),
782                                tx_id: header.tx_id,
783                            },
784                        })
785                    }
786                    _ => Err(fidl::Error::UnknownOrdinal {
787                        ordinal: header.ordinal,
788                        protocol_name:
789                            <FrameControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
790                    }),
791                }))
792            },
793        )
794    }
795}
796
797#[derive(Debug)]
798pub enum FrameControlRequest {
799    StartFrame {
800        duration_ms: u16,
801        rate_change_offset_ms: u16,
802        responder: FrameControlStartFrameResponder,
803    },
804}
805
806impl FrameControlRequest {
807    #[allow(irrefutable_let_patterns)]
808    pub fn into_start_frame(self) -> Option<(u16, u16, FrameControlStartFrameResponder)> {
809        if let FrameControlRequest::StartFrame { duration_ms, rate_change_offset_ms, responder } =
810            self
811        {
812            Some((duration_ms, rate_change_offset_ms, responder))
813        } else {
814            None
815        }
816    }
817
818    /// Name of the method defined in FIDL
819    pub fn method_name(&self) -> &'static str {
820        match *self {
821            FrameControlRequest::StartFrame { .. } => "start_frame",
822        }
823    }
824}
825
826#[derive(Debug, Clone)]
827pub struct FrameControlControlHandle {
828    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
829}
830
831impl fidl::endpoints::ControlHandle for FrameControlControlHandle {
832    fn shutdown(&self) {
833        self.inner.shutdown()
834    }
835
836    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
837        self.inner.shutdown_with_epitaph(status)
838    }
839
840    fn is_closed(&self) -> bool {
841        self.inner.channel().is_closed()
842    }
843    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
844        self.inner.channel().on_closed()
845    }
846
847    #[cfg(target_os = "fuchsia")]
848    fn signal_peer(
849        &self,
850        clear_mask: zx::Signals,
851        set_mask: zx::Signals,
852    ) -> Result<(), zx_status::Status> {
853        use fidl::Peered;
854        self.inner.channel().signal_peer(clear_mask, set_mask)
855    }
856}
857
858impl FrameControlControlHandle {}
859
860#[must_use = "FIDL methods require a response to be sent"]
861#[derive(Debug)]
862pub struct FrameControlStartFrameResponder {
863    control_handle: std::mem::ManuallyDrop<FrameControlControlHandle>,
864    tx_id: u32,
865}
866
867/// Set the the channel to be shutdown (see [`FrameControlControlHandle::shutdown`])
868/// if the responder is dropped without sending a response, so that the client
869/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
870impl std::ops::Drop for FrameControlStartFrameResponder {
871    fn drop(&mut self) {
872        self.control_handle.shutdown();
873        // Safety: drops once, never accessed again
874        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
875    }
876}
877
878impl fidl::endpoints::Responder for FrameControlStartFrameResponder {
879    type ControlHandle = FrameControlControlHandle;
880
881    fn control_handle(&self) -> &FrameControlControlHandle {
882        &self.control_handle
883    }
884
885    fn drop_without_shutdown(mut self) {
886        // Safety: drops once, never accessed again due to mem::forget
887        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
888        // Prevent Drop from running (which would shut down the channel)
889        std::mem::forget(self);
890    }
891}
892
893impl FrameControlStartFrameResponder {
894    /// Sends a response to the FIDL transaction.
895    ///
896    /// Sets the channel to shutdown if an error occurs.
897    pub fn send(self) -> Result<(), fidl::Error> {
898        let _result = self.send_raw();
899        if _result.is_err() {
900            self.control_handle.shutdown();
901        }
902        self.drop_without_shutdown();
903        _result
904    }
905
906    /// Similar to "send" but does not shutdown the channel if an error occurs.
907    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
908        let _result = self.send_raw();
909        self.drop_without_shutdown();
910        _result
911    }
912
913    fn send_raw(&self) -> Result<(), fidl::Error> {
914        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
915            (),
916            self.tx_id,
917            0x187c1cc46de29b5e,
918            fidl::encoding::DynamicFlags::empty(),
919        )
920    }
921}
922
923#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
924pub struct MessageSourceMarker;
925
926impl fidl::endpoints::ProtocolMarker for MessageSourceMarker {
927    type Proxy = MessageSourceProxy;
928    type RequestStream = MessageSourceRequestStream;
929    #[cfg(target_os = "fuchsia")]
930    type SynchronousProxy = MessageSourceSynchronousProxy;
931
932    const DEBUG_NAME: &'static str = "fuchsia.example.power.MessageSource";
933}
934impl fidl::endpoints::DiscoverableProtocolMarker for MessageSourceMarker {}
935
936pub trait MessageSourceProxyInterface: Send + Sync {
937    type ReceiveMessagesResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
938    fn r#receive_messages(&self, socket: fidl::Socket) -> Self::ReceiveMessagesResponseFut;
939    type ReceiveBatonResponseFut: std::future::Future<Output = Result<LeaseBaton, fidl::Error>>
940        + Send;
941    fn r#receive_baton(&self) -> Self::ReceiveBatonResponseFut;
942}
943#[derive(Debug)]
944#[cfg(target_os = "fuchsia")]
945pub struct MessageSourceSynchronousProxy {
946    client: fidl::client::sync::Client,
947}
948
949#[cfg(target_os = "fuchsia")]
950impl fidl::endpoints::SynchronousProxy for MessageSourceSynchronousProxy {
951    type Proxy = MessageSourceProxy;
952    type Protocol = MessageSourceMarker;
953
954    fn from_channel(inner: fidl::Channel) -> Self {
955        Self::new(inner)
956    }
957
958    fn into_channel(self) -> fidl::Channel {
959        self.client.into_channel()
960    }
961
962    fn as_channel(&self) -> &fidl::Channel {
963        self.client.as_channel()
964    }
965}
966
967#[cfg(target_os = "fuchsia")]
968impl MessageSourceSynchronousProxy {
969    pub fn new(channel: fidl::Channel) -> Self {
970        let protocol_name = <MessageSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
971        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
972    }
973
974    pub fn into_channel(self) -> fidl::Channel {
975        self.client.into_channel()
976    }
977
978    /// Waits until an event arrives and returns it. It is safe for other
979    /// threads to make concurrent requests while waiting for an event.
980    pub fn wait_for_event(
981        &self,
982        deadline: zx::MonotonicInstant,
983    ) -> Result<MessageSourceEvent, fidl::Error> {
984        MessageSourceEvent::decode(self.client.wait_for_event(deadline)?)
985    }
986
987    pub fn r#receive_messages(
988        &self,
989        mut socket: fidl::Socket,
990        ___deadline: zx::MonotonicInstant,
991    ) -> Result<(), fidl::Error> {
992        let _response = self
993            .client
994            .send_query::<MessageSourceReceiveMessagesRequest, fidl::encoding::EmptyPayload>(
995                (socket,),
996                0x23351bdac594c749,
997                fidl::encoding::DynamicFlags::empty(),
998                ___deadline,
999            )?;
1000        Ok(_response)
1001    }
1002
1003    pub fn r#receive_baton(
1004        &self,
1005        ___deadline: zx::MonotonicInstant,
1006    ) -> Result<LeaseBaton, fidl::Error> {
1007        let _response = self.client.send_query::<fidl::encoding::EmptyPayload, LeaseBaton>(
1008            (),
1009            0x18ed150a92dd23ee,
1010            fidl::encoding::DynamicFlags::empty(),
1011            ___deadline,
1012        )?;
1013        Ok(_response)
1014    }
1015}
1016
1017#[cfg(target_os = "fuchsia")]
1018impl From<MessageSourceSynchronousProxy> for zx::NullableHandle {
1019    fn from(value: MessageSourceSynchronousProxy) -> Self {
1020        value.into_channel().into()
1021    }
1022}
1023
1024#[cfg(target_os = "fuchsia")]
1025impl From<fidl::Channel> for MessageSourceSynchronousProxy {
1026    fn from(value: fidl::Channel) -> Self {
1027        Self::new(value)
1028    }
1029}
1030
1031#[cfg(target_os = "fuchsia")]
1032impl fidl::endpoints::FromClient for MessageSourceSynchronousProxy {
1033    type Protocol = MessageSourceMarker;
1034
1035    fn from_client(value: fidl::endpoints::ClientEnd<MessageSourceMarker>) -> Self {
1036        Self::new(value.into_channel())
1037    }
1038}
1039
1040#[derive(Debug, Clone)]
1041pub struct MessageSourceProxy {
1042    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1043}
1044
1045impl fidl::endpoints::Proxy for MessageSourceProxy {
1046    type Protocol = MessageSourceMarker;
1047
1048    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1049        Self::new(inner)
1050    }
1051
1052    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1053        self.client.into_channel().map_err(|client| Self { client })
1054    }
1055
1056    fn as_channel(&self) -> &::fidl::AsyncChannel {
1057        self.client.as_channel()
1058    }
1059}
1060
1061impl MessageSourceProxy {
1062    /// Create a new Proxy for fuchsia.example.power/MessageSource.
1063    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1064        let protocol_name = <MessageSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1065        Self { client: fidl::client::Client::new(channel, protocol_name) }
1066    }
1067
1068    /// Get a Stream of events from the remote end of the protocol.
1069    ///
1070    /// # Panics
1071    ///
1072    /// Panics if the event stream was already taken.
1073    pub fn take_event_stream(&self) -> MessageSourceEventStream {
1074        MessageSourceEventStream { event_receiver: self.client.take_event_receiver() }
1075    }
1076
1077    pub fn r#receive_messages(
1078        &self,
1079        mut socket: fidl::Socket,
1080    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1081        MessageSourceProxyInterface::r#receive_messages(self, socket)
1082    }
1083
1084    pub fn r#receive_baton(
1085        &self,
1086    ) -> fidl::client::QueryResponseFut<LeaseBaton, fidl::encoding::DefaultFuchsiaResourceDialect>
1087    {
1088        MessageSourceProxyInterface::r#receive_baton(self)
1089    }
1090}
1091
1092impl MessageSourceProxyInterface for MessageSourceProxy {
1093    type ReceiveMessagesResponseFut =
1094        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1095    fn r#receive_messages(&self, mut socket: fidl::Socket) -> Self::ReceiveMessagesResponseFut {
1096        fn _decode(
1097            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1098        ) -> Result<(), fidl::Error> {
1099            let _response = fidl::client::decode_transaction_body::<
1100                fidl::encoding::EmptyPayload,
1101                fidl::encoding::DefaultFuchsiaResourceDialect,
1102                0x23351bdac594c749,
1103            >(_buf?)?;
1104            Ok(_response)
1105        }
1106        self.client.send_query_and_decode::<MessageSourceReceiveMessagesRequest, ()>(
1107            (socket,),
1108            0x23351bdac594c749,
1109            fidl::encoding::DynamicFlags::empty(),
1110            _decode,
1111        )
1112    }
1113
1114    type ReceiveBatonResponseFut =
1115        fidl::client::QueryResponseFut<LeaseBaton, fidl::encoding::DefaultFuchsiaResourceDialect>;
1116    fn r#receive_baton(&self) -> Self::ReceiveBatonResponseFut {
1117        fn _decode(
1118            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1119        ) -> Result<LeaseBaton, fidl::Error> {
1120            let _response = fidl::client::decode_transaction_body::<
1121                LeaseBaton,
1122                fidl::encoding::DefaultFuchsiaResourceDialect,
1123                0x18ed150a92dd23ee,
1124            >(_buf?)?;
1125            Ok(_response)
1126        }
1127        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, LeaseBaton>(
1128            (),
1129            0x18ed150a92dd23ee,
1130            fidl::encoding::DynamicFlags::empty(),
1131            _decode,
1132        )
1133    }
1134}
1135
1136pub struct MessageSourceEventStream {
1137    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1138}
1139
1140impl std::marker::Unpin for MessageSourceEventStream {}
1141
1142impl futures::stream::FusedStream for MessageSourceEventStream {
1143    fn is_terminated(&self) -> bool {
1144        self.event_receiver.is_terminated()
1145    }
1146}
1147
1148impl futures::Stream for MessageSourceEventStream {
1149    type Item = Result<MessageSourceEvent, fidl::Error>;
1150
1151    fn poll_next(
1152        mut self: std::pin::Pin<&mut Self>,
1153        cx: &mut std::task::Context<'_>,
1154    ) -> std::task::Poll<Option<Self::Item>> {
1155        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1156            &mut self.event_receiver,
1157            cx
1158        )?) {
1159            Some(buf) => std::task::Poll::Ready(Some(MessageSourceEvent::decode(buf))),
1160            None => std::task::Poll::Ready(None),
1161        }
1162    }
1163}
1164
1165#[derive(Debug)]
1166pub enum MessageSourceEvent {}
1167
1168impl MessageSourceEvent {
1169    /// Decodes a message buffer as a [`MessageSourceEvent`].
1170    fn decode(
1171        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1172    ) -> Result<MessageSourceEvent, fidl::Error> {
1173        let (bytes, _handles) = buf.split_mut();
1174        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1175        debug_assert_eq!(tx_header.tx_id, 0);
1176        match tx_header.ordinal {
1177            _ => Err(fidl::Error::UnknownOrdinal {
1178                ordinal: tx_header.ordinal,
1179                protocol_name: <MessageSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1180            }),
1181        }
1182    }
1183}
1184
1185/// A Stream of incoming requests for fuchsia.example.power/MessageSource.
1186pub struct MessageSourceRequestStream {
1187    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1188    is_terminated: bool,
1189}
1190
1191impl std::marker::Unpin for MessageSourceRequestStream {}
1192
1193impl futures::stream::FusedStream for MessageSourceRequestStream {
1194    fn is_terminated(&self) -> bool {
1195        self.is_terminated
1196    }
1197}
1198
1199impl fidl::endpoints::RequestStream for MessageSourceRequestStream {
1200    type Protocol = MessageSourceMarker;
1201    type ControlHandle = MessageSourceControlHandle;
1202
1203    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1204        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1205    }
1206
1207    fn control_handle(&self) -> Self::ControlHandle {
1208        MessageSourceControlHandle { inner: self.inner.clone() }
1209    }
1210
1211    fn into_inner(
1212        self,
1213    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1214    {
1215        (self.inner, self.is_terminated)
1216    }
1217
1218    fn from_inner(
1219        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1220        is_terminated: bool,
1221    ) -> Self {
1222        Self { inner, is_terminated }
1223    }
1224}
1225
1226impl futures::Stream for MessageSourceRequestStream {
1227    type Item = Result<MessageSourceRequest, fidl::Error>;
1228
1229    fn poll_next(
1230        mut self: std::pin::Pin<&mut Self>,
1231        cx: &mut std::task::Context<'_>,
1232    ) -> std::task::Poll<Option<Self::Item>> {
1233        let this = &mut *self;
1234        if this.inner.check_shutdown(cx) {
1235            this.is_terminated = true;
1236            return std::task::Poll::Ready(None);
1237        }
1238        if this.is_terminated {
1239            panic!("polled MessageSourceRequestStream after completion");
1240        }
1241        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1242            |bytes, handles| {
1243                match this.inner.channel().read_etc(cx, bytes, handles) {
1244                    std::task::Poll::Ready(Ok(())) => {}
1245                    std::task::Poll::Pending => return std::task::Poll::Pending,
1246                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1247                        this.is_terminated = true;
1248                        return std::task::Poll::Ready(None);
1249                    }
1250                    std::task::Poll::Ready(Err(e)) => {
1251                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1252                            e.into(),
1253                        ))));
1254                    }
1255                }
1256
1257                // A message has been received from the channel
1258                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1259
1260                std::task::Poll::Ready(Some(match header.ordinal {
1261                    0x23351bdac594c749 => {
1262                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1263                        let mut req = fidl::new_empty!(
1264                            MessageSourceReceiveMessagesRequest,
1265                            fidl::encoding::DefaultFuchsiaResourceDialect
1266                        );
1267                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MessageSourceReceiveMessagesRequest>(&header, _body_bytes, handles, &mut req)?;
1268                        let control_handle =
1269                            MessageSourceControlHandle { inner: this.inner.clone() };
1270                        Ok(MessageSourceRequest::ReceiveMessages {
1271                            socket: req.socket,
1272
1273                            responder: MessageSourceReceiveMessagesResponder {
1274                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1275                                tx_id: header.tx_id,
1276                            },
1277                        })
1278                    }
1279                    0x18ed150a92dd23ee => {
1280                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1281                        let mut req = fidl::new_empty!(
1282                            fidl::encoding::EmptyPayload,
1283                            fidl::encoding::DefaultFuchsiaResourceDialect
1284                        );
1285                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1286                        let control_handle =
1287                            MessageSourceControlHandle { inner: this.inner.clone() };
1288                        Ok(MessageSourceRequest::ReceiveBaton {
1289                            responder: MessageSourceReceiveBatonResponder {
1290                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1291                                tx_id: header.tx_id,
1292                            },
1293                        })
1294                    }
1295                    _ => Err(fidl::Error::UnknownOrdinal {
1296                        ordinal: header.ordinal,
1297                        protocol_name:
1298                            <MessageSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1299                    }),
1300                }))
1301            },
1302        )
1303    }
1304}
1305
1306#[derive(Debug)]
1307pub enum MessageSourceRequest {
1308    ReceiveMessages { socket: fidl::Socket, responder: MessageSourceReceiveMessagesResponder },
1309    ReceiveBaton { responder: MessageSourceReceiveBatonResponder },
1310}
1311
1312impl MessageSourceRequest {
1313    #[allow(irrefutable_let_patterns)]
1314    pub fn into_receive_messages(
1315        self,
1316    ) -> Option<(fidl::Socket, MessageSourceReceiveMessagesResponder)> {
1317        if let MessageSourceRequest::ReceiveMessages { socket, responder } = self {
1318            Some((socket, responder))
1319        } else {
1320            None
1321        }
1322    }
1323
1324    #[allow(irrefutable_let_patterns)]
1325    pub fn into_receive_baton(self) -> Option<(MessageSourceReceiveBatonResponder)> {
1326        if let MessageSourceRequest::ReceiveBaton { responder } = self {
1327            Some((responder))
1328        } else {
1329            None
1330        }
1331    }
1332
1333    /// Name of the method defined in FIDL
1334    pub fn method_name(&self) -> &'static str {
1335        match *self {
1336            MessageSourceRequest::ReceiveMessages { .. } => "receive_messages",
1337            MessageSourceRequest::ReceiveBaton { .. } => "receive_baton",
1338        }
1339    }
1340}
1341
1342#[derive(Debug, Clone)]
1343pub struct MessageSourceControlHandle {
1344    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1345}
1346
1347impl fidl::endpoints::ControlHandle for MessageSourceControlHandle {
1348    fn shutdown(&self) {
1349        self.inner.shutdown()
1350    }
1351
1352    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1353        self.inner.shutdown_with_epitaph(status)
1354    }
1355
1356    fn is_closed(&self) -> bool {
1357        self.inner.channel().is_closed()
1358    }
1359    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1360        self.inner.channel().on_closed()
1361    }
1362
1363    #[cfg(target_os = "fuchsia")]
1364    fn signal_peer(
1365        &self,
1366        clear_mask: zx::Signals,
1367        set_mask: zx::Signals,
1368    ) -> Result<(), zx_status::Status> {
1369        use fidl::Peered;
1370        self.inner.channel().signal_peer(clear_mask, set_mask)
1371    }
1372}
1373
1374impl MessageSourceControlHandle {}
1375
1376#[must_use = "FIDL methods require a response to be sent"]
1377#[derive(Debug)]
1378pub struct MessageSourceReceiveMessagesResponder {
1379    control_handle: std::mem::ManuallyDrop<MessageSourceControlHandle>,
1380    tx_id: u32,
1381}
1382
1383/// Set the the channel to be shutdown (see [`MessageSourceControlHandle::shutdown`])
1384/// if the responder is dropped without sending a response, so that the client
1385/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1386impl std::ops::Drop for MessageSourceReceiveMessagesResponder {
1387    fn drop(&mut self) {
1388        self.control_handle.shutdown();
1389        // Safety: drops once, never accessed again
1390        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1391    }
1392}
1393
1394impl fidl::endpoints::Responder for MessageSourceReceiveMessagesResponder {
1395    type ControlHandle = MessageSourceControlHandle;
1396
1397    fn control_handle(&self) -> &MessageSourceControlHandle {
1398        &self.control_handle
1399    }
1400
1401    fn drop_without_shutdown(mut self) {
1402        // Safety: drops once, never accessed again due to mem::forget
1403        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1404        // Prevent Drop from running (which would shut down the channel)
1405        std::mem::forget(self);
1406    }
1407}
1408
1409impl MessageSourceReceiveMessagesResponder {
1410    /// Sends a response to the FIDL transaction.
1411    ///
1412    /// Sets the channel to shutdown if an error occurs.
1413    pub fn send(self) -> Result<(), fidl::Error> {
1414        let _result = self.send_raw();
1415        if _result.is_err() {
1416            self.control_handle.shutdown();
1417        }
1418        self.drop_without_shutdown();
1419        _result
1420    }
1421
1422    /// Similar to "send" but does not shutdown the channel if an error occurs.
1423    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1424        let _result = self.send_raw();
1425        self.drop_without_shutdown();
1426        _result
1427    }
1428
1429    fn send_raw(&self) -> Result<(), fidl::Error> {
1430        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1431            (),
1432            self.tx_id,
1433            0x23351bdac594c749,
1434            fidl::encoding::DynamicFlags::empty(),
1435        )
1436    }
1437}
1438
1439#[must_use = "FIDL methods require a response to be sent"]
1440#[derive(Debug)]
1441pub struct MessageSourceReceiveBatonResponder {
1442    control_handle: std::mem::ManuallyDrop<MessageSourceControlHandle>,
1443    tx_id: u32,
1444}
1445
1446/// Set the the channel to be shutdown (see [`MessageSourceControlHandle::shutdown`])
1447/// if the responder is dropped without sending a response, so that the client
1448/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1449impl std::ops::Drop for MessageSourceReceiveBatonResponder {
1450    fn drop(&mut self) {
1451        self.control_handle.shutdown();
1452        // Safety: drops once, never accessed again
1453        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1454    }
1455}
1456
1457impl fidl::endpoints::Responder for MessageSourceReceiveBatonResponder {
1458    type ControlHandle = MessageSourceControlHandle;
1459
1460    fn control_handle(&self) -> &MessageSourceControlHandle {
1461        &self.control_handle
1462    }
1463
1464    fn drop_without_shutdown(mut self) {
1465        // Safety: drops once, never accessed again due to mem::forget
1466        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1467        // Prevent Drop from running (which would shut down the channel)
1468        std::mem::forget(self);
1469    }
1470}
1471
1472impl MessageSourceReceiveBatonResponder {
1473    /// Sends a response to the FIDL transaction.
1474    ///
1475    /// Sets the channel to shutdown if an error occurs.
1476    pub fn send(self, mut payload: LeaseBaton) -> Result<(), fidl::Error> {
1477        let _result = self.send_raw(payload);
1478        if _result.is_err() {
1479            self.control_handle.shutdown();
1480        }
1481        self.drop_without_shutdown();
1482        _result
1483    }
1484
1485    /// Similar to "send" but does not shutdown the channel if an error occurs.
1486    pub fn send_no_shutdown_on_err(self, mut payload: LeaseBaton) -> Result<(), fidl::Error> {
1487        let _result = self.send_raw(payload);
1488        self.drop_without_shutdown();
1489        _result
1490    }
1491
1492    fn send_raw(&self, mut payload: LeaseBaton) -> Result<(), fidl::Error> {
1493        self.control_handle.inner.send::<LeaseBaton>(
1494            &mut payload,
1495            self.tx_id,
1496            0x18ed150a92dd23ee,
1497            fidl::encoding::DynamicFlags::empty(),
1498        )
1499    }
1500}
1501
1502mod internal {
1503    use super::*;
1504
1505    impl fidl::encoding::ResourceTypeMarker for MessageSourceReceiveMessagesRequest {
1506        type Borrowed<'a> = &'a mut Self;
1507        fn take_or_borrow<'a>(
1508            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1509        ) -> Self::Borrowed<'a> {
1510            value
1511        }
1512    }
1513
1514    unsafe impl fidl::encoding::TypeMarker for MessageSourceReceiveMessagesRequest {
1515        type Owned = Self;
1516
1517        #[inline(always)]
1518        fn inline_align(_context: fidl::encoding::Context) -> usize {
1519            4
1520        }
1521
1522        #[inline(always)]
1523        fn inline_size(_context: fidl::encoding::Context) -> usize {
1524            4
1525        }
1526    }
1527
1528    unsafe impl
1529        fidl::encoding::Encode<
1530            MessageSourceReceiveMessagesRequest,
1531            fidl::encoding::DefaultFuchsiaResourceDialect,
1532        > for &mut MessageSourceReceiveMessagesRequest
1533    {
1534        #[inline]
1535        unsafe fn encode(
1536            self,
1537            encoder: &mut fidl::encoding::Encoder<
1538                '_,
1539                fidl::encoding::DefaultFuchsiaResourceDialect,
1540            >,
1541            offset: usize,
1542            _depth: fidl::encoding::Depth,
1543        ) -> fidl::Result<()> {
1544            encoder.debug_check_bounds::<MessageSourceReceiveMessagesRequest>(offset);
1545            // Delegate to tuple encoding.
1546            fidl::encoding::Encode::<
1547                MessageSourceReceiveMessagesRequest,
1548                fidl::encoding::DefaultFuchsiaResourceDialect,
1549            >::encode(
1550                (<fidl::encoding::HandleType<
1551                    fidl::Socket,
1552                    { fidl::ObjectType::SOCKET.into_raw() },
1553                    2147483648,
1554                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1555                    &mut self.socket
1556                ),),
1557                encoder,
1558                offset,
1559                _depth,
1560            )
1561        }
1562    }
1563    unsafe impl<
1564        T0: fidl::encoding::Encode<
1565                fidl::encoding::HandleType<
1566                    fidl::Socket,
1567                    { fidl::ObjectType::SOCKET.into_raw() },
1568                    2147483648,
1569                >,
1570                fidl::encoding::DefaultFuchsiaResourceDialect,
1571            >,
1572    >
1573        fidl::encoding::Encode<
1574            MessageSourceReceiveMessagesRequest,
1575            fidl::encoding::DefaultFuchsiaResourceDialect,
1576        > for (T0,)
1577    {
1578        #[inline]
1579        unsafe fn encode(
1580            self,
1581            encoder: &mut fidl::encoding::Encoder<
1582                '_,
1583                fidl::encoding::DefaultFuchsiaResourceDialect,
1584            >,
1585            offset: usize,
1586            depth: fidl::encoding::Depth,
1587        ) -> fidl::Result<()> {
1588            encoder.debug_check_bounds::<MessageSourceReceiveMessagesRequest>(offset);
1589            // Zero out padding regions. There's no need to apply masks
1590            // because the unmasked parts will be overwritten by fields.
1591            // Write the fields.
1592            self.0.encode(encoder, offset + 0, depth)?;
1593            Ok(())
1594        }
1595    }
1596
1597    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1598        for MessageSourceReceiveMessagesRequest
1599    {
1600        #[inline(always)]
1601        fn new_empty() -> Self {
1602            Self {
1603                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1604            }
1605        }
1606
1607        #[inline]
1608        unsafe fn decode(
1609            &mut self,
1610            decoder: &mut fidl::encoding::Decoder<
1611                '_,
1612                fidl::encoding::DefaultFuchsiaResourceDialect,
1613            >,
1614            offset: usize,
1615            _depth: fidl::encoding::Depth,
1616        ) -> fidl::Result<()> {
1617            decoder.debug_check_bounds::<Self>(offset);
1618            // Verify that padding bytes are zero.
1619            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
1620            Ok(())
1621        }
1622    }
1623
1624    impl LeaseBaton {
1625        #[inline(always)]
1626        fn max_ordinal_present(&self) -> u64 {
1627            if let Some(_) = self.msg_index {
1628                return 2;
1629            }
1630            if let Some(_) = self.lease {
1631                return 1;
1632            }
1633            0
1634        }
1635    }
1636
1637    impl fidl::encoding::ResourceTypeMarker for LeaseBaton {
1638        type Borrowed<'a> = &'a mut Self;
1639        fn take_or_borrow<'a>(
1640            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1641        ) -> Self::Borrowed<'a> {
1642            value
1643        }
1644    }
1645
1646    unsafe impl fidl::encoding::TypeMarker for LeaseBaton {
1647        type Owned = Self;
1648
1649        #[inline(always)]
1650        fn inline_align(_context: fidl::encoding::Context) -> usize {
1651            8
1652        }
1653
1654        #[inline(always)]
1655        fn inline_size(_context: fidl::encoding::Context) -> usize {
1656            16
1657        }
1658    }
1659
1660    unsafe impl fidl::encoding::Encode<LeaseBaton, fidl::encoding::DefaultFuchsiaResourceDialect>
1661        for &mut LeaseBaton
1662    {
1663        unsafe fn encode(
1664            self,
1665            encoder: &mut fidl::encoding::Encoder<
1666                '_,
1667                fidl::encoding::DefaultFuchsiaResourceDialect,
1668            >,
1669            offset: usize,
1670            mut depth: fidl::encoding::Depth,
1671        ) -> fidl::Result<()> {
1672            encoder.debug_check_bounds::<LeaseBaton>(offset);
1673            // Vector header
1674            let max_ordinal: u64 = self.max_ordinal_present();
1675            encoder.write_num(max_ordinal, offset);
1676            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1677            // Calling encoder.out_of_line_offset(0) is not allowed.
1678            if max_ordinal == 0 {
1679                return Ok(());
1680            }
1681            depth.increment()?;
1682            let envelope_size = 8;
1683            let bytes_len = max_ordinal as usize * envelope_size;
1684            #[allow(unused_variables)]
1685            let offset = encoder.out_of_line_offset(bytes_len);
1686            let mut _prev_end_offset: usize = 0;
1687            if 1 > max_ordinal {
1688                return Ok(());
1689            }
1690
1691            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1692            // are envelope_size bytes.
1693            let cur_offset: usize = (1 - 1) * envelope_size;
1694
1695            // Zero reserved fields.
1696            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1697
1698            // Safety:
1699            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1700            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1701            //   envelope_size bytes, there is always sufficient room.
1702            fidl::encoding::encode_in_envelope_optional::<
1703                fidl::encoding::HandleType<
1704                    fidl::EventPair,
1705                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1706                    2147483648,
1707                >,
1708                fidl::encoding::DefaultFuchsiaResourceDialect,
1709            >(
1710                self.lease.as_mut().map(
1711                    <fidl::encoding::HandleType<
1712                        fidl::EventPair,
1713                        { fidl::ObjectType::EVENTPAIR.into_raw() },
1714                        2147483648,
1715                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1716                ),
1717                encoder,
1718                offset + cur_offset,
1719                depth,
1720            )?;
1721
1722            _prev_end_offset = cur_offset + envelope_size;
1723            if 2 > max_ordinal {
1724                return Ok(());
1725            }
1726
1727            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1728            // are envelope_size bytes.
1729            let cur_offset: usize = (2 - 1) * envelope_size;
1730
1731            // Zero reserved fields.
1732            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1733
1734            // Safety:
1735            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1736            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1737            //   envelope_size bytes, there is always sufficient room.
1738            fidl::encoding::encode_in_envelope_optional::<
1739                u64,
1740                fidl::encoding::DefaultFuchsiaResourceDialect,
1741            >(
1742                self.msg_index.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1743                encoder,
1744                offset + cur_offset,
1745                depth,
1746            )?;
1747
1748            _prev_end_offset = cur_offset + envelope_size;
1749
1750            Ok(())
1751        }
1752    }
1753
1754    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for LeaseBaton {
1755        #[inline(always)]
1756        fn new_empty() -> Self {
1757            Self::default()
1758        }
1759
1760        unsafe fn decode(
1761            &mut self,
1762            decoder: &mut fidl::encoding::Decoder<
1763                '_,
1764                fidl::encoding::DefaultFuchsiaResourceDialect,
1765            >,
1766            offset: usize,
1767            mut depth: fidl::encoding::Depth,
1768        ) -> fidl::Result<()> {
1769            decoder.debug_check_bounds::<Self>(offset);
1770            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1771                None => return Err(fidl::Error::NotNullable),
1772                Some(len) => len,
1773            };
1774            // Calling decoder.out_of_line_offset(0) is not allowed.
1775            if len == 0 {
1776                return Ok(());
1777            };
1778            depth.increment()?;
1779            let envelope_size = 8;
1780            let bytes_len = len * envelope_size;
1781            let offset = decoder.out_of_line_offset(bytes_len)?;
1782            // Decode the envelope for each type.
1783            let mut _next_ordinal_to_read = 0;
1784            let mut next_offset = offset;
1785            let end_offset = offset + bytes_len;
1786            _next_ordinal_to_read += 1;
1787            if next_offset >= end_offset {
1788                return Ok(());
1789            }
1790
1791            // Decode unknown envelopes for gaps in ordinals.
1792            while _next_ordinal_to_read < 1 {
1793                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1794                _next_ordinal_to_read += 1;
1795                next_offset += envelope_size;
1796            }
1797
1798            let next_out_of_line = decoder.next_out_of_line();
1799            let handles_before = decoder.remaining_handles();
1800            if let Some((inlined, num_bytes, num_handles)) =
1801                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1802            {
1803                let member_inline_size = <fidl::encoding::HandleType<
1804                    fidl::EventPair,
1805                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1806                    2147483648,
1807                > as fidl::encoding::TypeMarker>::inline_size(
1808                    decoder.context
1809                );
1810                if inlined != (member_inline_size <= 4) {
1811                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1812                }
1813                let inner_offset;
1814                let mut inner_depth = depth.clone();
1815                if inlined {
1816                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1817                    inner_offset = next_offset;
1818                } else {
1819                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1820                    inner_depth.increment()?;
1821                }
1822                let val_ref =
1823                self.lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
1824                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
1825                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1826                {
1827                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1828                }
1829                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1830                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1831                }
1832            }
1833
1834            next_offset += envelope_size;
1835            _next_ordinal_to_read += 1;
1836            if next_offset >= end_offset {
1837                return Ok(());
1838            }
1839
1840            // Decode unknown envelopes for gaps in ordinals.
1841            while _next_ordinal_to_read < 2 {
1842                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1843                _next_ordinal_to_read += 1;
1844                next_offset += envelope_size;
1845            }
1846
1847            let next_out_of_line = decoder.next_out_of_line();
1848            let handles_before = decoder.remaining_handles();
1849            if let Some((inlined, num_bytes, num_handles)) =
1850                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1851            {
1852                let member_inline_size =
1853                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1854                if inlined != (member_inline_size <= 4) {
1855                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1856                }
1857                let inner_offset;
1858                let mut inner_depth = depth.clone();
1859                if inlined {
1860                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1861                    inner_offset = next_offset;
1862                } else {
1863                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1864                    inner_depth.increment()?;
1865                }
1866                let val_ref = self.msg_index.get_or_insert_with(|| {
1867                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
1868                });
1869                fidl::decode!(
1870                    u64,
1871                    fidl::encoding::DefaultFuchsiaResourceDialect,
1872                    val_ref,
1873                    decoder,
1874                    inner_offset,
1875                    inner_depth
1876                )?;
1877                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1878                {
1879                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1880                }
1881                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1882                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1883                }
1884            }
1885
1886            next_offset += envelope_size;
1887
1888            // Decode the remaining unknown envelopes.
1889            while next_offset < end_offset {
1890                _next_ordinal_to_read += 1;
1891                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1892                next_offset += envelope_size;
1893            }
1894
1895            Ok(())
1896        }
1897    }
1898}