Skip to main content

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