fidl_fuchsia_diagnostics/
fidl_fuchsia_diagnostics.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__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ArchiveAccessorStreamDiagnosticsRequest {
16    pub stream_parameters: StreamParameters,
17    pub result_stream: fidl::endpoints::ServerEnd<BatchIteratorMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for ArchiveAccessorStreamDiagnosticsRequest
22{
23}
24
25#[derive(Debug, PartialEq)]
26pub struct BatchIteratorGetNextResponse {
27    pub batch: Vec<FormattedContent>,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for BatchIteratorGetNextResponse
32{
33}
34
35#[derive(Debug, PartialEq)]
36pub struct LogStreamConnectRequest {
37    pub socket: fidl::Socket,
38    pub opts: LogStreamOptions,
39}
40
41impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for LogStreamConnectRequest {}
42
43#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
44pub struct SampleCommitRequest {
45    /// Where results are sent.
46    pub sink: fidl::endpoints::ClientEnd<SampleSinkMarker>,
47}
48
49impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SampleCommitRequest {}
50
51#[derive(Debug, PartialEq)]
52pub struct SampleSetRequest {
53    /// The data configuration for this sample server.
54    pub sample_parameters: SampleParameters,
55}
56
57impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SampleSetRequest {}
58
59#[derive(Debug, PartialEq)]
60pub struct SampleSinkOnSampleReadiedRequest {
61    pub event: SampleSinkResult,
62}
63
64impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
65    for SampleSinkOnSampleReadiedRequest
66{
67}
68
69/// `SampleReady` carries the data for a ready-to-consume sample.
70#[derive(Debug, Default, PartialEq)]
71pub struct SampleReady {
72    /// `batch_iter` is the `BatchIterator` over the set of data.
73    pub batch_iter: Option<fidl::endpoints::ClientEnd<BatchIteratorMarker>>,
74    /// `seconds_since_start` is `ticks * interval_secs` for the current
75    /// polling period.
76    ///
77    /// This can be used to check whether a value in the batch corresponds
78    /// to a `SampleDatum`, assuming you have not registered the same selector
79    /// with different `SampleStrategy` types. The procedure is:
80    ///
81    /// 1) Resolve `batch_iter` into a set of Inspect hierarchies.
82    /// 2) Filter the set of `SampleDatum`s committed to this server with
83    ///    the predicate `seconds_since_start % datum.interval_secs == 0`.
84    /// 3) Any selector from the filtered `SampleDatum`s that matches data
85    ///    in the resolved Inspect hierarchies is valid.
86    ///
87    /// If you DO have one selector registered twice with different strategies,
88    /// you must maintain a local cache and check the value yourself.
89    pub seconds_since_start: Option<i64>,
90    #[doc(hidden)]
91    pub __source_breaking: fidl::marker::SourceBreaking,
92}
93
94impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SampleReady {}
95
96/// A fidl union containing a complete hierarchy of structured diagnostics
97/// data, such that the content can be parsed into a file by itself.
98#[derive(Debug)]
99pub enum FormattedContent {
100    /// A diagnostics schema encoded as json.
101    /// The VMO will contain up to 1mb of diagnostics data.
102    Json(fidl_fuchsia_mem::Buffer),
103    /// A diagnostics schema encoded as cbor.
104    /// The VMO will contain up to 1mb of diagnostics data.
105    /// The size will be in ZX_PROP_VMO_CONTENT_SIZE.
106    Cbor(fidl::Vmo),
107    /// A diagnostics schema encoded as FXT.
108    /// This is only valid for logs data.
109    /// The VMO will contain up to PerformanceConfiguration/max_aggregate_content_size_bytes
110    /// of diagnostics data, or 1mb if not specified.
111    /// The size will be in ZX_PROP_VMO_CONTENT_SIZE.
112    Fxt(fidl::Vmo),
113    #[doc(hidden)]
114    __SourceBreaking { unknown_ordinal: u64 },
115}
116
117/// Pattern that matches an unknown `FormattedContent` member.
118#[macro_export]
119macro_rules! FormattedContentUnknown {
120    () => {
121        _
122    };
123}
124
125// Custom PartialEq so that unknown variants are not equal to themselves.
126impl PartialEq for FormattedContent {
127    fn eq(&self, other: &Self) -> bool {
128        match (self, other) {
129            (Self::Json(x), Self::Json(y)) => *x == *y,
130            (Self::Cbor(x), Self::Cbor(y)) => *x == *y,
131            (Self::Fxt(x), Self::Fxt(y)) => *x == *y,
132            _ => false,
133        }
134    }
135}
136
137impl FormattedContent {
138    #[inline]
139    pub fn ordinal(&self) -> u64 {
140        match *self {
141            Self::Json(_) => 1,
142            Self::Cbor(_) => 3,
143            Self::Fxt(_) => 4,
144            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
145        }
146    }
147
148    #[inline]
149    pub fn unknown_variant_for_testing() -> Self {
150        Self::__SourceBreaking { unknown_ordinal: 0 }
151    }
152
153    #[inline]
154    pub fn is_unknown(&self) -> bool {
155        match self {
156            Self::__SourceBreaking { .. } => true,
157            _ => false,
158        }
159    }
160}
161
162impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for FormattedContent {}
163
164#[derive(Debug)]
165pub enum SampleSinkResult {
166    /// `SampleReady` provides a `BatchIterator` for the client containing all
167    /// ready samples.
168    ///
169    /// This will include all `SampleStrategy::ALWAYS` samples and all
170    /// `SampleStrategy::ON_DIFF` for which there was a changed value.
171    Ready(SampleReady),
172    /// `error` provides an interface for receiving runtime errors from the
173    /// sample server.
174    Error(RuntimeError),
175    #[doc(hidden)]
176    __SourceBreaking { unknown_ordinal: u64 },
177}
178
179/// Pattern that matches an unknown `SampleSinkResult` member.
180#[macro_export]
181macro_rules! SampleSinkResultUnknown {
182    () => {
183        _
184    };
185}
186
187// Custom PartialEq so that unknown variants are not equal to themselves.
188impl PartialEq for SampleSinkResult {
189    fn eq(&self, other: &Self) -> bool {
190        match (self, other) {
191            (Self::Ready(x), Self::Ready(y)) => *x == *y,
192            (Self::Error(x), Self::Error(y)) => *x == *y,
193            _ => false,
194        }
195    }
196}
197
198impl SampleSinkResult {
199    #[inline]
200    pub fn ordinal(&self) -> u64 {
201        match *self {
202            Self::Ready(_) => 1,
203            Self::Error(_) => 2,
204            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
205        }
206    }
207
208    #[inline]
209    pub fn unknown_variant_for_testing() -> Self {
210        Self::__SourceBreaking { unknown_ordinal: 0 }
211    }
212
213    #[inline]
214    pub fn is_unknown(&self) -> bool {
215        match self {
216            Self::__SourceBreaking { .. } => true,
217            _ => false,
218        }
219    }
220}
221
222impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SampleSinkResult {}
223
224#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
225pub struct ArchiveAccessorMarker;
226
227impl fidl::endpoints::ProtocolMarker for ArchiveAccessorMarker {
228    type Proxy = ArchiveAccessorProxy;
229    type RequestStream = ArchiveAccessorRequestStream;
230    #[cfg(target_os = "fuchsia")]
231    type SynchronousProxy = ArchiveAccessorSynchronousProxy;
232
233    const DEBUG_NAME: &'static str = "fuchsia.diagnostics.ArchiveAccessor";
234}
235impl fidl::endpoints::DiscoverableProtocolMarker for ArchiveAccessorMarker {}
236
237pub trait ArchiveAccessorProxyInterface: Send + Sync {
238    fn r#stream_diagnostics(
239        &self,
240        stream_parameters: &StreamParameters,
241        result_stream: fidl::endpoints::ServerEnd<BatchIteratorMarker>,
242    ) -> Result<(), fidl::Error>;
243    type WaitForReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
244    fn r#wait_for_ready(&self) -> Self::WaitForReadyResponseFut;
245}
246#[derive(Debug)]
247#[cfg(target_os = "fuchsia")]
248pub struct ArchiveAccessorSynchronousProxy {
249    client: fidl::client::sync::Client,
250}
251
252#[cfg(target_os = "fuchsia")]
253impl fidl::endpoints::SynchronousProxy for ArchiveAccessorSynchronousProxy {
254    type Proxy = ArchiveAccessorProxy;
255    type Protocol = ArchiveAccessorMarker;
256
257    fn from_channel(inner: fidl::Channel) -> Self {
258        Self::new(inner)
259    }
260
261    fn into_channel(self) -> fidl::Channel {
262        self.client.into_channel()
263    }
264
265    fn as_channel(&self) -> &fidl::Channel {
266        self.client.as_channel()
267    }
268}
269
270#[cfg(target_os = "fuchsia")]
271impl ArchiveAccessorSynchronousProxy {
272    pub fn new(channel: fidl::Channel) -> Self {
273        let protocol_name = <ArchiveAccessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
274        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
275    }
276
277    pub fn into_channel(self) -> fidl::Channel {
278        self.client.into_channel()
279    }
280
281    /// Waits until an event arrives and returns it. It is safe for other
282    /// threads to make concurrent requests while waiting for an event.
283    pub fn wait_for_event(
284        &self,
285        deadline: zx::MonotonicInstant,
286    ) -> Result<ArchiveAccessorEvent, fidl::Error> {
287        ArchiveAccessorEvent::decode(self.client.wait_for_event(deadline)?)
288    }
289
290    /// Creates an iterator over diagnostics data on the system.
291    ///   * The iterator may be finite by streaming in SNAPSHOT mode, serving only the
292    ///     current state of diagnostics data on the system.
293    ///   * The iterator may be infinite by streaming in either SNAPSHOT_THEN_SUBSCRIBE
294    ///     or SUBSCRIBE mode; the prior first provides iteration over the current state of
295    ///     the sytem, and then both provide ongoing iteration over newly arriving diagnostics
296    ///     data.
297    ///
298    /// + request `result stream` a [fuchsia.diagnostics/BatchIterator] that diagnostic
299    ///   records are exposed to the client over.
300    ///   * epitaphs:
301    ///      - INVALID_ARGS: A required argument in the StreamParameters struct was missing.
302    ///      - WRONG_TYPE: A selector provided by the StreamParameters struct was incorrectly
303    ///                    formatted.
304    ///
305    /// + request `stream_parameters` is a [fuchsia.diagnostics/StreamParameter] which
306    ///   specifies how to configure the stream.
307    pub fn r#stream_diagnostics(
308        &self,
309        mut stream_parameters: &StreamParameters,
310        mut result_stream: fidl::endpoints::ServerEnd<BatchIteratorMarker>,
311    ) -> Result<(), fidl::Error> {
312        self.client.send::<ArchiveAccessorStreamDiagnosticsRequest>(
313            (stream_parameters, result_stream),
314            0x20c73e2ecd653c3e,
315            fidl::encoding::DynamicFlags::FLEXIBLE,
316        )
317    }
318
319    /// Ensures that the connection with the server was established to prevent
320    /// races when using other pipelined methods of this protocol.
321    pub fn r#wait_for_ready(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
322        let _response = self.client.send_query::<
323            fidl::encoding::EmptyPayload,
324            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
325        >(
326            (),
327            0x122963198011bd24,
328            fidl::encoding::DynamicFlags::FLEXIBLE,
329            ___deadline,
330        )?
331        .into_result::<ArchiveAccessorMarker>("wait_for_ready")?;
332        Ok(_response)
333    }
334}
335
336#[cfg(target_os = "fuchsia")]
337impl From<ArchiveAccessorSynchronousProxy> for zx::NullableHandle {
338    fn from(value: ArchiveAccessorSynchronousProxy) -> Self {
339        value.into_channel().into()
340    }
341}
342
343#[cfg(target_os = "fuchsia")]
344impl From<fidl::Channel> for ArchiveAccessorSynchronousProxy {
345    fn from(value: fidl::Channel) -> Self {
346        Self::new(value)
347    }
348}
349
350#[cfg(target_os = "fuchsia")]
351impl fidl::endpoints::FromClient for ArchiveAccessorSynchronousProxy {
352    type Protocol = ArchiveAccessorMarker;
353
354    fn from_client(value: fidl::endpoints::ClientEnd<ArchiveAccessorMarker>) -> Self {
355        Self::new(value.into_channel())
356    }
357}
358
359#[derive(Debug, Clone)]
360pub struct ArchiveAccessorProxy {
361    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
362}
363
364impl fidl::endpoints::Proxy for ArchiveAccessorProxy {
365    type Protocol = ArchiveAccessorMarker;
366
367    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
368        Self::new(inner)
369    }
370
371    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
372        self.client.into_channel().map_err(|client| Self { client })
373    }
374
375    fn as_channel(&self) -> &::fidl::AsyncChannel {
376        self.client.as_channel()
377    }
378}
379
380impl ArchiveAccessorProxy {
381    /// Create a new Proxy for fuchsia.diagnostics/ArchiveAccessor.
382    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
383        let protocol_name = <ArchiveAccessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
384        Self { client: fidl::client::Client::new(channel, protocol_name) }
385    }
386
387    /// Get a Stream of events from the remote end of the protocol.
388    ///
389    /// # Panics
390    ///
391    /// Panics if the event stream was already taken.
392    pub fn take_event_stream(&self) -> ArchiveAccessorEventStream {
393        ArchiveAccessorEventStream { event_receiver: self.client.take_event_receiver() }
394    }
395
396    /// Creates an iterator over diagnostics data on the system.
397    ///   * The iterator may be finite by streaming in SNAPSHOT mode, serving only the
398    ///     current state of diagnostics data on the system.
399    ///   * The iterator may be infinite by streaming in either SNAPSHOT_THEN_SUBSCRIBE
400    ///     or SUBSCRIBE mode; the prior first provides iteration over the current state of
401    ///     the sytem, and then both provide ongoing iteration over newly arriving diagnostics
402    ///     data.
403    ///
404    /// + request `result stream` a [fuchsia.diagnostics/BatchIterator] that diagnostic
405    ///   records are exposed to the client over.
406    ///   * epitaphs:
407    ///      - INVALID_ARGS: A required argument in the StreamParameters struct was missing.
408    ///      - WRONG_TYPE: A selector provided by the StreamParameters struct was incorrectly
409    ///                    formatted.
410    ///
411    /// + request `stream_parameters` is a [fuchsia.diagnostics/StreamParameter] which
412    ///   specifies how to configure the stream.
413    pub fn r#stream_diagnostics(
414        &self,
415        mut stream_parameters: &StreamParameters,
416        mut result_stream: fidl::endpoints::ServerEnd<BatchIteratorMarker>,
417    ) -> Result<(), fidl::Error> {
418        ArchiveAccessorProxyInterface::r#stream_diagnostics(self, stream_parameters, result_stream)
419    }
420
421    /// Ensures that the connection with the server was established to prevent
422    /// races when using other pipelined methods of this protocol.
423    pub fn r#wait_for_ready(
424        &self,
425    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
426        ArchiveAccessorProxyInterface::r#wait_for_ready(self)
427    }
428}
429
430impl ArchiveAccessorProxyInterface for ArchiveAccessorProxy {
431    fn r#stream_diagnostics(
432        &self,
433        mut stream_parameters: &StreamParameters,
434        mut result_stream: fidl::endpoints::ServerEnd<BatchIteratorMarker>,
435    ) -> Result<(), fidl::Error> {
436        self.client.send::<ArchiveAccessorStreamDiagnosticsRequest>(
437            (stream_parameters, result_stream),
438            0x20c73e2ecd653c3e,
439            fidl::encoding::DynamicFlags::FLEXIBLE,
440        )
441    }
442
443    type WaitForReadyResponseFut =
444        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
445    fn r#wait_for_ready(&self) -> Self::WaitForReadyResponseFut {
446        fn _decode(
447            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
448        ) -> Result<(), fidl::Error> {
449            let _response = fidl::client::decode_transaction_body::<
450                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
451                fidl::encoding::DefaultFuchsiaResourceDialect,
452                0x122963198011bd24,
453            >(_buf?)?
454            .into_result::<ArchiveAccessorMarker>("wait_for_ready")?;
455            Ok(_response)
456        }
457        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
458            (),
459            0x122963198011bd24,
460            fidl::encoding::DynamicFlags::FLEXIBLE,
461            _decode,
462        )
463    }
464}
465
466pub struct ArchiveAccessorEventStream {
467    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
468}
469
470impl std::marker::Unpin for ArchiveAccessorEventStream {}
471
472impl futures::stream::FusedStream for ArchiveAccessorEventStream {
473    fn is_terminated(&self) -> bool {
474        self.event_receiver.is_terminated()
475    }
476}
477
478impl futures::Stream for ArchiveAccessorEventStream {
479    type Item = Result<ArchiveAccessorEvent, fidl::Error>;
480
481    fn poll_next(
482        mut self: std::pin::Pin<&mut Self>,
483        cx: &mut std::task::Context<'_>,
484    ) -> std::task::Poll<Option<Self::Item>> {
485        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
486            &mut self.event_receiver,
487            cx
488        )?) {
489            Some(buf) => std::task::Poll::Ready(Some(ArchiveAccessorEvent::decode(buf))),
490            None => std::task::Poll::Ready(None),
491        }
492    }
493}
494
495#[derive(Debug)]
496pub enum ArchiveAccessorEvent {
497    #[non_exhaustive]
498    _UnknownEvent {
499        /// Ordinal of the event that was sent.
500        ordinal: u64,
501    },
502}
503
504impl ArchiveAccessorEvent {
505    /// Decodes a message buffer as a [`ArchiveAccessorEvent`].
506    fn decode(
507        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
508    ) -> Result<ArchiveAccessorEvent, fidl::Error> {
509        let (bytes, _handles) = buf.split_mut();
510        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
511        debug_assert_eq!(tx_header.tx_id, 0);
512        match tx_header.ordinal {
513            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
514                Ok(ArchiveAccessorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
515            }
516            _ => Err(fidl::Error::UnknownOrdinal {
517                ordinal: tx_header.ordinal,
518                protocol_name:
519                    <ArchiveAccessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
520            }),
521        }
522    }
523}
524
525/// A Stream of incoming requests for fuchsia.diagnostics/ArchiveAccessor.
526pub struct ArchiveAccessorRequestStream {
527    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
528    is_terminated: bool,
529}
530
531impl std::marker::Unpin for ArchiveAccessorRequestStream {}
532
533impl futures::stream::FusedStream for ArchiveAccessorRequestStream {
534    fn is_terminated(&self) -> bool {
535        self.is_terminated
536    }
537}
538
539impl fidl::endpoints::RequestStream for ArchiveAccessorRequestStream {
540    type Protocol = ArchiveAccessorMarker;
541    type ControlHandle = ArchiveAccessorControlHandle;
542
543    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
544        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
545    }
546
547    fn control_handle(&self) -> Self::ControlHandle {
548        ArchiveAccessorControlHandle { inner: self.inner.clone() }
549    }
550
551    fn into_inner(
552        self,
553    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
554    {
555        (self.inner, self.is_terminated)
556    }
557
558    fn from_inner(
559        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
560        is_terminated: bool,
561    ) -> Self {
562        Self { inner, is_terminated }
563    }
564}
565
566impl futures::Stream for ArchiveAccessorRequestStream {
567    type Item = Result<ArchiveAccessorRequest, fidl::Error>;
568
569    fn poll_next(
570        mut self: std::pin::Pin<&mut Self>,
571        cx: &mut std::task::Context<'_>,
572    ) -> std::task::Poll<Option<Self::Item>> {
573        let this = &mut *self;
574        if this.inner.check_shutdown(cx) {
575            this.is_terminated = true;
576            return std::task::Poll::Ready(None);
577        }
578        if this.is_terminated {
579            panic!("polled ArchiveAccessorRequestStream after completion");
580        }
581        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
582            |bytes, handles| {
583                match this.inner.channel().read_etc(cx, bytes, handles) {
584                    std::task::Poll::Ready(Ok(())) => {}
585                    std::task::Poll::Pending => return std::task::Poll::Pending,
586                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
587                        this.is_terminated = true;
588                        return std::task::Poll::Ready(None);
589                    }
590                    std::task::Poll::Ready(Err(e)) => {
591                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
592                            e.into(),
593                        ))));
594                    }
595                }
596
597                // A message has been received from the channel
598                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
599
600                std::task::Poll::Ready(Some(match header.ordinal {
601                    0x20c73e2ecd653c3e => {
602                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
603                        let mut req = fidl::new_empty!(
604                            ArchiveAccessorStreamDiagnosticsRequest,
605                            fidl::encoding::DefaultFuchsiaResourceDialect
606                        );
607                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ArchiveAccessorStreamDiagnosticsRequest>(&header, _body_bytes, handles, &mut req)?;
608                        let control_handle =
609                            ArchiveAccessorControlHandle { inner: this.inner.clone() };
610                        Ok(ArchiveAccessorRequest::StreamDiagnostics {
611                            stream_parameters: req.stream_parameters,
612                            result_stream: req.result_stream,
613
614                            control_handle,
615                        })
616                    }
617                    0x122963198011bd24 => {
618                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
619                        let mut req = fidl::new_empty!(
620                            fidl::encoding::EmptyPayload,
621                            fidl::encoding::DefaultFuchsiaResourceDialect
622                        );
623                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
624                        let control_handle =
625                            ArchiveAccessorControlHandle { inner: this.inner.clone() };
626                        Ok(ArchiveAccessorRequest::WaitForReady {
627                            responder: ArchiveAccessorWaitForReadyResponder {
628                                control_handle: std::mem::ManuallyDrop::new(control_handle),
629                                tx_id: header.tx_id,
630                            },
631                        })
632                    }
633                    _ if header.tx_id == 0
634                        && header
635                            .dynamic_flags()
636                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
637                    {
638                        Ok(ArchiveAccessorRequest::_UnknownMethod {
639                            ordinal: header.ordinal,
640                            control_handle: ArchiveAccessorControlHandle {
641                                inner: this.inner.clone(),
642                            },
643                            method_type: fidl::MethodType::OneWay,
644                        })
645                    }
646                    _ if header
647                        .dynamic_flags()
648                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
649                    {
650                        this.inner.send_framework_err(
651                            fidl::encoding::FrameworkErr::UnknownMethod,
652                            header.tx_id,
653                            header.ordinal,
654                            header.dynamic_flags(),
655                            (bytes, handles),
656                        )?;
657                        Ok(ArchiveAccessorRequest::_UnknownMethod {
658                            ordinal: header.ordinal,
659                            control_handle: ArchiveAccessorControlHandle {
660                                inner: this.inner.clone(),
661                            },
662                            method_type: fidl::MethodType::TwoWay,
663                        })
664                    }
665                    _ => Err(fidl::Error::UnknownOrdinal {
666                        ordinal: header.ordinal,
667                        protocol_name:
668                            <ArchiveAccessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
669                    }),
670                }))
671            },
672        )
673    }
674}
675
676/// Outer protocol for interacting with the different diagnostics data sources.
677#[derive(Debug)]
678pub enum ArchiveAccessorRequest {
679    /// Creates an iterator over diagnostics data on the system.
680    ///   * The iterator may be finite by streaming in SNAPSHOT mode, serving only the
681    ///     current state of diagnostics data on the system.
682    ///   * The iterator may be infinite by streaming in either SNAPSHOT_THEN_SUBSCRIBE
683    ///     or SUBSCRIBE mode; the prior first provides iteration over the current state of
684    ///     the sytem, and then both provide ongoing iteration over newly arriving diagnostics
685    ///     data.
686    ///
687    /// + request `result stream` a [fuchsia.diagnostics/BatchIterator] that diagnostic
688    ///   records are exposed to the client over.
689    ///   * epitaphs:
690    ///      - INVALID_ARGS: A required argument in the StreamParameters struct was missing.
691    ///      - WRONG_TYPE: A selector provided by the StreamParameters struct was incorrectly
692    ///                    formatted.
693    ///
694    /// + request `stream_parameters` is a [fuchsia.diagnostics/StreamParameter] which
695    ///   specifies how to configure the stream.
696    StreamDiagnostics {
697        stream_parameters: StreamParameters,
698        result_stream: fidl::endpoints::ServerEnd<BatchIteratorMarker>,
699        control_handle: ArchiveAccessorControlHandle,
700    },
701    /// Ensures that the connection with the server was established to prevent
702    /// races when using other pipelined methods of this protocol.
703    WaitForReady { responder: ArchiveAccessorWaitForReadyResponder },
704    /// An interaction was received which does not match any known method.
705    #[non_exhaustive]
706    _UnknownMethod {
707        /// Ordinal of the method that was called.
708        ordinal: u64,
709        control_handle: ArchiveAccessorControlHandle,
710        method_type: fidl::MethodType,
711    },
712}
713
714impl ArchiveAccessorRequest {
715    #[allow(irrefutable_let_patterns)]
716    pub fn into_stream_diagnostics(
717        self,
718    ) -> Option<(
719        StreamParameters,
720        fidl::endpoints::ServerEnd<BatchIteratorMarker>,
721        ArchiveAccessorControlHandle,
722    )> {
723        if let ArchiveAccessorRequest::StreamDiagnostics {
724            stream_parameters,
725            result_stream,
726            control_handle,
727        } = self
728        {
729            Some((stream_parameters, result_stream, control_handle))
730        } else {
731            None
732        }
733    }
734
735    #[allow(irrefutable_let_patterns)]
736    pub fn into_wait_for_ready(self) -> Option<(ArchiveAccessorWaitForReadyResponder)> {
737        if let ArchiveAccessorRequest::WaitForReady { responder } = self {
738            Some((responder))
739        } else {
740            None
741        }
742    }
743
744    /// Name of the method defined in FIDL
745    pub fn method_name(&self) -> &'static str {
746        match *self {
747            ArchiveAccessorRequest::StreamDiagnostics { .. } => "stream_diagnostics",
748            ArchiveAccessorRequest::WaitForReady { .. } => "wait_for_ready",
749            ArchiveAccessorRequest::_UnknownMethod {
750                method_type: fidl::MethodType::OneWay,
751                ..
752            } => "unknown one-way method",
753            ArchiveAccessorRequest::_UnknownMethod {
754                method_type: fidl::MethodType::TwoWay,
755                ..
756            } => "unknown two-way method",
757        }
758    }
759}
760
761#[derive(Debug, Clone)]
762pub struct ArchiveAccessorControlHandle {
763    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
764}
765
766impl fidl::endpoints::ControlHandle for ArchiveAccessorControlHandle {
767    fn shutdown(&self) {
768        self.inner.shutdown()
769    }
770
771    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
772        self.inner.shutdown_with_epitaph(status)
773    }
774
775    fn is_closed(&self) -> bool {
776        self.inner.channel().is_closed()
777    }
778    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
779        self.inner.channel().on_closed()
780    }
781
782    #[cfg(target_os = "fuchsia")]
783    fn signal_peer(
784        &self,
785        clear_mask: zx::Signals,
786        set_mask: zx::Signals,
787    ) -> Result<(), zx_status::Status> {
788        use fidl::Peered;
789        self.inner.channel().signal_peer(clear_mask, set_mask)
790    }
791}
792
793impl ArchiveAccessorControlHandle {}
794
795#[must_use = "FIDL methods require a response to be sent"]
796#[derive(Debug)]
797pub struct ArchiveAccessorWaitForReadyResponder {
798    control_handle: std::mem::ManuallyDrop<ArchiveAccessorControlHandle>,
799    tx_id: u32,
800}
801
802/// Set the the channel to be shutdown (see [`ArchiveAccessorControlHandle::shutdown`])
803/// if the responder is dropped without sending a response, so that the client
804/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
805impl std::ops::Drop for ArchiveAccessorWaitForReadyResponder {
806    fn drop(&mut self) {
807        self.control_handle.shutdown();
808        // Safety: drops once, never accessed again
809        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
810    }
811}
812
813impl fidl::endpoints::Responder for ArchiveAccessorWaitForReadyResponder {
814    type ControlHandle = ArchiveAccessorControlHandle;
815
816    fn control_handle(&self) -> &ArchiveAccessorControlHandle {
817        &self.control_handle
818    }
819
820    fn drop_without_shutdown(mut self) {
821        // Safety: drops once, never accessed again due to mem::forget
822        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
823        // Prevent Drop from running (which would shut down the channel)
824        std::mem::forget(self);
825    }
826}
827
828impl ArchiveAccessorWaitForReadyResponder {
829    /// Sends a response to the FIDL transaction.
830    ///
831    /// Sets the channel to shutdown if an error occurs.
832    pub fn send(self) -> Result<(), fidl::Error> {
833        let _result = self.send_raw();
834        if _result.is_err() {
835            self.control_handle.shutdown();
836        }
837        self.drop_without_shutdown();
838        _result
839    }
840
841    /// Similar to "send" but does not shutdown the channel if an error occurs.
842    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
843        let _result = self.send_raw();
844        self.drop_without_shutdown();
845        _result
846    }
847
848    fn send_raw(&self) -> Result<(), fidl::Error> {
849        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
850            fidl::encoding::Flexible::new(()),
851            self.tx_id,
852            0x122963198011bd24,
853            fidl::encoding::DynamicFlags::FLEXIBLE,
854        )
855    }
856}
857
858#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
859pub struct BatchIteratorMarker;
860
861impl fidl::endpoints::ProtocolMarker for BatchIteratorMarker {
862    type Proxy = BatchIteratorProxy;
863    type RequestStream = BatchIteratorRequestStream;
864    #[cfg(target_os = "fuchsia")]
865    type SynchronousProxy = BatchIteratorSynchronousProxy;
866
867    const DEBUG_NAME: &'static str = "(anonymous) BatchIterator";
868}
869pub type BatchIteratorGetNextResult = Result<Vec<FormattedContent>, ReaderError>;
870
871pub trait BatchIteratorProxyInterface: Send + Sync {
872    type GetNextResponseFut: std::future::Future<Output = Result<BatchIteratorGetNextResult, fidl::Error>>
873        + Send;
874    fn r#get_next(&self) -> Self::GetNextResponseFut;
875    type WaitForReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
876    fn r#wait_for_ready(&self) -> Self::WaitForReadyResponseFut;
877}
878#[derive(Debug)]
879#[cfg(target_os = "fuchsia")]
880pub struct BatchIteratorSynchronousProxy {
881    client: fidl::client::sync::Client,
882}
883
884#[cfg(target_os = "fuchsia")]
885impl fidl::endpoints::SynchronousProxy for BatchIteratorSynchronousProxy {
886    type Proxy = BatchIteratorProxy;
887    type Protocol = BatchIteratorMarker;
888
889    fn from_channel(inner: fidl::Channel) -> Self {
890        Self::new(inner)
891    }
892
893    fn into_channel(self) -> fidl::Channel {
894        self.client.into_channel()
895    }
896
897    fn as_channel(&self) -> &fidl::Channel {
898        self.client.as_channel()
899    }
900}
901
902#[cfg(target_os = "fuchsia")]
903impl BatchIteratorSynchronousProxy {
904    pub fn new(channel: fidl::Channel) -> Self {
905        let protocol_name = <BatchIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
906        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
907    }
908
909    pub fn into_channel(self) -> fidl::Channel {
910        self.client.into_channel()
911    }
912
913    /// Waits until an event arrives and returns it. It is safe for other
914    /// threads to make concurrent requests while waiting for an event.
915    pub fn wait_for_event(
916        &self,
917        deadline: zx::MonotonicInstant,
918    ) -> Result<BatchIteratorEvent, fidl::Error> {
919        BatchIteratorEvent::decode(self.client.wait_for_event(deadline)?)
920    }
921
922    /// Returns a vector of [fuchsia.diagnostics/FormattedContent] structs
923    /// with a format dictated by the format_settings argument provided to the Reader protocol
924    /// which spawned this BatchIterator.
925    ///
926    /// An empty vector implies that the data hierarchy has been fully iterated, and subsequent
927    /// GetNext calls will always return the empty vector.
928    ///
929    /// When the BatchIterator is serving results via subscription model, calls to GetNext will
930    /// hang until there is new data available, it will not return an empty vector.
931    ///
932    /// - returns a vector of FormattedContent structs. Clients connected to a
933    ///   Batch are expected to call GetNext() until an empty vector
934    ///   is returned, denoting that the entire data hierarchy has been read.
935    ///
936    /// * error a [fuchsia.diagnostics/ReaderError]
937    ///   value indicating that there was an issue reading the underlying data hierarchies
938    ///   or formatting those hierarchies to populate the `batch`. Note, these
939    ///   issues do not include a single component's data hierarchy failing to be read.
940    ///   The iterator is tolerant of individual component data sources failing to be read,
941    ///   whether that failure is a timeout or a malformed binary file.
942    ///   In the event that a GetNext call fails, that subset of the data hierarchy results is
943    ///   dropped, but future calls to GetNext will provide new subsets of
944    ///   FormattedDataHierarchies.
945    pub fn r#get_next(
946        &self,
947        ___deadline: zx::MonotonicInstant,
948    ) -> Result<BatchIteratorGetNextResult, fidl::Error> {
949        let _response = self.client.send_query::<
950            fidl::encoding::EmptyPayload,
951            fidl::encoding::FlexibleResultType<BatchIteratorGetNextResponse, ReaderError>,
952        >(
953            (),
954            0x781986486c6254a5,
955            fidl::encoding::DynamicFlags::FLEXIBLE,
956            ___deadline,
957        )?
958        .into_result::<BatchIteratorMarker>("get_next")?;
959        Ok(_response.map(|x| x.batch))
960    }
961
962    /// Indicates that the BatchIterator has been connected. If the
963    /// BatchIterator hasn't been connected, this method will hang until it is.
964    pub fn r#wait_for_ready(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
965        let _response = self.client.send_query::<
966            fidl::encoding::EmptyPayload,
967            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
968        >(
969            (),
970            0x70598ee271597603,
971            fidl::encoding::DynamicFlags::FLEXIBLE,
972            ___deadline,
973        )?
974        .into_result::<BatchIteratorMarker>("wait_for_ready")?;
975        Ok(_response)
976    }
977}
978
979#[cfg(target_os = "fuchsia")]
980impl From<BatchIteratorSynchronousProxy> for zx::NullableHandle {
981    fn from(value: BatchIteratorSynchronousProxy) -> Self {
982        value.into_channel().into()
983    }
984}
985
986#[cfg(target_os = "fuchsia")]
987impl From<fidl::Channel> for BatchIteratorSynchronousProxy {
988    fn from(value: fidl::Channel) -> Self {
989        Self::new(value)
990    }
991}
992
993#[cfg(target_os = "fuchsia")]
994impl fidl::endpoints::FromClient for BatchIteratorSynchronousProxy {
995    type Protocol = BatchIteratorMarker;
996
997    fn from_client(value: fidl::endpoints::ClientEnd<BatchIteratorMarker>) -> Self {
998        Self::new(value.into_channel())
999    }
1000}
1001
1002#[derive(Debug, Clone)]
1003pub struct BatchIteratorProxy {
1004    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1005}
1006
1007impl fidl::endpoints::Proxy for BatchIteratorProxy {
1008    type Protocol = BatchIteratorMarker;
1009
1010    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1011        Self::new(inner)
1012    }
1013
1014    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1015        self.client.into_channel().map_err(|client| Self { client })
1016    }
1017
1018    fn as_channel(&self) -> &::fidl::AsyncChannel {
1019        self.client.as_channel()
1020    }
1021}
1022
1023impl BatchIteratorProxy {
1024    /// Create a new Proxy for fuchsia.diagnostics/BatchIterator.
1025    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1026        let protocol_name = <BatchIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1027        Self { client: fidl::client::Client::new(channel, protocol_name) }
1028    }
1029
1030    /// Get a Stream of events from the remote end of the protocol.
1031    ///
1032    /// # Panics
1033    ///
1034    /// Panics if the event stream was already taken.
1035    pub fn take_event_stream(&self) -> BatchIteratorEventStream {
1036        BatchIteratorEventStream { event_receiver: self.client.take_event_receiver() }
1037    }
1038
1039    /// Returns a vector of [fuchsia.diagnostics/FormattedContent] structs
1040    /// with a format dictated by the format_settings argument provided to the Reader protocol
1041    /// which spawned this BatchIterator.
1042    ///
1043    /// An empty vector implies that the data hierarchy has been fully iterated, and subsequent
1044    /// GetNext calls will always return the empty vector.
1045    ///
1046    /// When the BatchIterator is serving results via subscription model, calls to GetNext will
1047    /// hang until there is new data available, it will not return an empty vector.
1048    ///
1049    /// - returns a vector of FormattedContent structs. Clients connected to a
1050    ///   Batch are expected to call GetNext() until an empty vector
1051    ///   is returned, denoting that the entire data hierarchy has been read.
1052    ///
1053    /// * error a [fuchsia.diagnostics/ReaderError]
1054    ///   value indicating that there was an issue reading the underlying data hierarchies
1055    ///   or formatting those hierarchies to populate the `batch`. Note, these
1056    ///   issues do not include a single component's data hierarchy failing to be read.
1057    ///   The iterator is tolerant of individual component data sources failing to be read,
1058    ///   whether that failure is a timeout or a malformed binary file.
1059    ///   In the event that a GetNext call fails, that subset of the data hierarchy results is
1060    ///   dropped, but future calls to GetNext will provide new subsets of
1061    ///   FormattedDataHierarchies.
1062    pub fn r#get_next(
1063        &self,
1064    ) -> fidl::client::QueryResponseFut<
1065        BatchIteratorGetNextResult,
1066        fidl::encoding::DefaultFuchsiaResourceDialect,
1067    > {
1068        BatchIteratorProxyInterface::r#get_next(self)
1069    }
1070
1071    /// Indicates that the BatchIterator has been connected. If the
1072    /// BatchIterator hasn't been connected, this method will hang until it is.
1073    pub fn r#wait_for_ready(
1074        &self,
1075    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1076        BatchIteratorProxyInterface::r#wait_for_ready(self)
1077    }
1078}
1079
1080impl BatchIteratorProxyInterface for BatchIteratorProxy {
1081    type GetNextResponseFut = fidl::client::QueryResponseFut<
1082        BatchIteratorGetNextResult,
1083        fidl::encoding::DefaultFuchsiaResourceDialect,
1084    >;
1085    fn r#get_next(&self) -> Self::GetNextResponseFut {
1086        fn _decode(
1087            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1088        ) -> Result<BatchIteratorGetNextResult, fidl::Error> {
1089            let _response = fidl::client::decode_transaction_body::<
1090                fidl::encoding::FlexibleResultType<BatchIteratorGetNextResponse, ReaderError>,
1091                fidl::encoding::DefaultFuchsiaResourceDialect,
1092                0x781986486c6254a5,
1093            >(_buf?)?
1094            .into_result::<BatchIteratorMarker>("get_next")?;
1095            Ok(_response.map(|x| x.batch))
1096        }
1097        self.client
1098            .send_query_and_decode::<fidl::encoding::EmptyPayload, BatchIteratorGetNextResult>(
1099                (),
1100                0x781986486c6254a5,
1101                fidl::encoding::DynamicFlags::FLEXIBLE,
1102                _decode,
1103            )
1104    }
1105
1106    type WaitForReadyResponseFut =
1107        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1108    fn r#wait_for_ready(&self) -> Self::WaitForReadyResponseFut {
1109        fn _decode(
1110            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1111        ) -> Result<(), fidl::Error> {
1112            let _response = fidl::client::decode_transaction_body::<
1113                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
1114                fidl::encoding::DefaultFuchsiaResourceDialect,
1115                0x70598ee271597603,
1116            >(_buf?)?
1117            .into_result::<BatchIteratorMarker>("wait_for_ready")?;
1118            Ok(_response)
1119        }
1120        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1121            (),
1122            0x70598ee271597603,
1123            fidl::encoding::DynamicFlags::FLEXIBLE,
1124            _decode,
1125        )
1126    }
1127}
1128
1129pub struct BatchIteratorEventStream {
1130    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1131}
1132
1133impl std::marker::Unpin for BatchIteratorEventStream {}
1134
1135impl futures::stream::FusedStream for BatchIteratorEventStream {
1136    fn is_terminated(&self) -> bool {
1137        self.event_receiver.is_terminated()
1138    }
1139}
1140
1141impl futures::Stream for BatchIteratorEventStream {
1142    type Item = Result<BatchIteratorEvent, fidl::Error>;
1143
1144    fn poll_next(
1145        mut self: std::pin::Pin<&mut Self>,
1146        cx: &mut std::task::Context<'_>,
1147    ) -> std::task::Poll<Option<Self::Item>> {
1148        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1149            &mut self.event_receiver,
1150            cx
1151        )?) {
1152            Some(buf) => std::task::Poll::Ready(Some(BatchIteratorEvent::decode(buf))),
1153            None => std::task::Poll::Ready(None),
1154        }
1155    }
1156}
1157
1158#[derive(Debug)]
1159pub enum BatchIteratorEvent {
1160    #[non_exhaustive]
1161    _UnknownEvent {
1162        /// Ordinal of the event that was sent.
1163        ordinal: u64,
1164    },
1165}
1166
1167impl BatchIteratorEvent {
1168    /// Decodes a message buffer as a [`BatchIteratorEvent`].
1169    fn decode(
1170        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1171    ) -> Result<BatchIteratorEvent, fidl::Error> {
1172        let (bytes, _handles) = buf.split_mut();
1173        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1174        debug_assert_eq!(tx_header.tx_id, 0);
1175        match tx_header.ordinal {
1176            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1177                Ok(BatchIteratorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1178            }
1179            _ => Err(fidl::Error::UnknownOrdinal {
1180                ordinal: tx_header.ordinal,
1181                protocol_name: <BatchIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1182            }),
1183        }
1184    }
1185}
1186
1187/// A Stream of incoming requests for fuchsia.diagnostics/BatchIterator.
1188pub struct BatchIteratorRequestStream {
1189    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1190    is_terminated: bool,
1191}
1192
1193impl std::marker::Unpin for BatchIteratorRequestStream {}
1194
1195impl futures::stream::FusedStream for BatchIteratorRequestStream {
1196    fn is_terminated(&self) -> bool {
1197        self.is_terminated
1198    }
1199}
1200
1201impl fidl::endpoints::RequestStream for BatchIteratorRequestStream {
1202    type Protocol = BatchIteratorMarker;
1203    type ControlHandle = BatchIteratorControlHandle;
1204
1205    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1206        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1207    }
1208
1209    fn control_handle(&self) -> Self::ControlHandle {
1210        BatchIteratorControlHandle { inner: self.inner.clone() }
1211    }
1212
1213    fn into_inner(
1214        self,
1215    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1216    {
1217        (self.inner, self.is_terminated)
1218    }
1219
1220    fn from_inner(
1221        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1222        is_terminated: bool,
1223    ) -> Self {
1224        Self { inner, is_terminated }
1225    }
1226}
1227
1228impl futures::Stream for BatchIteratorRequestStream {
1229    type Item = Result<BatchIteratorRequest, fidl::Error>;
1230
1231    fn poll_next(
1232        mut self: std::pin::Pin<&mut Self>,
1233        cx: &mut std::task::Context<'_>,
1234    ) -> std::task::Poll<Option<Self::Item>> {
1235        let this = &mut *self;
1236        if this.inner.check_shutdown(cx) {
1237            this.is_terminated = true;
1238            return std::task::Poll::Ready(None);
1239        }
1240        if this.is_terminated {
1241            panic!("polled BatchIteratorRequestStream after completion");
1242        }
1243        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1244            |bytes, handles| {
1245                match this.inner.channel().read_etc(cx, bytes, handles) {
1246                    std::task::Poll::Ready(Ok(())) => {}
1247                    std::task::Poll::Pending => return std::task::Poll::Pending,
1248                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1249                        this.is_terminated = true;
1250                        return std::task::Poll::Ready(None);
1251                    }
1252                    std::task::Poll::Ready(Err(e)) => {
1253                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1254                            e.into(),
1255                        ))));
1256                    }
1257                }
1258
1259                // A message has been received from the channel
1260                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1261
1262                std::task::Poll::Ready(Some(match header.ordinal {
1263                    0x781986486c6254a5 => {
1264                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1265                        let mut req = fidl::new_empty!(
1266                            fidl::encoding::EmptyPayload,
1267                            fidl::encoding::DefaultFuchsiaResourceDialect
1268                        );
1269                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1270                        let control_handle =
1271                            BatchIteratorControlHandle { inner: this.inner.clone() };
1272                        Ok(BatchIteratorRequest::GetNext {
1273                            responder: BatchIteratorGetNextResponder {
1274                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1275                                tx_id: header.tx_id,
1276                            },
1277                        })
1278                    }
1279                    0x70598ee271597603 => {
1280                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1281                        let mut req = fidl::new_empty!(
1282                            fidl::encoding::EmptyPayload,
1283                            fidl::encoding::DefaultFuchsiaResourceDialect
1284                        );
1285                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1286                        let control_handle =
1287                            BatchIteratorControlHandle { inner: this.inner.clone() };
1288                        Ok(BatchIteratorRequest::WaitForReady {
1289                            responder: BatchIteratorWaitForReadyResponder {
1290                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1291                                tx_id: header.tx_id,
1292                            },
1293                        })
1294                    }
1295                    _ if header.tx_id == 0
1296                        && header
1297                            .dynamic_flags()
1298                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1299                    {
1300                        Ok(BatchIteratorRequest::_UnknownMethod {
1301                            ordinal: header.ordinal,
1302                            control_handle: BatchIteratorControlHandle {
1303                                inner: this.inner.clone(),
1304                            },
1305                            method_type: fidl::MethodType::OneWay,
1306                        })
1307                    }
1308                    _ if header
1309                        .dynamic_flags()
1310                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1311                    {
1312                        this.inner.send_framework_err(
1313                            fidl::encoding::FrameworkErr::UnknownMethod,
1314                            header.tx_id,
1315                            header.ordinal,
1316                            header.dynamic_flags(),
1317                            (bytes, handles),
1318                        )?;
1319                        Ok(BatchIteratorRequest::_UnknownMethod {
1320                            ordinal: header.ordinal,
1321                            control_handle: BatchIteratorControlHandle {
1322                                inner: this.inner.clone(),
1323                            },
1324                            method_type: fidl::MethodType::TwoWay,
1325                        })
1326                    }
1327                    _ => Err(fidl::Error::UnknownOrdinal {
1328                        ordinal: header.ordinal,
1329                        protocol_name:
1330                            <BatchIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1331                    }),
1332                }))
1333            },
1334        )
1335    }
1336}
1337
1338/// Conceptually, a directory iterator, where each element in the iterator is a single
1339/// complete file that can be concatenated with other results.
1340#[derive(Debug)]
1341pub enum BatchIteratorRequest {
1342    /// Returns a vector of [fuchsia.diagnostics/FormattedContent] structs
1343    /// with a format dictated by the format_settings argument provided to the Reader protocol
1344    /// which spawned this BatchIterator.
1345    ///
1346    /// An empty vector implies that the data hierarchy has been fully iterated, and subsequent
1347    /// GetNext calls will always return the empty vector.
1348    ///
1349    /// When the BatchIterator is serving results via subscription model, calls to GetNext will
1350    /// hang until there is new data available, it will not return an empty vector.
1351    ///
1352    /// - returns a vector of FormattedContent structs. Clients connected to a
1353    ///   Batch are expected to call GetNext() until an empty vector
1354    ///   is returned, denoting that the entire data hierarchy has been read.
1355    ///
1356    /// * error a [fuchsia.diagnostics/ReaderError]
1357    ///   value indicating that there was an issue reading the underlying data hierarchies
1358    ///   or formatting those hierarchies to populate the `batch`. Note, these
1359    ///   issues do not include a single component's data hierarchy failing to be read.
1360    ///   The iterator is tolerant of individual component data sources failing to be read,
1361    ///   whether that failure is a timeout or a malformed binary file.
1362    ///   In the event that a GetNext call fails, that subset of the data hierarchy results is
1363    ///   dropped, but future calls to GetNext will provide new subsets of
1364    ///   FormattedDataHierarchies.
1365    GetNext { responder: BatchIteratorGetNextResponder },
1366    /// Indicates that the BatchIterator has been connected. If the
1367    /// BatchIterator hasn't been connected, this method will hang until it is.
1368    WaitForReady { responder: BatchIteratorWaitForReadyResponder },
1369    /// An interaction was received which does not match any known method.
1370    #[non_exhaustive]
1371    _UnknownMethod {
1372        /// Ordinal of the method that was called.
1373        ordinal: u64,
1374        control_handle: BatchIteratorControlHandle,
1375        method_type: fidl::MethodType,
1376    },
1377}
1378
1379impl BatchIteratorRequest {
1380    #[allow(irrefutable_let_patterns)]
1381    pub fn into_get_next(self) -> Option<(BatchIteratorGetNextResponder)> {
1382        if let BatchIteratorRequest::GetNext { responder } = self {
1383            Some((responder))
1384        } else {
1385            None
1386        }
1387    }
1388
1389    #[allow(irrefutable_let_patterns)]
1390    pub fn into_wait_for_ready(self) -> Option<(BatchIteratorWaitForReadyResponder)> {
1391        if let BatchIteratorRequest::WaitForReady { responder } = self {
1392            Some((responder))
1393        } else {
1394            None
1395        }
1396    }
1397
1398    /// Name of the method defined in FIDL
1399    pub fn method_name(&self) -> &'static str {
1400        match *self {
1401            BatchIteratorRequest::GetNext { .. } => "get_next",
1402            BatchIteratorRequest::WaitForReady { .. } => "wait_for_ready",
1403            BatchIteratorRequest::_UnknownMethod {
1404                method_type: fidl::MethodType::OneWay, ..
1405            } => "unknown one-way method",
1406            BatchIteratorRequest::_UnknownMethod {
1407                method_type: fidl::MethodType::TwoWay, ..
1408            } => "unknown two-way method",
1409        }
1410    }
1411}
1412
1413#[derive(Debug, Clone)]
1414pub struct BatchIteratorControlHandle {
1415    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1416}
1417
1418impl fidl::endpoints::ControlHandle for BatchIteratorControlHandle {
1419    fn shutdown(&self) {
1420        self.inner.shutdown()
1421    }
1422
1423    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1424        self.inner.shutdown_with_epitaph(status)
1425    }
1426
1427    fn is_closed(&self) -> bool {
1428        self.inner.channel().is_closed()
1429    }
1430    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1431        self.inner.channel().on_closed()
1432    }
1433
1434    #[cfg(target_os = "fuchsia")]
1435    fn signal_peer(
1436        &self,
1437        clear_mask: zx::Signals,
1438        set_mask: zx::Signals,
1439    ) -> Result<(), zx_status::Status> {
1440        use fidl::Peered;
1441        self.inner.channel().signal_peer(clear_mask, set_mask)
1442    }
1443}
1444
1445impl BatchIteratorControlHandle {}
1446
1447#[must_use = "FIDL methods require a response to be sent"]
1448#[derive(Debug)]
1449pub struct BatchIteratorGetNextResponder {
1450    control_handle: std::mem::ManuallyDrop<BatchIteratorControlHandle>,
1451    tx_id: u32,
1452}
1453
1454/// Set the the channel to be shutdown (see [`BatchIteratorControlHandle::shutdown`])
1455/// if the responder is dropped without sending a response, so that the client
1456/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1457impl std::ops::Drop for BatchIteratorGetNextResponder {
1458    fn drop(&mut self) {
1459        self.control_handle.shutdown();
1460        // Safety: drops once, never accessed again
1461        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1462    }
1463}
1464
1465impl fidl::endpoints::Responder for BatchIteratorGetNextResponder {
1466    type ControlHandle = BatchIteratorControlHandle;
1467
1468    fn control_handle(&self) -> &BatchIteratorControlHandle {
1469        &self.control_handle
1470    }
1471
1472    fn drop_without_shutdown(mut self) {
1473        // Safety: drops once, never accessed again due to mem::forget
1474        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1475        // Prevent Drop from running (which would shut down the channel)
1476        std::mem::forget(self);
1477    }
1478}
1479
1480impl BatchIteratorGetNextResponder {
1481    /// Sends a response to the FIDL transaction.
1482    ///
1483    /// Sets the channel to shutdown if an error occurs.
1484    pub fn send(
1485        self,
1486        mut result: Result<Vec<FormattedContent>, ReaderError>,
1487    ) -> Result<(), fidl::Error> {
1488        let _result = self.send_raw(result);
1489        if _result.is_err() {
1490            self.control_handle.shutdown();
1491        }
1492        self.drop_without_shutdown();
1493        _result
1494    }
1495
1496    /// Similar to "send" but does not shutdown the channel if an error occurs.
1497    pub fn send_no_shutdown_on_err(
1498        self,
1499        mut result: Result<Vec<FormattedContent>, ReaderError>,
1500    ) -> Result<(), fidl::Error> {
1501        let _result = self.send_raw(result);
1502        self.drop_without_shutdown();
1503        _result
1504    }
1505
1506    fn send_raw(
1507        &self,
1508        mut result: Result<Vec<FormattedContent>, ReaderError>,
1509    ) -> Result<(), fidl::Error> {
1510        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1511            BatchIteratorGetNextResponse,
1512            ReaderError,
1513        >>(
1514            fidl::encoding::FlexibleResult::new(
1515                result.as_mut().map_err(|e| *e).map(|batch| (batch.as_mut_slice(),)),
1516            ),
1517            self.tx_id,
1518            0x781986486c6254a5,
1519            fidl::encoding::DynamicFlags::FLEXIBLE,
1520        )
1521    }
1522}
1523
1524#[must_use = "FIDL methods require a response to be sent"]
1525#[derive(Debug)]
1526pub struct BatchIteratorWaitForReadyResponder {
1527    control_handle: std::mem::ManuallyDrop<BatchIteratorControlHandle>,
1528    tx_id: u32,
1529}
1530
1531/// Set the the channel to be shutdown (see [`BatchIteratorControlHandle::shutdown`])
1532/// if the responder is dropped without sending a response, so that the client
1533/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1534impl std::ops::Drop for BatchIteratorWaitForReadyResponder {
1535    fn drop(&mut self) {
1536        self.control_handle.shutdown();
1537        // Safety: drops once, never accessed again
1538        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1539    }
1540}
1541
1542impl fidl::endpoints::Responder for BatchIteratorWaitForReadyResponder {
1543    type ControlHandle = BatchIteratorControlHandle;
1544
1545    fn control_handle(&self) -> &BatchIteratorControlHandle {
1546        &self.control_handle
1547    }
1548
1549    fn drop_without_shutdown(mut self) {
1550        // Safety: drops once, never accessed again due to mem::forget
1551        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1552        // Prevent Drop from running (which would shut down the channel)
1553        std::mem::forget(self);
1554    }
1555}
1556
1557impl BatchIteratorWaitForReadyResponder {
1558    /// Sends a response to the FIDL transaction.
1559    ///
1560    /// Sets the channel to shutdown if an error occurs.
1561    pub fn send(self) -> Result<(), fidl::Error> {
1562        let _result = self.send_raw();
1563        if _result.is_err() {
1564            self.control_handle.shutdown();
1565        }
1566        self.drop_without_shutdown();
1567        _result
1568    }
1569
1570    /// Similar to "send" but does not shutdown the channel if an error occurs.
1571    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1572        let _result = self.send_raw();
1573        self.drop_without_shutdown();
1574        _result
1575    }
1576
1577    fn send_raw(&self) -> Result<(), fidl::Error> {
1578        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
1579            fidl::encoding::Flexible::new(()),
1580            self.tx_id,
1581            0x70598ee271597603,
1582            fidl::encoding::DynamicFlags::FLEXIBLE,
1583        )
1584    }
1585}
1586
1587#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1588pub struct LogFlusherMarker;
1589
1590impl fidl::endpoints::ProtocolMarker for LogFlusherMarker {
1591    type Proxy = LogFlusherProxy;
1592    type RequestStream = LogFlusherRequestStream;
1593    #[cfg(target_os = "fuchsia")]
1594    type SynchronousProxy = LogFlusherSynchronousProxy;
1595
1596    const DEBUG_NAME: &'static str = "fuchsia.diagnostics.LogFlusher";
1597}
1598impl fidl::endpoints::DiscoverableProtocolMarker for LogFlusherMarker {}
1599
1600pub trait LogFlusherProxyInterface: Send + Sync {
1601    type WaitUntilFlushedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1602    fn r#wait_until_flushed(&self) -> Self::WaitUntilFlushedResponseFut;
1603}
1604#[derive(Debug)]
1605#[cfg(target_os = "fuchsia")]
1606pub struct LogFlusherSynchronousProxy {
1607    client: fidl::client::sync::Client,
1608}
1609
1610#[cfg(target_os = "fuchsia")]
1611impl fidl::endpoints::SynchronousProxy for LogFlusherSynchronousProxy {
1612    type Proxy = LogFlusherProxy;
1613    type Protocol = LogFlusherMarker;
1614
1615    fn from_channel(inner: fidl::Channel) -> Self {
1616        Self::new(inner)
1617    }
1618
1619    fn into_channel(self) -> fidl::Channel {
1620        self.client.into_channel()
1621    }
1622
1623    fn as_channel(&self) -> &fidl::Channel {
1624        self.client.as_channel()
1625    }
1626}
1627
1628#[cfg(target_os = "fuchsia")]
1629impl LogFlusherSynchronousProxy {
1630    pub fn new(channel: fidl::Channel) -> Self {
1631        let protocol_name = <LogFlusherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1632        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1633    }
1634
1635    pub fn into_channel(self) -> fidl::Channel {
1636        self.client.into_channel()
1637    }
1638
1639    /// Waits until an event arrives and returns it. It is safe for other
1640    /// threads to make concurrent requests while waiting for an event.
1641    pub fn wait_for_event(
1642        &self,
1643        deadline: zx::MonotonicInstant,
1644    ) -> Result<LogFlusherEvent, fidl::Error> {
1645        LogFlusherEvent::decode(self.client.wait_for_event(deadline)?)
1646    }
1647
1648    /// Flushes all pending logs through the logging pipeline
1649    /// to the serial port. Logs written to sockets prior to
1650    /// the call to Flush are guaranteed to be fully written
1651    /// to serial when this returns. Logs written to sockets
1652    /// after this call has been received by Archivist are
1653    /// not guaranteed to be flushed.
1654    /// Additionally, sockets must actually be connected to the Archivist
1655    /// before this call is made. If a socket hasn't been
1656    /// received by Archivist yet, those logs may be dropped.
1657    /// To ensure that logs are properly flushed, make sure
1658    /// to wait for the initial interest when logging.
1659    /// Important note: This may be called from the host,
1660    /// but host sockets will NOT be flushed by this method.
1661    /// If you write data from the host (not on the device,
1662    /// there is no guarantee that such logs will ever be printed).
1663    pub fn r#wait_until_flushed(
1664        &self,
1665        ___deadline: zx::MonotonicInstant,
1666    ) -> Result<(), fidl::Error> {
1667        let _response = self.client.send_query::<
1668            fidl::encoding::EmptyPayload,
1669            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
1670        >(
1671            (),
1672            0x7dc4892e46748b5b,
1673            fidl::encoding::DynamicFlags::FLEXIBLE,
1674            ___deadline,
1675        )?
1676        .into_result::<LogFlusherMarker>("wait_until_flushed")?;
1677        Ok(_response)
1678    }
1679}
1680
1681#[cfg(target_os = "fuchsia")]
1682impl From<LogFlusherSynchronousProxy> for zx::NullableHandle {
1683    fn from(value: LogFlusherSynchronousProxy) -> Self {
1684        value.into_channel().into()
1685    }
1686}
1687
1688#[cfg(target_os = "fuchsia")]
1689impl From<fidl::Channel> for LogFlusherSynchronousProxy {
1690    fn from(value: fidl::Channel) -> Self {
1691        Self::new(value)
1692    }
1693}
1694
1695#[cfg(target_os = "fuchsia")]
1696impl fidl::endpoints::FromClient for LogFlusherSynchronousProxy {
1697    type Protocol = LogFlusherMarker;
1698
1699    fn from_client(value: fidl::endpoints::ClientEnd<LogFlusherMarker>) -> Self {
1700        Self::new(value.into_channel())
1701    }
1702}
1703
1704#[derive(Debug, Clone)]
1705pub struct LogFlusherProxy {
1706    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1707}
1708
1709impl fidl::endpoints::Proxy for LogFlusherProxy {
1710    type Protocol = LogFlusherMarker;
1711
1712    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1713        Self::new(inner)
1714    }
1715
1716    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1717        self.client.into_channel().map_err(|client| Self { client })
1718    }
1719
1720    fn as_channel(&self) -> &::fidl::AsyncChannel {
1721        self.client.as_channel()
1722    }
1723}
1724
1725impl LogFlusherProxy {
1726    /// Create a new Proxy for fuchsia.diagnostics/LogFlusher.
1727    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1728        let protocol_name = <LogFlusherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1729        Self { client: fidl::client::Client::new(channel, protocol_name) }
1730    }
1731
1732    /// Get a Stream of events from the remote end of the protocol.
1733    ///
1734    /// # Panics
1735    ///
1736    /// Panics if the event stream was already taken.
1737    pub fn take_event_stream(&self) -> LogFlusherEventStream {
1738        LogFlusherEventStream { event_receiver: self.client.take_event_receiver() }
1739    }
1740
1741    /// Flushes all pending logs through the logging pipeline
1742    /// to the serial port. Logs written to sockets prior to
1743    /// the call to Flush are guaranteed to be fully written
1744    /// to serial when this returns. Logs written to sockets
1745    /// after this call has been received by Archivist are
1746    /// not guaranteed to be flushed.
1747    /// Additionally, sockets must actually be connected to the Archivist
1748    /// before this call is made. If a socket hasn't been
1749    /// received by Archivist yet, those logs may be dropped.
1750    /// To ensure that logs are properly flushed, make sure
1751    /// to wait for the initial interest when logging.
1752    /// Important note: This may be called from the host,
1753    /// but host sockets will NOT be flushed by this method.
1754    /// If you write data from the host (not on the device,
1755    /// there is no guarantee that such logs will ever be printed).
1756    pub fn r#wait_until_flushed(
1757        &self,
1758    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1759        LogFlusherProxyInterface::r#wait_until_flushed(self)
1760    }
1761}
1762
1763impl LogFlusherProxyInterface for LogFlusherProxy {
1764    type WaitUntilFlushedResponseFut =
1765        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1766    fn r#wait_until_flushed(&self) -> Self::WaitUntilFlushedResponseFut {
1767        fn _decode(
1768            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1769        ) -> Result<(), fidl::Error> {
1770            let _response = fidl::client::decode_transaction_body::<
1771                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
1772                fidl::encoding::DefaultFuchsiaResourceDialect,
1773                0x7dc4892e46748b5b,
1774            >(_buf?)?
1775            .into_result::<LogFlusherMarker>("wait_until_flushed")?;
1776            Ok(_response)
1777        }
1778        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1779            (),
1780            0x7dc4892e46748b5b,
1781            fidl::encoding::DynamicFlags::FLEXIBLE,
1782            _decode,
1783        )
1784    }
1785}
1786
1787pub struct LogFlusherEventStream {
1788    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1789}
1790
1791impl std::marker::Unpin for LogFlusherEventStream {}
1792
1793impl futures::stream::FusedStream for LogFlusherEventStream {
1794    fn is_terminated(&self) -> bool {
1795        self.event_receiver.is_terminated()
1796    }
1797}
1798
1799impl futures::Stream for LogFlusherEventStream {
1800    type Item = Result<LogFlusherEvent, fidl::Error>;
1801
1802    fn poll_next(
1803        mut self: std::pin::Pin<&mut Self>,
1804        cx: &mut std::task::Context<'_>,
1805    ) -> std::task::Poll<Option<Self::Item>> {
1806        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1807            &mut self.event_receiver,
1808            cx
1809        )?) {
1810            Some(buf) => std::task::Poll::Ready(Some(LogFlusherEvent::decode(buf))),
1811            None => std::task::Poll::Ready(None),
1812        }
1813    }
1814}
1815
1816#[derive(Debug)]
1817pub enum LogFlusherEvent {
1818    #[non_exhaustive]
1819    _UnknownEvent {
1820        /// Ordinal of the event that was sent.
1821        ordinal: u64,
1822    },
1823}
1824
1825impl LogFlusherEvent {
1826    /// Decodes a message buffer as a [`LogFlusherEvent`].
1827    fn decode(
1828        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1829    ) -> Result<LogFlusherEvent, fidl::Error> {
1830        let (bytes, _handles) = buf.split_mut();
1831        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1832        debug_assert_eq!(tx_header.tx_id, 0);
1833        match tx_header.ordinal {
1834            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1835                Ok(LogFlusherEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1836            }
1837            _ => Err(fidl::Error::UnknownOrdinal {
1838                ordinal: tx_header.ordinal,
1839                protocol_name: <LogFlusherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1840            }),
1841        }
1842    }
1843}
1844
1845/// A Stream of incoming requests for fuchsia.diagnostics/LogFlusher.
1846pub struct LogFlusherRequestStream {
1847    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1848    is_terminated: bool,
1849}
1850
1851impl std::marker::Unpin for LogFlusherRequestStream {}
1852
1853impl futures::stream::FusedStream for LogFlusherRequestStream {
1854    fn is_terminated(&self) -> bool {
1855        self.is_terminated
1856    }
1857}
1858
1859impl fidl::endpoints::RequestStream for LogFlusherRequestStream {
1860    type Protocol = LogFlusherMarker;
1861    type ControlHandle = LogFlusherControlHandle;
1862
1863    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1864        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1865    }
1866
1867    fn control_handle(&self) -> Self::ControlHandle {
1868        LogFlusherControlHandle { inner: self.inner.clone() }
1869    }
1870
1871    fn into_inner(
1872        self,
1873    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1874    {
1875        (self.inner, self.is_terminated)
1876    }
1877
1878    fn from_inner(
1879        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1880        is_terminated: bool,
1881    ) -> Self {
1882        Self { inner, is_terminated }
1883    }
1884}
1885
1886impl futures::Stream for LogFlusherRequestStream {
1887    type Item = Result<LogFlusherRequest, fidl::Error>;
1888
1889    fn poll_next(
1890        mut self: std::pin::Pin<&mut Self>,
1891        cx: &mut std::task::Context<'_>,
1892    ) -> std::task::Poll<Option<Self::Item>> {
1893        let this = &mut *self;
1894        if this.inner.check_shutdown(cx) {
1895            this.is_terminated = true;
1896            return std::task::Poll::Ready(None);
1897        }
1898        if this.is_terminated {
1899            panic!("polled LogFlusherRequestStream after completion");
1900        }
1901        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1902            |bytes, handles| {
1903                match this.inner.channel().read_etc(cx, bytes, handles) {
1904                    std::task::Poll::Ready(Ok(())) => {}
1905                    std::task::Poll::Pending => return std::task::Poll::Pending,
1906                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1907                        this.is_terminated = true;
1908                        return std::task::Poll::Ready(None);
1909                    }
1910                    std::task::Poll::Ready(Err(e)) => {
1911                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1912                            e.into(),
1913                        ))));
1914                    }
1915                }
1916
1917                // A message has been received from the channel
1918                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1919
1920                std::task::Poll::Ready(Some(match header.ordinal {
1921                    0x7dc4892e46748b5b => {
1922                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1923                        let mut req = fidl::new_empty!(
1924                            fidl::encoding::EmptyPayload,
1925                            fidl::encoding::DefaultFuchsiaResourceDialect
1926                        );
1927                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1928                        let control_handle = LogFlusherControlHandle { inner: this.inner.clone() };
1929                        Ok(LogFlusherRequest::WaitUntilFlushed {
1930                            responder: LogFlusherWaitUntilFlushedResponder {
1931                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1932                                tx_id: header.tx_id,
1933                            },
1934                        })
1935                    }
1936                    _ if header.tx_id == 0
1937                        && header
1938                            .dynamic_flags()
1939                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1940                    {
1941                        Ok(LogFlusherRequest::_UnknownMethod {
1942                            ordinal: header.ordinal,
1943                            control_handle: LogFlusherControlHandle { inner: this.inner.clone() },
1944                            method_type: fidl::MethodType::OneWay,
1945                        })
1946                    }
1947                    _ if header
1948                        .dynamic_flags()
1949                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1950                    {
1951                        this.inner.send_framework_err(
1952                            fidl::encoding::FrameworkErr::UnknownMethod,
1953                            header.tx_id,
1954                            header.ordinal,
1955                            header.dynamic_flags(),
1956                            (bytes, handles),
1957                        )?;
1958                        Ok(LogFlusherRequest::_UnknownMethod {
1959                            ordinal: header.ordinal,
1960                            control_handle: LogFlusherControlHandle { inner: this.inner.clone() },
1961                            method_type: fidl::MethodType::TwoWay,
1962                        })
1963                    }
1964                    _ => Err(fidl::Error::UnknownOrdinal {
1965                        ordinal: header.ordinal,
1966                        protocol_name:
1967                            <LogFlusherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1968                    }),
1969                }))
1970            },
1971        )
1972    }
1973}
1974
1975#[derive(Debug)]
1976pub enum LogFlusherRequest {
1977    /// Flushes all pending logs through the logging pipeline
1978    /// to the serial port. Logs written to sockets prior to
1979    /// the call to Flush are guaranteed to be fully written
1980    /// to serial when this returns. Logs written to sockets
1981    /// after this call has been received by Archivist are
1982    /// not guaranteed to be flushed.
1983    /// Additionally, sockets must actually be connected to the Archivist
1984    /// before this call is made. If a socket hasn't been
1985    /// received by Archivist yet, those logs may be dropped.
1986    /// To ensure that logs are properly flushed, make sure
1987    /// to wait for the initial interest when logging.
1988    /// Important note: This may be called from the host,
1989    /// but host sockets will NOT be flushed by this method.
1990    /// If you write data from the host (not on the device,
1991    /// there is no guarantee that such logs will ever be printed).
1992    WaitUntilFlushed { responder: LogFlusherWaitUntilFlushedResponder },
1993    /// An interaction was received which does not match any known method.
1994    #[non_exhaustive]
1995    _UnknownMethod {
1996        /// Ordinal of the method that was called.
1997        ordinal: u64,
1998        control_handle: LogFlusherControlHandle,
1999        method_type: fidl::MethodType,
2000    },
2001}
2002
2003impl LogFlusherRequest {
2004    #[allow(irrefutable_let_patterns)]
2005    pub fn into_wait_until_flushed(self) -> Option<(LogFlusherWaitUntilFlushedResponder)> {
2006        if let LogFlusherRequest::WaitUntilFlushed { responder } = self {
2007            Some((responder))
2008        } else {
2009            None
2010        }
2011    }
2012
2013    /// Name of the method defined in FIDL
2014    pub fn method_name(&self) -> &'static str {
2015        match *self {
2016            LogFlusherRequest::WaitUntilFlushed { .. } => "wait_until_flushed",
2017            LogFlusherRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2018                "unknown one-way method"
2019            }
2020            LogFlusherRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2021                "unknown two-way method"
2022            }
2023        }
2024    }
2025}
2026
2027#[derive(Debug, Clone)]
2028pub struct LogFlusherControlHandle {
2029    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2030}
2031
2032impl fidl::endpoints::ControlHandle for LogFlusherControlHandle {
2033    fn shutdown(&self) {
2034        self.inner.shutdown()
2035    }
2036
2037    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2038        self.inner.shutdown_with_epitaph(status)
2039    }
2040
2041    fn is_closed(&self) -> bool {
2042        self.inner.channel().is_closed()
2043    }
2044    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2045        self.inner.channel().on_closed()
2046    }
2047
2048    #[cfg(target_os = "fuchsia")]
2049    fn signal_peer(
2050        &self,
2051        clear_mask: zx::Signals,
2052        set_mask: zx::Signals,
2053    ) -> Result<(), zx_status::Status> {
2054        use fidl::Peered;
2055        self.inner.channel().signal_peer(clear_mask, set_mask)
2056    }
2057}
2058
2059impl LogFlusherControlHandle {}
2060
2061#[must_use = "FIDL methods require a response to be sent"]
2062#[derive(Debug)]
2063pub struct LogFlusherWaitUntilFlushedResponder {
2064    control_handle: std::mem::ManuallyDrop<LogFlusherControlHandle>,
2065    tx_id: u32,
2066}
2067
2068/// Set the the channel to be shutdown (see [`LogFlusherControlHandle::shutdown`])
2069/// if the responder is dropped without sending a response, so that the client
2070/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2071impl std::ops::Drop for LogFlusherWaitUntilFlushedResponder {
2072    fn drop(&mut self) {
2073        self.control_handle.shutdown();
2074        // Safety: drops once, never accessed again
2075        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2076    }
2077}
2078
2079impl fidl::endpoints::Responder for LogFlusherWaitUntilFlushedResponder {
2080    type ControlHandle = LogFlusherControlHandle;
2081
2082    fn control_handle(&self) -> &LogFlusherControlHandle {
2083        &self.control_handle
2084    }
2085
2086    fn drop_without_shutdown(mut self) {
2087        // Safety: drops once, never accessed again due to mem::forget
2088        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2089        // Prevent Drop from running (which would shut down the channel)
2090        std::mem::forget(self);
2091    }
2092}
2093
2094impl LogFlusherWaitUntilFlushedResponder {
2095    /// Sends a response to the FIDL transaction.
2096    ///
2097    /// Sets the channel to shutdown if an error occurs.
2098    pub fn send(self) -> Result<(), fidl::Error> {
2099        let _result = self.send_raw();
2100        if _result.is_err() {
2101            self.control_handle.shutdown();
2102        }
2103        self.drop_without_shutdown();
2104        _result
2105    }
2106
2107    /// Similar to "send" but does not shutdown the channel if an error occurs.
2108    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2109        let _result = self.send_raw();
2110        self.drop_without_shutdown();
2111        _result
2112    }
2113
2114    fn send_raw(&self) -> Result<(), fidl::Error> {
2115        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
2116            fidl::encoding::Flexible::new(()),
2117            self.tx_id,
2118            0x7dc4892e46748b5b,
2119            fidl::encoding::DynamicFlags::FLEXIBLE,
2120        )
2121    }
2122}
2123
2124#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2125pub struct LogSettingsMarker;
2126
2127impl fidl::endpoints::ProtocolMarker for LogSettingsMarker {
2128    type Proxy = LogSettingsProxy;
2129    type RequestStream = LogSettingsRequestStream;
2130    #[cfg(target_os = "fuchsia")]
2131    type SynchronousProxy = LogSettingsSynchronousProxy;
2132
2133    const DEBUG_NAME: &'static str = "fuchsia.diagnostics.LogSettings";
2134}
2135impl fidl::endpoints::DiscoverableProtocolMarker for LogSettingsMarker {}
2136
2137pub trait LogSettingsProxyInterface: Send + Sync {
2138    type SetComponentInterestResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
2139        + Send;
2140    fn r#set_component_interest(
2141        &self,
2142        payload: &LogSettingsSetComponentInterestRequest,
2143    ) -> Self::SetComponentInterestResponseFut;
2144}
2145#[derive(Debug)]
2146#[cfg(target_os = "fuchsia")]
2147pub struct LogSettingsSynchronousProxy {
2148    client: fidl::client::sync::Client,
2149}
2150
2151#[cfg(target_os = "fuchsia")]
2152impl fidl::endpoints::SynchronousProxy for LogSettingsSynchronousProxy {
2153    type Proxy = LogSettingsProxy;
2154    type Protocol = LogSettingsMarker;
2155
2156    fn from_channel(inner: fidl::Channel) -> Self {
2157        Self::new(inner)
2158    }
2159
2160    fn into_channel(self) -> fidl::Channel {
2161        self.client.into_channel()
2162    }
2163
2164    fn as_channel(&self) -> &fidl::Channel {
2165        self.client.as_channel()
2166    }
2167}
2168
2169#[cfg(target_os = "fuchsia")]
2170impl LogSettingsSynchronousProxy {
2171    pub fn new(channel: fidl::Channel) -> Self {
2172        let protocol_name = <LogSettingsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2173        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2174    }
2175
2176    pub fn into_channel(self) -> fidl::Channel {
2177        self.client.into_channel()
2178    }
2179
2180    /// Waits until an event arrives and returns it. It is safe for other
2181    /// threads to make concurrent requests while waiting for an event.
2182    pub fn wait_for_event(
2183        &self,
2184        deadline: zx::MonotonicInstant,
2185    ) -> Result<LogSettingsEvent, fidl::Error> {
2186        LogSettingsEvent::decode(self.client.wait_for_event(deadline)?)
2187    }
2188
2189    /// Requests a change in interest for the matched components.
2190    ///
2191    /// Each component holds a set of requested interests.
2192    ///
2193    /// When a new request on LogSettings#SetComponentInterest is received,
2194    /// the sets for matched components receive the new minimum interest.
2195    /// If the interest is less than the previous minimum interest, then a
2196    /// `SetComponentInterest` request is sent with the new minimum interest.
2197    ///
2198    /// If a connection to `LogSettings` sends another `SetComponentInterest`
2199    /// request, its previous interest request will be undone.
2200    ///
2201    /// When the connection to `LogSettings` is finished, the interests are
2202    /// undone, unless persist is set to true. Each matched component minimum
2203    /// interest is updated with the new minimum interest in the set.
2204    pub fn r#set_component_interest(
2205        &self,
2206        mut payload: &LogSettingsSetComponentInterestRequest,
2207        ___deadline: zx::MonotonicInstant,
2208    ) -> Result<(), fidl::Error> {
2209        let _response = self
2210            .client
2211            .send_query::<LogSettingsSetComponentInterestRequest, fidl::encoding::EmptyPayload>(
2212                payload,
2213                0x35f7004d2367f6c1,
2214                fidl::encoding::DynamicFlags::empty(),
2215                ___deadline,
2216            )?;
2217        Ok(_response)
2218    }
2219}
2220
2221#[cfg(target_os = "fuchsia")]
2222impl From<LogSettingsSynchronousProxy> for zx::NullableHandle {
2223    fn from(value: LogSettingsSynchronousProxy) -> Self {
2224        value.into_channel().into()
2225    }
2226}
2227
2228#[cfg(target_os = "fuchsia")]
2229impl From<fidl::Channel> for LogSettingsSynchronousProxy {
2230    fn from(value: fidl::Channel) -> Self {
2231        Self::new(value)
2232    }
2233}
2234
2235#[cfg(target_os = "fuchsia")]
2236impl fidl::endpoints::FromClient for LogSettingsSynchronousProxy {
2237    type Protocol = LogSettingsMarker;
2238
2239    fn from_client(value: fidl::endpoints::ClientEnd<LogSettingsMarker>) -> Self {
2240        Self::new(value.into_channel())
2241    }
2242}
2243
2244#[derive(Debug, Clone)]
2245pub struct LogSettingsProxy {
2246    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2247}
2248
2249impl fidl::endpoints::Proxy for LogSettingsProxy {
2250    type Protocol = LogSettingsMarker;
2251
2252    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2253        Self::new(inner)
2254    }
2255
2256    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2257        self.client.into_channel().map_err(|client| Self { client })
2258    }
2259
2260    fn as_channel(&self) -> &::fidl::AsyncChannel {
2261        self.client.as_channel()
2262    }
2263}
2264
2265impl LogSettingsProxy {
2266    /// Create a new Proxy for fuchsia.diagnostics/LogSettings.
2267    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2268        let protocol_name = <LogSettingsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2269        Self { client: fidl::client::Client::new(channel, protocol_name) }
2270    }
2271
2272    /// Get a Stream of events from the remote end of the protocol.
2273    ///
2274    /// # Panics
2275    ///
2276    /// Panics if the event stream was already taken.
2277    pub fn take_event_stream(&self) -> LogSettingsEventStream {
2278        LogSettingsEventStream { event_receiver: self.client.take_event_receiver() }
2279    }
2280
2281    /// Requests a change in interest for the matched components.
2282    ///
2283    /// Each component holds a set of requested interests.
2284    ///
2285    /// When a new request on LogSettings#SetComponentInterest is received,
2286    /// the sets for matched components receive the new minimum interest.
2287    /// If the interest is less than the previous minimum interest, then a
2288    /// `SetComponentInterest` request is sent with the new minimum interest.
2289    ///
2290    /// If a connection to `LogSettings` sends another `SetComponentInterest`
2291    /// request, its previous interest request will be undone.
2292    ///
2293    /// When the connection to `LogSettings` is finished, the interests are
2294    /// undone, unless persist is set to true. Each matched component minimum
2295    /// interest is updated with the new minimum interest in the set.
2296    pub fn r#set_component_interest(
2297        &self,
2298        mut payload: &LogSettingsSetComponentInterestRequest,
2299    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2300        LogSettingsProxyInterface::r#set_component_interest(self, payload)
2301    }
2302}
2303
2304impl LogSettingsProxyInterface for LogSettingsProxy {
2305    type SetComponentInterestResponseFut =
2306        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2307    fn r#set_component_interest(
2308        &self,
2309        mut payload: &LogSettingsSetComponentInterestRequest,
2310    ) -> Self::SetComponentInterestResponseFut {
2311        fn _decode(
2312            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2313        ) -> Result<(), fidl::Error> {
2314            let _response = fidl::client::decode_transaction_body::<
2315                fidl::encoding::EmptyPayload,
2316                fidl::encoding::DefaultFuchsiaResourceDialect,
2317                0x35f7004d2367f6c1,
2318            >(_buf?)?;
2319            Ok(_response)
2320        }
2321        self.client.send_query_and_decode::<LogSettingsSetComponentInterestRequest, ()>(
2322            payload,
2323            0x35f7004d2367f6c1,
2324            fidl::encoding::DynamicFlags::empty(),
2325            _decode,
2326        )
2327    }
2328}
2329
2330pub struct LogSettingsEventStream {
2331    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2332}
2333
2334impl std::marker::Unpin for LogSettingsEventStream {}
2335
2336impl futures::stream::FusedStream for LogSettingsEventStream {
2337    fn is_terminated(&self) -> bool {
2338        self.event_receiver.is_terminated()
2339    }
2340}
2341
2342impl futures::Stream for LogSettingsEventStream {
2343    type Item = Result<LogSettingsEvent, fidl::Error>;
2344
2345    fn poll_next(
2346        mut self: std::pin::Pin<&mut Self>,
2347        cx: &mut std::task::Context<'_>,
2348    ) -> std::task::Poll<Option<Self::Item>> {
2349        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2350            &mut self.event_receiver,
2351            cx
2352        )?) {
2353            Some(buf) => std::task::Poll::Ready(Some(LogSettingsEvent::decode(buf))),
2354            None => std::task::Poll::Ready(None),
2355        }
2356    }
2357}
2358
2359#[derive(Debug)]
2360pub enum LogSettingsEvent {}
2361
2362impl LogSettingsEvent {
2363    /// Decodes a message buffer as a [`LogSettingsEvent`].
2364    fn decode(
2365        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2366    ) -> Result<LogSettingsEvent, fidl::Error> {
2367        let (bytes, _handles) = buf.split_mut();
2368        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2369        debug_assert_eq!(tx_header.tx_id, 0);
2370        match tx_header.ordinal {
2371            _ => Err(fidl::Error::UnknownOrdinal {
2372                ordinal: tx_header.ordinal,
2373                protocol_name: <LogSettingsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2374            }),
2375        }
2376    }
2377}
2378
2379/// A Stream of incoming requests for fuchsia.diagnostics/LogSettings.
2380pub struct LogSettingsRequestStream {
2381    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2382    is_terminated: bool,
2383}
2384
2385impl std::marker::Unpin for LogSettingsRequestStream {}
2386
2387impl futures::stream::FusedStream for LogSettingsRequestStream {
2388    fn is_terminated(&self) -> bool {
2389        self.is_terminated
2390    }
2391}
2392
2393impl fidl::endpoints::RequestStream for LogSettingsRequestStream {
2394    type Protocol = LogSettingsMarker;
2395    type ControlHandle = LogSettingsControlHandle;
2396
2397    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2398        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2399    }
2400
2401    fn control_handle(&self) -> Self::ControlHandle {
2402        LogSettingsControlHandle { inner: self.inner.clone() }
2403    }
2404
2405    fn into_inner(
2406        self,
2407    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2408    {
2409        (self.inner, self.is_terminated)
2410    }
2411
2412    fn from_inner(
2413        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2414        is_terminated: bool,
2415    ) -> Self {
2416        Self { inner, is_terminated }
2417    }
2418}
2419
2420impl futures::Stream for LogSettingsRequestStream {
2421    type Item = Result<LogSettingsRequest, fidl::Error>;
2422
2423    fn poll_next(
2424        mut self: std::pin::Pin<&mut Self>,
2425        cx: &mut std::task::Context<'_>,
2426    ) -> std::task::Poll<Option<Self::Item>> {
2427        let this = &mut *self;
2428        if this.inner.check_shutdown(cx) {
2429            this.is_terminated = true;
2430            return std::task::Poll::Ready(None);
2431        }
2432        if this.is_terminated {
2433            panic!("polled LogSettingsRequestStream after completion");
2434        }
2435        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2436            |bytes, handles| {
2437                match this.inner.channel().read_etc(cx, bytes, handles) {
2438                    std::task::Poll::Ready(Ok(())) => {}
2439                    std::task::Poll::Pending => return std::task::Poll::Pending,
2440                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2441                        this.is_terminated = true;
2442                        return std::task::Poll::Ready(None);
2443                    }
2444                    std::task::Poll::Ready(Err(e)) => {
2445                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2446                            e.into(),
2447                        ))));
2448                    }
2449                }
2450
2451                // A message has been received from the channel
2452                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2453
2454                std::task::Poll::Ready(Some(match header.ordinal {
2455                    0x35f7004d2367f6c1 => {
2456                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2457                        let mut req = fidl::new_empty!(
2458                            LogSettingsSetComponentInterestRequest,
2459                            fidl::encoding::DefaultFuchsiaResourceDialect
2460                        );
2461                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LogSettingsSetComponentInterestRequest>(&header, _body_bytes, handles, &mut req)?;
2462                        let control_handle = LogSettingsControlHandle { inner: this.inner.clone() };
2463                        Ok(LogSettingsRequest::SetComponentInterest {
2464                            payload: req,
2465                            responder: LogSettingsSetComponentInterestResponder {
2466                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2467                                tx_id: header.tx_id,
2468                            },
2469                        })
2470                    }
2471                    _ => Err(fidl::Error::UnknownOrdinal {
2472                        ordinal: header.ordinal,
2473                        protocol_name:
2474                            <LogSettingsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2475                    }),
2476                }))
2477            },
2478        )
2479    }
2480}
2481
2482/// This protocol allows clients to modify the logging behavior of components
2483/// in the system.
2484#[derive(Debug)]
2485pub enum LogSettingsRequest {
2486    /// Requests a change in interest for the matched components.
2487    ///
2488    /// Each component holds a set of requested interests.
2489    ///
2490    /// When a new request on LogSettings#SetComponentInterest is received,
2491    /// the sets for matched components receive the new minimum interest.
2492    /// If the interest is less than the previous minimum interest, then a
2493    /// `SetComponentInterest` request is sent with the new minimum interest.
2494    ///
2495    /// If a connection to `LogSettings` sends another `SetComponentInterest`
2496    /// request, its previous interest request will be undone.
2497    ///
2498    /// When the connection to `LogSettings` is finished, the interests are
2499    /// undone, unless persist is set to true. Each matched component minimum
2500    /// interest is updated with the new minimum interest in the set.
2501    SetComponentInterest {
2502        payload: LogSettingsSetComponentInterestRequest,
2503        responder: LogSettingsSetComponentInterestResponder,
2504    },
2505}
2506
2507impl LogSettingsRequest {
2508    #[allow(irrefutable_let_patterns)]
2509    pub fn into_set_component_interest(
2510        self,
2511    ) -> Option<(LogSettingsSetComponentInterestRequest, LogSettingsSetComponentInterestResponder)>
2512    {
2513        if let LogSettingsRequest::SetComponentInterest { payload, responder } = self {
2514            Some((payload, responder))
2515        } else {
2516            None
2517        }
2518    }
2519
2520    /// Name of the method defined in FIDL
2521    pub fn method_name(&self) -> &'static str {
2522        match *self {
2523            LogSettingsRequest::SetComponentInterest { .. } => "set_component_interest",
2524        }
2525    }
2526}
2527
2528#[derive(Debug, Clone)]
2529pub struct LogSettingsControlHandle {
2530    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2531}
2532
2533impl fidl::endpoints::ControlHandle for LogSettingsControlHandle {
2534    fn shutdown(&self) {
2535        self.inner.shutdown()
2536    }
2537
2538    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2539        self.inner.shutdown_with_epitaph(status)
2540    }
2541
2542    fn is_closed(&self) -> bool {
2543        self.inner.channel().is_closed()
2544    }
2545    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2546        self.inner.channel().on_closed()
2547    }
2548
2549    #[cfg(target_os = "fuchsia")]
2550    fn signal_peer(
2551        &self,
2552        clear_mask: zx::Signals,
2553        set_mask: zx::Signals,
2554    ) -> Result<(), zx_status::Status> {
2555        use fidl::Peered;
2556        self.inner.channel().signal_peer(clear_mask, set_mask)
2557    }
2558}
2559
2560impl LogSettingsControlHandle {}
2561
2562#[must_use = "FIDL methods require a response to be sent"]
2563#[derive(Debug)]
2564pub struct LogSettingsSetComponentInterestResponder {
2565    control_handle: std::mem::ManuallyDrop<LogSettingsControlHandle>,
2566    tx_id: u32,
2567}
2568
2569/// Set the the channel to be shutdown (see [`LogSettingsControlHandle::shutdown`])
2570/// if the responder is dropped without sending a response, so that the client
2571/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2572impl std::ops::Drop for LogSettingsSetComponentInterestResponder {
2573    fn drop(&mut self) {
2574        self.control_handle.shutdown();
2575        // Safety: drops once, never accessed again
2576        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2577    }
2578}
2579
2580impl fidl::endpoints::Responder for LogSettingsSetComponentInterestResponder {
2581    type ControlHandle = LogSettingsControlHandle;
2582
2583    fn control_handle(&self) -> &LogSettingsControlHandle {
2584        &self.control_handle
2585    }
2586
2587    fn drop_without_shutdown(mut self) {
2588        // Safety: drops once, never accessed again due to mem::forget
2589        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2590        // Prevent Drop from running (which would shut down the channel)
2591        std::mem::forget(self);
2592    }
2593}
2594
2595impl LogSettingsSetComponentInterestResponder {
2596    /// Sends a response to the FIDL transaction.
2597    ///
2598    /// Sets the channel to shutdown if an error occurs.
2599    pub fn send(self) -> Result<(), fidl::Error> {
2600        let _result = self.send_raw();
2601        if _result.is_err() {
2602            self.control_handle.shutdown();
2603        }
2604        self.drop_without_shutdown();
2605        _result
2606    }
2607
2608    /// Similar to "send" but does not shutdown the channel if an error occurs.
2609    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2610        let _result = self.send_raw();
2611        self.drop_without_shutdown();
2612        _result
2613    }
2614
2615    fn send_raw(&self) -> Result<(), fidl::Error> {
2616        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2617            (),
2618            self.tx_id,
2619            0x35f7004d2367f6c1,
2620            fidl::encoding::DynamicFlags::empty(),
2621        )
2622    }
2623}
2624
2625#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2626pub struct LogStreamMarker;
2627
2628impl fidl::endpoints::ProtocolMarker for LogStreamMarker {
2629    type Proxy = LogStreamProxy;
2630    type RequestStream = LogStreamRequestStream;
2631    #[cfg(target_os = "fuchsia")]
2632    type SynchronousProxy = LogStreamSynchronousProxy;
2633
2634    const DEBUG_NAME: &'static str = "fuchsia.diagnostics.LogStream";
2635}
2636impl fidl::endpoints::DiscoverableProtocolMarker for LogStreamMarker {}
2637
2638pub trait LogStreamProxyInterface: Send + Sync {
2639    fn r#connect(&self, socket: fidl::Socket, opts: &LogStreamOptions) -> Result<(), fidl::Error>;
2640}
2641#[derive(Debug)]
2642#[cfg(target_os = "fuchsia")]
2643pub struct LogStreamSynchronousProxy {
2644    client: fidl::client::sync::Client,
2645}
2646
2647#[cfg(target_os = "fuchsia")]
2648impl fidl::endpoints::SynchronousProxy for LogStreamSynchronousProxy {
2649    type Proxy = LogStreamProxy;
2650    type Protocol = LogStreamMarker;
2651
2652    fn from_channel(inner: fidl::Channel) -> Self {
2653        Self::new(inner)
2654    }
2655
2656    fn into_channel(self) -> fidl::Channel {
2657        self.client.into_channel()
2658    }
2659
2660    fn as_channel(&self) -> &fidl::Channel {
2661        self.client.as_channel()
2662    }
2663}
2664
2665#[cfg(target_os = "fuchsia")]
2666impl LogStreamSynchronousProxy {
2667    pub fn new(channel: fidl::Channel) -> Self {
2668        let protocol_name = <LogStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2669        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2670    }
2671
2672    pub fn into_channel(self) -> fidl::Channel {
2673        self.client.into_channel()
2674    }
2675
2676    /// Waits until an event arrives and returns it. It is safe for other
2677    /// threads to make concurrent requests while waiting for an event.
2678    pub fn wait_for_event(
2679        &self,
2680        deadline: zx::MonotonicInstant,
2681    ) -> Result<LogStreamEvent, fidl::Error> {
2682        LogStreamEvent::decode(self.client.wait_for_event(deadline)?)
2683    }
2684
2685    /// Enables clients to stream all logs stored in the Archivist.
2686    /// Expects a Datagram socket handle that can be written to.
2687    ///
2688    /// Logs will be written in the original FXT format with two additional
2689    /// arguments appended at the end of the record depending on the options
2690    /// passed:
2691    ///
2692    ///     - `$__moniker`: the moniker of the component that emitted the log.
2693    ///     - `$__url`: the URL of the component that emitted the log.
2694    ///     - `$__rolled_out`: the number of logs that were rolled out from the
2695    ///       buffer before this one.
2696    pub fn r#connect(
2697        &self,
2698        mut socket: fidl::Socket,
2699        mut opts: &LogStreamOptions,
2700    ) -> Result<(), fidl::Error> {
2701        self.client.send::<LogStreamConnectRequest>(
2702            (socket, opts),
2703            0x745eb34f10d51a88,
2704            fidl::encoding::DynamicFlags::FLEXIBLE,
2705        )
2706    }
2707}
2708
2709#[cfg(target_os = "fuchsia")]
2710impl From<LogStreamSynchronousProxy> for zx::NullableHandle {
2711    fn from(value: LogStreamSynchronousProxy) -> Self {
2712        value.into_channel().into()
2713    }
2714}
2715
2716#[cfg(target_os = "fuchsia")]
2717impl From<fidl::Channel> for LogStreamSynchronousProxy {
2718    fn from(value: fidl::Channel) -> Self {
2719        Self::new(value)
2720    }
2721}
2722
2723#[cfg(target_os = "fuchsia")]
2724impl fidl::endpoints::FromClient for LogStreamSynchronousProxy {
2725    type Protocol = LogStreamMarker;
2726
2727    fn from_client(value: fidl::endpoints::ClientEnd<LogStreamMarker>) -> Self {
2728        Self::new(value.into_channel())
2729    }
2730}
2731
2732#[derive(Debug, Clone)]
2733pub struct LogStreamProxy {
2734    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2735}
2736
2737impl fidl::endpoints::Proxy for LogStreamProxy {
2738    type Protocol = LogStreamMarker;
2739
2740    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2741        Self::new(inner)
2742    }
2743
2744    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2745        self.client.into_channel().map_err(|client| Self { client })
2746    }
2747
2748    fn as_channel(&self) -> &::fidl::AsyncChannel {
2749        self.client.as_channel()
2750    }
2751}
2752
2753impl LogStreamProxy {
2754    /// Create a new Proxy for fuchsia.diagnostics/LogStream.
2755    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2756        let protocol_name = <LogStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2757        Self { client: fidl::client::Client::new(channel, protocol_name) }
2758    }
2759
2760    /// Get a Stream of events from the remote end of the protocol.
2761    ///
2762    /// # Panics
2763    ///
2764    /// Panics if the event stream was already taken.
2765    pub fn take_event_stream(&self) -> LogStreamEventStream {
2766        LogStreamEventStream { event_receiver: self.client.take_event_receiver() }
2767    }
2768
2769    /// Enables clients to stream all logs stored in the Archivist.
2770    /// Expects a Datagram socket handle that can be written to.
2771    ///
2772    /// Logs will be written in the original FXT format with two additional
2773    /// arguments appended at the end of the record depending on the options
2774    /// passed:
2775    ///
2776    ///     - `$__moniker`: the moniker of the component that emitted the log.
2777    ///     - `$__url`: the URL of the component that emitted the log.
2778    ///     - `$__rolled_out`: the number of logs that were rolled out from the
2779    ///       buffer before this one.
2780    pub fn r#connect(
2781        &self,
2782        mut socket: fidl::Socket,
2783        mut opts: &LogStreamOptions,
2784    ) -> Result<(), fidl::Error> {
2785        LogStreamProxyInterface::r#connect(self, socket, opts)
2786    }
2787}
2788
2789impl LogStreamProxyInterface for LogStreamProxy {
2790    fn r#connect(
2791        &self,
2792        mut socket: fidl::Socket,
2793        mut opts: &LogStreamOptions,
2794    ) -> Result<(), fidl::Error> {
2795        self.client.send::<LogStreamConnectRequest>(
2796            (socket, opts),
2797            0x745eb34f10d51a88,
2798            fidl::encoding::DynamicFlags::FLEXIBLE,
2799        )
2800    }
2801}
2802
2803pub struct LogStreamEventStream {
2804    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2805}
2806
2807impl std::marker::Unpin for LogStreamEventStream {}
2808
2809impl futures::stream::FusedStream for LogStreamEventStream {
2810    fn is_terminated(&self) -> bool {
2811        self.event_receiver.is_terminated()
2812    }
2813}
2814
2815impl futures::Stream for LogStreamEventStream {
2816    type Item = Result<LogStreamEvent, fidl::Error>;
2817
2818    fn poll_next(
2819        mut self: std::pin::Pin<&mut Self>,
2820        cx: &mut std::task::Context<'_>,
2821    ) -> std::task::Poll<Option<Self::Item>> {
2822        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2823            &mut self.event_receiver,
2824            cx
2825        )?) {
2826            Some(buf) => std::task::Poll::Ready(Some(LogStreamEvent::decode(buf))),
2827            None => std::task::Poll::Ready(None),
2828        }
2829    }
2830}
2831
2832#[derive(Debug)]
2833pub enum LogStreamEvent {
2834    #[non_exhaustive]
2835    _UnknownEvent {
2836        /// Ordinal of the event that was sent.
2837        ordinal: u64,
2838    },
2839}
2840
2841impl LogStreamEvent {
2842    /// Decodes a message buffer as a [`LogStreamEvent`].
2843    fn decode(
2844        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2845    ) -> Result<LogStreamEvent, fidl::Error> {
2846        let (bytes, _handles) = buf.split_mut();
2847        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2848        debug_assert_eq!(tx_header.tx_id, 0);
2849        match tx_header.ordinal {
2850            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2851                Ok(LogStreamEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2852            }
2853            _ => Err(fidl::Error::UnknownOrdinal {
2854                ordinal: tx_header.ordinal,
2855                protocol_name: <LogStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2856            }),
2857        }
2858    }
2859}
2860
2861/// A Stream of incoming requests for fuchsia.diagnostics/LogStream.
2862pub struct LogStreamRequestStream {
2863    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2864    is_terminated: bool,
2865}
2866
2867impl std::marker::Unpin for LogStreamRequestStream {}
2868
2869impl futures::stream::FusedStream for LogStreamRequestStream {
2870    fn is_terminated(&self) -> bool {
2871        self.is_terminated
2872    }
2873}
2874
2875impl fidl::endpoints::RequestStream for LogStreamRequestStream {
2876    type Protocol = LogStreamMarker;
2877    type ControlHandle = LogStreamControlHandle;
2878
2879    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2880        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2881    }
2882
2883    fn control_handle(&self) -> Self::ControlHandle {
2884        LogStreamControlHandle { inner: self.inner.clone() }
2885    }
2886
2887    fn into_inner(
2888        self,
2889    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2890    {
2891        (self.inner, self.is_terminated)
2892    }
2893
2894    fn from_inner(
2895        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2896        is_terminated: bool,
2897    ) -> Self {
2898        Self { inner, is_terminated }
2899    }
2900}
2901
2902impl futures::Stream for LogStreamRequestStream {
2903    type Item = Result<LogStreamRequest, fidl::Error>;
2904
2905    fn poll_next(
2906        mut self: std::pin::Pin<&mut Self>,
2907        cx: &mut std::task::Context<'_>,
2908    ) -> std::task::Poll<Option<Self::Item>> {
2909        let this = &mut *self;
2910        if this.inner.check_shutdown(cx) {
2911            this.is_terminated = true;
2912            return std::task::Poll::Ready(None);
2913        }
2914        if this.is_terminated {
2915            panic!("polled LogStreamRequestStream after completion");
2916        }
2917        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2918            |bytes, handles| {
2919                match this.inner.channel().read_etc(cx, bytes, handles) {
2920                    std::task::Poll::Ready(Ok(())) => {}
2921                    std::task::Poll::Pending => return std::task::Poll::Pending,
2922                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2923                        this.is_terminated = true;
2924                        return std::task::Poll::Ready(None);
2925                    }
2926                    std::task::Poll::Ready(Err(e)) => {
2927                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2928                            e.into(),
2929                        ))));
2930                    }
2931                }
2932
2933                // A message has been received from the channel
2934                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2935
2936                std::task::Poll::Ready(Some(match header.ordinal {
2937                    0x745eb34f10d51a88 => {
2938                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2939                        let mut req = fidl::new_empty!(
2940                            LogStreamConnectRequest,
2941                            fidl::encoding::DefaultFuchsiaResourceDialect
2942                        );
2943                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LogStreamConnectRequest>(&header, _body_bytes, handles, &mut req)?;
2944                        let control_handle = LogStreamControlHandle { inner: this.inner.clone() };
2945                        Ok(LogStreamRequest::Connect {
2946                            socket: req.socket,
2947                            opts: req.opts,
2948
2949                            control_handle,
2950                        })
2951                    }
2952                    _ if header.tx_id == 0
2953                        && header
2954                            .dynamic_flags()
2955                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2956                    {
2957                        Ok(LogStreamRequest::_UnknownMethod {
2958                            ordinal: header.ordinal,
2959                            control_handle: LogStreamControlHandle { inner: this.inner.clone() },
2960                            method_type: fidl::MethodType::OneWay,
2961                        })
2962                    }
2963                    _ if header
2964                        .dynamic_flags()
2965                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2966                    {
2967                        this.inner.send_framework_err(
2968                            fidl::encoding::FrameworkErr::UnknownMethod,
2969                            header.tx_id,
2970                            header.ordinal,
2971                            header.dynamic_flags(),
2972                            (bytes, handles),
2973                        )?;
2974                        Ok(LogStreamRequest::_UnknownMethod {
2975                            ordinal: header.ordinal,
2976                            control_handle: LogStreamControlHandle { inner: this.inner.clone() },
2977                            method_type: fidl::MethodType::TwoWay,
2978                        })
2979                    }
2980                    _ => Err(fidl::Error::UnknownOrdinal {
2981                        ordinal: header.ordinal,
2982                        protocol_name:
2983                            <LogStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2984                    }),
2985                }))
2986            },
2987        )
2988    }
2989}
2990
2991#[derive(Debug)]
2992pub enum LogStreamRequest {
2993    /// Enables clients to stream all logs stored in the Archivist.
2994    /// Expects a Datagram socket handle that can be written to.
2995    ///
2996    /// Logs will be written in the original FXT format with two additional
2997    /// arguments appended at the end of the record depending on the options
2998    /// passed:
2999    ///
3000    ///     - `$__moniker`: the moniker of the component that emitted the log.
3001    ///     - `$__url`: the URL of the component that emitted the log.
3002    ///     - `$__rolled_out`: the number of logs that were rolled out from the
3003    ///       buffer before this one.
3004    Connect { socket: fidl::Socket, opts: LogStreamOptions, control_handle: LogStreamControlHandle },
3005    /// An interaction was received which does not match any known method.
3006    #[non_exhaustive]
3007    _UnknownMethod {
3008        /// Ordinal of the method that was called.
3009        ordinal: u64,
3010        control_handle: LogStreamControlHandle,
3011        method_type: fidl::MethodType,
3012    },
3013}
3014
3015impl LogStreamRequest {
3016    #[allow(irrefutable_let_patterns)]
3017    pub fn into_connect(self) -> Option<(fidl::Socket, LogStreamOptions, LogStreamControlHandle)> {
3018        if let LogStreamRequest::Connect { socket, opts, control_handle } = self {
3019            Some((socket, opts, control_handle))
3020        } else {
3021            None
3022        }
3023    }
3024
3025    /// Name of the method defined in FIDL
3026    pub fn method_name(&self) -> &'static str {
3027        match *self {
3028            LogStreamRequest::Connect { .. } => "connect",
3029            LogStreamRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
3030                "unknown one-way method"
3031            }
3032            LogStreamRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
3033                "unknown two-way method"
3034            }
3035        }
3036    }
3037}
3038
3039#[derive(Debug, Clone)]
3040pub struct LogStreamControlHandle {
3041    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3042}
3043
3044impl fidl::endpoints::ControlHandle for LogStreamControlHandle {
3045    fn shutdown(&self) {
3046        self.inner.shutdown()
3047    }
3048
3049    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3050        self.inner.shutdown_with_epitaph(status)
3051    }
3052
3053    fn is_closed(&self) -> bool {
3054        self.inner.channel().is_closed()
3055    }
3056    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3057        self.inner.channel().on_closed()
3058    }
3059
3060    #[cfg(target_os = "fuchsia")]
3061    fn signal_peer(
3062        &self,
3063        clear_mask: zx::Signals,
3064        set_mask: zx::Signals,
3065    ) -> Result<(), zx_status::Status> {
3066        use fidl::Peered;
3067        self.inner.channel().signal_peer(clear_mask, set_mask)
3068    }
3069}
3070
3071impl LogStreamControlHandle {}
3072
3073#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3074pub struct SampleMarker;
3075
3076impl fidl::endpoints::ProtocolMarker for SampleMarker {
3077    type Proxy = SampleProxy;
3078    type RequestStream = SampleRequestStream;
3079    #[cfg(target_os = "fuchsia")]
3080    type SynchronousProxy = SampleSynchronousProxy;
3081
3082    const DEBUG_NAME: &'static str = "fuchsia.diagnostics.Sample";
3083}
3084impl fidl::endpoints::DiscoverableProtocolMarker for SampleMarker {}
3085pub type SampleCommitResult = Result<(), ConfigurationError>;
3086
3087pub trait SampleProxyInterface: Send + Sync {
3088    fn r#set(&self, sample_parameters: &SampleParameters) -> Result<(), fidl::Error>;
3089    type CommitResponseFut: std::future::Future<Output = Result<SampleCommitResult, fidl::Error>>
3090        + Send;
3091    fn r#commit(
3092        &self,
3093        sink: fidl::endpoints::ClientEnd<SampleSinkMarker>,
3094    ) -> Self::CommitResponseFut;
3095}
3096#[derive(Debug)]
3097#[cfg(target_os = "fuchsia")]
3098pub struct SampleSynchronousProxy {
3099    client: fidl::client::sync::Client,
3100}
3101
3102#[cfg(target_os = "fuchsia")]
3103impl fidl::endpoints::SynchronousProxy for SampleSynchronousProxy {
3104    type Proxy = SampleProxy;
3105    type Protocol = SampleMarker;
3106
3107    fn from_channel(inner: fidl::Channel) -> Self {
3108        Self::new(inner)
3109    }
3110
3111    fn into_channel(self) -> fidl::Channel {
3112        self.client.into_channel()
3113    }
3114
3115    fn as_channel(&self) -> &fidl::Channel {
3116        self.client.as_channel()
3117    }
3118}
3119
3120#[cfg(target_os = "fuchsia")]
3121impl SampleSynchronousProxy {
3122    pub fn new(channel: fidl::Channel) -> Self {
3123        let protocol_name = <SampleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3124        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3125    }
3126
3127    pub fn into_channel(self) -> fidl::Channel {
3128        self.client.into_channel()
3129    }
3130
3131    /// Waits until an event arrives and returns it. It is safe for other
3132    /// threads to make concurrent requests while waiting for an event.
3133    pub fn wait_for_event(
3134        &self,
3135        deadline: zx::MonotonicInstant,
3136    ) -> Result<SampleEvent, fidl::Error> {
3137        SampleEvent::decode(self.client.wait_for_event(deadline)?)
3138    }
3139
3140    /// Add sample parameters.
3141    ///
3142    /// Since this is limited by channel size, this API paginates at 300
3143    /// items. That should fit in a channel unless a selector is particularly
3144    /// gigantic.
3145    ///
3146    /// Use `Commit` to indicate that all samples are sent over.
3147    pub fn r#set(&self, mut sample_parameters: &SampleParameters) -> Result<(), fidl::Error> {
3148        self.client.send::<SampleSetRequest>(
3149            (sample_parameters,),
3150            0x421a79bdbf45418e,
3151            fidl::encoding::DynamicFlags::FLEXIBLE,
3152        )
3153    }
3154
3155    /// `Commit` returns errors quickly, as all configuration is validated
3156    /// before the first sample is taken.
3157    pub fn r#commit(
3158        &self,
3159        mut sink: fidl::endpoints::ClientEnd<SampleSinkMarker>,
3160        ___deadline: zx::MonotonicInstant,
3161    ) -> Result<SampleCommitResult, fidl::Error> {
3162        let _response = self.client.send_query::<
3163            SampleCommitRequest,
3164            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, ConfigurationError>,
3165        >(
3166            (sink,),
3167            0x25a3bc5f26787e9b,
3168            fidl::encoding::DynamicFlags::FLEXIBLE,
3169            ___deadline,
3170        )?
3171        .into_result::<SampleMarker>("commit")?;
3172        Ok(_response.map(|x| x))
3173    }
3174}
3175
3176#[cfg(target_os = "fuchsia")]
3177impl From<SampleSynchronousProxy> for zx::NullableHandle {
3178    fn from(value: SampleSynchronousProxy) -> Self {
3179        value.into_channel().into()
3180    }
3181}
3182
3183#[cfg(target_os = "fuchsia")]
3184impl From<fidl::Channel> for SampleSynchronousProxy {
3185    fn from(value: fidl::Channel) -> Self {
3186        Self::new(value)
3187    }
3188}
3189
3190#[cfg(target_os = "fuchsia")]
3191impl fidl::endpoints::FromClient for SampleSynchronousProxy {
3192    type Protocol = SampleMarker;
3193
3194    fn from_client(value: fidl::endpoints::ClientEnd<SampleMarker>) -> Self {
3195        Self::new(value.into_channel())
3196    }
3197}
3198
3199#[derive(Debug, Clone)]
3200pub struct SampleProxy {
3201    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3202}
3203
3204impl fidl::endpoints::Proxy for SampleProxy {
3205    type Protocol = SampleMarker;
3206
3207    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3208        Self::new(inner)
3209    }
3210
3211    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3212        self.client.into_channel().map_err(|client| Self { client })
3213    }
3214
3215    fn as_channel(&self) -> &::fidl::AsyncChannel {
3216        self.client.as_channel()
3217    }
3218}
3219
3220impl SampleProxy {
3221    /// Create a new Proxy for fuchsia.diagnostics/Sample.
3222    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3223        let protocol_name = <SampleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3224        Self { client: fidl::client::Client::new(channel, protocol_name) }
3225    }
3226
3227    /// Get a Stream of events from the remote end of the protocol.
3228    ///
3229    /// # Panics
3230    ///
3231    /// Panics if the event stream was already taken.
3232    pub fn take_event_stream(&self) -> SampleEventStream {
3233        SampleEventStream { event_receiver: self.client.take_event_receiver() }
3234    }
3235
3236    /// Add sample parameters.
3237    ///
3238    /// Since this is limited by channel size, this API paginates at 300
3239    /// items. That should fit in a channel unless a selector is particularly
3240    /// gigantic.
3241    ///
3242    /// Use `Commit` to indicate that all samples are sent over.
3243    pub fn r#set(&self, mut sample_parameters: &SampleParameters) -> Result<(), fidl::Error> {
3244        SampleProxyInterface::r#set(self, sample_parameters)
3245    }
3246
3247    /// `Commit` returns errors quickly, as all configuration is validated
3248    /// before the first sample is taken.
3249    pub fn r#commit(
3250        &self,
3251        mut sink: fidl::endpoints::ClientEnd<SampleSinkMarker>,
3252    ) -> fidl::client::QueryResponseFut<
3253        SampleCommitResult,
3254        fidl::encoding::DefaultFuchsiaResourceDialect,
3255    > {
3256        SampleProxyInterface::r#commit(self, sink)
3257    }
3258}
3259
3260impl SampleProxyInterface for SampleProxy {
3261    fn r#set(&self, mut sample_parameters: &SampleParameters) -> Result<(), fidl::Error> {
3262        self.client.send::<SampleSetRequest>(
3263            (sample_parameters,),
3264            0x421a79bdbf45418e,
3265            fidl::encoding::DynamicFlags::FLEXIBLE,
3266        )
3267    }
3268
3269    type CommitResponseFut = fidl::client::QueryResponseFut<
3270        SampleCommitResult,
3271        fidl::encoding::DefaultFuchsiaResourceDialect,
3272    >;
3273    fn r#commit(
3274        &self,
3275        mut sink: fidl::endpoints::ClientEnd<SampleSinkMarker>,
3276    ) -> Self::CommitResponseFut {
3277        fn _decode(
3278            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3279        ) -> Result<SampleCommitResult, fidl::Error> {
3280            let _response = fidl::client::decode_transaction_body::<
3281                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, ConfigurationError>,
3282                fidl::encoding::DefaultFuchsiaResourceDialect,
3283                0x25a3bc5f26787e9b,
3284            >(_buf?)?
3285            .into_result::<SampleMarker>("commit")?;
3286            Ok(_response.map(|x| x))
3287        }
3288        self.client.send_query_and_decode::<SampleCommitRequest, SampleCommitResult>(
3289            (sink,),
3290            0x25a3bc5f26787e9b,
3291            fidl::encoding::DynamicFlags::FLEXIBLE,
3292            _decode,
3293        )
3294    }
3295}
3296
3297pub struct SampleEventStream {
3298    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3299}
3300
3301impl std::marker::Unpin for SampleEventStream {}
3302
3303impl futures::stream::FusedStream for SampleEventStream {
3304    fn is_terminated(&self) -> bool {
3305        self.event_receiver.is_terminated()
3306    }
3307}
3308
3309impl futures::Stream for SampleEventStream {
3310    type Item = Result<SampleEvent, fidl::Error>;
3311
3312    fn poll_next(
3313        mut self: std::pin::Pin<&mut Self>,
3314        cx: &mut std::task::Context<'_>,
3315    ) -> std::task::Poll<Option<Self::Item>> {
3316        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3317            &mut self.event_receiver,
3318            cx
3319        )?) {
3320            Some(buf) => std::task::Poll::Ready(Some(SampleEvent::decode(buf))),
3321            None => std::task::Poll::Ready(None),
3322        }
3323    }
3324}
3325
3326#[derive(Debug)]
3327pub enum SampleEvent {
3328    #[non_exhaustive]
3329    _UnknownEvent {
3330        /// Ordinal of the event that was sent.
3331        ordinal: u64,
3332    },
3333}
3334
3335impl SampleEvent {
3336    /// Decodes a message buffer as a [`SampleEvent`].
3337    fn decode(
3338        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3339    ) -> Result<SampleEvent, fidl::Error> {
3340        let (bytes, _handles) = buf.split_mut();
3341        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3342        debug_assert_eq!(tx_header.tx_id, 0);
3343        match tx_header.ordinal {
3344            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3345                Ok(SampleEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3346            }
3347            _ => Err(fidl::Error::UnknownOrdinal {
3348                ordinal: tx_header.ordinal,
3349                protocol_name: <SampleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3350            }),
3351        }
3352    }
3353}
3354
3355/// A Stream of incoming requests for fuchsia.diagnostics/Sample.
3356pub struct SampleRequestStream {
3357    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3358    is_terminated: bool,
3359}
3360
3361impl std::marker::Unpin for SampleRequestStream {}
3362
3363impl futures::stream::FusedStream for SampleRequestStream {
3364    fn is_terminated(&self) -> bool {
3365        self.is_terminated
3366    }
3367}
3368
3369impl fidl::endpoints::RequestStream for SampleRequestStream {
3370    type Protocol = SampleMarker;
3371    type ControlHandle = SampleControlHandle;
3372
3373    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3374        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3375    }
3376
3377    fn control_handle(&self) -> Self::ControlHandle {
3378        SampleControlHandle { inner: self.inner.clone() }
3379    }
3380
3381    fn into_inner(
3382        self,
3383    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3384    {
3385        (self.inner, self.is_terminated)
3386    }
3387
3388    fn from_inner(
3389        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3390        is_terminated: bool,
3391    ) -> Self {
3392        Self { inner, is_terminated }
3393    }
3394}
3395
3396impl futures::Stream for SampleRequestStream {
3397    type Item = Result<SampleRequest, fidl::Error>;
3398
3399    fn poll_next(
3400        mut self: std::pin::Pin<&mut Self>,
3401        cx: &mut std::task::Context<'_>,
3402    ) -> std::task::Poll<Option<Self::Item>> {
3403        let this = &mut *self;
3404        if this.inner.check_shutdown(cx) {
3405            this.is_terminated = true;
3406            return std::task::Poll::Ready(None);
3407        }
3408        if this.is_terminated {
3409            panic!("polled SampleRequestStream after completion");
3410        }
3411        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3412            |bytes, handles| {
3413                match this.inner.channel().read_etc(cx, bytes, handles) {
3414                    std::task::Poll::Ready(Ok(())) => {}
3415                    std::task::Poll::Pending => return std::task::Poll::Pending,
3416                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3417                        this.is_terminated = true;
3418                        return std::task::Poll::Ready(None);
3419                    }
3420                    std::task::Poll::Ready(Err(e)) => {
3421                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3422                            e.into(),
3423                        ))));
3424                    }
3425                }
3426
3427                // A message has been received from the channel
3428                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3429
3430                std::task::Poll::Ready(Some(match header.ordinal {
3431                    0x421a79bdbf45418e => {
3432                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3433                        let mut req = fidl::new_empty!(
3434                            SampleSetRequest,
3435                            fidl::encoding::DefaultFuchsiaResourceDialect
3436                        );
3437                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SampleSetRequest>(&header, _body_bytes, handles, &mut req)?;
3438                        let control_handle = SampleControlHandle { inner: this.inner.clone() };
3439                        Ok(SampleRequest::Set {
3440                            sample_parameters: req.sample_parameters,
3441
3442                            control_handle,
3443                        })
3444                    }
3445                    0x25a3bc5f26787e9b => {
3446                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3447                        let mut req = fidl::new_empty!(
3448                            SampleCommitRequest,
3449                            fidl::encoding::DefaultFuchsiaResourceDialect
3450                        );
3451                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SampleCommitRequest>(&header, _body_bytes, handles, &mut req)?;
3452                        let control_handle = SampleControlHandle { inner: this.inner.clone() };
3453                        Ok(SampleRequest::Commit {
3454                            sink: req.sink,
3455
3456                            responder: SampleCommitResponder {
3457                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3458                                tx_id: header.tx_id,
3459                            },
3460                        })
3461                    }
3462                    _ if header.tx_id == 0
3463                        && header
3464                            .dynamic_flags()
3465                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3466                    {
3467                        Ok(SampleRequest::_UnknownMethod {
3468                            ordinal: header.ordinal,
3469                            control_handle: SampleControlHandle { inner: this.inner.clone() },
3470                            method_type: fidl::MethodType::OneWay,
3471                        })
3472                    }
3473                    _ if header
3474                        .dynamic_flags()
3475                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3476                    {
3477                        this.inner.send_framework_err(
3478                            fidl::encoding::FrameworkErr::UnknownMethod,
3479                            header.tx_id,
3480                            header.ordinal,
3481                            header.dynamic_flags(),
3482                            (bytes, handles),
3483                        )?;
3484                        Ok(SampleRequest::_UnknownMethod {
3485                            ordinal: header.ordinal,
3486                            control_handle: SampleControlHandle { inner: this.inner.clone() },
3487                            method_type: fidl::MethodType::TwoWay,
3488                        })
3489                    }
3490                    _ => Err(fidl::Error::UnknownOrdinal {
3491                        ordinal: header.ordinal,
3492                        protocol_name:
3493                            <SampleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3494                    }),
3495                }))
3496            },
3497        )
3498    }
3499}
3500
3501/// Configure Archivist to alert you periodically about the state of data
3502/// provided via `SampleParameters`.
3503///
3504/// If the given configuration results in a hit, a `BatchIterator` is sent
3505/// over the `sink` provided. That iterator may be drained, and then the
3506/// `sink` will go quiet until the next hit.
3507///
3508/// Archivist does not inform the client which data result in a success,
3509/// because it has not inherent advantaged ability to do so. Clients who
3510/// need to know which data was queried should cache their selectors and
3511/// use `selectors::select_from_hierarchy` (or similar in C++).
3512#[derive(Debug)]
3513pub enum SampleRequest {
3514    /// Add sample parameters.
3515    ///
3516    /// Since this is limited by channel size, this API paginates at 300
3517    /// items. That should fit in a channel unless a selector is particularly
3518    /// gigantic.
3519    ///
3520    /// Use `Commit` to indicate that all samples are sent over.
3521    Set { sample_parameters: SampleParameters, control_handle: SampleControlHandle },
3522    /// `Commit` returns errors quickly, as all configuration is validated
3523    /// before the first sample is taken.
3524    Commit { sink: fidl::endpoints::ClientEnd<SampleSinkMarker>, responder: SampleCommitResponder },
3525    /// An interaction was received which does not match any known method.
3526    #[non_exhaustive]
3527    _UnknownMethod {
3528        /// Ordinal of the method that was called.
3529        ordinal: u64,
3530        control_handle: SampleControlHandle,
3531        method_type: fidl::MethodType,
3532    },
3533}
3534
3535impl SampleRequest {
3536    #[allow(irrefutable_let_patterns)]
3537    pub fn into_set(self) -> Option<(SampleParameters, SampleControlHandle)> {
3538        if let SampleRequest::Set { sample_parameters, control_handle } = self {
3539            Some((sample_parameters, control_handle))
3540        } else {
3541            None
3542        }
3543    }
3544
3545    #[allow(irrefutable_let_patterns)]
3546    pub fn into_commit(
3547        self,
3548    ) -> Option<(fidl::endpoints::ClientEnd<SampleSinkMarker>, SampleCommitResponder)> {
3549        if let SampleRequest::Commit { sink, responder } = self {
3550            Some((sink, responder))
3551        } else {
3552            None
3553        }
3554    }
3555
3556    /// Name of the method defined in FIDL
3557    pub fn method_name(&self) -> &'static str {
3558        match *self {
3559            SampleRequest::Set { .. } => "set",
3560            SampleRequest::Commit { .. } => "commit",
3561            SampleRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
3562                "unknown one-way method"
3563            }
3564            SampleRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
3565                "unknown two-way method"
3566            }
3567        }
3568    }
3569}
3570
3571#[derive(Debug, Clone)]
3572pub struct SampleControlHandle {
3573    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3574}
3575
3576impl fidl::endpoints::ControlHandle for SampleControlHandle {
3577    fn shutdown(&self) {
3578        self.inner.shutdown()
3579    }
3580
3581    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3582        self.inner.shutdown_with_epitaph(status)
3583    }
3584
3585    fn is_closed(&self) -> bool {
3586        self.inner.channel().is_closed()
3587    }
3588    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3589        self.inner.channel().on_closed()
3590    }
3591
3592    #[cfg(target_os = "fuchsia")]
3593    fn signal_peer(
3594        &self,
3595        clear_mask: zx::Signals,
3596        set_mask: zx::Signals,
3597    ) -> Result<(), zx_status::Status> {
3598        use fidl::Peered;
3599        self.inner.channel().signal_peer(clear_mask, set_mask)
3600    }
3601}
3602
3603impl SampleControlHandle {}
3604
3605#[must_use = "FIDL methods require a response to be sent"]
3606#[derive(Debug)]
3607pub struct SampleCommitResponder {
3608    control_handle: std::mem::ManuallyDrop<SampleControlHandle>,
3609    tx_id: u32,
3610}
3611
3612/// Set the the channel to be shutdown (see [`SampleControlHandle::shutdown`])
3613/// if the responder is dropped without sending a response, so that the client
3614/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3615impl std::ops::Drop for SampleCommitResponder {
3616    fn drop(&mut self) {
3617        self.control_handle.shutdown();
3618        // Safety: drops once, never accessed again
3619        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3620    }
3621}
3622
3623impl fidl::endpoints::Responder for SampleCommitResponder {
3624    type ControlHandle = SampleControlHandle;
3625
3626    fn control_handle(&self) -> &SampleControlHandle {
3627        &self.control_handle
3628    }
3629
3630    fn drop_without_shutdown(mut self) {
3631        // Safety: drops once, never accessed again due to mem::forget
3632        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3633        // Prevent Drop from running (which would shut down the channel)
3634        std::mem::forget(self);
3635    }
3636}
3637
3638impl SampleCommitResponder {
3639    /// Sends a response to the FIDL transaction.
3640    ///
3641    /// Sets the channel to shutdown if an error occurs.
3642    pub fn send(self, mut result: Result<(), ConfigurationError>) -> Result<(), fidl::Error> {
3643        let _result = self.send_raw(result);
3644        if _result.is_err() {
3645            self.control_handle.shutdown();
3646        }
3647        self.drop_without_shutdown();
3648        _result
3649    }
3650
3651    /// Similar to "send" but does not shutdown the channel if an error occurs.
3652    pub fn send_no_shutdown_on_err(
3653        self,
3654        mut result: Result<(), ConfigurationError>,
3655    ) -> Result<(), fidl::Error> {
3656        let _result = self.send_raw(result);
3657        self.drop_without_shutdown();
3658        _result
3659    }
3660
3661    fn send_raw(&self, mut result: Result<(), ConfigurationError>) -> Result<(), fidl::Error> {
3662        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3663            fidl::encoding::EmptyStruct,
3664            ConfigurationError,
3665        >>(
3666            fidl::encoding::FlexibleResult::new(result),
3667            self.tx_id,
3668            0x25a3bc5f26787e9b,
3669            fidl::encoding::DynamicFlags::FLEXIBLE,
3670        )
3671    }
3672}
3673
3674#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3675pub struct SampleSinkMarker;
3676
3677impl fidl::endpoints::ProtocolMarker for SampleSinkMarker {
3678    type Proxy = SampleSinkProxy;
3679    type RequestStream = SampleSinkRequestStream;
3680    #[cfg(target_os = "fuchsia")]
3681    type SynchronousProxy = SampleSinkSynchronousProxy;
3682
3683    const DEBUG_NAME: &'static str = "(anonymous) SampleSink";
3684}
3685
3686pub trait SampleSinkProxyInterface: Send + Sync {
3687    fn r#on_sample_readied(&self, event: SampleSinkResult) -> Result<(), fidl::Error>;
3688}
3689#[derive(Debug)]
3690#[cfg(target_os = "fuchsia")]
3691pub struct SampleSinkSynchronousProxy {
3692    client: fidl::client::sync::Client,
3693}
3694
3695#[cfg(target_os = "fuchsia")]
3696impl fidl::endpoints::SynchronousProxy for SampleSinkSynchronousProxy {
3697    type Proxy = SampleSinkProxy;
3698    type Protocol = SampleSinkMarker;
3699
3700    fn from_channel(inner: fidl::Channel) -> Self {
3701        Self::new(inner)
3702    }
3703
3704    fn into_channel(self) -> fidl::Channel {
3705        self.client.into_channel()
3706    }
3707
3708    fn as_channel(&self) -> &fidl::Channel {
3709        self.client.as_channel()
3710    }
3711}
3712
3713#[cfg(target_os = "fuchsia")]
3714impl SampleSinkSynchronousProxy {
3715    pub fn new(channel: fidl::Channel) -> Self {
3716        let protocol_name = <SampleSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3717        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3718    }
3719
3720    pub fn into_channel(self) -> fidl::Channel {
3721        self.client.into_channel()
3722    }
3723
3724    /// Waits until an event arrives and returns it. It is safe for other
3725    /// threads to make concurrent requests while waiting for an event.
3726    pub fn wait_for_event(
3727        &self,
3728        deadline: zx::MonotonicInstant,
3729    ) -> Result<SampleSinkEvent, fidl::Error> {
3730        SampleSinkEvent::decode(self.client.wait_for_event(deadline)?)
3731    }
3732
3733    pub fn r#on_sample_readied(&self, mut event: SampleSinkResult) -> Result<(), fidl::Error> {
3734        self.client.send::<SampleSinkOnSampleReadiedRequest>(
3735            (&mut event,),
3736            0x39096d97ed03335f,
3737            fidl::encoding::DynamicFlags::FLEXIBLE,
3738        )
3739    }
3740}
3741
3742#[cfg(target_os = "fuchsia")]
3743impl From<SampleSinkSynchronousProxy> for zx::NullableHandle {
3744    fn from(value: SampleSinkSynchronousProxy) -> Self {
3745        value.into_channel().into()
3746    }
3747}
3748
3749#[cfg(target_os = "fuchsia")]
3750impl From<fidl::Channel> for SampleSinkSynchronousProxy {
3751    fn from(value: fidl::Channel) -> Self {
3752        Self::new(value)
3753    }
3754}
3755
3756#[cfg(target_os = "fuchsia")]
3757impl fidl::endpoints::FromClient for SampleSinkSynchronousProxy {
3758    type Protocol = SampleSinkMarker;
3759
3760    fn from_client(value: fidl::endpoints::ClientEnd<SampleSinkMarker>) -> Self {
3761        Self::new(value.into_channel())
3762    }
3763}
3764
3765#[derive(Debug, Clone)]
3766pub struct SampleSinkProxy {
3767    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3768}
3769
3770impl fidl::endpoints::Proxy for SampleSinkProxy {
3771    type Protocol = SampleSinkMarker;
3772
3773    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3774        Self::new(inner)
3775    }
3776
3777    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3778        self.client.into_channel().map_err(|client| Self { client })
3779    }
3780
3781    fn as_channel(&self) -> &::fidl::AsyncChannel {
3782        self.client.as_channel()
3783    }
3784}
3785
3786impl SampleSinkProxy {
3787    /// Create a new Proxy for fuchsia.diagnostics/SampleSink.
3788    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3789        let protocol_name = <SampleSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3790        Self { client: fidl::client::Client::new(channel, protocol_name) }
3791    }
3792
3793    /// Get a Stream of events from the remote end of the protocol.
3794    ///
3795    /// # Panics
3796    ///
3797    /// Panics if the event stream was already taken.
3798    pub fn take_event_stream(&self) -> SampleSinkEventStream {
3799        SampleSinkEventStream { event_receiver: self.client.take_event_receiver() }
3800    }
3801
3802    pub fn r#on_sample_readied(&self, mut event: SampleSinkResult) -> Result<(), fidl::Error> {
3803        SampleSinkProxyInterface::r#on_sample_readied(self, event)
3804    }
3805}
3806
3807impl SampleSinkProxyInterface for SampleSinkProxy {
3808    fn r#on_sample_readied(&self, mut event: SampleSinkResult) -> Result<(), fidl::Error> {
3809        self.client.send::<SampleSinkOnSampleReadiedRequest>(
3810            (&mut event,),
3811            0x39096d97ed03335f,
3812            fidl::encoding::DynamicFlags::FLEXIBLE,
3813        )
3814    }
3815}
3816
3817pub struct SampleSinkEventStream {
3818    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3819}
3820
3821impl std::marker::Unpin for SampleSinkEventStream {}
3822
3823impl futures::stream::FusedStream for SampleSinkEventStream {
3824    fn is_terminated(&self) -> bool {
3825        self.event_receiver.is_terminated()
3826    }
3827}
3828
3829impl futures::Stream for SampleSinkEventStream {
3830    type Item = Result<SampleSinkEvent, fidl::Error>;
3831
3832    fn poll_next(
3833        mut self: std::pin::Pin<&mut Self>,
3834        cx: &mut std::task::Context<'_>,
3835    ) -> std::task::Poll<Option<Self::Item>> {
3836        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3837            &mut self.event_receiver,
3838            cx
3839        )?) {
3840            Some(buf) => std::task::Poll::Ready(Some(SampleSinkEvent::decode(buf))),
3841            None => std::task::Poll::Ready(None),
3842        }
3843    }
3844}
3845
3846#[derive(Debug)]
3847pub enum SampleSinkEvent {
3848    OnNowOrNever {},
3849    #[non_exhaustive]
3850    _UnknownEvent {
3851        /// Ordinal of the event that was sent.
3852        ordinal: u64,
3853    },
3854}
3855
3856impl SampleSinkEvent {
3857    #[allow(irrefutable_let_patterns)]
3858    pub fn into_on_now_or_never(self) -> Option<()> {
3859        if let SampleSinkEvent::OnNowOrNever {} = self { Some(()) } else { None }
3860    }
3861
3862    /// Decodes a message buffer as a [`SampleSinkEvent`].
3863    fn decode(
3864        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3865    ) -> Result<SampleSinkEvent, fidl::Error> {
3866        let (bytes, _handles) = buf.split_mut();
3867        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3868        debug_assert_eq!(tx_header.tx_id, 0);
3869        match tx_header.ordinal {
3870            0x3dc94ca1e1290894 => {
3871                let mut out = fidl::new_empty!(
3872                    fidl::encoding::EmptyPayload,
3873                    fidl::encoding::DefaultFuchsiaResourceDialect
3874                );
3875                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
3876                Ok((SampleSinkEvent::OnNowOrNever {}))
3877            }
3878            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3879                Ok(SampleSinkEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3880            }
3881            _ => Err(fidl::Error::UnknownOrdinal {
3882                ordinal: tx_header.ordinal,
3883                protocol_name: <SampleSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3884            }),
3885        }
3886    }
3887}
3888
3889/// A Stream of incoming requests for fuchsia.diagnostics/SampleSink.
3890pub struct SampleSinkRequestStream {
3891    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3892    is_terminated: bool,
3893}
3894
3895impl std::marker::Unpin for SampleSinkRequestStream {}
3896
3897impl futures::stream::FusedStream for SampleSinkRequestStream {
3898    fn is_terminated(&self) -> bool {
3899        self.is_terminated
3900    }
3901}
3902
3903impl fidl::endpoints::RequestStream for SampleSinkRequestStream {
3904    type Protocol = SampleSinkMarker;
3905    type ControlHandle = SampleSinkControlHandle;
3906
3907    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3908        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3909    }
3910
3911    fn control_handle(&self) -> Self::ControlHandle {
3912        SampleSinkControlHandle { inner: self.inner.clone() }
3913    }
3914
3915    fn into_inner(
3916        self,
3917    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3918    {
3919        (self.inner, self.is_terminated)
3920    }
3921
3922    fn from_inner(
3923        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3924        is_terminated: bool,
3925    ) -> Self {
3926        Self { inner, is_terminated }
3927    }
3928}
3929
3930impl futures::Stream for SampleSinkRequestStream {
3931    type Item = Result<SampleSinkRequest, fidl::Error>;
3932
3933    fn poll_next(
3934        mut self: std::pin::Pin<&mut Self>,
3935        cx: &mut std::task::Context<'_>,
3936    ) -> std::task::Poll<Option<Self::Item>> {
3937        let this = &mut *self;
3938        if this.inner.check_shutdown(cx) {
3939            this.is_terminated = true;
3940            return std::task::Poll::Ready(None);
3941        }
3942        if this.is_terminated {
3943            panic!("polled SampleSinkRequestStream after completion");
3944        }
3945        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3946            |bytes, handles| {
3947                match this.inner.channel().read_etc(cx, bytes, handles) {
3948                    std::task::Poll::Ready(Ok(())) => {}
3949                    std::task::Poll::Pending => return std::task::Poll::Pending,
3950                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3951                        this.is_terminated = true;
3952                        return std::task::Poll::Ready(None);
3953                    }
3954                    std::task::Poll::Ready(Err(e)) => {
3955                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3956                            e.into(),
3957                        ))));
3958                    }
3959                }
3960
3961                // A message has been received from the channel
3962                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3963
3964                std::task::Poll::Ready(Some(match header.ordinal {
3965                    0x39096d97ed03335f => {
3966                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3967                        let mut req = fidl::new_empty!(
3968                            SampleSinkOnSampleReadiedRequest,
3969                            fidl::encoding::DefaultFuchsiaResourceDialect
3970                        );
3971                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SampleSinkOnSampleReadiedRequest>(&header, _body_bytes, handles, &mut req)?;
3972                        let control_handle = SampleSinkControlHandle { inner: this.inner.clone() };
3973                        Ok(SampleSinkRequest::OnSampleReadied { event: req.event, control_handle })
3974                    }
3975                    _ if header.tx_id == 0
3976                        && header
3977                            .dynamic_flags()
3978                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3979                    {
3980                        Ok(SampleSinkRequest::_UnknownMethod {
3981                            ordinal: header.ordinal,
3982                            control_handle: SampleSinkControlHandle { inner: this.inner.clone() },
3983                            method_type: fidl::MethodType::OneWay,
3984                        })
3985                    }
3986                    _ if header
3987                        .dynamic_flags()
3988                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3989                    {
3990                        this.inner.send_framework_err(
3991                            fidl::encoding::FrameworkErr::UnknownMethod,
3992                            header.tx_id,
3993                            header.ordinal,
3994                            header.dynamic_flags(),
3995                            (bytes, handles),
3996                        )?;
3997                        Ok(SampleSinkRequest::_UnknownMethod {
3998                            ordinal: header.ordinal,
3999                            control_handle: SampleSinkControlHandle { inner: this.inner.clone() },
4000                            method_type: fidl::MethodType::TwoWay,
4001                        })
4002                    }
4003                    _ => Err(fidl::Error::UnknownOrdinal {
4004                        ordinal: header.ordinal,
4005                        protocol_name:
4006                            <SampleSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4007                    }),
4008                }))
4009            },
4010        )
4011    }
4012}
4013
4014/// `SampleSink` is served by the client, in order to be notified when samples
4015/// are ready.
4016#[derive(Debug)]
4017pub enum SampleSinkRequest {
4018    OnSampleReadied {
4019        event: SampleSinkResult,
4020        control_handle: SampleSinkControlHandle,
4021    },
4022    /// An interaction was received which does not match any known method.
4023    #[non_exhaustive]
4024    _UnknownMethod {
4025        /// Ordinal of the method that was called.
4026        ordinal: u64,
4027        control_handle: SampleSinkControlHandle,
4028        method_type: fidl::MethodType,
4029    },
4030}
4031
4032impl SampleSinkRequest {
4033    #[allow(irrefutable_let_patterns)]
4034    pub fn into_on_sample_readied(self) -> Option<(SampleSinkResult, SampleSinkControlHandle)> {
4035        if let SampleSinkRequest::OnSampleReadied { event, control_handle } = self {
4036            Some((event, control_handle))
4037        } else {
4038            None
4039        }
4040    }
4041
4042    /// Name of the method defined in FIDL
4043    pub fn method_name(&self) -> &'static str {
4044        match *self {
4045            SampleSinkRequest::OnSampleReadied { .. } => "on_sample_readied",
4046            SampleSinkRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
4047                "unknown one-way method"
4048            }
4049            SampleSinkRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
4050                "unknown two-way method"
4051            }
4052        }
4053    }
4054}
4055
4056#[derive(Debug, Clone)]
4057pub struct SampleSinkControlHandle {
4058    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4059}
4060
4061impl fidl::endpoints::ControlHandle for SampleSinkControlHandle {
4062    fn shutdown(&self) {
4063        self.inner.shutdown()
4064    }
4065
4066    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4067        self.inner.shutdown_with_epitaph(status)
4068    }
4069
4070    fn is_closed(&self) -> bool {
4071        self.inner.channel().is_closed()
4072    }
4073    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4074        self.inner.channel().on_closed()
4075    }
4076
4077    #[cfg(target_os = "fuchsia")]
4078    fn signal_peer(
4079        &self,
4080        clear_mask: zx::Signals,
4081        set_mask: zx::Signals,
4082    ) -> Result<(), zx_status::Status> {
4083        use fidl::Peered;
4084        self.inner.channel().signal_peer(clear_mask, set_mask)
4085    }
4086}
4087
4088impl SampleSinkControlHandle {
4089    pub fn send_on_now_or_never(&self) -> Result<(), fidl::Error> {
4090        self.inner.send::<fidl::encoding::EmptyPayload>(
4091            (),
4092            0,
4093            0x3dc94ca1e1290894,
4094            fidl::encoding::DynamicFlags::FLEXIBLE,
4095        )
4096    }
4097}
4098
4099mod internal {
4100    use super::*;
4101
4102    impl fidl::encoding::ResourceTypeMarker for ArchiveAccessorStreamDiagnosticsRequest {
4103        type Borrowed<'a> = &'a mut Self;
4104        fn take_or_borrow<'a>(
4105            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4106        ) -> Self::Borrowed<'a> {
4107            value
4108        }
4109    }
4110
4111    unsafe impl fidl::encoding::TypeMarker for ArchiveAccessorStreamDiagnosticsRequest {
4112        type Owned = Self;
4113
4114        #[inline(always)]
4115        fn inline_align(_context: fidl::encoding::Context) -> usize {
4116            8
4117        }
4118
4119        #[inline(always)]
4120        fn inline_size(_context: fidl::encoding::Context) -> usize {
4121            24
4122        }
4123    }
4124
4125    unsafe impl
4126        fidl::encoding::Encode<
4127            ArchiveAccessorStreamDiagnosticsRequest,
4128            fidl::encoding::DefaultFuchsiaResourceDialect,
4129        > for &mut ArchiveAccessorStreamDiagnosticsRequest
4130    {
4131        #[inline]
4132        unsafe fn encode(
4133            self,
4134            encoder: &mut fidl::encoding::Encoder<
4135                '_,
4136                fidl::encoding::DefaultFuchsiaResourceDialect,
4137            >,
4138            offset: usize,
4139            _depth: fidl::encoding::Depth,
4140        ) -> fidl::Result<()> {
4141            encoder.debug_check_bounds::<ArchiveAccessorStreamDiagnosticsRequest>(offset);
4142            // Delegate to tuple encoding.
4143            fidl::encoding::Encode::<ArchiveAccessorStreamDiagnosticsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4144                (
4145                    <StreamParameters as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_parameters),
4146                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BatchIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.result_stream),
4147                ),
4148                encoder, offset, _depth
4149            )
4150        }
4151    }
4152    unsafe impl<
4153        T0: fidl::encoding::Encode<StreamParameters, fidl::encoding::DefaultFuchsiaResourceDialect>,
4154        T1: fidl::encoding::Encode<
4155                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BatchIteratorMarker>>,
4156                fidl::encoding::DefaultFuchsiaResourceDialect,
4157            >,
4158    >
4159        fidl::encoding::Encode<
4160            ArchiveAccessorStreamDiagnosticsRequest,
4161            fidl::encoding::DefaultFuchsiaResourceDialect,
4162        > for (T0, T1)
4163    {
4164        #[inline]
4165        unsafe fn encode(
4166            self,
4167            encoder: &mut fidl::encoding::Encoder<
4168                '_,
4169                fidl::encoding::DefaultFuchsiaResourceDialect,
4170            >,
4171            offset: usize,
4172            depth: fidl::encoding::Depth,
4173        ) -> fidl::Result<()> {
4174            encoder.debug_check_bounds::<ArchiveAccessorStreamDiagnosticsRequest>(offset);
4175            // Zero out padding regions. There's no need to apply masks
4176            // because the unmasked parts will be overwritten by fields.
4177            unsafe {
4178                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
4179                (ptr as *mut u64).write_unaligned(0);
4180            }
4181            // Write the fields.
4182            self.0.encode(encoder, offset + 0, depth)?;
4183            self.1.encode(encoder, offset + 16, depth)?;
4184            Ok(())
4185        }
4186    }
4187
4188    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4189        for ArchiveAccessorStreamDiagnosticsRequest
4190    {
4191        #[inline(always)]
4192        fn new_empty() -> Self {
4193            Self {
4194                stream_parameters: fidl::new_empty!(
4195                    StreamParameters,
4196                    fidl::encoding::DefaultFuchsiaResourceDialect
4197                ),
4198                result_stream: fidl::new_empty!(
4199                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BatchIteratorMarker>>,
4200                    fidl::encoding::DefaultFuchsiaResourceDialect
4201                ),
4202            }
4203        }
4204
4205        #[inline]
4206        unsafe fn decode(
4207            &mut self,
4208            decoder: &mut fidl::encoding::Decoder<
4209                '_,
4210                fidl::encoding::DefaultFuchsiaResourceDialect,
4211            >,
4212            offset: usize,
4213            _depth: fidl::encoding::Depth,
4214        ) -> fidl::Result<()> {
4215            decoder.debug_check_bounds::<Self>(offset);
4216            // Verify that padding bytes are zero.
4217            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
4218            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4219            let mask = 0xffffffff00000000u64;
4220            let maskedval = padval & mask;
4221            if maskedval != 0 {
4222                return Err(fidl::Error::NonZeroPadding {
4223                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
4224                });
4225            }
4226            fidl::decode!(
4227                StreamParameters,
4228                fidl::encoding::DefaultFuchsiaResourceDialect,
4229                &mut self.stream_parameters,
4230                decoder,
4231                offset + 0,
4232                _depth
4233            )?;
4234            fidl::decode!(
4235                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BatchIteratorMarker>>,
4236                fidl::encoding::DefaultFuchsiaResourceDialect,
4237                &mut self.result_stream,
4238                decoder,
4239                offset + 16,
4240                _depth
4241            )?;
4242            Ok(())
4243        }
4244    }
4245
4246    impl fidl::encoding::ResourceTypeMarker for BatchIteratorGetNextResponse {
4247        type Borrowed<'a> = &'a mut Self;
4248        fn take_or_borrow<'a>(
4249            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4250        ) -> Self::Borrowed<'a> {
4251            value
4252        }
4253    }
4254
4255    unsafe impl fidl::encoding::TypeMarker for BatchIteratorGetNextResponse {
4256        type Owned = Self;
4257
4258        #[inline(always)]
4259        fn inline_align(_context: fidl::encoding::Context) -> usize {
4260            8
4261        }
4262
4263        #[inline(always)]
4264        fn inline_size(_context: fidl::encoding::Context) -> usize {
4265            16
4266        }
4267    }
4268
4269    unsafe impl
4270        fidl::encoding::Encode<
4271            BatchIteratorGetNextResponse,
4272            fidl::encoding::DefaultFuchsiaResourceDialect,
4273        > for &mut BatchIteratorGetNextResponse
4274    {
4275        #[inline]
4276        unsafe fn encode(
4277            self,
4278            encoder: &mut fidl::encoding::Encoder<
4279                '_,
4280                fidl::encoding::DefaultFuchsiaResourceDialect,
4281            >,
4282            offset: usize,
4283            _depth: fidl::encoding::Depth,
4284        ) -> fidl::Result<()> {
4285            encoder.debug_check_bounds::<BatchIteratorGetNextResponse>(offset);
4286            // Delegate to tuple encoding.
4287            fidl::encoding::Encode::<BatchIteratorGetNextResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4288                (
4289                    <fidl::encoding::Vector<FormattedContent, 64> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.batch),
4290                ),
4291                encoder, offset, _depth
4292            )
4293        }
4294    }
4295    unsafe impl<
4296        T0: fidl::encoding::Encode<
4297                fidl::encoding::Vector<FormattedContent, 64>,
4298                fidl::encoding::DefaultFuchsiaResourceDialect,
4299            >,
4300    >
4301        fidl::encoding::Encode<
4302            BatchIteratorGetNextResponse,
4303            fidl::encoding::DefaultFuchsiaResourceDialect,
4304        > for (T0,)
4305    {
4306        #[inline]
4307        unsafe fn encode(
4308            self,
4309            encoder: &mut fidl::encoding::Encoder<
4310                '_,
4311                fidl::encoding::DefaultFuchsiaResourceDialect,
4312            >,
4313            offset: usize,
4314            depth: fidl::encoding::Depth,
4315        ) -> fidl::Result<()> {
4316            encoder.debug_check_bounds::<BatchIteratorGetNextResponse>(offset);
4317            // Zero out padding regions. There's no need to apply masks
4318            // because the unmasked parts will be overwritten by fields.
4319            // Write the fields.
4320            self.0.encode(encoder, offset + 0, depth)?;
4321            Ok(())
4322        }
4323    }
4324
4325    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4326        for BatchIteratorGetNextResponse
4327    {
4328        #[inline(always)]
4329        fn new_empty() -> Self {
4330            Self {
4331                batch: fidl::new_empty!(fidl::encoding::Vector<FormattedContent, 64>, fidl::encoding::DefaultFuchsiaResourceDialect),
4332            }
4333        }
4334
4335        #[inline]
4336        unsafe fn decode(
4337            &mut self,
4338            decoder: &mut fidl::encoding::Decoder<
4339                '_,
4340                fidl::encoding::DefaultFuchsiaResourceDialect,
4341            >,
4342            offset: usize,
4343            _depth: fidl::encoding::Depth,
4344        ) -> fidl::Result<()> {
4345            decoder.debug_check_bounds::<Self>(offset);
4346            // Verify that padding bytes are zero.
4347            fidl::decode!(fidl::encoding::Vector<FormattedContent, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.batch, decoder, offset + 0, _depth)?;
4348            Ok(())
4349        }
4350    }
4351
4352    impl fidl::encoding::ResourceTypeMarker for LogStreamConnectRequest {
4353        type Borrowed<'a> = &'a mut Self;
4354        fn take_or_borrow<'a>(
4355            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4356        ) -> Self::Borrowed<'a> {
4357            value
4358        }
4359    }
4360
4361    unsafe impl fidl::encoding::TypeMarker for LogStreamConnectRequest {
4362        type Owned = Self;
4363
4364        #[inline(always)]
4365        fn inline_align(_context: fidl::encoding::Context) -> usize {
4366            8
4367        }
4368
4369        #[inline(always)]
4370        fn inline_size(_context: fidl::encoding::Context) -> usize {
4371            24
4372        }
4373    }
4374
4375    unsafe impl
4376        fidl::encoding::Encode<
4377            LogStreamConnectRequest,
4378            fidl::encoding::DefaultFuchsiaResourceDialect,
4379        > for &mut LogStreamConnectRequest
4380    {
4381        #[inline]
4382        unsafe fn encode(
4383            self,
4384            encoder: &mut fidl::encoding::Encoder<
4385                '_,
4386                fidl::encoding::DefaultFuchsiaResourceDialect,
4387            >,
4388            offset: usize,
4389            _depth: fidl::encoding::Depth,
4390        ) -> fidl::Result<()> {
4391            encoder.debug_check_bounds::<LogStreamConnectRequest>(offset);
4392            // Delegate to tuple encoding.
4393            fidl::encoding::Encode::<
4394                LogStreamConnectRequest,
4395                fidl::encoding::DefaultFuchsiaResourceDialect,
4396            >::encode(
4397                (
4398                    <fidl::encoding::HandleType<
4399                        fidl::Socket,
4400                        { fidl::ObjectType::SOCKET.into_raw() },
4401                        16392,
4402                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4403                        &mut self.socket
4404                    ),
4405                    <LogStreamOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.opts),
4406                ),
4407                encoder,
4408                offset,
4409                _depth,
4410            )
4411        }
4412    }
4413    unsafe impl<
4414        T0: fidl::encoding::Encode<
4415                fidl::encoding::HandleType<
4416                    fidl::Socket,
4417                    { fidl::ObjectType::SOCKET.into_raw() },
4418                    16392,
4419                >,
4420                fidl::encoding::DefaultFuchsiaResourceDialect,
4421            >,
4422        T1: fidl::encoding::Encode<LogStreamOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
4423    >
4424        fidl::encoding::Encode<
4425            LogStreamConnectRequest,
4426            fidl::encoding::DefaultFuchsiaResourceDialect,
4427        > for (T0, T1)
4428    {
4429        #[inline]
4430        unsafe fn encode(
4431            self,
4432            encoder: &mut fidl::encoding::Encoder<
4433                '_,
4434                fidl::encoding::DefaultFuchsiaResourceDialect,
4435            >,
4436            offset: usize,
4437            depth: fidl::encoding::Depth,
4438        ) -> fidl::Result<()> {
4439            encoder.debug_check_bounds::<LogStreamConnectRequest>(offset);
4440            // Zero out padding regions. There's no need to apply masks
4441            // because the unmasked parts will be overwritten by fields.
4442            unsafe {
4443                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
4444                (ptr as *mut u64).write_unaligned(0);
4445            }
4446            // Write the fields.
4447            self.0.encode(encoder, offset + 0, depth)?;
4448            self.1.encode(encoder, offset + 8, depth)?;
4449            Ok(())
4450        }
4451    }
4452
4453    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4454        for LogStreamConnectRequest
4455    {
4456        #[inline(always)]
4457        fn new_empty() -> Self {
4458            Self {
4459                socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 16392>, fidl::encoding::DefaultFuchsiaResourceDialect),
4460                opts: fidl::new_empty!(
4461                    LogStreamOptions,
4462                    fidl::encoding::DefaultFuchsiaResourceDialect
4463                ),
4464            }
4465        }
4466
4467        #[inline]
4468        unsafe fn decode(
4469            &mut self,
4470            decoder: &mut fidl::encoding::Decoder<
4471                '_,
4472                fidl::encoding::DefaultFuchsiaResourceDialect,
4473            >,
4474            offset: usize,
4475            _depth: fidl::encoding::Depth,
4476        ) -> fidl::Result<()> {
4477            decoder.debug_check_bounds::<Self>(offset);
4478            // Verify that padding bytes are zero.
4479            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
4480            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4481            let mask = 0xffffffff00000000u64;
4482            let maskedval = padval & mask;
4483            if maskedval != 0 {
4484                return Err(fidl::Error::NonZeroPadding {
4485                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
4486                });
4487            }
4488            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 16392>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.socket, decoder, offset + 0, _depth)?;
4489            fidl::decode!(
4490                LogStreamOptions,
4491                fidl::encoding::DefaultFuchsiaResourceDialect,
4492                &mut self.opts,
4493                decoder,
4494                offset + 8,
4495                _depth
4496            )?;
4497            Ok(())
4498        }
4499    }
4500
4501    impl fidl::encoding::ResourceTypeMarker for SampleCommitRequest {
4502        type Borrowed<'a> = &'a mut Self;
4503        fn take_or_borrow<'a>(
4504            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4505        ) -> Self::Borrowed<'a> {
4506            value
4507        }
4508    }
4509
4510    unsafe impl fidl::encoding::TypeMarker for SampleCommitRequest {
4511        type Owned = Self;
4512
4513        #[inline(always)]
4514        fn inline_align(_context: fidl::encoding::Context) -> usize {
4515            4
4516        }
4517
4518        #[inline(always)]
4519        fn inline_size(_context: fidl::encoding::Context) -> usize {
4520            4
4521        }
4522    }
4523
4524    unsafe impl
4525        fidl::encoding::Encode<SampleCommitRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4526        for &mut SampleCommitRequest
4527    {
4528        #[inline]
4529        unsafe fn encode(
4530            self,
4531            encoder: &mut fidl::encoding::Encoder<
4532                '_,
4533                fidl::encoding::DefaultFuchsiaResourceDialect,
4534            >,
4535            offset: usize,
4536            _depth: fidl::encoding::Depth,
4537        ) -> fidl::Result<()> {
4538            encoder.debug_check_bounds::<SampleCommitRequest>(offset);
4539            // Delegate to tuple encoding.
4540            fidl::encoding::Encode::<SampleCommitRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4541                (
4542                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SampleSinkMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.sink),
4543                ),
4544                encoder, offset, _depth
4545            )
4546        }
4547    }
4548    unsafe impl<
4549        T0: fidl::encoding::Encode<
4550                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SampleSinkMarker>>,
4551                fidl::encoding::DefaultFuchsiaResourceDialect,
4552            >,
4553    > fidl::encoding::Encode<SampleCommitRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4554        for (T0,)
4555    {
4556        #[inline]
4557        unsafe fn encode(
4558            self,
4559            encoder: &mut fidl::encoding::Encoder<
4560                '_,
4561                fidl::encoding::DefaultFuchsiaResourceDialect,
4562            >,
4563            offset: usize,
4564            depth: fidl::encoding::Depth,
4565        ) -> fidl::Result<()> {
4566            encoder.debug_check_bounds::<SampleCommitRequest>(offset);
4567            // Zero out padding regions. There's no need to apply masks
4568            // because the unmasked parts will be overwritten by fields.
4569            // Write the fields.
4570            self.0.encode(encoder, offset + 0, depth)?;
4571            Ok(())
4572        }
4573    }
4574
4575    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4576        for SampleCommitRequest
4577    {
4578        #[inline(always)]
4579        fn new_empty() -> Self {
4580            Self {
4581                sink: fidl::new_empty!(
4582                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SampleSinkMarker>>,
4583                    fidl::encoding::DefaultFuchsiaResourceDialect
4584                ),
4585            }
4586        }
4587
4588        #[inline]
4589        unsafe fn decode(
4590            &mut self,
4591            decoder: &mut fidl::encoding::Decoder<
4592                '_,
4593                fidl::encoding::DefaultFuchsiaResourceDialect,
4594            >,
4595            offset: usize,
4596            _depth: fidl::encoding::Depth,
4597        ) -> fidl::Result<()> {
4598            decoder.debug_check_bounds::<Self>(offset);
4599            // Verify that padding bytes are zero.
4600            fidl::decode!(
4601                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SampleSinkMarker>>,
4602                fidl::encoding::DefaultFuchsiaResourceDialect,
4603                &mut self.sink,
4604                decoder,
4605                offset + 0,
4606                _depth
4607            )?;
4608            Ok(())
4609        }
4610    }
4611
4612    impl fidl::encoding::ResourceTypeMarker for SampleSetRequest {
4613        type Borrowed<'a> = &'a mut Self;
4614        fn take_or_borrow<'a>(
4615            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4616        ) -> Self::Borrowed<'a> {
4617            value
4618        }
4619    }
4620
4621    unsafe impl fidl::encoding::TypeMarker for SampleSetRequest {
4622        type Owned = Self;
4623
4624        #[inline(always)]
4625        fn inline_align(_context: fidl::encoding::Context) -> usize {
4626            8
4627        }
4628
4629        #[inline(always)]
4630        fn inline_size(_context: fidl::encoding::Context) -> usize {
4631            16
4632        }
4633    }
4634
4635    unsafe impl
4636        fidl::encoding::Encode<SampleSetRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4637        for &mut SampleSetRequest
4638    {
4639        #[inline]
4640        unsafe fn encode(
4641            self,
4642            encoder: &mut fidl::encoding::Encoder<
4643                '_,
4644                fidl::encoding::DefaultFuchsiaResourceDialect,
4645            >,
4646            offset: usize,
4647            _depth: fidl::encoding::Depth,
4648        ) -> fidl::Result<()> {
4649            encoder.debug_check_bounds::<SampleSetRequest>(offset);
4650            // Delegate to tuple encoding.
4651            fidl::encoding::Encode::<SampleSetRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4652                (
4653                    <SampleParameters as fidl::encoding::ValueTypeMarker>::borrow(&self.sample_parameters),
4654                ),
4655                encoder, offset, _depth
4656            )
4657        }
4658    }
4659    unsafe impl<
4660        T0: fidl::encoding::Encode<SampleParameters, fidl::encoding::DefaultFuchsiaResourceDialect>,
4661    > fidl::encoding::Encode<SampleSetRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4662        for (T0,)
4663    {
4664        #[inline]
4665        unsafe fn encode(
4666            self,
4667            encoder: &mut fidl::encoding::Encoder<
4668                '_,
4669                fidl::encoding::DefaultFuchsiaResourceDialect,
4670            >,
4671            offset: usize,
4672            depth: fidl::encoding::Depth,
4673        ) -> fidl::Result<()> {
4674            encoder.debug_check_bounds::<SampleSetRequest>(offset);
4675            // Zero out padding regions. There's no need to apply masks
4676            // because the unmasked parts will be overwritten by fields.
4677            // Write the fields.
4678            self.0.encode(encoder, offset + 0, depth)?;
4679            Ok(())
4680        }
4681    }
4682
4683    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4684        for SampleSetRequest
4685    {
4686        #[inline(always)]
4687        fn new_empty() -> Self {
4688            Self {
4689                sample_parameters: fidl::new_empty!(
4690                    SampleParameters,
4691                    fidl::encoding::DefaultFuchsiaResourceDialect
4692                ),
4693            }
4694        }
4695
4696        #[inline]
4697        unsafe fn decode(
4698            &mut self,
4699            decoder: &mut fidl::encoding::Decoder<
4700                '_,
4701                fidl::encoding::DefaultFuchsiaResourceDialect,
4702            >,
4703            offset: usize,
4704            _depth: fidl::encoding::Depth,
4705        ) -> fidl::Result<()> {
4706            decoder.debug_check_bounds::<Self>(offset);
4707            // Verify that padding bytes are zero.
4708            fidl::decode!(
4709                SampleParameters,
4710                fidl::encoding::DefaultFuchsiaResourceDialect,
4711                &mut self.sample_parameters,
4712                decoder,
4713                offset + 0,
4714                _depth
4715            )?;
4716            Ok(())
4717        }
4718    }
4719
4720    impl fidl::encoding::ResourceTypeMarker for SampleSinkOnSampleReadiedRequest {
4721        type Borrowed<'a> = &'a mut Self;
4722        fn take_or_borrow<'a>(
4723            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4724        ) -> Self::Borrowed<'a> {
4725            value
4726        }
4727    }
4728
4729    unsafe impl fidl::encoding::TypeMarker for SampleSinkOnSampleReadiedRequest {
4730        type Owned = Self;
4731
4732        #[inline(always)]
4733        fn inline_align(_context: fidl::encoding::Context) -> usize {
4734            8
4735        }
4736
4737        #[inline(always)]
4738        fn inline_size(_context: fidl::encoding::Context) -> usize {
4739            16
4740        }
4741    }
4742
4743    unsafe impl
4744        fidl::encoding::Encode<
4745            SampleSinkOnSampleReadiedRequest,
4746            fidl::encoding::DefaultFuchsiaResourceDialect,
4747        > for &mut SampleSinkOnSampleReadiedRequest
4748    {
4749        #[inline]
4750        unsafe fn encode(
4751            self,
4752            encoder: &mut fidl::encoding::Encoder<
4753                '_,
4754                fidl::encoding::DefaultFuchsiaResourceDialect,
4755            >,
4756            offset: usize,
4757            _depth: fidl::encoding::Depth,
4758        ) -> fidl::Result<()> {
4759            encoder.debug_check_bounds::<SampleSinkOnSampleReadiedRequest>(offset);
4760            // Delegate to tuple encoding.
4761            fidl::encoding::Encode::<
4762                SampleSinkOnSampleReadiedRequest,
4763                fidl::encoding::DefaultFuchsiaResourceDialect,
4764            >::encode(
4765                (<SampleSinkResult as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4766                    &mut self.event,
4767                ),),
4768                encoder,
4769                offset,
4770                _depth,
4771            )
4772        }
4773    }
4774    unsafe impl<
4775        T0: fidl::encoding::Encode<SampleSinkResult, fidl::encoding::DefaultFuchsiaResourceDialect>,
4776    >
4777        fidl::encoding::Encode<
4778            SampleSinkOnSampleReadiedRequest,
4779            fidl::encoding::DefaultFuchsiaResourceDialect,
4780        > for (T0,)
4781    {
4782        #[inline]
4783        unsafe fn encode(
4784            self,
4785            encoder: &mut fidl::encoding::Encoder<
4786                '_,
4787                fidl::encoding::DefaultFuchsiaResourceDialect,
4788            >,
4789            offset: usize,
4790            depth: fidl::encoding::Depth,
4791        ) -> fidl::Result<()> {
4792            encoder.debug_check_bounds::<SampleSinkOnSampleReadiedRequest>(offset);
4793            // Zero out padding regions. There's no need to apply masks
4794            // because the unmasked parts will be overwritten by fields.
4795            // Write the fields.
4796            self.0.encode(encoder, offset + 0, depth)?;
4797            Ok(())
4798        }
4799    }
4800
4801    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4802        for SampleSinkOnSampleReadiedRequest
4803    {
4804        #[inline(always)]
4805        fn new_empty() -> Self {
4806            Self {
4807                event: fidl::new_empty!(
4808                    SampleSinkResult,
4809                    fidl::encoding::DefaultFuchsiaResourceDialect
4810                ),
4811            }
4812        }
4813
4814        #[inline]
4815        unsafe fn decode(
4816            &mut self,
4817            decoder: &mut fidl::encoding::Decoder<
4818                '_,
4819                fidl::encoding::DefaultFuchsiaResourceDialect,
4820            >,
4821            offset: usize,
4822            _depth: fidl::encoding::Depth,
4823        ) -> fidl::Result<()> {
4824            decoder.debug_check_bounds::<Self>(offset);
4825            // Verify that padding bytes are zero.
4826            fidl::decode!(
4827                SampleSinkResult,
4828                fidl::encoding::DefaultFuchsiaResourceDialect,
4829                &mut self.event,
4830                decoder,
4831                offset + 0,
4832                _depth
4833            )?;
4834            Ok(())
4835        }
4836    }
4837
4838    impl SampleReady {
4839        #[inline(always)]
4840        fn max_ordinal_present(&self) -> u64 {
4841            if let Some(_) = self.seconds_since_start {
4842                return 2;
4843            }
4844            if let Some(_) = self.batch_iter {
4845                return 1;
4846            }
4847            0
4848        }
4849    }
4850
4851    impl fidl::encoding::ResourceTypeMarker for SampleReady {
4852        type Borrowed<'a> = &'a mut Self;
4853        fn take_or_borrow<'a>(
4854            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4855        ) -> Self::Borrowed<'a> {
4856            value
4857        }
4858    }
4859
4860    unsafe impl fidl::encoding::TypeMarker for SampleReady {
4861        type Owned = Self;
4862
4863        #[inline(always)]
4864        fn inline_align(_context: fidl::encoding::Context) -> usize {
4865            8
4866        }
4867
4868        #[inline(always)]
4869        fn inline_size(_context: fidl::encoding::Context) -> usize {
4870            16
4871        }
4872    }
4873
4874    unsafe impl fidl::encoding::Encode<SampleReady, fidl::encoding::DefaultFuchsiaResourceDialect>
4875        for &mut SampleReady
4876    {
4877        unsafe fn encode(
4878            self,
4879            encoder: &mut fidl::encoding::Encoder<
4880                '_,
4881                fidl::encoding::DefaultFuchsiaResourceDialect,
4882            >,
4883            offset: usize,
4884            mut depth: fidl::encoding::Depth,
4885        ) -> fidl::Result<()> {
4886            encoder.debug_check_bounds::<SampleReady>(offset);
4887            // Vector header
4888            let max_ordinal: u64 = self.max_ordinal_present();
4889            encoder.write_num(max_ordinal, offset);
4890            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4891            // Calling encoder.out_of_line_offset(0) is not allowed.
4892            if max_ordinal == 0 {
4893                return Ok(());
4894            }
4895            depth.increment()?;
4896            let envelope_size = 8;
4897            let bytes_len = max_ordinal as usize * envelope_size;
4898            #[allow(unused_variables)]
4899            let offset = encoder.out_of_line_offset(bytes_len);
4900            let mut _prev_end_offset: usize = 0;
4901            if 1 > max_ordinal {
4902                return Ok(());
4903            }
4904
4905            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4906            // are envelope_size bytes.
4907            let cur_offset: usize = (1 - 1) * envelope_size;
4908
4909            // Zero reserved fields.
4910            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4911
4912            // Safety:
4913            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4914            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4915            //   envelope_size bytes, there is always sufficient room.
4916            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BatchIteratorMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
4917            self.batch_iter.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BatchIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4918            encoder, offset + cur_offset, depth
4919        )?;
4920
4921            _prev_end_offset = cur_offset + envelope_size;
4922            if 2 > max_ordinal {
4923                return Ok(());
4924            }
4925
4926            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4927            // are envelope_size bytes.
4928            let cur_offset: usize = (2 - 1) * envelope_size;
4929
4930            // Zero reserved fields.
4931            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4932
4933            // Safety:
4934            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4935            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4936            //   envelope_size bytes, there is always sufficient room.
4937            fidl::encoding::encode_in_envelope_optional::<
4938                i64,
4939                fidl::encoding::DefaultFuchsiaResourceDialect,
4940            >(
4941                self.seconds_since_start
4942                    .as_ref()
4943                    .map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
4944                encoder,
4945                offset + cur_offset,
4946                depth,
4947            )?;
4948
4949            _prev_end_offset = cur_offset + envelope_size;
4950
4951            Ok(())
4952        }
4953    }
4954
4955    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for SampleReady {
4956        #[inline(always)]
4957        fn new_empty() -> Self {
4958            Self::default()
4959        }
4960
4961        unsafe fn decode(
4962            &mut self,
4963            decoder: &mut fidl::encoding::Decoder<
4964                '_,
4965                fidl::encoding::DefaultFuchsiaResourceDialect,
4966            >,
4967            offset: usize,
4968            mut depth: fidl::encoding::Depth,
4969        ) -> fidl::Result<()> {
4970            decoder.debug_check_bounds::<Self>(offset);
4971            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4972                None => return Err(fidl::Error::NotNullable),
4973                Some(len) => len,
4974            };
4975            // Calling decoder.out_of_line_offset(0) is not allowed.
4976            if len == 0 {
4977                return Ok(());
4978            };
4979            depth.increment()?;
4980            let envelope_size = 8;
4981            let bytes_len = len * envelope_size;
4982            let offset = decoder.out_of_line_offset(bytes_len)?;
4983            // Decode the envelope for each type.
4984            let mut _next_ordinal_to_read = 0;
4985            let mut next_offset = offset;
4986            let end_offset = offset + bytes_len;
4987            _next_ordinal_to_read += 1;
4988            if next_offset >= end_offset {
4989                return Ok(());
4990            }
4991
4992            // Decode unknown envelopes for gaps in ordinals.
4993            while _next_ordinal_to_read < 1 {
4994                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4995                _next_ordinal_to_read += 1;
4996                next_offset += envelope_size;
4997            }
4998
4999            let next_out_of_line = decoder.next_out_of_line();
5000            let handles_before = decoder.remaining_handles();
5001            if let Some((inlined, num_bytes, num_handles)) =
5002                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5003            {
5004                let member_inline_size = <fidl::encoding::Endpoint<
5005                    fidl::endpoints::ClientEnd<BatchIteratorMarker>,
5006                > as fidl::encoding::TypeMarker>::inline_size(
5007                    decoder.context
5008                );
5009                if inlined != (member_inline_size <= 4) {
5010                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5011                }
5012                let inner_offset;
5013                let mut inner_depth = depth.clone();
5014                if inlined {
5015                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5016                    inner_offset = next_offset;
5017                } else {
5018                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5019                    inner_depth.increment()?;
5020                }
5021                let val_ref = self.batch_iter.get_or_insert_with(|| {
5022                    fidl::new_empty!(
5023                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BatchIteratorMarker>>,
5024                        fidl::encoding::DefaultFuchsiaResourceDialect
5025                    )
5026                });
5027                fidl::decode!(
5028                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BatchIteratorMarker>>,
5029                    fidl::encoding::DefaultFuchsiaResourceDialect,
5030                    val_ref,
5031                    decoder,
5032                    inner_offset,
5033                    inner_depth
5034                )?;
5035                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5036                {
5037                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5038                }
5039                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5040                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5041                }
5042            }
5043
5044            next_offset += envelope_size;
5045            _next_ordinal_to_read += 1;
5046            if next_offset >= end_offset {
5047                return Ok(());
5048            }
5049
5050            // Decode unknown envelopes for gaps in ordinals.
5051            while _next_ordinal_to_read < 2 {
5052                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5053                _next_ordinal_to_read += 1;
5054                next_offset += envelope_size;
5055            }
5056
5057            let next_out_of_line = decoder.next_out_of_line();
5058            let handles_before = decoder.remaining_handles();
5059            if let Some((inlined, num_bytes, num_handles)) =
5060                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5061            {
5062                let member_inline_size =
5063                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5064                if inlined != (member_inline_size <= 4) {
5065                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5066                }
5067                let inner_offset;
5068                let mut inner_depth = depth.clone();
5069                if inlined {
5070                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5071                    inner_offset = next_offset;
5072                } else {
5073                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5074                    inner_depth.increment()?;
5075                }
5076                let val_ref = self.seconds_since_start.get_or_insert_with(|| {
5077                    fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect)
5078                });
5079                fidl::decode!(
5080                    i64,
5081                    fidl::encoding::DefaultFuchsiaResourceDialect,
5082                    val_ref,
5083                    decoder,
5084                    inner_offset,
5085                    inner_depth
5086                )?;
5087                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5088                {
5089                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5090                }
5091                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5092                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5093                }
5094            }
5095
5096            next_offset += envelope_size;
5097
5098            // Decode the remaining unknown envelopes.
5099            while next_offset < end_offset {
5100                _next_ordinal_to_read += 1;
5101                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5102                next_offset += envelope_size;
5103            }
5104
5105            Ok(())
5106        }
5107    }
5108
5109    impl fidl::encoding::ResourceTypeMarker for FormattedContent {
5110        type Borrowed<'a> = &'a mut Self;
5111        fn take_or_borrow<'a>(
5112            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5113        ) -> Self::Borrowed<'a> {
5114            value
5115        }
5116    }
5117
5118    unsafe impl fidl::encoding::TypeMarker for FormattedContent {
5119        type Owned = Self;
5120
5121        #[inline(always)]
5122        fn inline_align(_context: fidl::encoding::Context) -> usize {
5123            8
5124        }
5125
5126        #[inline(always)]
5127        fn inline_size(_context: fidl::encoding::Context) -> usize {
5128            16
5129        }
5130    }
5131
5132    unsafe impl
5133        fidl::encoding::Encode<FormattedContent, fidl::encoding::DefaultFuchsiaResourceDialect>
5134        for &mut FormattedContent
5135    {
5136        #[inline]
5137        unsafe fn encode(
5138            self,
5139            encoder: &mut fidl::encoding::Encoder<
5140                '_,
5141                fidl::encoding::DefaultFuchsiaResourceDialect,
5142            >,
5143            offset: usize,
5144            _depth: fidl::encoding::Depth,
5145        ) -> fidl::Result<()> {
5146            encoder.debug_check_bounds::<FormattedContent>(offset);
5147            encoder.write_num::<u64>(self.ordinal(), offset);
5148            match self {
5149            FormattedContent::Json(ref mut val) => {
5150                fidl::encoding::encode_in_envelope::<fidl_fuchsia_mem::Buffer, fidl::encoding::DefaultFuchsiaResourceDialect>(
5151                    <fidl_fuchsia_mem::Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
5152                    encoder, offset + 8, _depth
5153                )
5154            }
5155            FormattedContent::Cbor(ref mut val) => {
5156                fidl::encoding::encode_in_envelope::<fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5157                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
5158                    encoder, offset + 8, _depth
5159                )
5160            }
5161            FormattedContent::Fxt(ref mut val) => {
5162                fidl::encoding::encode_in_envelope::<fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5163                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
5164                    encoder, offset + 8, _depth
5165                )
5166            }
5167            FormattedContent::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
5168        }
5169        }
5170    }
5171
5172    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5173        for FormattedContent
5174    {
5175        #[inline(always)]
5176        fn new_empty() -> Self {
5177            Self::__SourceBreaking { unknown_ordinal: 0 }
5178        }
5179
5180        #[inline]
5181        unsafe fn decode(
5182            &mut self,
5183            decoder: &mut fidl::encoding::Decoder<
5184                '_,
5185                fidl::encoding::DefaultFuchsiaResourceDialect,
5186            >,
5187            offset: usize,
5188            mut depth: fidl::encoding::Depth,
5189        ) -> fidl::Result<()> {
5190            decoder.debug_check_bounds::<Self>(offset);
5191            #[allow(unused_variables)]
5192            let next_out_of_line = decoder.next_out_of_line();
5193            let handles_before = decoder.remaining_handles();
5194            let (ordinal, inlined, num_bytes, num_handles) =
5195                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
5196
5197            let member_inline_size = match ordinal {
5198                1 => <fidl_fuchsia_mem::Buffer as fidl::encoding::TypeMarker>::inline_size(
5199                    decoder.context,
5200                ),
5201                3 => <fidl::encoding::HandleType<
5202                    fidl::Vmo,
5203                    { fidl::ObjectType::VMO.into_raw() },
5204                    2147483648,
5205                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5206                4 => <fidl::encoding::HandleType<
5207                    fidl::Vmo,
5208                    { fidl::ObjectType::VMO.into_raw() },
5209                    2147483648,
5210                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5211                0 => return Err(fidl::Error::UnknownUnionTag),
5212                _ => num_bytes as usize,
5213            };
5214
5215            if inlined != (member_inline_size <= 4) {
5216                return Err(fidl::Error::InvalidInlineBitInEnvelope);
5217            }
5218            let _inner_offset;
5219            if inlined {
5220                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
5221                _inner_offset = offset + 8;
5222            } else {
5223                depth.increment()?;
5224                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5225            }
5226            match ordinal {
5227                1 => {
5228                    #[allow(irrefutable_let_patterns)]
5229                    if let FormattedContent::Json(_) = self {
5230                        // Do nothing, read the value into the object
5231                    } else {
5232                        // Initialize `self` to the right variant
5233                        *self = FormattedContent::Json(fidl::new_empty!(
5234                            fidl_fuchsia_mem::Buffer,
5235                            fidl::encoding::DefaultFuchsiaResourceDialect
5236                        ));
5237                    }
5238                    #[allow(irrefutable_let_patterns)]
5239                    if let FormattedContent::Json(ref mut val) = self {
5240                        fidl::decode!(
5241                            fidl_fuchsia_mem::Buffer,
5242                            fidl::encoding::DefaultFuchsiaResourceDialect,
5243                            val,
5244                            decoder,
5245                            _inner_offset,
5246                            depth
5247                        )?;
5248                    } else {
5249                        unreachable!()
5250                    }
5251                }
5252                3 => {
5253                    #[allow(irrefutable_let_patterns)]
5254                    if let FormattedContent::Cbor(_) = self {
5255                        // Do nothing, read the value into the object
5256                    } else {
5257                        // Initialize `self` to the right variant
5258                        *self = FormattedContent::Cbor(
5259                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
5260                        );
5261                    }
5262                    #[allow(irrefutable_let_patterns)]
5263                    if let FormattedContent::Cbor(ref mut val) = self {
5264                        fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
5265                    } else {
5266                        unreachable!()
5267                    }
5268                }
5269                4 => {
5270                    #[allow(irrefutable_let_patterns)]
5271                    if let FormattedContent::Fxt(_) = self {
5272                        // Do nothing, read the value into the object
5273                    } else {
5274                        // Initialize `self` to the right variant
5275                        *self = FormattedContent::Fxt(
5276                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
5277                        );
5278                    }
5279                    #[allow(irrefutable_let_patterns)]
5280                    if let FormattedContent::Fxt(ref mut val) = self {
5281                        fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
5282                    } else {
5283                        unreachable!()
5284                    }
5285                }
5286                #[allow(deprecated)]
5287                ordinal => {
5288                    for _ in 0..num_handles {
5289                        decoder.drop_next_handle()?;
5290                    }
5291                    *self = FormattedContent::__SourceBreaking { unknown_ordinal: ordinal };
5292                }
5293            }
5294            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
5295                return Err(fidl::Error::InvalidNumBytesInEnvelope);
5296            }
5297            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5298                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5299            }
5300            Ok(())
5301        }
5302    }
5303
5304    impl fidl::encoding::ResourceTypeMarker for SampleSinkResult {
5305        type Borrowed<'a> = &'a mut Self;
5306        fn take_or_borrow<'a>(
5307            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5308        ) -> Self::Borrowed<'a> {
5309            value
5310        }
5311    }
5312
5313    unsafe impl fidl::encoding::TypeMarker for SampleSinkResult {
5314        type Owned = Self;
5315
5316        #[inline(always)]
5317        fn inline_align(_context: fidl::encoding::Context) -> usize {
5318            8
5319        }
5320
5321        #[inline(always)]
5322        fn inline_size(_context: fidl::encoding::Context) -> usize {
5323            16
5324        }
5325    }
5326
5327    unsafe impl
5328        fidl::encoding::Encode<SampleSinkResult, fidl::encoding::DefaultFuchsiaResourceDialect>
5329        for &mut SampleSinkResult
5330    {
5331        #[inline]
5332        unsafe fn encode(
5333            self,
5334            encoder: &mut fidl::encoding::Encoder<
5335                '_,
5336                fidl::encoding::DefaultFuchsiaResourceDialect,
5337            >,
5338            offset: usize,
5339            _depth: fidl::encoding::Depth,
5340        ) -> fidl::Result<()> {
5341            encoder.debug_check_bounds::<SampleSinkResult>(offset);
5342            encoder.write_num::<u64>(self.ordinal(), offset);
5343            match self {
5344                SampleSinkResult::Ready(ref mut val) => fidl::encoding::encode_in_envelope::<
5345                    SampleReady,
5346                    fidl::encoding::DefaultFuchsiaResourceDialect,
5347                >(
5348                    <SampleReady as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
5349                    encoder,
5350                    offset + 8,
5351                    _depth,
5352                ),
5353                SampleSinkResult::Error(ref val) => fidl::encoding::encode_in_envelope::<
5354                    RuntimeError,
5355                    fidl::encoding::DefaultFuchsiaResourceDialect,
5356                >(
5357                    <RuntimeError as fidl::encoding::ValueTypeMarker>::borrow(val),
5358                    encoder,
5359                    offset + 8,
5360                    _depth,
5361                ),
5362                SampleSinkResult::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
5363            }
5364        }
5365    }
5366
5367    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5368        for SampleSinkResult
5369    {
5370        #[inline(always)]
5371        fn new_empty() -> Self {
5372            Self::__SourceBreaking { unknown_ordinal: 0 }
5373        }
5374
5375        #[inline]
5376        unsafe fn decode(
5377            &mut self,
5378            decoder: &mut fidl::encoding::Decoder<
5379                '_,
5380                fidl::encoding::DefaultFuchsiaResourceDialect,
5381            >,
5382            offset: usize,
5383            mut depth: fidl::encoding::Depth,
5384        ) -> fidl::Result<()> {
5385            decoder.debug_check_bounds::<Self>(offset);
5386            #[allow(unused_variables)]
5387            let next_out_of_line = decoder.next_out_of_line();
5388            let handles_before = decoder.remaining_handles();
5389            let (ordinal, inlined, num_bytes, num_handles) =
5390                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
5391
5392            let member_inline_size = match ordinal {
5393                1 => <SampleReady as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5394                2 => <RuntimeError as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5395                0 => return Err(fidl::Error::UnknownUnionTag),
5396                _ => num_bytes as usize,
5397            };
5398
5399            if inlined != (member_inline_size <= 4) {
5400                return Err(fidl::Error::InvalidInlineBitInEnvelope);
5401            }
5402            let _inner_offset;
5403            if inlined {
5404                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
5405                _inner_offset = offset + 8;
5406            } else {
5407                depth.increment()?;
5408                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5409            }
5410            match ordinal {
5411                1 => {
5412                    #[allow(irrefutable_let_patterns)]
5413                    if let SampleSinkResult::Ready(_) = self {
5414                        // Do nothing, read the value into the object
5415                    } else {
5416                        // Initialize `self` to the right variant
5417                        *self = SampleSinkResult::Ready(fidl::new_empty!(
5418                            SampleReady,
5419                            fidl::encoding::DefaultFuchsiaResourceDialect
5420                        ));
5421                    }
5422                    #[allow(irrefutable_let_patterns)]
5423                    if let SampleSinkResult::Ready(ref mut val) = self {
5424                        fidl::decode!(
5425                            SampleReady,
5426                            fidl::encoding::DefaultFuchsiaResourceDialect,
5427                            val,
5428                            decoder,
5429                            _inner_offset,
5430                            depth
5431                        )?;
5432                    } else {
5433                        unreachable!()
5434                    }
5435                }
5436                2 => {
5437                    #[allow(irrefutable_let_patterns)]
5438                    if let SampleSinkResult::Error(_) = self {
5439                        // Do nothing, read the value into the object
5440                    } else {
5441                        // Initialize `self` to the right variant
5442                        *self = SampleSinkResult::Error(fidl::new_empty!(
5443                            RuntimeError,
5444                            fidl::encoding::DefaultFuchsiaResourceDialect
5445                        ));
5446                    }
5447                    #[allow(irrefutable_let_patterns)]
5448                    if let SampleSinkResult::Error(ref mut val) = self {
5449                        fidl::decode!(
5450                            RuntimeError,
5451                            fidl::encoding::DefaultFuchsiaResourceDialect,
5452                            val,
5453                            decoder,
5454                            _inner_offset,
5455                            depth
5456                        )?;
5457                    } else {
5458                        unreachable!()
5459                    }
5460                }
5461                #[allow(deprecated)]
5462                ordinal => {
5463                    for _ in 0..num_handles {
5464                        decoder.drop_next_handle()?;
5465                    }
5466                    *self = SampleSinkResult::__SourceBreaking { unknown_ordinal: ordinal };
5467                }
5468            }
5469            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
5470                return Err(fidl::Error::InvalidNumBytesInEnvelope);
5471            }
5472            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5473                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5474            }
5475            Ok(())
5476        }
5477    }
5478}