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