Skip to main content

fidl_fuchsia_firmware_crash/
fidl_fuchsia_firmware_crash.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_firmware_crash__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Default, PartialEq)]
15pub struct Crash {
16    /// Name or identifier for the subsystem which crashed.
17    pub subsystem_name: Option<String>,
18    /// Approximate timestamp when the crash occurred.
19    pub timestamp: Option<fidl::BootInstant>,
20    /// The description or code indicating why the crash occurred.
21    pub reason: Option<String>,
22    /// The number of times this subsystem has crashed.
23    /// Note that this is ignored if supplied by in Reporter.Report and instead
24    /// aggregated by the protocol implementer based on subsystem_name.
25    pub count: Option<u32>,
26    /// Optional version of the subsystem's firmware.
27    pub firmware_version: Option<String>,
28    /// Optional dump of the subsystem's failure. Not available on user builds.
29    pub crash_dump: Option<fidl::Vmo>,
30    #[doc(hidden)]
31    pub __source_breaking: fidl::marker::SourceBreaking,
32}
33
34impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Crash {}
35
36#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
37pub struct ReporterMarker;
38
39impl fidl::endpoints::ProtocolMarker for ReporterMarker {
40    type Proxy = ReporterProxy;
41    type RequestStream = ReporterRequestStream;
42    #[cfg(target_os = "fuchsia")]
43    type SynchronousProxy = ReporterSynchronousProxy;
44
45    const DEBUG_NAME: &'static str = "fuchsia.firmware.crash.Reporter";
46}
47impl fidl::endpoints::DiscoverableProtocolMarker for ReporterMarker {}
48
49pub trait ReporterProxyInterface: Send + Sync {
50    fn r#report(&self, payload: Crash) -> Result<(), fidl::Error>;
51}
52#[derive(Debug)]
53#[cfg(target_os = "fuchsia")]
54pub struct ReporterSynchronousProxy {
55    client: fidl::client::sync::Client,
56}
57
58#[cfg(target_os = "fuchsia")]
59impl fidl::endpoints::SynchronousProxy for ReporterSynchronousProxy {
60    type Proxy = ReporterProxy;
61    type Protocol = ReporterMarker;
62
63    fn from_channel(inner: fidl::Channel) -> Self {
64        Self::new(inner)
65    }
66
67    fn into_channel(self) -> fidl::Channel {
68        self.client.into_channel()
69    }
70
71    fn as_channel(&self) -> &fidl::Channel {
72        self.client.as_channel()
73    }
74}
75
76#[cfg(target_os = "fuchsia")]
77impl ReporterSynchronousProxy {
78    pub fn new(channel: fidl::Channel) -> Self {
79        Self { client: fidl::client::sync::Client::new(channel) }
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<ReporterEvent, fidl::Error> {
92        ReporterEvent::decode(self.client.wait_for_event::<ReporterMarker>(deadline)?)
93    }
94
95    /// Report a subsystem firmware crash.
96    pub fn r#report(&self, mut payload: Crash) -> Result<(), fidl::Error> {
97        self.client.send::<Crash>(
98            &mut payload,
99            0x6283d741761d9fe5,
100            fidl::encoding::DynamicFlags::FLEXIBLE,
101        )
102    }
103}
104
105#[cfg(target_os = "fuchsia")]
106impl From<ReporterSynchronousProxy> for zx::NullableHandle {
107    fn from(value: ReporterSynchronousProxy) -> Self {
108        value.into_channel().into()
109    }
110}
111
112#[cfg(target_os = "fuchsia")]
113impl From<fidl::Channel> for ReporterSynchronousProxy {
114    fn from(value: fidl::Channel) -> Self {
115        Self::new(value)
116    }
117}
118
119#[cfg(target_os = "fuchsia")]
120impl fidl::endpoints::FromClient for ReporterSynchronousProxy {
121    type Protocol = ReporterMarker;
122
123    fn from_client(value: fidl::endpoints::ClientEnd<ReporterMarker>) -> Self {
124        Self::new(value.into_channel())
125    }
126}
127
128#[derive(Debug, Clone)]
129pub struct ReporterProxy {
130    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
131}
132
133impl fidl::endpoints::Proxy for ReporterProxy {
134    type Protocol = ReporterMarker;
135
136    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
137        Self::new(inner)
138    }
139
140    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
141        self.client.into_channel().map_err(|client| Self { client })
142    }
143
144    fn as_channel(&self) -> &::fidl::AsyncChannel {
145        self.client.as_channel()
146    }
147}
148
149impl ReporterProxy {
150    /// Create a new Proxy for fuchsia.firmware.crash/Reporter.
151    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
152        let protocol_name = <ReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
153        Self { client: fidl::client::Client::new(channel, protocol_name) }
154    }
155
156    /// Get a Stream of events from the remote end of the protocol.
157    ///
158    /// # Panics
159    ///
160    /// Panics if the event stream was already taken.
161    pub fn take_event_stream(&self) -> ReporterEventStream {
162        ReporterEventStream { event_receiver: self.client.take_event_receiver() }
163    }
164
165    /// Report a subsystem firmware crash.
166    pub fn r#report(&self, mut payload: Crash) -> Result<(), fidl::Error> {
167        ReporterProxyInterface::r#report(self, payload)
168    }
169}
170
171impl ReporterProxyInterface for ReporterProxy {
172    fn r#report(&self, mut payload: Crash) -> Result<(), fidl::Error> {
173        self.client.send::<Crash>(
174            &mut payload,
175            0x6283d741761d9fe5,
176            fidl::encoding::DynamicFlags::FLEXIBLE,
177        )
178    }
179}
180
181pub struct ReporterEventStream {
182    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
183}
184
185impl std::marker::Unpin for ReporterEventStream {}
186
187impl futures::stream::FusedStream for ReporterEventStream {
188    fn is_terminated(&self) -> bool {
189        self.event_receiver.is_terminated()
190    }
191}
192
193impl futures::Stream for ReporterEventStream {
194    type Item = Result<ReporterEvent, fidl::Error>;
195
196    fn poll_next(
197        mut self: std::pin::Pin<&mut Self>,
198        cx: &mut std::task::Context<'_>,
199    ) -> std::task::Poll<Option<Self::Item>> {
200        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
201            &mut self.event_receiver,
202            cx
203        )?) {
204            Some(buf) => std::task::Poll::Ready(Some(ReporterEvent::decode(buf))),
205            None => std::task::Poll::Ready(None),
206        }
207    }
208}
209
210#[derive(Debug)]
211pub enum ReporterEvent {
212    #[non_exhaustive]
213    _UnknownEvent {
214        /// Ordinal of the event that was sent.
215        ordinal: u64,
216    },
217}
218
219impl ReporterEvent {
220    /// Decodes a message buffer as a [`ReporterEvent`].
221    fn decode(
222        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
223    ) -> Result<ReporterEvent, fidl::Error> {
224        let (bytes, _handles) = buf.split_mut();
225        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
226        debug_assert_eq!(tx_header.tx_id, 0);
227        match tx_header.ordinal {
228            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
229                Ok(ReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
230            }
231            _ => Err(fidl::Error::UnknownOrdinal {
232                ordinal: tx_header.ordinal,
233                protocol_name: <ReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
234            }),
235        }
236    }
237}
238
239/// A Stream of incoming requests for fuchsia.firmware.crash/Reporter.
240pub struct ReporterRequestStream {
241    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
242    is_terminated: bool,
243}
244
245impl std::marker::Unpin for ReporterRequestStream {}
246
247impl futures::stream::FusedStream for ReporterRequestStream {
248    fn is_terminated(&self) -> bool {
249        self.is_terminated
250    }
251}
252
253impl fidl::endpoints::RequestStream for ReporterRequestStream {
254    type Protocol = ReporterMarker;
255    type ControlHandle = ReporterControlHandle;
256
257    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
258        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
259    }
260
261    fn control_handle(&self) -> Self::ControlHandle {
262        ReporterControlHandle { inner: self.inner.clone() }
263    }
264
265    fn into_inner(
266        self,
267    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
268    {
269        (self.inner, self.is_terminated)
270    }
271
272    fn from_inner(
273        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
274        is_terminated: bool,
275    ) -> Self {
276        Self { inner, is_terminated }
277    }
278}
279
280impl futures::Stream for ReporterRequestStream {
281    type Item = Result<ReporterRequest, fidl::Error>;
282
283    fn poll_next(
284        mut self: std::pin::Pin<&mut Self>,
285        cx: &mut std::task::Context<'_>,
286    ) -> std::task::Poll<Option<Self::Item>> {
287        let this = &mut *self;
288        if this.inner.check_shutdown(cx) {
289            this.is_terminated = true;
290            return std::task::Poll::Ready(None);
291        }
292        if this.is_terminated {
293            panic!("polled ReporterRequestStream after completion");
294        }
295        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
296            |bytes, handles| {
297                match this.inner.channel().read_etc(cx, bytes, handles) {
298                    std::task::Poll::Ready(Ok(())) => {}
299                    std::task::Poll::Pending => return std::task::Poll::Pending,
300                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
301                        this.is_terminated = true;
302                        return std::task::Poll::Ready(None);
303                    }
304                    std::task::Poll::Ready(Err(e)) => {
305                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
306                            e.into(),
307                        ))));
308                    }
309                }
310
311                // A message has been received from the channel
312                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
313
314                std::task::Poll::Ready(Some(match header.ordinal {
315                    0x6283d741761d9fe5 => {
316                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
317                        let mut req =
318                            fidl::new_empty!(Crash, fidl::encoding::DefaultFuchsiaResourceDialect);
319                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Crash>(&header, _body_bytes, handles, &mut req)?;
320                        let control_handle = ReporterControlHandle { inner: this.inner.clone() };
321                        Ok(ReporterRequest::Report { payload: req, control_handle })
322                    }
323                    _ if header.tx_id == 0
324                        && header
325                            .dynamic_flags()
326                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
327                    {
328                        Ok(ReporterRequest::_UnknownMethod {
329                            ordinal: header.ordinal,
330                            control_handle: ReporterControlHandle { inner: this.inner.clone() },
331                            method_type: fidl::MethodType::OneWay,
332                        })
333                    }
334                    _ if header
335                        .dynamic_flags()
336                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
337                    {
338                        this.inner.send_framework_err(
339                            fidl::encoding::FrameworkErr::UnknownMethod,
340                            header.tx_id,
341                            header.ordinal,
342                            header.dynamic_flags(),
343                            (bytes, handles),
344                        )?;
345                        Ok(ReporterRequest::_UnknownMethod {
346                            ordinal: header.ordinal,
347                            control_handle: ReporterControlHandle { inner: this.inner.clone() },
348                            method_type: fidl::MethodType::TwoWay,
349                        })
350                    }
351                    _ => Err(fidl::Error::UnknownOrdinal {
352                        ordinal: header.ordinal,
353                        protocol_name:
354                            <ReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
355                    }),
356                }))
357            },
358        )
359    }
360}
361
362#[derive(Debug)]
363pub enum ReporterRequest {
364    /// Report a subsystem firmware crash.
365    Report { payload: Crash, control_handle: ReporterControlHandle },
366    /// An interaction was received which does not match any known method.
367    #[non_exhaustive]
368    _UnknownMethod {
369        /// Ordinal of the method that was called.
370        ordinal: u64,
371        control_handle: ReporterControlHandle,
372        method_type: fidl::MethodType,
373    },
374}
375
376impl ReporterRequest {
377    #[allow(irrefutable_let_patterns)]
378    pub fn into_report(self) -> Option<(Crash, ReporterControlHandle)> {
379        if let ReporterRequest::Report { payload, control_handle } = self {
380            Some((payload, control_handle))
381        } else {
382            None
383        }
384    }
385
386    /// Name of the method defined in FIDL
387    pub fn method_name(&self) -> &'static str {
388        match *self {
389            ReporterRequest::Report { .. } => "report",
390            ReporterRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
391                "unknown one-way method"
392            }
393            ReporterRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
394                "unknown two-way method"
395            }
396        }
397    }
398}
399
400#[derive(Debug, Clone)]
401pub struct ReporterControlHandle {
402    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
403}
404
405impl fidl::endpoints::ControlHandle for ReporterControlHandle {
406    fn shutdown(&self) {
407        self.inner.shutdown()
408    }
409
410    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
411        self.inner.shutdown_with_epitaph(status)
412    }
413
414    fn is_closed(&self) -> bool {
415        self.inner.channel().is_closed()
416    }
417    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
418        self.inner.channel().on_closed()
419    }
420
421    #[cfg(target_os = "fuchsia")]
422    fn signal_peer(
423        &self,
424        clear_mask: zx::Signals,
425        set_mask: zx::Signals,
426    ) -> Result<(), zx_status::Status> {
427        use fidl::Peered;
428        self.inner.channel().signal_peer(clear_mask, set_mask)
429    }
430}
431
432impl ReporterControlHandle {}
433
434#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
435pub struct WatcherMarker;
436
437impl fidl::endpoints::ProtocolMarker for WatcherMarker {
438    type Proxy = WatcherProxy;
439    type RequestStream = WatcherRequestStream;
440    #[cfg(target_os = "fuchsia")]
441    type SynchronousProxy = WatcherSynchronousProxy;
442
443    const DEBUG_NAME: &'static str = "fuchsia.firmware.crash.Watcher";
444}
445impl fidl::endpoints::DiscoverableProtocolMarker for WatcherMarker {}
446pub type WatcherGetCrashResult = Result<Crash, Error>;
447
448pub trait WatcherProxyInterface: Send + Sync {
449    type GetCrashResponseFut: std::future::Future<Output = Result<WatcherGetCrashResult, fidl::Error>>
450        + Send;
451    fn r#get_crash(&self) -> Self::GetCrashResponseFut;
452}
453#[derive(Debug)]
454#[cfg(target_os = "fuchsia")]
455pub struct WatcherSynchronousProxy {
456    client: fidl::client::sync::Client,
457}
458
459#[cfg(target_os = "fuchsia")]
460impl fidl::endpoints::SynchronousProxy for WatcherSynchronousProxy {
461    type Proxy = WatcherProxy;
462    type Protocol = WatcherMarker;
463
464    fn from_channel(inner: fidl::Channel) -> Self {
465        Self::new(inner)
466    }
467
468    fn into_channel(self) -> fidl::Channel {
469        self.client.into_channel()
470    }
471
472    fn as_channel(&self) -> &fidl::Channel {
473        self.client.as_channel()
474    }
475}
476
477#[cfg(target_os = "fuchsia")]
478impl WatcherSynchronousProxy {
479    pub fn new(channel: fidl::Channel) -> Self {
480        Self { client: fidl::client::sync::Client::new(channel) }
481    }
482
483    pub fn into_channel(self) -> fidl::Channel {
484        self.client.into_channel()
485    }
486
487    /// Waits until an event arrives and returns it. It is safe for other
488    /// threads to make concurrent requests while waiting for an event.
489    pub fn wait_for_event(
490        &self,
491        deadline: zx::MonotonicInstant,
492    ) -> Result<WatcherEvent, fidl::Error> {
493        WatcherEvent::decode(self.client.wait_for_event::<WatcherMarker>(deadline)?)
494    }
495
496    /// Returns crashes as they occur. Each subsequent call will return a new crash.
497    pub fn r#get_crash(
498        &self,
499        ___deadline: zx::MonotonicInstant,
500    ) -> Result<WatcherGetCrashResult, fidl::Error> {
501        let _response = self.client.send_query::<
502            fidl::encoding::EmptyPayload,
503            fidl::encoding::FlexibleResultType<Crash, Error>,
504            WatcherMarker,
505        >(
506            (),
507            0x3958bce1352d0890,
508            fidl::encoding::DynamicFlags::FLEXIBLE,
509            ___deadline,
510        )?
511        .into_result::<WatcherMarker>("get_crash")?;
512        Ok(_response.map(|x| x))
513    }
514}
515
516#[cfg(target_os = "fuchsia")]
517impl From<WatcherSynchronousProxy> for zx::NullableHandle {
518    fn from(value: WatcherSynchronousProxy) -> Self {
519        value.into_channel().into()
520    }
521}
522
523#[cfg(target_os = "fuchsia")]
524impl From<fidl::Channel> for WatcherSynchronousProxy {
525    fn from(value: fidl::Channel) -> Self {
526        Self::new(value)
527    }
528}
529
530#[cfg(target_os = "fuchsia")]
531impl fidl::endpoints::FromClient for WatcherSynchronousProxy {
532    type Protocol = WatcherMarker;
533
534    fn from_client(value: fidl::endpoints::ClientEnd<WatcherMarker>) -> Self {
535        Self::new(value.into_channel())
536    }
537}
538
539#[derive(Debug, Clone)]
540pub struct WatcherProxy {
541    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
542}
543
544impl fidl::endpoints::Proxy for WatcherProxy {
545    type Protocol = WatcherMarker;
546
547    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
548        Self::new(inner)
549    }
550
551    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
552        self.client.into_channel().map_err(|client| Self { client })
553    }
554
555    fn as_channel(&self) -> &::fidl::AsyncChannel {
556        self.client.as_channel()
557    }
558}
559
560impl WatcherProxy {
561    /// Create a new Proxy for fuchsia.firmware.crash/Watcher.
562    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
563        let protocol_name = <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
564        Self { client: fidl::client::Client::new(channel, protocol_name) }
565    }
566
567    /// Get a Stream of events from the remote end of the protocol.
568    ///
569    /// # Panics
570    ///
571    /// Panics if the event stream was already taken.
572    pub fn take_event_stream(&self) -> WatcherEventStream {
573        WatcherEventStream { event_receiver: self.client.take_event_receiver() }
574    }
575
576    /// Returns crashes as they occur. Each subsequent call will return a new crash.
577    pub fn r#get_crash(
578        &self,
579    ) -> fidl::client::QueryResponseFut<
580        WatcherGetCrashResult,
581        fidl::encoding::DefaultFuchsiaResourceDialect,
582    > {
583        WatcherProxyInterface::r#get_crash(self)
584    }
585}
586
587impl WatcherProxyInterface for WatcherProxy {
588    type GetCrashResponseFut = fidl::client::QueryResponseFut<
589        WatcherGetCrashResult,
590        fidl::encoding::DefaultFuchsiaResourceDialect,
591    >;
592    fn r#get_crash(&self) -> Self::GetCrashResponseFut {
593        fn _decode(
594            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
595        ) -> Result<WatcherGetCrashResult, fidl::Error> {
596            let _response = fidl::client::decode_transaction_body::<
597                fidl::encoding::FlexibleResultType<Crash, Error>,
598                fidl::encoding::DefaultFuchsiaResourceDialect,
599                0x3958bce1352d0890,
600            >(_buf?)?
601            .into_result::<WatcherMarker>("get_crash")?;
602            Ok(_response.map(|x| x))
603        }
604        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, WatcherGetCrashResult>(
605            (),
606            0x3958bce1352d0890,
607            fidl::encoding::DynamicFlags::FLEXIBLE,
608            _decode,
609        )
610    }
611}
612
613pub struct WatcherEventStream {
614    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
615}
616
617impl std::marker::Unpin for WatcherEventStream {}
618
619impl futures::stream::FusedStream for WatcherEventStream {
620    fn is_terminated(&self) -> bool {
621        self.event_receiver.is_terminated()
622    }
623}
624
625impl futures::Stream for WatcherEventStream {
626    type Item = Result<WatcherEvent, fidl::Error>;
627
628    fn poll_next(
629        mut self: std::pin::Pin<&mut Self>,
630        cx: &mut std::task::Context<'_>,
631    ) -> std::task::Poll<Option<Self::Item>> {
632        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
633            &mut self.event_receiver,
634            cx
635        )?) {
636            Some(buf) => std::task::Poll::Ready(Some(WatcherEvent::decode(buf))),
637            None => std::task::Poll::Ready(None),
638        }
639    }
640}
641
642#[derive(Debug)]
643pub enum WatcherEvent {
644    #[non_exhaustive]
645    _UnknownEvent {
646        /// Ordinal of the event that was sent.
647        ordinal: u64,
648    },
649}
650
651impl WatcherEvent {
652    /// Decodes a message buffer as a [`WatcherEvent`].
653    fn decode(
654        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
655    ) -> Result<WatcherEvent, fidl::Error> {
656        let (bytes, _handles) = buf.split_mut();
657        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
658        debug_assert_eq!(tx_header.tx_id, 0);
659        match tx_header.ordinal {
660            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
661                Ok(WatcherEvent::_UnknownEvent { ordinal: tx_header.ordinal })
662            }
663            _ => Err(fidl::Error::UnknownOrdinal {
664                ordinal: tx_header.ordinal,
665                protocol_name: <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
666            }),
667        }
668    }
669}
670
671/// A Stream of incoming requests for fuchsia.firmware.crash/Watcher.
672pub struct WatcherRequestStream {
673    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
674    is_terminated: bool,
675}
676
677impl std::marker::Unpin for WatcherRequestStream {}
678
679impl futures::stream::FusedStream for WatcherRequestStream {
680    fn is_terminated(&self) -> bool {
681        self.is_terminated
682    }
683}
684
685impl fidl::endpoints::RequestStream for WatcherRequestStream {
686    type Protocol = WatcherMarker;
687    type ControlHandle = WatcherControlHandle;
688
689    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
690        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
691    }
692
693    fn control_handle(&self) -> Self::ControlHandle {
694        WatcherControlHandle { inner: self.inner.clone() }
695    }
696
697    fn into_inner(
698        self,
699    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
700    {
701        (self.inner, self.is_terminated)
702    }
703
704    fn from_inner(
705        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
706        is_terminated: bool,
707    ) -> Self {
708        Self { inner, is_terminated }
709    }
710}
711
712impl futures::Stream for WatcherRequestStream {
713    type Item = Result<WatcherRequest, fidl::Error>;
714
715    fn poll_next(
716        mut self: std::pin::Pin<&mut Self>,
717        cx: &mut std::task::Context<'_>,
718    ) -> std::task::Poll<Option<Self::Item>> {
719        let this = &mut *self;
720        if this.inner.check_shutdown(cx) {
721            this.is_terminated = true;
722            return std::task::Poll::Ready(None);
723        }
724        if this.is_terminated {
725            panic!("polled WatcherRequestStream after completion");
726        }
727        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
728            |bytes, handles| {
729                match this.inner.channel().read_etc(cx, bytes, handles) {
730                    std::task::Poll::Ready(Ok(())) => {}
731                    std::task::Poll::Pending => return std::task::Poll::Pending,
732                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
733                        this.is_terminated = true;
734                        return std::task::Poll::Ready(None);
735                    }
736                    std::task::Poll::Ready(Err(e)) => {
737                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
738                            e.into(),
739                        ))));
740                    }
741                }
742
743                // A message has been received from the channel
744                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
745
746                std::task::Poll::Ready(Some(match header.ordinal {
747                    0x3958bce1352d0890 => {
748                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
749                        let mut req = fidl::new_empty!(
750                            fidl::encoding::EmptyPayload,
751                            fidl::encoding::DefaultFuchsiaResourceDialect
752                        );
753                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
754                        let control_handle = WatcherControlHandle { inner: this.inner.clone() };
755                        Ok(WatcherRequest::GetCrash {
756                            responder: WatcherGetCrashResponder {
757                                control_handle: std::mem::ManuallyDrop::new(control_handle),
758                                tx_id: header.tx_id,
759                            },
760                        })
761                    }
762                    _ if header.tx_id == 0
763                        && header
764                            .dynamic_flags()
765                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
766                    {
767                        Ok(WatcherRequest::_UnknownMethod {
768                            ordinal: header.ordinal,
769                            control_handle: WatcherControlHandle { inner: this.inner.clone() },
770                            method_type: fidl::MethodType::OneWay,
771                        })
772                    }
773                    _ if header
774                        .dynamic_flags()
775                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
776                    {
777                        this.inner.send_framework_err(
778                            fidl::encoding::FrameworkErr::UnknownMethod,
779                            header.tx_id,
780                            header.ordinal,
781                            header.dynamic_flags(),
782                            (bytes, handles),
783                        )?;
784                        Ok(WatcherRequest::_UnknownMethod {
785                            ordinal: header.ordinal,
786                            control_handle: WatcherControlHandle { inner: this.inner.clone() },
787                            method_type: fidl::MethodType::TwoWay,
788                        })
789                    }
790                    _ => Err(fidl::Error::UnknownOrdinal {
791                        ordinal: header.ordinal,
792                        protocol_name:
793                            <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
794                    }),
795                }))
796            },
797        )
798    }
799}
800
801#[derive(Debug)]
802pub enum WatcherRequest {
803    /// Returns crashes as they occur. Each subsequent call will return a new crash.
804    GetCrash { responder: WatcherGetCrashResponder },
805    /// An interaction was received which does not match any known method.
806    #[non_exhaustive]
807    _UnknownMethod {
808        /// Ordinal of the method that was called.
809        ordinal: u64,
810        control_handle: WatcherControlHandle,
811        method_type: fidl::MethodType,
812    },
813}
814
815impl WatcherRequest {
816    #[allow(irrefutable_let_patterns)]
817    pub fn into_get_crash(self) -> Option<(WatcherGetCrashResponder)> {
818        if let WatcherRequest::GetCrash { responder } = self { Some((responder)) } else { None }
819    }
820
821    /// Name of the method defined in FIDL
822    pub fn method_name(&self) -> &'static str {
823        match *self {
824            WatcherRequest::GetCrash { .. } => "get_crash",
825            WatcherRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
826                "unknown one-way method"
827            }
828            WatcherRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
829                "unknown two-way method"
830            }
831        }
832    }
833}
834
835#[derive(Debug, Clone)]
836pub struct WatcherControlHandle {
837    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
838}
839
840impl fidl::endpoints::ControlHandle for WatcherControlHandle {
841    fn shutdown(&self) {
842        self.inner.shutdown()
843    }
844
845    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
846        self.inner.shutdown_with_epitaph(status)
847    }
848
849    fn is_closed(&self) -> bool {
850        self.inner.channel().is_closed()
851    }
852    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
853        self.inner.channel().on_closed()
854    }
855
856    #[cfg(target_os = "fuchsia")]
857    fn signal_peer(
858        &self,
859        clear_mask: zx::Signals,
860        set_mask: zx::Signals,
861    ) -> Result<(), zx_status::Status> {
862        use fidl::Peered;
863        self.inner.channel().signal_peer(clear_mask, set_mask)
864    }
865}
866
867impl WatcherControlHandle {}
868
869#[must_use = "FIDL methods require a response to be sent"]
870#[derive(Debug)]
871pub struct WatcherGetCrashResponder {
872    control_handle: std::mem::ManuallyDrop<WatcherControlHandle>,
873    tx_id: u32,
874}
875
876/// Set the the channel to be shutdown (see [`WatcherControlHandle::shutdown`])
877/// if the responder is dropped without sending a response, so that the client
878/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
879impl std::ops::Drop for WatcherGetCrashResponder {
880    fn drop(&mut self) {
881        self.control_handle.shutdown();
882        // Safety: drops once, never accessed again
883        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
884    }
885}
886
887impl fidl::endpoints::Responder for WatcherGetCrashResponder {
888    type ControlHandle = WatcherControlHandle;
889
890    fn control_handle(&self) -> &WatcherControlHandle {
891        &self.control_handle
892    }
893
894    fn drop_without_shutdown(mut self) {
895        // Safety: drops once, never accessed again due to mem::forget
896        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
897        // Prevent Drop from running (which would shut down the channel)
898        std::mem::forget(self);
899    }
900}
901
902impl WatcherGetCrashResponder {
903    /// Sends a response to the FIDL transaction.
904    ///
905    /// Sets the channel to shutdown if an error occurs.
906    pub fn send(self, mut result: Result<Crash, Error>) -> Result<(), fidl::Error> {
907        let _result = self.send_raw(result);
908        if _result.is_err() {
909            self.control_handle.shutdown();
910        }
911        self.drop_without_shutdown();
912        _result
913    }
914
915    /// Similar to "send" but does not shutdown the channel if an error occurs.
916    pub fn send_no_shutdown_on_err(
917        self,
918        mut result: Result<Crash, Error>,
919    ) -> Result<(), fidl::Error> {
920        let _result = self.send_raw(result);
921        self.drop_without_shutdown();
922        _result
923    }
924
925    fn send_raw(&self, mut result: Result<Crash, Error>) -> Result<(), fidl::Error> {
926        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<Crash, Error>>(
927            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
928            self.tx_id,
929            0x3958bce1352d0890,
930            fidl::encoding::DynamicFlags::FLEXIBLE,
931        )
932    }
933}
934
935mod internal {
936    use super::*;
937
938    impl Crash {
939        #[inline(always)]
940        fn max_ordinal_present(&self) -> u64 {
941            if let Some(_) = self.crash_dump {
942                return 6;
943            }
944            if let Some(_) = self.firmware_version {
945                return 5;
946            }
947            if let Some(_) = self.count {
948                return 4;
949            }
950            if let Some(_) = self.reason {
951                return 3;
952            }
953            if let Some(_) = self.timestamp {
954                return 2;
955            }
956            if let Some(_) = self.subsystem_name {
957                return 1;
958            }
959            0
960        }
961    }
962
963    impl fidl::encoding::ResourceTypeMarker for Crash {
964        type Borrowed<'a> = &'a mut Self;
965        fn take_or_borrow<'a>(
966            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
967        ) -> Self::Borrowed<'a> {
968            value
969        }
970    }
971
972    unsafe impl fidl::encoding::TypeMarker for Crash {
973        type Owned = Self;
974
975        #[inline(always)]
976        fn inline_align(_context: fidl::encoding::Context) -> usize {
977            8
978        }
979
980        #[inline(always)]
981        fn inline_size(_context: fidl::encoding::Context) -> usize {
982            16
983        }
984    }
985
986    unsafe impl fidl::encoding::Encode<Crash, fidl::encoding::DefaultFuchsiaResourceDialect>
987        for &mut Crash
988    {
989        unsafe fn encode(
990            self,
991            encoder: &mut fidl::encoding::Encoder<
992                '_,
993                fidl::encoding::DefaultFuchsiaResourceDialect,
994            >,
995            offset: usize,
996            mut depth: fidl::encoding::Depth,
997        ) -> fidl::Result<()> {
998            encoder.debug_check_bounds::<Crash>(offset);
999            // Vector header
1000            let max_ordinal: u64 = self.max_ordinal_present();
1001            encoder.write_num(max_ordinal, offset);
1002            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1003            // Calling encoder.out_of_line_offset(0) is not allowed.
1004            if max_ordinal == 0 {
1005                return Ok(());
1006            }
1007            depth.increment()?;
1008            let envelope_size = 8;
1009            let bytes_len = max_ordinal as usize * envelope_size;
1010            #[allow(unused_variables)]
1011            let offset = encoder.out_of_line_offset(bytes_len);
1012            let mut _prev_end_offset: usize = 0;
1013            if 1 > max_ordinal {
1014                return Ok(());
1015            }
1016
1017            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1018            // are envelope_size bytes.
1019            let cur_offset: usize = (1 - 1) * envelope_size;
1020
1021            // Zero reserved fields.
1022            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1023
1024            // Safety:
1025            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1026            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1027            //   envelope_size bytes, there is always sufficient room.
1028            fidl::encoding::encode_in_envelope_optional::<
1029                fidl::encoding::BoundedString<64>,
1030                fidl::encoding::DefaultFuchsiaResourceDialect,
1031            >(
1032                self.subsystem_name.as_ref().map(
1033                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow,
1034                ),
1035                encoder,
1036                offset + cur_offset,
1037                depth,
1038            )?;
1039
1040            _prev_end_offset = cur_offset + envelope_size;
1041            if 2 > max_ordinal {
1042                return Ok(());
1043            }
1044
1045            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1046            // are envelope_size bytes.
1047            let cur_offset: usize = (2 - 1) * envelope_size;
1048
1049            // Zero reserved fields.
1050            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1051
1052            // Safety:
1053            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1054            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1055            //   envelope_size bytes, there is always sufficient room.
1056            fidl::encoding::encode_in_envelope_optional::<
1057                fidl::BootInstant,
1058                fidl::encoding::DefaultFuchsiaResourceDialect,
1059            >(
1060                self.timestamp
1061                    .as_ref()
1062                    .map(<fidl::BootInstant as fidl::encoding::ValueTypeMarker>::borrow),
1063                encoder,
1064                offset + cur_offset,
1065                depth,
1066            )?;
1067
1068            _prev_end_offset = cur_offset + envelope_size;
1069            if 3 > max_ordinal {
1070                return Ok(());
1071            }
1072
1073            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1074            // are envelope_size bytes.
1075            let cur_offset: usize = (3 - 1) * envelope_size;
1076
1077            // Zero reserved fields.
1078            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1079
1080            // Safety:
1081            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1082            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1083            //   envelope_size bytes, there is always sufficient room.
1084            fidl::encoding::encode_in_envelope_optional::<
1085                fidl::encoding::BoundedString<128>,
1086                fidl::encoding::DefaultFuchsiaResourceDialect,
1087            >(
1088                self.reason.as_ref().map(
1089                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
1090                ),
1091                encoder,
1092                offset + cur_offset,
1093                depth,
1094            )?;
1095
1096            _prev_end_offset = cur_offset + envelope_size;
1097            if 4 > max_ordinal {
1098                return Ok(());
1099            }
1100
1101            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1102            // are envelope_size bytes.
1103            let cur_offset: usize = (4 - 1) * envelope_size;
1104
1105            // Zero reserved fields.
1106            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1107
1108            // Safety:
1109            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1110            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1111            //   envelope_size bytes, there is always sufficient room.
1112            fidl::encoding::encode_in_envelope_optional::<
1113                u32,
1114                fidl::encoding::DefaultFuchsiaResourceDialect,
1115            >(
1116                self.count.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1117                encoder,
1118                offset + cur_offset,
1119                depth,
1120            )?;
1121
1122            _prev_end_offset = cur_offset + envelope_size;
1123            if 5 > max_ordinal {
1124                return Ok(());
1125            }
1126
1127            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1128            // are envelope_size bytes.
1129            let cur_offset: usize = (5 - 1) * envelope_size;
1130
1131            // Zero reserved fields.
1132            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1133
1134            // Safety:
1135            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1136            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1137            //   envelope_size bytes, there is always sufficient room.
1138            fidl::encoding::encode_in_envelope_optional::<
1139                fidl::encoding::BoundedString<32>,
1140                fidl::encoding::DefaultFuchsiaResourceDialect,
1141            >(
1142                self.firmware_version.as_ref().map(
1143                    <fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow,
1144                ),
1145                encoder,
1146                offset + cur_offset,
1147                depth,
1148            )?;
1149
1150            _prev_end_offset = cur_offset + envelope_size;
1151            if 6 > max_ordinal {
1152                return Ok(());
1153            }
1154
1155            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1156            // are envelope_size bytes.
1157            let cur_offset: usize = (6 - 1) * envelope_size;
1158
1159            // Zero reserved fields.
1160            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1161
1162            // Safety:
1163            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1164            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1165            //   envelope_size bytes, there is always sufficient room.
1166            fidl::encoding::encode_in_envelope_optional::<
1167                fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49255>,
1168                fidl::encoding::DefaultFuchsiaResourceDialect,
1169            >(
1170                self.crash_dump.as_mut().map(
1171                    <fidl::encoding::HandleType<
1172                        fidl::Vmo,
1173                        { fidl::ObjectType::VMO.into_raw() },
1174                        49255,
1175                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1176                ),
1177                encoder,
1178                offset + cur_offset,
1179                depth,
1180            )?;
1181
1182            _prev_end_offset = cur_offset + envelope_size;
1183
1184            Ok(())
1185        }
1186    }
1187
1188    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Crash {
1189        #[inline(always)]
1190        fn new_empty() -> Self {
1191            Self::default()
1192        }
1193
1194        unsafe fn decode(
1195            &mut self,
1196            decoder: &mut fidl::encoding::Decoder<
1197                '_,
1198                fidl::encoding::DefaultFuchsiaResourceDialect,
1199            >,
1200            offset: usize,
1201            mut depth: fidl::encoding::Depth,
1202        ) -> fidl::Result<()> {
1203            decoder.debug_check_bounds::<Self>(offset);
1204            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1205                None => return Err(fidl::Error::NotNullable),
1206                Some(len) => len,
1207            };
1208            // Calling decoder.out_of_line_offset(0) is not allowed.
1209            if len == 0 {
1210                return Ok(());
1211            };
1212            depth.increment()?;
1213            let envelope_size = 8;
1214            let bytes_len = len * envelope_size;
1215            let offset = decoder.out_of_line_offset(bytes_len)?;
1216            // Decode the envelope for each type.
1217            let mut _next_ordinal_to_read = 0;
1218            let mut next_offset = offset;
1219            let end_offset = offset + bytes_len;
1220            _next_ordinal_to_read += 1;
1221            if next_offset >= end_offset {
1222                return Ok(());
1223            }
1224
1225            // Decode unknown envelopes for gaps in ordinals.
1226            while _next_ordinal_to_read < 1 {
1227                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1228                _next_ordinal_to_read += 1;
1229                next_offset += envelope_size;
1230            }
1231
1232            let next_out_of_line = decoder.next_out_of_line();
1233            let handles_before = decoder.remaining_handles();
1234            if let Some((inlined, num_bytes, num_handles)) =
1235                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1236            {
1237                let member_inline_size =
1238                    <fidl::encoding::BoundedString<64> as fidl::encoding::TypeMarker>::inline_size(
1239                        decoder.context,
1240                    );
1241                if inlined != (member_inline_size <= 4) {
1242                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1243                }
1244                let inner_offset;
1245                let mut inner_depth = depth.clone();
1246                if inlined {
1247                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1248                    inner_offset = next_offset;
1249                } else {
1250                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1251                    inner_depth.increment()?;
1252                }
1253                let val_ref = self.subsystem_name.get_or_insert_with(|| {
1254                    fidl::new_empty!(
1255                        fidl::encoding::BoundedString<64>,
1256                        fidl::encoding::DefaultFuchsiaResourceDialect
1257                    )
1258                });
1259                fidl::decode!(
1260                    fidl::encoding::BoundedString<64>,
1261                    fidl::encoding::DefaultFuchsiaResourceDialect,
1262                    val_ref,
1263                    decoder,
1264                    inner_offset,
1265                    inner_depth
1266                )?;
1267                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1268                {
1269                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1270                }
1271                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1272                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1273                }
1274            }
1275
1276            next_offset += envelope_size;
1277            _next_ordinal_to_read += 1;
1278            if next_offset >= end_offset {
1279                return Ok(());
1280            }
1281
1282            // Decode unknown envelopes for gaps in ordinals.
1283            while _next_ordinal_to_read < 2 {
1284                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1285                _next_ordinal_to_read += 1;
1286                next_offset += envelope_size;
1287            }
1288
1289            let next_out_of_line = decoder.next_out_of_line();
1290            let handles_before = decoder.remaining_handles();
1291            if let Some((inlined, num_bytes, num_handles)) =
1292                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1293            {
1294                let member_inline_size =
1295                    <fidl::BootInstant as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1296                if inlined != (member_inline_size <= 4) {
1297                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1298                }
1299                let inner_offset;
1300                let mut inner_depth = depth.clone();
1301                if inlined {
1302                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1303                    inner_offset = next_offset;
1304                } else {
1305                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1306                    inner_depth.increment()?;
1307                }
1308                let val_ref = self.timestamp.get_or_insert_with(|| {
1309                    fidl::new_empty!(
1310                        fidl::BootInstant,
1311                        fidl::encoding::DefaultFuchsiaResourceDialect
1312                    )
1313                });
1314                fidl::decode!(
1315                    fidl::BootInstant,
1316                    fidl::encoding::DefaultFuchsiaResourceDialect,
1317                    val_ref,
1318                    decoder,
1319                    inner_offset,
1320                    inner_depth
1321                )?;
1322                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1323                {
1324                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1325                }
1326                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1327                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1328                }
1329            }
1330
1331            next_offset += envelope_size;
1332            _next_ordinal_to_read += 1;
1333            if next_offset >= end_offset {
1334                return Ok(());
1335            }
1336
1337            // Decode unknown envelopes for gaps in ordinals.
1338            while _next_ordinal_to_read < 3 {
1339                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1340                _next_ordinal_to_read += 1;
1341                next_offset += envelope_size;
1342            }
1343
1344            let next_out_of_line = decoder.next_out_of_line();
1345            let handles_before = decoder.remaining_handles();
1346            if let Some((inlined, num_bytes, num_handles)) =
1347                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1348            {
1349                let member_inline_size =
1350                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
1351                        decoder.context,
1352                    );
1353                if inlined != (member_inline_size <= 4) {
1354                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1355                }
1356                let inner_offset;
1357                let mut inner_depth = depth.clone();
1358                if inlined {
1359                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1360                    inner_offset = next_offset;
1361                } else {
1362                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1363                    inner_depth.increment()?;
1364                }
1365                let val_ref = self.reason.get_or_insert_with(|| {
1366                    fidl::new_empty!(
1367                        fidl::encoding::BoundedString<128>,
1368                        fidl::encoding::DefaultFuchsiaResourceDialect
1369                    )
1370                });
1371                fidl::decode!(
1372                    fidl::encoding::BoundedString<128>,
1373                    fidl::encoding::DefaultFuchsiaResourceDialect,
1374                    val_ref,
1375                    decoder,
1376                    inner_offset,
1377                    inner_depth
1378                )?;
1379                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1380                {
1381                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1382                }
1383                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1384                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1385                }
1386            }
1387
1388            next_offset += envelope_size;
1389            _next_ordinal_to_read += 1;
1390            if next_offset >= end_offset {
1391                return Ok(());
1392            }
1393
1394            // Decode unknown envelopes for gaps in ordinals.
1395            while _next_ordinal_to_read < 4 {
1396                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1397                _next_ordinal_to_read += 1;
1398                next_offset += envelope_size;
1399            }
1400
1401            let next_out_of_line = decoder.next_out_of_line();
1402            let handles_before = decoder.remaining_handles();
1403            if let Some((inlined, num_bytes, num_handles)) =
1404                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1405            {
1406                let member_inline_size =
1407                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1408                if inlined != (member_inline_size <= 4) {
1409                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1410                }
1411                let inner_offset;
1412                let mut inner_depth = depth.clone();
1413                if inlined {
1414                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1415                    inner_offset = next_offset;
1416                } else {
1417                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1418                    inner_depth.increment()?;
1419                }
1420                let val_ref = self.count.get_or_insert_with(|| {
1421                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
1422                });
1423                fidl::decode!(
1424                    u32,
1425                    fidl::encoding::DefaultFuchsiaResourceDialect,
1426                    val_ref,
1427                    decoder,
1428                    inner_offset,
1429                    inner_depth
1430                )?;
1431                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1432                {
1433                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1434                }
1435                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1436                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1437                }
1438            }
1439
1440            next_offset += envelope_size;
1441            _next_ordinal_to_read += 1;
1442            if next_offset >= end_offset {
1443                return Ok(());
1444            }
1445
1446            // Decode unknown envelopes for gaps in ordinals.
1447            while _next_ordinal_to_read < 5 {
1448                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1449                _next_ordinal_to_read += 1;
1450                next_offset += envelope_size;
1451            }
1452
1453            let next_out_of_line = decoder.next_out_of_line();
1454            let handles_before = decoder.remaining_handles();
1455            if let Some((inlined, num_bytes, num_handles)) =
1456                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1457            {
1458                let member_inline_size =
1459                    <fidl::encoding::BoundedString<32> as fidl::encoding::TypeMarker>::inline_size(
1460                        decoder.context,
1461                    );
1462                if inlined != (member_inline_size <= 4) {
1463                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1464                }
1465                let inner_offset;
1466                let mut inner_depth = depth.clone();
1467                if inlined {
1468                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1469                    inner_offset = next_offset;
1470                } else {
1471                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1472                    inner_depth.increment()?;
1473                }
1474                let val_ref = self.firmware_version.get_or_insert_with(|| {
1475                    fidl::new_empty!(
1476                        fidl::encoding::BoundedString<32>,
1477                        fidl::encoding::DefaultFuchsiaResourceDialect
1478                    )
1479                });
1480                fidl::decode!(
1481                    fidl::encoding::BoundedString<32>,
1482                    fidl::encoding::DefaultFuchsiaResourceDialect,
1483                    val_ref,
1484                    decoder,
1485                    inner_offset,
1486                    inner_depth
1487                )?;
1488                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1489                {
1490                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1491                }
1492                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1493                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1494                }
1495            }
1496
1497            next_offset += envelope_size;
1498            _next_ordinal_to_read += 1;
1499            if next_offset >= end_offset {
1500                return Ok(());
1501            }
1502
1503            // Decode unknown envelopes for gaps in ordinals.
1504            while _next_ordinal_to_read < 6 {
1505                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1506                _next_ordinal_to_read += 1;
1507                next_offset += envelope_size;
1508            }
1509
1510            let next_out_of_line = decoder.next_out_of_line();
1511            let handles_before = decoder.remaining_handles();
1512            if let Some((inlined, num_bytes, num_handles)) =
1513                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1514            {
1515                let member_inline_size = <fidl::encoding::HandleType<
1516                    fidl::Vmo,
1517                    { fidl::ObjectType::VMO.into_raw() },
1518                    49255,
1519                > as fidl::encoding::TypeMarker>::inline_size(
1520                    decoder.context
1521                );
1522                if inlined != (member_inline_size <= 4) {
1523                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1524                }
1525                let inner_offset;
1526                let mut inner_depth = depth.clone();
1527                if inlined {
1528                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1529                    inner_offset = next_offset;
1530                } else {
1531                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1532                    inner_depth.increment()?;
1533                }
1534                let val_ref =
1535                self.crash_dump.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49255>, fidl::encoding::DefaultFuchsiaResourceDialect));
1536                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49255>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
1537                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1538                {
1539                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1540                }
1541                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1542                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1543                }
1544            }
1545
1546            next_offset += envelope_size;
1547
1548            // Decode the remaining unknown envelopes.
1549            while next_offset < end_offset {
1550                _next_ordinal_to_read += 1;
1551                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1552                next_offset += envelope_size;
1553            }
1554
1555            Ok(())
1556        }
1557    }
1558}