fidl_fuchsia_diagnostics/
fidl_fuchsia_diagnostics.rs

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