Skip to main content

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