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