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