Skip to main content

fidl_fuchsia_diagnostics_persistence/
fidl_fuchsia_diagnostics_persistence.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_diagnostics_persistence_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct PreviousBootDataProviderWatchPreviousBootDataResponse {
16    pub data: PreviousBootData,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for PreviousBootDataProviderWatchPreviousBootDataResponse
21{
22}
23
24/// Represents the processed data from the previous boot once it is ready.
25#[derive(Debug, Default, PartialEq)]
26pub struct PreviousBootData {
27    /// The monotonic timestamp associated with when this data was captured/processed.
28    pub monotonic_timestamp: Option<fidl::MonotonicInstant>,
29    /// The boot timestamp associated with when this data was captured/processed.
30    pub boot_timestamp: Option<fidl::BootInstant>,
31    /// The UTC timestamp at which this data was captured, if the UTC time was at logging
32    /// quality. This field is omitted if UTC is not available or not at logging quality.
33    /// See //sdk/fidl/fuchsia.time.fidl for reference.
34    pub utc_timestamp_ns: Option<i64>,
35    /// An open, read-only file handle to the processed data file.
36    /// The client can read the data directly from this channel.
37    pub inspect: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
38    #[doc(hidden)]
39    pub __source_breaking: fidl::marker::SourceBreaking,
40}
41
42impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PreviousBootData {}
43
44#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
45pub struct PreviousBootDataProviderMarker;
46
47impl fidl::endpoints::ProtocolMarker for PreviousBootDataProviderMarker {
48    type Proxy = PreviousBootDataProviderProxy;
49    type RequestStream = PreviousBootDataProviderRequestStream;
50    #[cfg(target_os = "fuchsia")]
51    type SynchronousProxy = PreviousBootDataProviderSynchronousProxy;
52
53    const DEBUG_NAME: &'static str = "fuchsia.diagnostics.persistence.PreviousBootDataProvider";
54}
55impl fidl::endpoints::DiscoverableProtocolMarker for PreviousBootDataProviderMarker {}
56
57pub trait PreviousBootDataProviderProxyInterface: Send + Sync {
58    type WatchPreviousBootDataResponseFut: std::future::Future<Output = Result<PreviousBootData, fidl::Error>>
59        + Send;
60    fn r#watch_previous_boot_data(
61        &self,
62        options: &PreviousBootDataProviderOptions,
63    ) -> Self::WatchPreviousBootDataResponseFut;
64}
65#[derive(Debug)]
66#[cfg(target_os = "fuchsia")]
67pub struct PreviousBootDataProviderSynchronousProxy {
68    client: fidl::client::sync::Client,
69}
70
71#[cfg(target_os = "fuchsia")]
72impl fidl::endpoints::SynchronousProxy for PreviousBootDataProviderSynchronousProxy {
73    type Proxy = PreviousBootDataProviderProxy;
74    type Protocol = PreviousBootDataProviderMarker;
75
76    fn from_channel(inner: fidl::Channel) -> Self {
77        Self::new(inner)
78    }
79
80    fn into_channel(self) -> fidl::Channel {
81        self.client.into_channel()
82    }
83
84    fn as_channel(&self) -> &fidl::Channel {
85        self.client.as_channel()
86    }
87}
88
89#[cfg(target_os = "fuchsia")]
90impl PreviousBootDataProviderSynchronousProxy {
91    pub fn new(channel: fidl::Channel) -> Self {
92        Self { client: fidl::client::sync::Client::new(channel) }
93    }
94
95    pub fn into_channel(self) -> fidl::Channel {
96        self.client.into_channel()
97    }
98
99    /// Waits until an event arrives and returns it. It is safe for other
100    /// threads to make concurrent requests while waiting for an event.
101    pub fn wait_for_event(
102        &self,
103        deadline: zx::MonotonicInstant,
104    ) -> Result<PreviousBootDataProviderEvent, fidl::Error> {
105        PreviousBootDataProviderEvent::decode(
106            self.client.wait_for_event::<PreviousBootDataProviderMarker>(deadline)?,
107        )
108    }
109
110    /// Hanging get: Returns the data once it has been rotated and is ready.
111    ///
112    /// If the data is already ready when this method is called, the responder
113    /// returns immediately. Otherwise, the responder holds the request until
114    /// the data becomes available.
115    ///
116    /// Clients should only call this method once per boot. This data does not
117    /// change across a given boot.
118    pub fn r#watch_previous_boot_data(
119        &self,
120        mut options: &PreviousBootDataProviderOptions,
121        ___deadline: zx::MonotonicInstant,
122    ) -> Result<PreviousBootData, fidl::Error> {
123        let _response = self.client.send_query::<
124            PreviousBootDataProviderWatchPreviousBootDataRequest,
125            fidl::encoding::FlexibleType<PreviousBootDataProviderWatchPreviousBootDataResponse>,
126            PreviousBootDataProviderMarker,
127        >(
128            (options,),
129            0x33be9dc62a95ac58,
130            fidl::encoding::DynamicFlags::FLEXIBLE,
131            ___deadline,
132        )?
133        .into_result::<PreviousBootDataProviderMarker>("watch_previous_boot_data")?;
134        Ok(_response.data)
135    }
136}
137
138#[cfg(target_os = "fuchsia")]
139impl From<PreviousBootDataProviderSynchronousProxy> for zx::NullableHandle {
140    fn from(value: PreviousBootDataProviderSynchronousProxy) -> Self {
141        value.into_channel().into()
142    }
143}
144
145#[cfg(target_os = "fuchsia")]
146impl From<fidl::Channel> for PreviousBootDataProviderSynchronousProxy {
147    fn from(value: fidl::Channel) -> Self {
148        Self::new(value)
149    }
150}
151
152#[cfg(target_os = "fuchsia")]
153impl fidl::endpoints::FromClient for PreviousBootDataProviderSynchronousProxy {
154    type Protocol = PreviousBootDataProviderMarker;
155
156    fn from_client(value: fidl::endpoints::ClientEnd<PreviousBootDataProviderMarker>) -> Self {
157        Self::new(value.into_channel())
158    }
159}
160
161#[derive(Debug, Clone)]
162pub struct PreviousBootDataProviderProxy {
163    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
164}
165
166impl fidl::endpoints::Proxy for PreviousBootDataProviderProxy {
167    type Protocol = PreviousBootDataProviderMarker;
168
169    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
170        Self::new(inner)
171    }
172
173    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
174        self.client.into_channel().map_err(|client| Self { client })
175    }
176
177    fn as_channel(&self) -> &::fidl::AsyncChannel {
178        self.client.as_channel()
179    }
180}
181
182impl PreviousBootDataProviderProxy {
183    /// Create a new Proxy for fuchsia.diagnostics.persistence/PreviousBootDataProvider.
184    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
185        let protocol_name =
186            <PreviousBootDataProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
187        Self { client: fidl::client::Client::new(channel, protocol_name) }
188    }
189
190    /// Get a Stream of events from the remote end of the protocol.
191    ///
192    /// # Panics
193    ///
194    /// Panics if the event stream was already taken.
195    pub fn take_event_stream(&self) -> PreviousBootDataProviderEventStream {
196        PreviousBootDataProviderEventStream { event_receiver: self.client.take_event_receiver() }
197    }
198
199    /// Hanging get: Returns the data once it has been rotated and is ready.
200    ///
201    /// If the data is already ready when this method is called, the responder
202    /// returns immediately. Otherwise, the responder holds the request until
203    /// the data becomes available.
204    ///
205    /// Clients should only call this method once per boot. This data does not
206    /// change across a given boot.
207    pub fn r#watch_previous_boot_data(
208        &self,
209        mut options: &PreviousBootDataProviderOptions,
210    ) -> fidl::client::QueryResponseFut<
211        PreviousBootData,
212        fidl::encoding::DefaultFuchsiaResourceDialect,
213    > {
214        PreviousBootDataProviderProxyInterface::r#watch_previous_boot_data(self, options)
215    }
216}
217
218impl PreviousBootDataProviderProxyInterface for PreviousBootDataProviderProxy {
219    type WatchPreviousBootDataResponseFut = fidl::client::QueryResponseFut<
220        PreviousBootData,
221        fidl::encoding::DefaultFuchsiaResourceDialect,
222    >;
223    fn r#watch_previous_boot_data(
224        &self,
225        mut options: &PreviousBootDataProviderOptions,
226    ) -> Self::WatchPreviousBootDataResponseFut {
227        fn _decode(
228            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
229        ) -> Result<PreviousBootData, fidl::Error> {
230            let _response = fidl::client::decode_transaction_body::<
231                fidl::encoding::FlexibleType<PreviousBootDataProviderWatchPreviousBootDataResponse>,
232                fidl::encoding::DefaultFuchsiaResourceDialect,
233                0x33be9dc62a95ac58,
234            >(_buf?)?
235            .into_result::<PreviousBootDataProviderMarker>("watch_previous_boot_data")?;
236            Ok(_response.data)
237        }
238        self.client.send_query_and_decode::<
239            PreviousBootDataProviderWatchPreviousBootDataRequest,
240            PreviousBootData,
241        >(
242            (options,),
243            0x33be9dc62a95ac58,
244            fidl::encoding::DynamicFlags::FLEXIBLE,
245            _decode,
246        )
247    }
248}
249
250pub struct PreviousBootDataProviderEventStream {
251    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
252}
253
254impl std::marker::Unpin for PreviousBootDataProviderEventStream {}
255
256impl futures::stream::FusedStream for PreviousBootDataProviderEventStream {
257    fn is_terminated(&self) -> bool {
258        self.event_receiver.is_terminated()
259    }
260}
261
262impl futures::Stream for PreviousBootDataProviderEventStream {
263    type Item = Result<PreviousBootDataProviderEvent, fidl::Error>;
264
265    fn poll_next(
266        mut self: std::pin::Pin<&mut Self>,
267        cx: &mut std::task::Context<'_>,
268    ) -> std::task::Poll<Option<Self::Item>> {
269        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
270            &mut self.event_receiver,
271            cx
272        )?) {
273            Some(buf) => std::task::Poll::Ready(Some(PreviousBootDataProviderEvent::decode(buf))),
274            None => std::task::Poll::Ready(None),
275        }
276    }
277}
278
279#[derive(Debug)]
280pub enum PreviousBootDataProviderEvent {
281    #[non_exhaustive]
282    _UnknownEvent {
283        /// Ordinal of the event that was sent.
284        ordinal: u64,
285    },
286}
287
288impl PreviousBootDataProviderEvent {
289    /// Decodes a message buffer as a [`PreviousBootDataProviderEvent`].
290    fn decode(
291        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
292    ) -> Result<PreviousBootDataProviderEvent, fidl::Error> {
293        let (bytes, _handles) = buf.split_mut();
294        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
295        debug_assert_eq!(tx_header.tx_id, 0);
296        match tx_header.ordinal {
297            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
298                Ok(PreviousBootDataProviderEvent::_UnknownEvent { ordinal: tx_header.ordinal })
299            }
300            _ => Err(fidl::Error::UnknownOrdinal {
301                ordinal: tx_header.ordinal,
302                protocol_name:
303                    <PreviousBootDataProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
304            }),
305        }
306    }
307}
308
309/// A Stream of incoming requests for fuchsia.diagnostics.persistence/PreviousBootDataProvider.
310pub struct PreviousBootDataProviderRequestStream {
311    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
312    is_terminated: bool,
313}
314
315impl std::marker::Unpin for PreviousBootDataProviderRequestStream {}
316
317impl futures::stream::FusedStream for PreviousBootDataProviderRequestStream {
318    fn is_terminated(&self) -> bool {
319        self.is_terminated
320    }
321}
322
323impl fidl::endpoints::RequestStream for PreviousBootDataProviderRequestStream {
324    type Protocol = PreviousBootDataProviderMarker;
325    type ControlHandle = PreviousBootDataProviderControlHandle;
326
327    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
328        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
329    }
330
331    fn control_handle(&self) -> Self::ControlHandle {
332        PreviousBootDataProviderControlHandle { inner: self.inner.clone() }
333    }
334
335    fn into_inner(
336        self,
337    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
338    {
339        (self.inner, self.is_terminated)
340    }
341
342    fn from_inner(
343        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
344        is_terminated: bool,
345    ) -> Self {
346        Self { inner, is_terminated }
347    }
348}
349
350impl futures::Stream for PreviousBootDataProviderRequestStream {
351    type Item = Result<PreviousBootDataProviderRequest, fidl::Error>;
352
353    fn poll_next(
354        mut self: std::pin::Pin<&mut Self>,
355        cx: &mut std::task::Context<'_>,
356    ) -> std::task::Poll<Option<Self::Item>> {
357        let this = &mut *self;
358        if this.inner.check_shutdown(cx) {
359            this.is_terminated = true;
360            return std::task::Poll::Ready(None);
361        }
362        if this.is_terminated {
363            panic!("polled PreviousBootDataProviderRequestStream after completion");
364        }
365        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
366            |bytes, handles| {
367                match this.inner.channel().read_etc(cx, bytes, handles) {
368                    std::task::Poll::Ready(Ok(())) => {}
369                    std::task::Poll::Pending => return std::task::Poll::Pending,
370                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
371                        this.is_terminated = true;
372                        return std::task::Poll::Ready(None);
373                    }
374                    std::task::Poll::Ready(Err(e)) => {
375                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
376                            e.into(),
377                        ))));
378                    }
379                }
380
381                // A message has been received from the channel
382                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
383
384                std::task::Poll::Ready(Some(match header.ordinal {
385                0x33be9dc62a95ac58 => {
386                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
387                    let mut req = fidl::new_empty!(PreviousBootDataProviderWatchPreviousBootDataRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
388                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PreviousBootDataProviderWatchPreviousBootDataRequest>(&header, _body_bytes, handles, &mut req)?;
389                    let control_handle = PreviousBootDataProviderControlHandle {
390                        inner: this.inner.clone(),
391                    };
392                    Ok(PreviousBootDataProviderRequest::WatchPreviousBootData {options: req.options,
393
394                        responder: PreviousBootDataProviderWatchPreviousBootDataResponder {
395                            control_handle: std::mem::ManuallyDrop::new(control_handle),
396                            tx_id: header.tx_id,
397                        },
398                    })
399                }
400                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
401                    Ok(PreviousBootDataProviderRequest::_UnknownMethod {
402                        ordinal: header.ordinal,
403                        control_handle: PreviousBootDataProviderControlHandle { inner: this.inner.clone() },
404                        method_type: fidl::MethodType::OneWay,
405                    })
406                }
407                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
408                    this.inner.send_framework_err(
409                        fidl::encoding::FrameworkErr::UnknownMethod,
410                        header.tx_id,
411                        header.ordinal,
412                        header.dynamic_flags(),
413                        (bytes, handles),
414                    )?;
415                    Ok(PreviousBootDataProviderRequest::_UnknownMethod {
416                        ordinal: header.ordinal,
417                        control_handle: PreviousBootDataProviderControlHandle { inner: this.inner.clone() },
418                        method_type: fidl::MethodType::TwoWay,
419                    })
420                }
421                _ => Err(fidl::Error::UnknownOrdinal {
422                    ordinal: header.ordinal,
423                    protocol_name: <PreviousBootDataProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
424                }),
425            }))
426            },
427        )
428    }
429}
430
431#[derive(Debug)]
432pub enum PreviousBootDataProviderRequest {
433    /// Hanging get: Returns the data once it has been rotated and is ready.
434    ///
435    /// If the data is already ready when this method is called, the responder
436    /// returns immediately. Otherwise, the responder holds the request until
437    /// the data becomes available.
438    ///
439    /// Clients should only call this method once per boot. This data does not
440    /// change across a given boot.
441    WatchPreviousBootData {
442        options: PreviousBootDataProviderOptions,
443        responder: PreviousBootDataProviderWatchPreviousBootDataResponder,
444    },
445    /// An interaction was received which does not match any known method.
446    #[non_exhaustive]
447    _UnknownMethod {
448        /// Ordinal of the method that was called.
449        ordinal: u64,
450        control_handle: PreviousBootDataProviderControlHandle,
451        method_type: fidl::MethodType,
452    },
453}
454
455impl PreviousBootDataProviderRequest {
456    #[allow(irrefutable_let_patterns)]
457    pub fn into_watch_previous_boot_data(
458        self,
459    ) -> Option<(
460        PreviousBootDataProviderOptions,
461        PreviousBootDataProviderWatchPreviousBootDataResponder,
462    )> {
463        if let PreviousBootDataProviderRequest::WatchPreviousBootData { options, responder } = self
464        {
465            Some((options, responder))
466        } else {
467            None
468        }
469    }
470
471    /// Name of the method defined in FIDL
472    pub fn method_name(&self) -> &'static str {
473        match *self {
474            PreviousBootDataProviderRequest::WatchPreviousBootData { .. } => {
475                "watch_previous_boot_data"
476            }
477            PreviousBootDataProviderRequest::_UnknownMethod {
478                method_type: fidl::MethodType::OneWay,
479                ..
480            } => "unknown one-way method",
481            PreviousBootDataProviderRequest::_UnknownMethod {
482                method_type: fidl::MethodType::TwoWay,
483                ..
484            } => "unknown two-way method",
485        }
486    }
487}
488
489#[derive(Debug, Clone)]
490pub struct PreviousBootDataProviderControlHandle {
491    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
492}
493
494impl PreviousBootDataProviderControlHandle {
495    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
496        self.inner.shutdown_with_epitaph(status.into())
497    }
498}
499
500impl fidl::endpoints::ControlHandle for PreviousBootDataProviderControlHandle {
501    fn shutdown(&self) {
502        self.inner.shutdown()
503    }
504
505    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
506        self.inner.shutdown_with_epitaph(status)
507    }
508
509    fn is_closed(&self) -> bool {
510        self.inner.channel().is_closed()
511    }
512    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
513        self.inner.channel().on_closed()
514    }
515
516    #[cfg(target_os = "fuchsia")]
517    fn signal_peer(
518        &self,
519        clear_mask: zx::Signals,
520        set_mask: zx::Signals,
521    ) -> Result<(), zx_status::Status> {
522        use fidl::Peered;
523        self.inner.channel().signal_peer(clear_mask, set_mask)
524    }
525}
526
527impl PreviousBootDataProviderControlHandle {}
528
529#[must_use = "FIDL methods require a response to be sent"]
530#[derive(Debug)]
531pub struct PreviousBootDataProviderWatchPreviousBootDataResponder {
532    control_handle: std::mem::ManuallyDrop<PreviousBootDataProviderControlHandle>,
533    tx_id: u32,
534}
535
536/// Set the the channel to be shutdown (see [`PreviousBootDataProviderControlHandle::shutdown`])
537/// if the responder is dropped without sending a response, so that the client
538/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
539impl std::ops::Drop for PreviousBootDataProviderWatchPreviousBootDataResponder {
540    fn drop(&mut self) {
541        self.control_handle.shutdown();
542        // Safety: drops once, never accessed again
543        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
544    }
545}
546
547impl fidl::endpoints::Responder for PreviousBootDataProviderWatchPreviousBootDataResponder {
548    type ControlHandle = PreviousBootDataProviderControlHandle;
549
550    fn control_handle(&self) -> &PreviousBootDataProviderControlHandle {
551        &self.control_handle
552    }
553
554    fn drop_without_shutdown(mut self) {
555        // Safety: drops once, never accessed again due to mem::forget
556        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
557        // Prevent Drop from running (which would shut down the channel)
558        std::mem::forget(self);
559    }
560}
561
562impl PreviousBootDataProviderWatchPreviousBootDataResponder {
563    /// Sends a response to the FIDL transaction.
564    ///
565    /// Sets the channel to shutdown if an error occurs.
566    pub fn send(self, mut data: PreviousBootData) -> Result<(), fidl::Error> {
567        let _result = self.send_raw(data);
568        if _result.is_err() {
569            self.control_handle.shutdown();
570        }
571        self.drop_without_shutdown();
572        _result
573    }
574
575    /// Similar to "send" but does not shutdown the channel if an error occurs.
576    pub fn send_no_shutdown_on_err(self, mut data: PreviousBootData) -> Result<(), fidl::Error> {
577        let _result = self.send_raw(data);
578        self.drop_without_shutdown();
579        _result
580    }
581
582    fn send_raw(&self, mut data: PreviousBootData) -> Result<(), fidl::Error> {
583        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
584            PreviousBootDataProviderWatchPreviousBootDataResponse,
585        >>(
586            fidl::encoding::Flexible::new((&mut data,)),
587            self.tx_id,
588            0x33be9dc62a95ac58,
589            fidl::encoding::DynamicFlags::FLEXIBLE,
590        )
591    }
592}
593
594mod internal {
595    use super::*;
596
597    impl fidl::encoding::ResourceTypeMarker for PreviousBootDataProviderWatchPreviousBootDataResponse {
598        type Borrowed<'a> = &'a mut Self;
599        fn take_or_borrow<'a>(
600            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
601        ) -> Self::Borrowed<'a> {
602            value
603        }
604    }
605
606    unsafe impl fidl::encoding::TypeMarker for PreviousBootDataProviderWatchPreviousBootDataResponse {
607        type Owned = Self;
608
609        #[inline(always)]
610        fn inline_align(_context: fidl::encoding::Context) -> usize {
611            8
612        }
613
614        #[inline(always)]
615        fn inline_size(_context: fidl::encoding::Context) -> usize {
616            16
617        }
618    }
619
620    unsafe impl
621        fidl::encoding::Encode<
622            PreviousBootDataProviderWatchPreviousBootDataResponse,
623            fidl::encoding::DefaultFuchsiaResourceDialect,
624        > for &mut PreviousBootDataProviderWatchPreviousBootDataResponse
625    {
626        #[inline]
627        unsafe fn encode(
628            self,
629            encoder: &mut fidl::encoding::Encoder<
630                '_,
631                fidl::encoding::DefaultFuchsiaResourceDialect,
632            >,
633            offset: usize,
634            _depth: fidl::encoding::Depth,
635        ) -> fidl::Result<()> {
636            encoder.debug_check_bounds::<PreviousBootDataProviderWatchPreviousBootDataResponse>(
637                offset,
638            );
639            // Delegate to tuple encoding.
640            fidl::encoding::Encode::<
641                PreviousBootDataProviderWatchPreviousBootDataResponse,
642                fidl::encoding::DefaultFuchsiaResourceDialect,
643            >::encode(
644                (<PreviousBootData as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
645                    &mut self.data,
646                ),),
647                encoder,
648                offset,
649                _depth,
650            )
651        }
652    }
653    unsafe impl<
654        T0: fidl::encoding::Encode<PreviousBootData, fidl::encoding::DefaultFuchsiaResourceDialect>,
655    >
656        fidl::encoding::Encode<
657            PreviousBootDataProviderWatchPreviousBootDataResponse,
658            fidl::encoding::DefaultFuchsiaResourceDialect,
659        > for (T0,)
660    {
661        #[inline]
662        unsafe fn encode(
663            self,
664            encoder: &mut fidl::encoding::Encoder<
665                '_,
666                fidl::encoding::DefaultFuchsiaResourceDialect,
667            >,
668            offset: usize,
669            depth: fidl::encoding::Depth,
670        ) -> fidl::Result<()> {
671            encoder.debug_check_bounds::<PreviousBootDataProviderWatchPreviousBootDataResponse>(
672                offset,
673            );
674            // Zero out padding regions. There's no need to apply masks
675            // because the unmasked parts will be overwritten by fields.
676            // Write the fields.
677            self.0.encode(encoder, offset + 0, depth)?;
678            Ok(())
679        }
680    }
681
682    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
683        for PreviousBootDataProviderWatchPreviousBootDataResponse
684    {
685        #[inline(always)]
686        fn new_empty() -> Self {
687            Self {
688                data: fidl::new_empty!(
689                    PreviousBootData,
690                    fidl::encoding::DefaultFuchsiaResourceDialect
691                ),
692            }
693        }
694
695        #[inline]
696        unsafe fn decode(
697            &mut self,
698            decoder: &mut fidl::encoding::Decoder<
699                '_,
700                fidl::encoding::DefaultFuchsiaResourceDialect,
701            >,
702            offset: usize,
703            _depth: fidl::encoding::Depth,
704        ) -> fidl::Result<()> {
705            decoder.debug_check_bounds::<Self>(offset);
706            // Verify that padding bytes are zero.
707            fidl::decode!(
708                PreviousBootData,
709                fidl::encoding::DefaultFuchsiaResourceDialect,
710                &mut self.data,
711                decoder,
712                offset + 0,
713                _depth
714            )?;
715            Ok(())
716        }
717    }
718
719    impl PreviousBootData {
720        #[inline(always)]
721        fn max_ordinal_present(&self) -> u64 {
722            if let Some(_) = self.inspect {
723                return 4;
724            }
725            if let Some(_) = self.utc_timestamp_ns {
726                return 3;
727            }
728            if let Some(_) = self.boot_timestamp {
729                return 2;
730            }
731            if let Some(_) = self.monotonic_timestamp {
732                return 1;
733            }
734            0
735        }
736    }
737
738    impl fidl::encoding::ResourceTypeMarker for PreviousBootData {
739        type Borrowed<'a> = &'a mut Self;
740        fn take_or_borrow<'a>(
741            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
742        ) -> Self::Borrowed<'a> {
743            value
744        }
745    }
746
747    unsafe impl fidl::encoding::TypeMarker for PreviousBootData {
748        type Owned = Self;
749
750        #[inline(always)]
751        fn inline_align(_context: fidl::encoding::Context) -> usize {
752            8
753        }
754
755        #[inline(always)]
756        fn inline_size(_context: fidl::encoding::Context) -> usize {
757            16
758        }
759    }
760
761    unsafe impl
762        fidl::encoding::Encode<PreviousBootData, fidl::encoding::DefaultFuchsiaResourceDialect>
763        for &mut PreviousBootData
764    {
765        unsafe fn encode(
766            self,
767            encoder: &mut fidl::encoding::Encoder<
768                '_,
769                fidl::encoding::DefaultFuchsiaResourceDialect,
770            >,
771            offset: usize,
772            mut depth: fidl::encoding::Depth,
773        ) -> fidl::Result<()> {
774            encoder.debug_check_bounds::<PreviousBootData>(offset);
775            // Vector header
776            let max_ordinal: u64 = self.max_ordinal_present();
777            encoder.write_num(max_ordinal, offset);
778            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
779            // Calling encoder.out_of_line_offset(0) is not allowed.
780            if max_ordinal == 0 {
781                return Ok(());
782            }
783            depth.increment()?;
784            let envelope_size = 8;
785            let bytes_len = max_ordinal as usize * envelope_size;
786            #[allow(unused_variables)]
787            let offset = encoder.out_of_line_offset(bytes_len);
788            let mut _prev_end_offset: usize = 0;
789            if 1 > max_ordinal {
790                return Ok(());
791            }
792
793            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
794            // are envelope_size bytes.
795            let cur_offset: usize = (1 - 1) * envelope_size;
796
797            // Zero reserved fields.
798            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
799
800            // Safety:
801            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
802            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
803            //   envelope_size bytes, there is always sufficient room.
804            fidl::encoding::encode_in_envelope_optional::<
805                fidl::MonotonicInstant,
806                fidl::encoding::DefaultFuchsiaResourceDialect,
807            >(
808                self.monotonic_timestamp
809                    .as_ref()
810                    .map(<fidl::MonotonicInstant as fidl::encoding::ValueTypeMarker>::borrow),
811                encoder,
812                offset + cur_offset,
813                depth,
814            )?;
815
816            _prev_end_offset = cur_offset + envelope_size;
817            if 2 > max_ordinal {
818                return Ok(());
819            }
820
821            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
822            // are envelope_size bytes.
823            let cur_offset: usize = (2 - 1) * envelope_size;
824
825            // Zero reserved fields.
826            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
827
828            // Safety:
829            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
830            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
831            //   envelope_size bytes, there is always sufficient room.
832            fidl::encoding::encode_in_envelope_optional::<
833                fidl::BootInstant,
834                fidl::encoding::DefaultFuchsiaResourceDialect,
835            >(
836                self.boot_timestamp
837                    .as_ref()
838                    .map(<fidl::BootInstant as fidl::encoding::ValueTypeMarker>::borrow),
839                encoder,
840                offset + cur_offset,
841                depth,
842            )?;
843
844            _prev_end_offset = cur_offset + envelope_size;
845            if 3 > max_ordinal {
846                return Ok(());
847            }
848
849            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
850            // are envelope_size bytes.
851            let cur_offset: usize = (3 - 1) * envelope_size;
852
853            // Zero reserved fields.
854            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
855
856            // Safety:
857            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
858            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
859            //   envelope_size bytes, there is always sufficient room.
860            fidl::encoding::encode_in_envelope_optional::<
861                i64,
862                fidl::encoding::DefaultFuchsiaResourceDialect,
863            >(
864                self.utc_timestamp_ns
865                    .as_ref()
866                    .map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
867                encoder,
868                offset + cur_offset,
869                depth,
870            )?;
871
872            _prev_end_offset = cur_offset + envelope_size;
873            if 4 > max_ordinal {
874                return Ok(());
875            }
876
877            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
878            // are envelope_size bytes.
879            let cur_offset: usize = (4 - 1) * envelope_size;
880
881            // Zero reserved fields.
882            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
883
884            // Safety:
885            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
886            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
887            //   envelope_size bytes, there is always sufficient room.
888            fidl::encoding::encode_in_envelope_optional::<
889                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
890                fidl::encoding::DefaultFuchsiaResourceDialect,
891            >(
892                self.inspect.as_mut().map(
893                    <fidl::encoding::Endpoint<
894                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
895                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
896                ),
897                encoder,
898                offset + cur_offset,
899                depth,
900            )?;
901
902            _prev_end_offset = cur_offset + envelope_size;
903
904            Ok(())
905        }
906    }
907
908    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
909        for PreviousBootData
910    {
911        #[inline(always)]
912        fn new_empty() -> Self {
913            Self::default()
914        }
915
916        unsafe fn decode(
917            &mut self,
918            decoder: &mut fidl::encoding::Decoder<
919                '_,
920                fidl::encoding::DefaultFuchsiaResourceDialect,
921            >,
922            offset: usize,
923            mut depth: fidl::encoding::Depth,
924        ) -> fidl::Result<()> {
925            decoder.debug_check_bounds::<Self>(offset);
926            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
927                None => return Err(fidl::Error::NotNullable),
928                Some(len) => len,
929            };
930            // Calling decoder.out_of_line_offset(0) is not allowed.
931            if len == 0 {
932                return Ok(());
933            };
934            depth.increment()?;
935            let envelope_size = 8;
936            let bytes_len = len * envelope_size;
937            let offset = decoder.out_of_line_offset(bytes_len)?;
938            // Decode the envelope for each type.
939            let mut _next_ordinal_to_read = 0;
940            let mut next_offset = offset;
941            let end_offset = offset + bytes_len;
942            _next_ordinal_to_read += 1;
943            if next_offset >= end_offset {
944                return Ok(());
945            }
946
947            // Decode unknown envelopes for gaps in ordinals.
948            while _next_ordinal_to_read < 1 {
949                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
950                _next_ordinal_to_read += 1;
951                next_offset += envelope_size;
952            }
953
954            let next_out_of_line = decoder.next_out_of_line();
955            let handles_before = decoder.remaining_handles();
956            if let Some((inlined, num_bytes, num_handles)) =
957                fidl::encoding::decode_envelope_header(decoder, next_offset)?
958            {
959                let member_inline_size =
960                    <fidl::MonotonicInstant as fidl::encoding::TypeMarker>::inline_size(
961                        decoder.context,
962                    );
963                if inlined != (member_inline_size <= 4) {
964                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
965                }
966                let inner_offset;
967                let mut inner_depth = depth.clone();
968                if inlined {
969                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
970                    inner_offset = next_offset;
971                } else {
972                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
973                    inner_depth.increment()?;
974                }
975                let val_ref = self.monotonic_timestamp.get_or_insert_with(|| {
976                    fidl::new_empty!(
977                        fidl::MonotonicInstant,
978                        fidl::encoding::DefaultFuchsiaResourceDialect
979                    )
980                });
981                fidl::decode!(
982                    fidl::MonotonicInstant,
983                    fidl::encoding::DefaultFuchsiaResourceDialect,
984                    val_ref,
985                    decoder,
986                    inner_offset,
987                    inner_depth
988                )?;
989                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
990                {
991                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
992                }
993                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
994                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
995                }
996            }
997
998            next_offset += envelope_size;
999            _next_ordinal_to_read += 1;
1000            if next_offset >= end_offset {
1001                return Ok(());
1002            }
1003
1004            // Decode unknown envelopes for gaps in ordinals.
1005            while _next_ordinal_to_read < 2 {
1006                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1007                _next_ordinal_to_read += 1;
1008                next_offset += envelope_size;
1009            }
1010
1011            let next_out_of_line = decoder.next_out_of_line();
1012            let handles_before = decoder.remaining_handles();
1013            if let Some((inlined, num_bytes, num_handles)) =
1014                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1015            {
1016                let member_inline_size =
1017                    <fidl::BootInstant as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1018                if inlined != (member_inline_size <= 4) {
1019                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1020                }
1021                let inner_offset;
1022                let mut inner_depth = depth.clone();
1023                if inlined {
1024                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1025                    inner_offset = next_offset;
1026                } else {
1027                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1028                    inner_depth.increment()?;
1029                }
1030                let val_ref = self.boot_timestamp.get_or_insert_with(|| {
1031                    fidl::new_empty!(
1032                        fidl::BootInstant,
1033                        fidl::encoding::DefaultFuchsiaResourceDialect
1034                    )
1035                });
1036                fidl::decode!(
1037                    fidl::BootInstant,
1038                    fidl::encoding::DefaultFuchsiaResourceDialect,
1039                    val_ref,
1040                    decoder,
1041                    inner_offset,
1042                    inner_depth
1043                )?;
1044                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1045                {
1046                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1047                }
1048                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1049                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1050                }
1051            }
1052
1053            next_offset += envelope_size;
1054            _next_ordinal_to_read += 1;
1055            if next_offset >= end_offset {
1056                return Ok(());
1057            }
1058
1059            // Decode unknown envelopes for gaps in ordinals.
1060            while _next_ordinal_to_read < 3 {
1061                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1062                _next_ordinal_to_read += 1;
1063                next_offset += envelope_size;
1064            }
1065
1066            let next_out_of_line = decoder.next_out_of_line();
1067            let handles_before = decoder.remaining_handles();
1068            if let Some((inlined, num_bytes, num_handles)) =
1069                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1070            {
1071                let member_inline_size =
1072                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1073                if inlined != (member_inline_size <= 4) {
1074                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1075                }
1076                let inner_offset;
1077                let mut inner_depth = depth.clone();
1078                if inlined {
1079                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1080                    inner_offset = next_offset;
1081                } else {
1082                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1083                    inner_depth.increment()?;
1084                }
1085                let val_ref = self.utc_timestamp_ns.get_or_insert_with(|| {
1086                    fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect)
1087                });
1088                fidl::decode!(
1089                    i64,
1090                    fidl::encoding::DefaultFuchsiaResourceDialect,
1091                    val_ref,
1092                    decoder,
1093                    inner_offset,
1094                    inner_depth
1095                )?;
1096                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1097                {
1098                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1099                }
1100                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1101                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1102                }
1103            }
1104
1105            next_offset += envelope_size;
1106            _next_ordinal_to_read += 1;
1107            if next_offset >= end_offset {
1108                return Ok(());
1109            }
1110
1111            // Decode unknown envelopes for gaps in ordinals.
1112            while _next_ordinal_to_read < 4 {
1113                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1114                _next_ordinal_to_read += 1;
1115                next_offset += envelope_size;
1116            }
1117
1118            let next_out_of_line = decoder.next_out_of_line();
1119            let handles_before = decoder.remaining_handles();
1120            if let Some((inlined, num_bytes, num_handles)) =
1121                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1122            {
1123                let member_inline_size = <fidl::encoding::Endpoint<
1124                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
1125                > as fidl::encoding::TypeMarker>::inline_size(
1126                    decoder.context
1127                );
1128                if inlined != (member_inline_size <= 4) {
1129                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1130                }
1131                let inner_offset;
1132                let mut inner_depth = depth.clone();
1133                if inlined {
1134                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1135                    inner_offset = next_offset;
1136                } else {
1137                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1138                    inner_depth.increment()?;
1139                }
1140                let val_ref = self.inspect.get_or_insert_with(|| {
1141                    fidl::new_empty!(
1142                        fidl::encoding::Endpoint<
1143                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
1144                        >,
1145                        fidl::encoding::DefaultFuchsiaResourceDialect
1146                    )
1147                });
1148                fidl::decode!(
1149                    fidl::encoding::Endpoint<
1150                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
1151                    >,
1152                    fidl::encoding::DefaultFuchsiaResourceDialect,
1153                    val_ref,
1154                    decoder,
1155                    inner_offset,
1156                    inner_depth
1157                )?;
1158                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1159                {
1160                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1161                }
1162                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1163                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1164                }
1165            }
1166
1167            next_offset += envelope_size;
1168
1169            // Decode the remaining unknown envelopes.
1170            while next_offset < end_offset {
1171                _next_ordinal_to_read += 1;
1172                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1173                next_offset += envelope_size;
1174            }
1175
1176            Ok(())
1177        }
1178    }
1179}