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 Datagram socket handle that can be written to.
2174    ///
2175    /// Logs will be written in the original FXT format with two additional
2176    /// arguments appended at the end of the record depending on the options
2177    /// passed:
2178    ///
2179    ///     - `$__moniker`: the moniker of the component that emitted the log.
2180    ///     - `$__url`: the URL of the component that emitted the log.
2181    ///     - `$__rolled_out`: the number of logs that were rolled out from the
2182    ///       buffer before this one.
2183    pub fn r#connect(
2184        &self,
2185        mut socket: fdomain_client::Socket,
2186        mut opts: &LogStreamOptions,
2187    ) -> Result<(), fidl::Error> {
2188        LogStreamProxyInterface::r#connect(self, socket, opts)
2189    }
2190}
2191
2192impl LogStreamProxyInterface for LogStreamProxy {
2193    fn r#connect(
2194        &self,
2195        mut socket: fdomain_client::Socket,
2196        mut opts: &LogStreamOptions,
2197    ) -> Result<(), fidl::Error> {
2198        self.client.send::<LogStreamConnectRequest>(
2199            (socket, opts),
2200            0x745eb34f10d51a88,
2201            fidl::encoding::DynamicFlags::FLEXIBLE,
2202        )
2203    }
2204}
2205
2206pub struct LogStreamEventStream {
2207    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
2208}
2209
2210impl std::marker::Unpin for LogStreamEventStream {}
2211
2212impl futures::stream::FusedStream for LogStreamEventStream {
2213    fn is_terminated(&self) -> bool {
2214        self.event_receiver.is_terminated()
2215    }
2216}
2217
2218impl futures::Stream for LogStreamEventStream {
2219    type Item = Result<LogStreamEvent, fidl::Error>;
2220
2221    fn poll_next(
2222        mut self: std::pin::Pin<&mut Self>,
2223        cx: &mut std::task::Context<'_>,
2224    ) -> std::task::Poll<Option<Self::Item>> {
2225        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2226            &mut self.event_receiver,
2227            cx
2228        )?) {
2229            Some(buf) => std::task::Poll::Ready(Some(LogStreamEvent::decode(buf))),
2230            None => std::task::Poll::Ready(None),
2231        }
2232    }
2233}
2234
2235#[derive(Debug)]
2236pub enum LogStreamEvent {
2237    #[non_exhaustive]
2238    _UnknownEvent {
2239        /// Ordinal of the event that was sent.
2240        ordinal: u64,
2241    },
2242}
2243
2244impl LogStreamEvent {
2245    /// Decodes a message buffer as a [`LogStreamEvent`].
2246    fn decode(
2247        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2248    ) -> Result<LogStreamEvent, fidl::Error> {
2249        let (bytes, _handles) = buf.split_mut();
2250        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2251        debug_assert_eq!(tx_header.tx_id, 0);
2252        match tx_header.ordinal {
2253            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2254                Ok(LogStreamEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2255            }
2256            _ => Err(fidl::Error::UnknownOrdinal {
2257                ordinal: tx_header.ordinal,
2258                protocol_name:
2259                    <LogStreamMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2260            }),
2261        }
2262    }
2263}
2264
2265/// A Stream of incoming requests for fuchsia.diagnostics/LogStream.
2266pub struct LogStreamRequestStream {
2267    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2268    is_terminated: bool,
2269}
2270
2271impl std::marker::Unpin for LogStreamRequestStream {}
2272
2273impl futures::stream::FusedStream for LogStreamRequestStream {
2274    fn is_terminated(&self) -> bool {
2275        self.is_terminated
2276    }
2277}
2278
2279impl fdomain_client::fidl::RequestStream for LogStreamRequestStream {
2280    type Protocol = LogStreamMarker;
2281    type ControlHandle = LogStreamControlHandle;
2282
2283    fn from_channel(channel: fdomain_client::Channel) -> Self {
2284        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2285    }
2286
2287    fn control_handle(&self) -> Self::ControlHandle {
2288        LogStreamControlHandle { inner: self.inner.clone() }
2289    }
2290
2291    fn into_inner(
2292        self,
2293    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
2294    {
2295        (self.inner, self.is_terminated)
2296    }
2297
2298    fn from_inner(
2299        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2300        is_terminated: bool,
2301    ) -> Self {
2302        Self { inner, is_terminated }
2303    }
2304}
2305
2306impl futures::Stream for LogStreamRequestStream {
2307    type Item = Result<LogStreamRequest, fidl::Error>;
2308
2309    fn poll_next(
2310        mut self: std::pin::Pin<&mut Self>,
2311        cx: &mut std::task::Context<'_>,
2312    ) -> std::task::Poll<Option<Self::Item>> {
2313        let this = &mut *self;
2314        if this.inner.check_shutdown(cx) {
2315            this.is_terminated = true;
2316            return std::task::Poll::Ready(None);
2317        }
2318        if this.is_terminated {
2319            panic!("polled LogStreamRequestStream after completion");
2320        }
2321        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
2322            |bytes, handles| {
2323                match this.inner.channel().read_etc(cx, bytes, handles) {
2324                    std::task::Poll::Ready(Ok(())) => {}
2325                    std::task::Poll::Pending => return std::task::Poll::Pending,
2326                    std::task::Poll::Ready(Err(None)) => {
2327                        this.is_terminated = true;
2328                        return std::task::Poll::Ready(None);
2329                    }
2330                    std::task::Poll::Ready(Err(Some(e))) => {
2331                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2332                            e.into(),
2333                        ))));
2334                    }
2335                }
2336
2337                // A message has been received from the channel
2338                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2339
2340                std::task::Poll::Ready(Some(match header.ordinal {
2341                    0x745eb34f10d51a88 => {
2342                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2343                        let mut req = fidl::new_empty!(
2344                            LogStreamConnectRequest,
2345                            fdomain_client::fidl::FDomainResourceDialect
2346                        );
2347                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<LogStreamConnectRequest>(&header, _body_bytes, handles, &mut req)?;
2348                        let control_handle = LogStreamControlHandle { inner: this.inner.clone() };
2349                        Ok(LogStreamRequest::Connect {
2350                            socket: req.socket,
2351                            opts: req.opts,
2352
2353                            control_handle,
2354                        })
2355                    }
2356                    _ if header.tx_id == 0
2357                        && header
2358                            .dynamic_flags()
2359                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2360                    {
2361                        Ok(LogStreamRequest::_UnknownMethod {
2362                            ordinal: header.ordinal,
2363                            control_handle: LogStreamControlHandle { inner: this.inner.clone() },
2364                            method_type: fidl::MethodType::OneWay,
2365                        })
2366                    }
2367                    _ if header
2368                        .dynamic_flags()
2369                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2370                    {
2371                        this.inner.send_framework_err(
2372                            fidl::encoding::FrameworkErr::UnknownMethod,
2373                            header.tx_id,
2374                            header.ordinal,
2375                            header.dynamic_flags(),
2376                            (bytes, handles),
2377                        )?;
2378                        Ok(LogStreamRequest::_UnknownMethod {
2379                            ordinal: header.ordinal,
2380                            control_handle: LogStreamControlHandle { inner: this.inner.clone() },
2381                            method_type: fidl::MethodType::TwoWay,
2382                        })
2383                    }
2384                    _ => Err(fidl::Error::UnknownOrdinal {
2385                        ordinal: header.ordinal,
2386                        protocol_name:
2387                            <LogStreamMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2388                    }),
2389                }))
2390            },
2391        )
2392    }
2393}
2394
2395#[derive(Debug)]
2396pub enum LogStreamRequest {
2397    /// Enables clients to stream all logs stored in the Archivist.
2398    /// Expects a Datagram socket handle that can be written to.
2399    ///
2400    /// Logs will be written in the original FXT format with two additional
2401    /// arguments appended at the end of the record depending on the options
2402    /// passed:
2403    ///
2404    ///     - `$__moniker`: the moniker of the component that emitted the log.
2405    ///     - `$__url`: the URL of the component that emitted the log.
2406    ///     - `$__rolled_out`: the number of logs that were rolled out from the
2407    ///       buffer before this one.
2408    Connect {
2409        socket: fdomain_client::Socket,
2410        opts: LogStreamOptions,
2411        control_handle: LogStreamControlHandle,
2412    },
2413    /// An interaction was received which does not match any known method.
2414    #[non_exhaustive]
2415    _UnknownMethod {
2416        /// Ordinal of the method that was called.
2417        ordinal: u64,
2418        control_handle: LogStreamControlHandle,
2419        method_type: fidl::MethodType,
2420    },
2421}
2422
2423impl LogStreamRequest {
2424    #[allow(irrefutable_let_patterns)]
2425    pub fn into_connect(
2426        self,
2427    ) -> Option<(fdomain_client::Socket, LogStreamOptions, LogStreamControlHandle)> {
2428        if let LogStreamRequest::Connect { socket, opts, control_handle } = self {
2429            Some((socket, opts, control_handle))
2430        } else {
2431            None
2432        }
2433    }
2434
2435    /// Name of the method defined in FIDL
2436    pub fn method_name(&self) -> &'static str {
2437        match *self {
2438            LogStreamRequest::Connect { .. } => "connect",
2439            LogStreamRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2440                "unknown one-way method"
2441            }
2442            LogStreamRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2443                "unknown two-way method"
2444            }
2445        }
2446    }
2447}
2448
2449#[derive(Debug, Clone)]
2450pub struct LogStreamControlHandle {
2451    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2452}
2453
2454impl fdomain_client::fidl::ControlHandle for LogStreamControlHandle {
2455    fn shutdown(&self) {
2456        self.inner.shutdown()
2457    }
2458
2459    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2460        self.inner.shutdown_with_epitaph(status)
2461    }
2462
2463    fn is_closed(&self) -> bool {
2464        self.inner.channel().is_closed()
2465    }
2466    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
2467        self.inner.channel().on_closed()
2468    }
2469}
2470
2471impl LogStreamControlHandle {}
2472
2473#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2474pub struct SampleMarker;
2475
2476impl fdomain_client::fidl::ProtocolMarker for SampleMarker {
2477    type Proxy = SampleProxy;
2478    type RequestStream = SampleRequestStream;
2479
2480    const DEBUG_NAME: &'static str = "fuchsia.diagnostics.Sample";
2481}
2482impl fdomain_client::fidl::DiscoverableProtocolMarker for SampleMarker {}
2483pub type SampleCommitResult = Result<(), ConfigurationError>;
2484
2485pub trait SampleProxyInterface: Send + Sync {
2486    fn r#set(&self, sample_parameters: &SampleParameters) -> Result<(), fidl::Error>;
2487    type CommitResponseFut: std::future::Future<Output = Result<SampleCommitResult, fidl::Error>>
2488        + Send;
2489    fn r#commit(
2490        &self,
2491        sink: fdomain_client::fidl::ClientEnd<SampleSinkMarker>,
2492    ) -> Self::CommitResponseFut;
2493}
2494
2495#[derive(Debug, Clone)]
2496pub struct SampleProxy {
2497    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
2498}
2499
2500impl fdomain_client::fidl::Proxy for SampleProxy {
2501    type Protocol = SampleMarker;
2502
2503    fn from_channel(inner: fdomain_client::Channel) -> Self {
2504        Self::new(inner)
2505    }
2506
2507    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
2508        self.client.into_channel().map_err(|client| Self { client })
2509    }
2510
2511    fn as_channel(&self) -> &fdomain_client::Channel {
2512        self.client.as_channel()
2513    }
2514}
2515
2516impl SampleProxy {
2517    /// Create a new Proxy for fuchsia.diagnostics/Sample.
2518    pub fn new(channel: fdomain_client::Channel) -> Self {
2519        let protocol_name = <SampleMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
2520        Self { client: fidl::client::Client::new(channel, protocol_name) }
2521    }
2522
2523    /// Get a Stream of events from the remote end of the protocol.
2524    ///
2525    /// # Panics
2526    ///
2527    /// Panics if the event stream was already taken.
2528    pub fn take_event_stream(&self) -> SampleEventStream {
2529        SampleEventStream { event_receiver: self.client.take_event_receiver() }
2530    }
2531
2532    /// Add sample parameters.
2533    ///
2534    /// Since this is limited by channel size, this API paginates at 300
2535    /// items. That should fit in a channel unless a selector is particularly
2536    /// gigantic.
2537    ///
2538    /// Use `Commit` to indicate that all samples are sent over.
2539    pub fn r#set(&self, mut sample_parameters: &SampleParameters) -> Result<(), fidl::Error> {
2540        SampleProxyInterface::r#set(self, sample_parameters)
2541    }
2542
2543    /// `Commit` returns errors quickly, as all configuration is validated
2544    /// before the first sample is taken.
2545    pub fn r#commit(
2546        &self,
2547        mut sink: fdomain_client::fidl::ClientEnd<SampleSinkMarker>,
2548    ) -> fidl::client::QueryResponseFut<
2549        SampleCommitResult,
2550        fdomain_client::fidl::FDomainResourceDialect,
2551    > {
2552        SampleProxyInterface::r#commit(self, sink)
2553    }
2554}
2555
2556impl SampleProxyInterface for SampleProxy {
2557    fn r#set(&self, mut sample_parameters: &SampleParameters) -> Result<(), fidl::Error> {
2558        self.client.send::<SampleSetRequest>(
2559            (sample_parameters,),
2560            0x421a79bdbf45418e,
2561            fidl::encoding::DynamicFlags::FLEXIBLE,
2562        )
2563    }
2564
2565    type CommitResponseFut = fidl::client::QueryResponseFut<
2566        SampleCommitResult,
2567        fdomain_client::fidl::FDomainResourceDialect,
2568    >;
2569    fn r#commit(
2570        &self,
2571        mut sink: fdomain_client::fidl::ClientEnd<SampleSinkMarker>,
2572    ) -> Self::CommitResponseFut {
2573        fn _decode(
2574            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2575        ) -> Result<SampleCommitResult, fidl::Error> {
2576            let _response = fidl::client::decode_transaction_body::<
2577                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, ConfigurationError>,
2578                fdomain_client::fidl::FDomainResourceDialect,
2579                0x25a3bc5f26787e9b,
2580            >(_buf?)?
2581            .into_result_fdomain::<SampleMarker>("commit")?;
2582            Ok(_response.map(|x| x))
2583        }
2584        self.client.send_query_and_decode::<SampleCommitRequest, SampleCommitResult>(
2585            (sink,),
2586            0x25a3bc5f26787e9b,
2587            fidl::encoding::DynamicFlags::FLEXIBLE,
2588            _decode,
2589        )
2590    }
2591}
2592
2593pub struct SampleEventStream {
2594    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
2595}
2596
2597impl std::marker::Unpin for SampleEventStream {}
2598
2599impl futures::stream::FusedStream for SampleEventStream {
2600    fn is_terminated(&self) -> bool {
2601        self.event_receiver.is_terminated()
2602    }
2603}
2604
2605impl futures::Stream for SampleEventStream {
2606    type Item = Result<SampleEvent, fidl::Error>;
2607
2608    fn poll_next(
2609        mut self: std::pin::Pin<&mut Self>,
2610        cx: &mut std::task::Context<'_>,
2611    ) -> std::task::Poll<Option<Self::Item>> {
2612        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2613            &mut self.event_receiver,
2614            cx
2615        )?) {
2616            Some(buf) => std::task::Poll::Ready(Some(SampleEvent::decode(buf))),
2617            None => std::task::Poll::Ready(None),
2618        }
2619    }
2620}
2621
2622#[derive(Debug)]
2623pub enum SampleEvent {
2624    #[non_exhaustive]
2625    _UnknownEvent {
2626        /// Ordinal of the event that was sent.
2627        ordinal: u64,
2628    },
2629}
2630
2631impl SampleEvent {
2632    /// Decodes a message buffer as a [`SampleEvent`].
2633    fn decode(
2634        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2635    ) -> Result<SampleEvent, fidl::Error> {
2636        let (bytes, _handles) = buf.split_mut();
2637        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2638        debug_assert_eq!(tx_header.tx_id, 0);
2639        match tx_header.ordinal {
2640            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2641                Ok(SampleEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2642            }
2643            _ => Err(fidl::Error::UnknownOrdinal {
2644                ordinal: tx_header.ordinal,
2645                protocol_name: <SampleMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2646            }),
2647        }
2648    }
2649}
2650
2651/// A Stream of incoming requests for fuchsia.diagnostics/Sample.
2652pub struct SampleRequestStream {
2653    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2654    is_terminated: bool,
2655}
2656
2657impl std::marker::Unpin for SampleRequestStream {}
2658
2659impl futures::stream::FusedStream for SampleRequestStream {
2660    fn is_terminated(&self) -> bool {
2661        self.is_terminated
2662    }
2663}
2664
2665impl fdomain_client::fidl::RequestStream for SampleRequestStream {
2666    type Protocol = SampleMarker;
2667    type ControlHandle = SampleControlHandle;
2668
2669    fn from_channel(channel: fdomain_client::Channel) -> Self {
2670        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2671    }
2672
2673    fn control_handle(&self) -> Self::ControlHandle {
2674        SampleControlHandle { inner: self.inner.clone() }
2675    }
2676
2677    fn into_inner(
2678        self,
2679    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
2680    {
2681        (self.inner, self.is_terminated)
2682    }
2683
2684    fn from_inner(
2685        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2686        is_terminated: bool,
2687    ) -> Self {
2688        Self { inner, is_terminated }
2689    }
2690}
2691
2692impl futures::Stream for SampleRequestStream {
2693    type Item = Result<SampleRequest, fidl::Error>;
2694
2695    fn poll_next(
2696        mut self: std::pin::Pin<&mut Self>,
2697        cx: &mut std::task::Context<'_>,
2698    ) -> std::task::Poll<Option<Self::Item>> {
2699        let this = &mut *self;
2700        if this.inner.check_shutdown(cx) {
2701            this.is_terminated = true;
2702            return std::task::Poll::Ready(None);
2703        }
2704        if this.is_terminated {
2705            panic!("polled SampleRequestStream after completion");
2706        }
2707        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
2708            |bytes, handles| {
2709                match this.inner.channel().read_etc(cx, bytes, handles) {
2710                    std::task::Poll::Ready(Ok(())) => {}
2711                    std::task::Poll::Pending => return std::task::Poll::Pending,
2712                    std::task::Poll::Ready(Err(None)) => {
2713                        this.is_terminated = true;
2714                        return std::task::Poll::Ready(None);
2715                    }
2716                    std::task::Poll::Ready(Err(Some(e))) => {
2717                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2718                            e.into(),
2719                        ))));
2720                    }
2721                }
2722
2723                // A message has been received from the channel
2724                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2725
2726                std::task::Poll::Ready(Some(match header.ordinal {
2727                    0x421a79bdbf45418e => {
2728                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2729                        let mut req = fidl::new_empty!(
2730                            SampleSetRequest,
2731                            fdomain_client::fidl::FDomainResourceDialect
2732                        );
2733                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SampleSetRequest>(&header, _body_bytes, handles, &mut req)?;
2734                        let control_handle = SampleControlHandle { inner: this.inner.clone() };
2735                        Ok(SampleRequest::Set {
2736                            sample_parameters: req.sample_parameters,
2737
2738                            control_handle,
2739                        })
2740                    }
2741                    0x25a3bc5f26787e9b => {
2742                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2743                        let mut req = fidl::new_empty!(
2744                            SampleCommitRequest,
2745                            fdomain_client::fidl::FDomainResourceDialect
2746                        );
2747                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SampleCommitRequest>(&header, _body_bytes, handles, &mut req)?;
2748                        let control_handle = SampleControlHandle { inner: this.inner.clone() };
2749                        Ok(SampleRequest::Commit {
2750                            sink: req.sink,
2751
2752                            responder: SampleCommitResponder {
2753                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2754                                tx_id: header.tx_id,
2755                            },
2756                        })
2757                    }
2758                    _ if header.tx_id == 0
2759                        && header
2760                            .dynamic_flags()
2761                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2762                    {
2763                        Ok(SampleRequest::_UnknownMethod {
2764                            ordinal: header.ordinal,
2765                            control_handle: SampleControlHandle { inner: this.inner.clone() },
2766                            method_type: fidl::MethodType::OneWay,
2767                        })
2768                    }
2769                    _ if header
2770                        .dynamic_flags()
2771                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2772                    {
2773                        this.inner.send_framework_err(
2774                            fidl::encoding::FrameworkErr::UnknownMethod,
2775                            header.tx_id,
2776                            header.ordinal,
2777                            header.dynamic_flags(),
2778                            (bytes, handles),
2779                        )?;
2780                        Ok(SampleRequest::_UnknownMethod {
2781                            ordinal: header.ordinal,
2782                            control_handle: SampleControlHandle { inner: this.inner.clone() },
2783                            method_type: fidl::MethodType::TwoWay,
2784                        })
2785                    }
2786                    _ => Err(fidl::Error::UnknownOrdinal {
2787                        ordinal: header.ordinal,
2788                        protocol_name:
2789                            <SampleMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2790                    }),
2791                }))
2792            },
2793        )
2794    }
2795}
2796
2797/// Configure Archivist to alert you periodically about the state of data
2798/// provided via `SampleParameters`.
2799///
2800/// If the given configuration results in a hit, a `BatchIterator` is sent
2801/// over the `sink` provided. That iterator may be drained, and then the
2802/// `sink` will go quiet until the next hit.
2803///
2804/// Archivist does not inform the client which data result in a success,
2805/// because it has not inherent advantaged ability to do so. Clients who
2806/// need to know which data was queried should cache their selectors and
2807/// use `selectors::select_from_hierarchy` (or similar in C++).
2808#[derive(Debug)]
2809pub enum SampleRequest {
2810    /// Add sample parameters.
2811    ///
2812    /// Since this is limited by channel size, this API paginates at 300
2813    /// items. That should fit in a channel unless a selector is particularly
2814    /// gigantic.
2815    ///
2816    /// Use `Commit` to indicate that all samples are sent over.
2817    Set { sample_parameters: SampleParameters, control_handle: SampleControlHandle },
2818    /// `Commit` returns errors quickly, as all configuration is validated
2819    /// before the first sample is taken.
2820    Commit {
2821        sink: fdomain_client::fidl::ClientEnd<SampleSinkMarker>,
2822        responder: SampleCommitResponder,
2823    },
2824    /// An interaction was received which does not match any known method.
2825    #[non_exhaustive]
2826    _UnknownMethod {
2827        /// Ordinal of the method that was called.
2828        ordinal: u64,
2829        control_handle: SampleControlHandle,
2830        method_type: fidl::MethodType,
2831    },
2832}
2833
2834impl SampleRequest {
2835    #[allow(irrefutable_let_patterns)]
2836    pub fn into_set(self) -> Option<(SampleParameters, SampleControlHandle)> {
2837        if let SampleRequest::Set { sample_parameters, control_handle } = self {
2838            Some((sample_parameters, control_handle))
2839        } else {
2840            None
2841        }
2842    }
2843
2844    #[allow(irrefutable_let_patterns)]
2845    pub fn into_commit(
2846        self,
2847    ) -> Option<(fdomain_client::fidl::ClientEnd<SampleSinkMarker>, SampleCommitResponder)> {
2848        if let SampleRequest::Commit { sink, responder } = self {
2849            Some((sink, responder))
2850        } else {
2851            None
2852        }
2853    }
2854
2855    /// Name of the method defined in FIDL
2856    pub fn method_name(&self) -> &'static str {
2857        match *self {
2858            SampleRequest::Set { .. } => "set",
2859            SampleRequest::Commit { .. } => "commit",
2860            SampleRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2861                "unknown one-way method"
2862            }
2863            SampleRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2864                "unknown two-way method"
2865            }
2866        }
2867    }
2868}
2869
2870#[derive(Debug, Clone)]
2871pub struct SampleControlHandle {
2872    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2873}
2874
2875impl fdomain_client::fidl::ControlHandle for SampleControlHandle {
2876    fn shutdown(&self) {
2877        self.inner.shutdown()
2878    }
2879
2880    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2881        self.inner.shutdown_with_epitaph(status)
2882    }
2883
2884    fn is_closed(&self) -> bool {
2885        self.inner.channel().is_closed()
2886    }
2887    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
2888        self.inner.channel().on_closed()
2889    }
2890}
2891
2892impl SampleControlHandle {}
2893
2894#[must_use = "FIDL methods require a response to be sent"]
2895#[derive(Debug)]
2896pub struct SampleCommitResponder {
2897    control_handle: std::mem::ManuallyDrop<SampleControlHandle>,
2898    tx_id: u32,
2899}
2900
2901/// Set the the channel to be shutdown (see [`SampleControlHandle::shutdown`])
2902/// if the responder is dropped without sending a response, so that the client
2903/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2904impl std::ops::Drop for SampleCommitResponder {
2905    fn drop(&mut self) {
2906        self.control_handle.shutdown();
2907        // Safety: drops once, never accessed again
2908        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2909    }
2910}
2911
2912impl fdomain_client::fidl::Responder for SampleCommitResponder {
2913    type ControlHandle = SampleControlHandle;
2914
2915    fn control_handle(&self) -> &SampleControlHandle {
2916        &self.control_handle
2917    }
2918
2919    fn drop_without_shutdown(mut self) {
2920        // Safety: drops once, never accessed again due to mem::forget
2921        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2922        // Prevent Drop from running (which would shut down the channel)
2923        std::mem::forget(self);
2924    }
2925}
2926
2927impl SampleCommitResponder {
2928    /// Sends a response to the FIDL transaction.
2929    ///
2930    /// Sets the channel to shutdown if an error occurs.
2931    pub fn send(self, mut result: Result<(), ConfigurationError>) -> Result<(), fidl::Error> {
2932        let _result = self.send_raw(result);
2933        if _result.is_err() {
2934            self.control_handle.shutdown();
2935        }
2936        self.drop_without_shutdown();
2937        _result
2938    }
2939
2940    /// Similar to "send" but does not shutdown the channel if an error occurs.
2941    pub fn send_no_shutdown_on_err(
2942        self,
2943        mut result: Result<(), ConfigurationError>,
2944    ) -> Result<(), fidl::Error> {
2945        let _result = self.send_raw(result);
2946        self.drop_without_shutdown();
2947        _result
2948    }
2949
2950    fn send_raw(&self, mut result: Result<(), ConfigurationError>) -> Result<(), fidl::Error> {
2951        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2952            fidl::encoding::EmptyStruct,
2953            ConfigurationError,
2954        >>(
2955            fidl::encoding::FlexibleResult::new(result),
2956            self.tx_id,
2957            0x25a3bc5f26787e9b,
2958            fidl::encoding::DynamicFlags::FLEXIBLE,
2959        )
2960    }
2961}
2962
2963#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2964pub struct SampleSinkMarker;
2965
2966impl fdomain_client::fidl::ProtocolMarker for SampleSinkMarker {
2967    type Proxy = SampleSinkProxy;
2968    type RequestStream = SampleSinkRequestStream;
2969
2970    const DEBUG_NAME: &'static str = "(anonymous) SampleSink";
2971}
2972
2973pub trait SampleSinkProxyInterface: Send + Sync {
2974    fn r#on_sample_readied(&self, event: SampleSinkResult) -> Result<(), fidl::Error>;
2975}
2976
2977#[derive(Debug, Clone)]
2978pub struct SampleSinkProxy {
2979    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
2980}
2981
2982impl fdomain_client::fidl::Proxy for SampleSinkProxy {
2983    type Protocol = SampleSinkMarker;
2984
2985    fn from_channel(inner: fdomain_client::Channel) -> Self {
2986        Self::new(inner)
2987    }
2988
2989    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
2990        self.client.into_channel().map_err(|client| Self { client })
2991    }
2992
2993    fn as_channel(&self) -> &fdomain_client::Channel {
2994        self.client.as_channel()
2995    }
2996}
2997
2998impl SampleSinkProxy {
2999    /// Create a new Proxy for fuchsia.diagnostics/SampleSink.
3000    pub fn new(channel: fdomain_client::Channel) -> Self {
3001        let protocol_name = <SampleSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
3002        Self { client: fidl::client::Client::new(channel, protocol_name) }
3003    }
3004
3005    /// Get a Stream of events from the remote end of the protocol.
3006    ///
3007    /// # Panics
3008    ///
3009    /// Panics if the event stream was already taken.
3010    pub fn take_event_stream(&self) -> SampleSinkEventStream {
3011        SampleSinkEventStream { event_receiver: self.client.take_event_receiver() }
3012    }
3013
3014    pub fn r#on_sample_readied(&self, mut event: SampleSinkResult) -> Result<(), fidl::Error> {
3015        SampleSinkProxyInterface::r#on_sample_readied(self, event)
3016    }
3017}
3018
3019impl SampleSinkProxyInterface for SampleSinkProxy {
3020    fn r#on_sample_readied(&self, mut event: SampleSinkResult) -> Result<(), fidl::Error> {
3021        self.client.send::<SampleSinkOnSampleReadiedRequest>(
3022            (&mut event,),
3023            0x39096d97ed03335f,
3024            fidl::encoding::DynamicFlags::FLEXIBLE,
3025        )
3026    }
3027}
3028
3029pub struct SampleSinkEventStream {
3030    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
3031}
3032
3033impl std::marker::Unpin for SampleSinkEventStream {}
3034
3035impl futures::stream::FusedStream for SampleSinkEventStream {
3036    fn is_terminated(&self) -> bool {
3037        self.event_receiver.is_terminated()
3038    }
3039}
3040
3041impl futures::Stream for SampleSinkEventStream {
3042    type Item = Result<SampleSinkEvent, fidl::Error>;
3043
3044    fn poll_next(
3045        mut self: std::pin::Pin<&mut Self>,
3046        cx: &mut std::task::Context<'_>,
3047    ) -> std::task::Poll<Option<Self::Item>> {
3048        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3049            &mut self.event_receiver,
3050            cx
3051        )?) {
3052            Some(buf) => std::task::Poll::Ready(Some(SampleSinkEvent::decode(buf))),
3053            None => std::task::Poll::Ready(None),
3054        }
3055    }
3056}
3057
3058#[derive(Debug)]
3059pub enum SampleSinkEvent {
3060    OnNowOrNever {},
3061    #[non_exhaustive]
3062    _UnknownEvent {
3063        /// Ordinal of the event that was sent.
3064        ordinal: u64,
3065    },
3066}
3067
3068impl SampleSinkEvent {
3069    #[allow(irrefutable_let_patterns)]
3070    pub fn into_on_now_or_never(self) -> Option<()> {
3071        if let SampleSinkEvent::OnNowOrNever {} = self { Some(()) } else { None }
3072    }
3073
3074    /// Decodes a message buffer as a [`SampleSinkEvent`].
3075    fn decode(
3076        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3077    ) -> Result<SampleSinkEvent, fidl::Error> {
3078        let (bytes, _handles) = buf.split_mut();
3079        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3080        debug_assert_eq!(tx_header.tx_id, 0);
3081        match tx_header.ordinal {
3082            0x3dc94ca1e1290894 => {
3083                let mut out = fidl::new_empty!(
3084                    fidl::encoding::EmptyPayload,
3085                    fdomain_client::fidl::FDomainResourceDialect
3086                );
3087                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
3088                Ok((SampleSinkEvent::OnNowOrNever {}))
3089            }
3090            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3091                Ok(SampleSinkEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3092            }
3093            _ => Err(fidl::Error::UnknownOrdinal {
3094                ordinal: tx_header.ordinal,
3095                protocol_name:
3096                    <SampleSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
3097            }),
3098        }
3099    }
3100}
3101
3102/// A Stream of incoming requests for fuchsia.diagnostics/SampleSink.
3103pub struct SampleSinkRequestStream {
3104    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3105    is_terminated: bool,
3106}
3107
3108impl std::marker::Unpin for SampleSinkRequestStream {}
3109
3110impl futures::stream::FusedStream for SampleSinkRequestStream {
3111    fn is_terminated(&self) -> bool {
3112        self.is_terminated
3113    }
3114}
3115
3116impl fdomain_client::fidl::RequestStream for SampleSinkRequestStream {
3117    type Protocol = SampleSinkMarker;
3118    type ControlHandle = SampleSinkControlHandle;
3119
3120    fn from_channel(channel: fdomain_client::Channel) -> Self {
3121        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3122    }
3123
3124    fn control_handle(&self) -> Self::ControlHandle {
3125        SampleSinkControlHandle { inner: self.inner.clone() }
3126    }
3127
3128    fn into_inner(
3129        self,
3130    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
3131    {
3132        (self.inner, self.is_terminated)
3133    }
3134
3135    fn from_inner(
3136        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3137        is_terminated: bool,
3138    ) -> Self {
3139        Self { inner, is_terminated }
3140    }
3141}
3142
3143impl futures::Stream for SampleSinkRequestStream {
3144    type Item = Result<SampleSinkRequest, fidl::Error>;
3145
3146    fn poll_next(
3147        mut self: std::pin::Pin<&mut Self>,
3148        cx: &mut std::task::Context<'_>,
3149    ) -> std::task::Poll<Option<Self::Item>> {
3150        let this = &mut *self;
3151        if this.inner.check_shutdown(cx) {
3152            this.is_terminated = true;
3153            return std::task::Poll::Ready(None);
3154        }
3155        if this.is_terminated {
3156            panic!("polled SampleSinkRequestStream after completion");
3157        }
3158        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
3159            |bytes, handles| {
3160                match this.inner.channel().read_etc(cx, bytes, handles) {
3161                    std::task::Poll::Ready(Ok(())) => {}
3162                    std::task::Poll::Pending => return std::task::Poll::Pending,
3163                    std::task::Poll::Ready(Err(None)) => {
3164                        this.is_terminated = true;
3165                        return std::task::Poll::Ready(None);
3166                    }
3167                    std::task::Poll::Ready(Err(Some(e))) => {
3168                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3169                            e.into(),
3170                        ))));
3171                    }
3172                }
3173
3174                // A message has been received from the channel
3175                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3176
3177                std::task::Poll::Ready(Some(match header.ordinal {
3178                    0x39096d97ed03335f => {
3179                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3180                        let mut req = fidl::new_empty!(
3181                            SampleSinkOnSampleReadiedRequest,
3182                            fdomain_client::fidl::FDomainResourceDialect
3183                        );
3184                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SampleSinkOnSampleReadiedRequest>(&header, _body_bytes, handles, &mut req)?;
3185                        let control_handle = SampleSinkControlHandle { inner: this.inner.clone() };
3186                        Ok(SampleSinkRequest::OnSampleReadied { event: req.event, control_handle })
3187                    }
3188                    _ if header.tx_id == 0
3189                        && header
3190                            .dynamic_flags()
3191                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3192                    {
3193                        Ok(SampleSinkRequest::_UnknownMethod {
3194                            ordinal: header.ordinal,
3195                            control_handle: SampleSinkControlHandle { inner: this.inner.clone() },
3196                            method_type: fidl::MethodType::OneWay,
3197                        })
3198                    }
3199                    _ if header
3200                        .dynamic_flags()
3201                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3202                    {
3203                        this.inner.send_framework_err(
3204                            fidl::encoding::FrameworkErr::UnknownMethod,
3205                            header.tx_id,
3206                            header.ordinal,
3207                            header.dynamic_flags(),
3208                            (bytes, handles),
3209                        )?;
3210                        Ok(SampleSinkRequest::_UnknownMethod {
3211                            ordinal: header.ordinal,
3212                            control_handle: SampleSinkControlHandle { inner: this.inner.clone() },
3213                            method_type: fidl::MethodType::TwoWay,
3214                        })
3215                    }
3216                    _ => Err(fidl::Error::UnknownOrdinal {
3217                        ordinal: header.ordinal,
3218                        protocol_name:
3219                            <SampleSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
3220                    }),
3221                }))
3222            },
3223        )
3224    }
3225}
3226
3227/// `SampleSink` is served by the client, in order to be notified when samples
3228/// are ready.
3229#[derive(Debug)]
3230pub enum SampleSinkRequest {
3231    OnSampleReadied {
3232        event: SampleSinkResult,
3233        control_handle: SampleSinkControlHandle,
3234    },
3235    /// An interaction was received which does not match any known method.
3236    #[non_exhaustive]
3237    _UnknownMethod {
3238        /// Ordinal of the method that was called.
3239        ordinal: u64,
3240        control_handle: SampleSinkControlHandle,
3241        method_type: fidl::MethodType,
3242    },
3243}
3244
3245impl SampleSinkRequest {
3246    #[allow(irrefutable_let_patterns)]
3247    pub fn into_on_sample_readied(self) -> Option<(SampleSinkResult, SampleSinkControlHandle)> {
3248        if let SampleSinkRequest::OnSampleReadied { event, control_handle } = self {
3249            Some((event, control_handle))
3250        } else {
3251            None
3252        }
3253    }
3254
3255    /// Name of the method defined in FIDL
3256    pub fn method_name(&self) -> &'static str {
3257        match *self {
3258            SampleSinkRequest::OnSampleReadied { .. } => "on_sample_readied",
3259            SampleSinkRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
3260                "unknown one-way method"
3261            }
3262            SampleSinkRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
3263                "unknown two-way method"
3264            }
3265        }
3266    }
3267}
3268
3269#[derive(Debug, Clone)]
3270pub struct SampleSinkControlHandle {
3271    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3272}
3273
3274impl fdomain_client::fidl::ControlHandle for SampleSinkControlHandle {
3275    fn shutdown(&self) {
3276        self.inner.shutdown()
3277    }
3278
3279    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3280        self.inner.shutdown_with_epitaph(status)
3281    }
3282
3283    fn is_closed(&self) -> bool {
3284        self.inner.channel().is_closed()
3285    }
3286    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
3287        self.inner.channel().on_closed()
3288    }
3289}
3290
3291impl SampleSinkControlHandle {
3292    pub fn send_on_now_or_never(&self) -> Result<(), fidl::Error> {
3293        self.inner.send::<fidl::encoding::EmptyPayload>(
3294            (),
3295            0,
3296            0x3dc94ca1e1290894,
3297            fidl::encoding::DynamicFlags::FLEXIBLE,
3298        )
3299    }
3300}
3301
3302mod internal {
3303    use super::*;
3304
3305    impl fidl::encoding::ResourceTypeMarker for ArchiveAccessorStreamDiagnosticsRequest {
3306        type Borrowed<'a> = &'a mut Self;
3307        fn take_or_borrow<'a>(
3308            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3309        ) -> Self::Borrowed<'a> {
3310            value
3311        }
3312    }
3313
3314    unsafe impl fidl::encoding::TypeMarker for ArchiveAccessorStreamDiagnosticsRequest {
3315        type Owned = Self;
3316
3317        #[inline(always)]
3318        fn inline_align(_context: fidl::encoding::Context) -> usize {
3319            8
3320        }
3321
3322        #[inline(always)]
3323        fn inline_size(_context: fidl::encoding::Context) -> usize {
3324            24
3325        }
3326    }
3327
3328    unsafe impl
3329        fidl::encoding::Encode<
3330            ArchiveAccessorStreamDiagnosticsRequest,
3331            fdomain_client::fidl::FDomainResourceDialect,
3332        > for &mut ArchiveAccessorStreamDiagnosticsRequest
3333    {
3334        #[inline]
3335        unsafe fn encode(
3336            self,
3337            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3338            offset: usize,
3339            _depth: fidl::encoding::Depth,
3340        ) -> fidl::Result<()> {
3341            encoder.debug_check_bounds::<ArchiveAccessorStreamDiagnosticsRequest>(offset);
3342            // Delegate to tuple encoding.
3343            fidl::encoding::Encode::<ArchiveAccessorStreamDiagnosticsRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
3344                (
3345                    <StreamParameters as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_parameters),
3346                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BatchIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.result_stream),
3347                ),
3348                encoder, offset, _depth
3349            )
3350        }
3351    }
3352    unsafe impl<
3353        T0: fidl::encoding::Encode<StreamParameters, fdomain_client::fidl::FDomainResourceDialect>,
3354        T1: fidl::encoding::Encode<
3355                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BatchIteratorMarker>>,
3356                fdomain_client::fidl::FDomainResourceDialect,
3357            >,
3358    >
3359        fidl::encoding::Encode<
3360            ArchiveAccessorStreamDiagnosticsRequest,
3361            fdomain_client::fidl::FDomainResourceDialect,
3362        > for (T0, T1)
3363    {
3364        #[inline]
3365        unsafe fn encode(
3366            self,
3367            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3368            offset: usize,
3369            depth: fidl::encoding::Depth,
3370        ) -> fidl::Result<()> {
3371            encoder.debug_check_bounds::<ArchiveAccessorStreamDiagnosticsRequest>(offset);
3372            // Zero out padding regions. There's no need to apply masks
3373            // because the unmasked parts will be overwritten by fields.
3374            unsafe {
3375                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3376                (ptr as *mut u64).write_unaligned(0);
3377            }
3378            // Write the fields.
3379            self.0.encode(encoder, offset + 0, depth)?;
3380            self.1.encode(encoder, offset + 16, depth)?;
3381            Ok(())
3382        }
3383    }
3384
3385    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
3386        for ArchiveAccessorStreamDiagnosticsRequest
3387    {
3388        #[inline(always)]
3389        fn new_empty() -> Self {
3390            Self {
3391                stream_parameters: fidl::new_empty!(
3392                    StreamParameters,
3393                    fdomain_client::fidl::FDomainResourceDialect
3394                ),
3395                result_stream: fidl::new_empty!(
3396                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BatchIteratorMarker>>,
3397                    fdomain_client::fidl::FDomainResourceDialect
3398                ),
3399            }
3400        }
3401
3402        #[inline]
3403        unsafe fn decode(
3404            &mut self,
3405            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3406            offset: usize,
3407            _depth: fidl::encoding::Depth,
3408        ) -> fidl::Result<()> {
3409            decoder.debug_check_bounds::<Self>(offset);
3410            // Verify that padding bytes are zero.
3411            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3412            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3413            let mask = 0xffffffff00000000u64;
3414            let maskedval = padval & mask;
3415            if maskedval != 0 {
3416                return Err(fidl::Error::NonZeroPadding {
3417                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3418                });
3419            }
3420            fidl::decode!(
3421                StreamParameters,
3422                fdomain_client::fidl::FDomainResourceDialect,
3423                &mut self.stream_parameters,
3424                decoder,
3425                offset + 0,
3426                _depth
3427            )?;
3428            fidl::decode!(
3429                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BatchIteratorMarker>>,
3430                fdomain_client::fidl::FDomainResourceDialect,
3431                &mut self.result_stream,
3432                decoder,
3433                offset + 16,
3434                _depth
3435            )?;
3436            Ok(())
3437        }
3438    }
3439
3440    impl fidl::encoding::ResourceTypeMarker for BatchIteratorGetNextResponse {
3441        type Borrowed<'a> = &'a mut Self;
3442        fn take_or_borrow<'a>(
3443            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3444        ) -> Self::Borrowed<'a> {
3445            value
3446        }
3447    }
3448
3449    unsafe impl fidl::encoding::TypeMarker for BatchIteratorGetNextResponse {
3450        type Owned = Self;
3451
3452        #[inline(always)]
3453        fn inline_align(_context: fidl::encoding::Context) -> usize {
3454            8
3455        }
3456
3457        #[inline(always)]
3458        fn inline_size(_context: fidl::encoding::Context) -> usize {
3459            16
3460        }
3461    }
3462
3463    unsafe impl
3464        fidl::encoding::Encode<
3465            BatchIteratorGetNextResponse,
3466            fdomain_client::fidl::FDomainResourceDialect,
3467        > for &mut BatchIteratorGetNextResponse
3468    {
3469        #[inline]
3470        unsafe fn encode(
3471            self,
3472            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3473            offset: usize,
3474            _depth: fidl::encoding::Depth,
3475        ) -> fidl::Result<()> {
3476            encoder.debug_check_bounds::<BatchIteratorGetNextResponse>(offset);
3477            // Delegate to tuple encoding.
3478            fidl::encoding::Encode::<BatchIteratorGetNextResponse, fdomain_client::fidl::FDomainResourceDialect>::encode(
3479                (
3480                    <fidl::encoding::Vector<FormattedContent, 64> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.batch),
3481                ),
3482                encoder, offset, _depth
3483            )
3484        }
3485    }
3486    unsafe impl<
3487        T0: fidl::encoding::Encode<
3488                fidl::encoding::Vector<FormattedContent, 64>,
3489                fdomain_client::fidl::FDomainResourceDialect,
3490            >,
3491    >
3492        fidl::encoding::Encode<
3493            BatchIteratorGetNextResponse,
3494            fdomain_client::fidl::FDomainResourceDialect,
3495        > for (T0,)
3496    {
3497        #[inline]
3498        unsafe fn encode(
3499            self,
3500            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3501            offset: usize,
3502            depth: fidl::encoding::Depth,
3503        ) -> fidl::Result<()> {
3504            encoder.debug_check_bounds::<BatchIteratorGetNextResponse>(offset);
3505            // Zero out padding regions. There's no need to apply masks
3506            // because the unmasked parts will be overwritten by fields.
3507            // Write the fields.
3508            self.0.encode(encoder, offset + 0, depth)?;
3509            Ok(())
3510        }
3511    }
3512
3513    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
3514        for BatchIteratorGetNextResponse
3515    {
3516        #[inline(always)]
3517        fn new_empty() -> Self {
3518            Self {
3519                batch: fidl::new_empty!(fidl::encoding::Vector<FormattedContent, 64>, fdomain_client::fidl::FDomainResourceDialect),
3520            }
3521        }
3522
3523        #[inline]
3524        unsafe fn decode(
3525            &mut self,
3526            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3527            offset: usize,
3528            _depth: fidl::encoding::Depth,
3529        ) -> fidl::Result<()> {
3530            decoder.debug_check_bounds::<Self>(offset);
3531            // Verify that padding bytes are zero.
3532            fidl::decode!(fidl::encoding::Vector<FormattedContent, 64>, fdomain_client::fidl::FDomainResourceDialect, &mut self.batch, decoder, offset + 0, _depth)?;
3533            Ok(())
3534        }
3535    }
3536
3537    impl fidl::encoding::ResourceTypeMarker for LogStreamConnectRequest {
3538        type Borrowed<'a> = &'a mut Self;
3539        fn take_or_borrow<'a>(
3540            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3541        ) -> Self::Borrowed<'a> {
3542            value
3543        }
3544    }
3545
3546    unsafe impl fidl::encoding::TypeMarker for LogStreamConnectRequest {
3547        type Owned = Self;
3548
3549        #[inline(always)]
3550        fn inline_align(_context: fidl::encoding::Context) -> usize {
3551            8
3552        }
3553
3554        #[inline(always)]
3555        fn inline_size(_context: fidl::encoding::Context) -> usize {
3556            24
3557        }
3558    }
3559
3560    unsafe impl
3561        fidl::encoding::Encode<
3562            LogStreamConnectRequest,
3563            fdomain_client::fidl::FDomainResourceDialect,
3564        > for &mut LogStreamConnectRequest
3565    {
3566        #[inline]
3567        unsafe fn encode(
3568            self,
3569            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3570            offset: usize,
3571            _depth: fidl::encoding::Depth,
3572        ) -> fidl::Result<()> {
3573            encoder.debug_check_bounds::<LogStreamConnectRequest>(offset);
3574            // Delegate to tuple encoding.
3575            fidl::encoding::Encode::<
3576                LogStreamConnectRequest,
3577                fdomain_client::fidl::FDomainResourceDialect,
3578            >::encode(
3579                (
3580                    <fidl::encoding::HandleType<
3581                        fdomain_client::Socket,
3582                        { fidl::ObjectType::SOCKET.into_raw() },
3583                        16392,
3584                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3585                        &mut self.socket
3586                    ),
3587                    <LogStreamOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.opts),
3588                ),
3589                encoder,
3590                offset,
3591                _depth,
3592            )
3593        }
3594    }
3595    unsafe impl<
3596        T0: fidl::encoding::Encode<
3597                fidl::encoding::HandleType<
3598                    fdomain_client::Socket,
3599                    { fidl::ObjectType::SOCKET.into_raw() },
3600                    16392,
3601                >,
3602                fdomain_client::fidl::FDomainResourceDialect,
3603            >,
3604        T1: fidl::encoding::Encode<LogStreamOptions, fdomain_client::fidl::FDomainResourceDialect>,
3605    >
3606        fidl::encoding::Encode<
3607            LogStreamConnectRequest,
3608            fdomain_client::fidl::FDomainResourceDialect,
3609        > for (T0, T1)
3610    {
3611        #[inline]
3612        unsafe fn encode(
3613            self,
3614            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3615            offset: usize,
3616            depth: fidl::encoding::Depth,
3617        ) -> fidl::Result<()> {
3618            encoder.debug_check_bounds::<LogStreamConnectRequest>(offset);
3619            // Zero out padding regions. There's no need to apply masks
3620            // because the unmasked parts will be overwritten by fields.
3621            unsafe {
3622                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3623                (ptr as *mut u64).write_unaligned(0);
3624            }
3625            // Write the fields.
3626            self.0.encode(encoder, offset + 0, depth)?;
3627            self.1.encode(encoder, offset + 8, depth)?;
3628            Ok(())
3629        }
3630    }
3631
3632    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
3633        for LogStreamConnectRequest
3634    {
3635        #[inline(always)]
3636        fn new_empty() -> Self {
3637            Self {
3638                socket: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 16392>, fdomain_client::fidl::FDomainResourceDialect),
3639                opts: fidl::new_empty!(
3640                    LogStreamOptions,
3641                    fdomain_client::fidl::FDomainResourceDialect
3642                ),
3643            }
3644        }
3645
3646        #[inline]
3647        unsafe fn decode(
3648            &mut self,
3649            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3650            offset: usize,
3651            _depth: fidl::encoding::Depth,
3652        ) -> fidl::Result<()> {
3653            decoder.debug_check_bounds::<Self>(offset);
3654            // Verify that padding bytes are zero.
3655            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3656            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3657            let mask = 0xffffffff00000000u64;
3658            let maskedval = padval & mask;
3659            if maskedval != 0 {
3660                return Err(fidl::Error::NonZeroPadding {
3661                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3662                });
3663            }
3664            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)?;
3665            fidl::decode!(
3666                LogStreamOptions,
3667                fdomain_client::fidl::FDomainResourceDialect,
3668                &mut self.opts,
3669                decoder,
3670                offset + 8,
3671                _depth
3672            )?;
3673            Ok(())
3674        }
3675    }
3676
3677    impl fidl::encoding::ResourceTypeMarker for SampleCommitRequest {
3678        type Borrowed<'a> = &'a mut Self;
3679        fn take_or_borrow<'a>(
3680            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3681        ) -> Self::Borrowed<'a> {
3682            value
3683        }
3684    }
3685
3686    unsafe impl fidl::encoding::TypeMarker for SampleCommitRequest {
3687        type Owned = Self;
3688
3689        #[inline(always)]
3690        fn inline_align(_context: fidl::encoding::Context) -> usize {
3691            4
3692        }
3693
3694        #[inline(always)]
3695        fn inline_size(_context: fidl::encoding::Context) -> usize {
3696            4
3697        }
3698    }
3699
3700    unsafe impl
3701        fidl::encoding::Encode<SampleCommitRequest, fdomain_client::fidl::FDomainResourceDialect>
3702        for &mut SampleCommitRequest
3703    {
3704        #[inline]
3705        unsafe fn encode(
3706            self,
3707            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3708            offset: usize,
3709            _depth: fidl::encoding::Depth,
3710        ) -> fidl::Result<()> {
3711            encoder.debug_check_bounds::<SampleCommitRequest>(offset);
3712            // Delegate to tuple encoding.
3713            fidl::encoding::Encode::<SampleCommitRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
3714                (
3715                    <fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<SampleSinkMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.sink),
3716                ),
3717                encoder, offset, _depth
3718            )
3719        }
3720    }
3721    unsafe impl<
3722        T0: fidl::encoding::Encode<
3723                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<SampleSinkMarker>>,
3724                fdomain_client::fidl::FDomainResourceDialect,
3725            >,
3726    > fidl::encoding::Encode<SampleCommitRequest, fdomain_client::fidl::FDomainResourceDialect>
3727        for (T0,)
3728    {
3729        #[inline]
3730        unsafe fn encode(
3731            self,
3732            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3733            offset: usize,
3734            depth: fidl::encoding::Depth,
3735        ) -> fidl::Result<()> {
3736            encoder.debug_check_bounds::<SampleCommitRequest>(offset);
3737            // Zero out padding regions. There's no need to apply masks
3738            // because the unmasked parts will be overwritten by fields.
3739            // Write the fields.
3740            self.0.encode(encoder, offset + 0, depth)?;
3741            Ok(())
3742        }
3743    }
3744
3745    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
3746        for SampleCommitRequest
3747    {
3748        #[inline(always)]
3749        fn new_empty() -> Self {
3750            Self {
3751                sink: fidl::new_empty!(
3752                    fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<SampleSinkMarker>>,
3753                    fdomain_client::fidl::FDomainResourceDialect
3754                ),
3755            }
3756        }
3757
3758        #[inline]
3759        unsafe fn decode(
3760            &mut self,
3761            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3762            offset: usize,
3763            _depth: fidl::encoding::Depth,
3764        ) -> fidl::Result<()> {
3765            decoder.debug_check_bounds::<Self>(offset);
3766            // Verify that padding bytes are zero.
3767            fidl::decode!(
3768                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<SampleSinkMarker>>,
3769                fdomain_client::fidl::FDomainResourceDialect,
3770                &mut self.sink,
3771                decoder,
3772                offset + 0,
3773                _depth
3774            )?;
3775            Ok(())
3776        }
3777    }
3778
3779    impl fidl::encoding::ResourceTypeMarker for SampleSetRequest {
3780        type Borrowed<'a> = &'a mut Self;
3781        fn take_or_borrow<'a>(
3782            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3783        ) -> Self::Borrowed<'a> {
3784            value
3785        }
3786    }
3787
3788    unsafe impl fidl::encoding::TypeMarker for SampleSetRequest {
3789        type Owned = Self;
3790
3791        #[inline(always)]
3792        fn inline_align(_context: fidl::encoding::Context) -> usize {
3793            8
3794        }
3795
3796        #[inline(always)]
3797        fn inline_size(_context: fidl::encoding::Context) -> usize {
3798            16
3799        }
3800    }
3801
3802    unsafe impl
3803        fidl::encoding::Encode<SampleSetRequest, fdomain_client::fidl::FDomainResourceDialect>
3804        for &mut SampleSetRequest
3805    {
3806        #[inline]
3807        unsafe fn encode(
3808            self,
3809            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3810            offset: usize,
3811            _depth: fidl::encoding::Depth,
3812        ) -> fidl::Result<()> {
3813            encoder.debug_check_bounds::<SampleSetRequest>(offset);
3814            // Delegate to tuple encoding.
3815            fidl::encoding::Encode::<SampleSetRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
3816                (
3817                    <SampleParameters as fidl::encoding::ValueTypeMarker>::borrow(&self.sample_parameters),
3818                ),
3819                encoder, offset, _depth
3820            )
3821        }
3822    }
3823    unsafe impl<
3824        T0: fidl::encoding::Encode<SampleParameters, fdomain_client::fidl::FDomainResourceDialect>,
3825    > fidl::encoding::Encode<SampleSetRequest, fdomain_client::fidl::FDomainResourceDialect>
3826        for (T0,)
3827    {
3828        #[inline]
3829        unsafe fn encode(
3830            self,
3831            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3832            offset: usize,
3833            depth: fidl::encoding::Depth,
3834        ) -> fidl::Result<()> {
3835            encoder.debug_check_bounds::<SampleSetRequest>(offset);
3836            // Zero out padding regions. There's no need to apply masks
3837            // because the unmasked parts will be overwritten by fields.
3838            // Write the fields.
3839            self.0.encode(encoder, offset + 0, depth)?;
3840            Ok(())
3841        }
3842    }
3843
3844    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
3845        for SampleSetRequest
3846    {
3847        #[inline(always)]
3848        fn new_empty() -> Self {
3849            Self {
3850                sample_parameters: fidl::new_empty!(
3851                    SampleParameters,
3852                    fdomain_client::fidl::FDomainResourceDialect
3853                ),
3854            }
3855        }
3856
3857        #[inline]
3858        unsafe fn decode(
3859            &mut self,
3860            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3861            offset: usize,
3862            _depth: fidl::encoding::Depth,
3863        ) -> fidl::Result<()> {
3864            decoder.debug_check_bounds::<Self>(offset);
3865            // Verify that padding bytes are zero.
3866            fidl::decode!(
3867                SampleParameters,
3868                fdomain_client::fidl::FDomainResourceDialect,
3869                &mut self.sample_parameters,
3870                decoder,
3871                offset + 0,
3872                _depth
3873            )?;
3874            Ok(())
3875        }
3876    }
3877
3878    impl fidl::encoding::ResourceTypeMarker for SampleSinkOnSampleReadiedRequest {
3879        type Borrowed<'a> = &'a mut Self;
3880        fn take_or_borrow<'a>(
3881            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3882        ) -> Self::Borrowed<'a> {
3883            value
3884        }
3885    }
3886
3887    unsafe impl fidl::encoding::TypeMarker for SampleSinkOnSampleReadiedRequest {
3888        type Owned = Self;
3889
3890        #[inline(always)]
3891        fn inline_align(_context: fidl::encoding::Context) -> usize {
3892            8
3893        }
3894
3895        #[inline(always)]
3896        fn inline_size(_context: fidl::encoding::Context) -> usize {
3897            16
3898        }
3899    }
3900
3901    unsafe impl
3902        fidl::encoding::Encode<
3903            SampleSinkOnSampleReadiedRequest,
3904            fdomain_client::fidl::FDomainResourceDialect,
3905        > for &mut SampleSinkOnSampleReadiedRequest
3906    {
3907        #[inline]
3908        unsafe fn encode(
3909            self,
3910            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3911            offset: usize,
3912            _depth: fidl::encoding::Depth,
3913        ) -> fidl::Result<()> {
3914            encoder.debug_check_bounds::<SampleSinkOnSampleReadiedRequest>(offset);
3915            // Delegate to tuple encoding.
3916            fidl::encoding::Encode::<
3917                SampleSinkOnSampleReadiedRequest,
3918                fdomain_client::fidl::FDomainResourceDialect,
3919            >::encode(
3920                (<SampleSinkResult as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3921                    &mut self.event,
3922                ),),
3923                encoder,
3924                offset,
3925                _depth,
3926            )
3927        }
3928    }
3929    unsafe impl<
3930        T0: fidl::encoding::Encode<SampleSinkResult, fdomain_client::fidl::FDomainResourceDialect>,
3931    >
3932        fidl::encoding::Encode<
3933            SampleSinkOnSampleReadiedRequest,
3934            fdomain_client::fidl::FDomainResourceDialect,
3935        > for (T0,)
3936    {
3937        #[inline]
3938        unsafe fn encode(
3939            self,
3940            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3941            offset: usize,
3942            depth: fidl::encoding::Depth,
3943        ) -> fidl::Result<()> {
3944            encoder.debug_check_bounds::<SampleSinkOnSampleReadiedRequest>(offset);
3945            // Zero out padding regions. There's no need to apply masks
3946            // because the unmasked parts will be overwritten by fields.
3947            // Write the fields.
3948            self.0.encode(encoder, offset + 0, depth)?;
3949            Ok(())
3950        }
3951    }
3952
3953    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
3954        for SampleSinkOnSampleReadiedRequest
3955    {
3956        #[inline(always)]
3957        fn new_empty() -> Self {
3958            Self {
3959                event: fidl::new_empty!(
3960                    SampleSinkResult,
3961                    fdomain_client::fidl::FDomainResourceDialect
3962                ),
3963            }
3964        }
3965
3966        #[inline]
3967        unsafe fn decode(
3968            &mut self,
3969            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3970            offset: usize,
3971            _depth: fidl::encoding::Depth,
3972        ) -> fidl::Result<()> {
3973            decoder.debug_check_bounds::<Self>(offset);
3974            // Verify that padding bytes are zero.
3975            fidl::decode!(
3976                SampleSinkResult,
3977                fdomain_client::fidl::FDomainResourceDialect,
3978                &mut self.event,
3979                decoder,
3980                offset + 0,
3981                _depth
3982            )?;
3983            Ok(())
3984        }
3985    }
3986
3987    impl SampleReady {
3988        #[inline(always)]
3989        fn max_ordinal_present(&self) -> u64 {
3990            if let Some(_) = self.seconds_since_start {
3991                return 2;
3992            }
3993            if let Some(_) = self.batch_iter {
3994                return 1;
3995            }
3996            0
3997        }
3998    }
3999
4000    impl fidl::encoding::ResourceTypeMarker for SampleReady {
4001        type Borrowed<'a> = &'a mut Self;
4002        fn take_or_borrow<'a>(
4003            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4004        ) -> Self::Borrowed<'a> {
4005            value
4006        }
4007    }
4008
4009    unsafe impl fidl::encoding::TypeMarker for SampleReady {
4010        type Owned = Self;
4011
4012        #[inline(always)]
4013        fn inline_align(_context: fidl::encoding::Context) -> usize {
4014            8
4015        }
4016
4017        #[inline(always)]
4018        fn inline_size(_context: fidl::encoding::Context) -> usize {
4019            16
4020        }
4021    }
4022
4023    unsafe impl fidl::encoding::Encode<SampleReady, fdomain_client::fidl::FDomainResourceDialect>
4024        for &mut SampleReady
4025    {
4026        unsafe fn encode(
4027            self,
4028            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
4029            offset: usize,
4030            mut depth: fidl::encoding::Depth,
4031        ) -> fidl::Result<()> {
4032            encoder.debug_check_bounds::<SampleReady>(offset);
4033            // Vector header
4034            let max_ordinal: u64 = self.max_ordinal_present();
4035            encoder.write_num(max_ordinal, offset);
4036            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4037            // Calling encoder.out_of_line_offset(0) is not allowed.
4038            if max_ordinal == 0 {
4039                return Ok(());
4040            }
4041            depth.increment()?;
4042            let envelope_size = 8;
4043            let bytes_len = max_ordinal as usize * envelope_size;
4044            #[allow(unused_variables)]
4045            let offset = encoder.out_of_line_offset(bytes_len);
4046            let mut _prev_end_offset: usize = 0;
4047            if 1 > max_ordinal {
4048                return Ok(());
4049            }
4050
4051            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4052            // are envelope_size bytes.
4053            let cur_offset: usize = (1 - 1) * envelope_size;
4054
4055            // Zero reserved fields.
4056            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4057
4058            // Safety:
4059            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4060            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4061            //   envelope_size bytes, there is always sufficient room.
4062            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<BatchIteratorMarker>>, fdomain_client::fidl::FDomainResourceDialect>(
4063            self.batch_iter.as_mut().map(<fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<BatchIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4064            encoder, offset + cur_offset, depth
4065        )?;
4066
4067            _prev_end_offset = cur_offset + envelope_size;
4068            if 2 > max_ordinal {
4069                return Ok(());
4070            }
4071
4072            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4073            // are envelope_size bytes.
4074            let cur_offset: usize = (2 - 1) * envelope_size;
4075
4076            // Zero reserved fields.
4077            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4078
4079            // Safety:
4080            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4081            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4082            //   envelope_size bytes, there is always sufficient room.
4083            fidl::encoding::encode_in_envelope_optional::<
4084                i64,
4085                fdomain_client::fidl::FDomainResourceDialect,
4086            >(
4087                self.seconds_since_start
4088                    .as_ref()
4089                    .map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
4090                encoder,
4091                offset + cur_offset,
4092                depth,
4093            )?;
4094
4095            _prev_end_offset = cur_offset + envelope_size;
4096
4097            Ok(())
4098        }
4099    }
4100
4101    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for SampleReady {
4102        #[inline(always)]
4103        fn new_empty() -> Self {
4104            Self::default()
4105        }
4106
4107        unsafe fn decode(
4108            &mut self,
4109            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
4110            offset: usize,
4111            mut depth: fidl::encoding::Depth,
4112        ) -> fidl::Result<()> {
4113            decoder.debug_check_bounds::<Self>(offset);
4114            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4115                None => return Err(fidl::Error::NotNullable),
4116                Some(len) => len,
4117            };
4118            // Calling decoder.out_of_line_offset(0) is not allowed.
4119            if len == 0 {
4120                return Ok(());
4121            };
4122            depth.increment()?;
4123            let envelope_size = 8;
4124            let bytes_len = len * envelope_size;
4125            let offset = decoder.out_of_line_offset(bytes_len)?;
4126            // Decode the envelope for each type.
4127            let mut _next_ordinal_to_read = 0;
4128            let mut next_offset = offset;
4129            let end_offset = offset + bytes_len;
4130            _next_ordinal_to_read += 1;
4131            if next_offset >= end_offset {
4132                return Ok(());
4133            }
4134
4135            // Decode unknown envelopes for gaps in ordinals.
4136            while _next_ordinal_to_read < 1 {
4137                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4138                _next_ordinal_to_read += 1;
4139                next_offset += envelope_size;
4140            }
4141
4142            let next_out_of_line = decoder.next_out_of_line();
4143            let handles_before = decoder.remaining_handles();
4144            if let Some((inlined, num_bytes, num_handles)) =
4145                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4146            {
4147                let member_inline_size = <fidl::encoding::Endpoint<
4148                    fdomain_client::fidl::ClientEnd<BatchIteratorMarker>,
4149                > as fidl::encoding::TypeMarker>::inline_size(
4150                    decoder.context
4151                );
4152                if inlined != (member_inline_size <= 4) {
4153                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4154                }
4155                let inner_offset;
4156                let mut inner_depth = depth.clone();
4157                if inlined {
4158                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4159                    inner_offset = next_offset;
4160                } else {
4161                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4162                    inner_depth.increment()?;
4163                }
4164                let val_ref = self.batch_iter.get_or_insert_with(|| {
4165                    fidl::new_empty!(
4166                        fidl::encoding::Endpoint<
4167                            fdomain_client::fidl::ClientEnd<BatchIteratorMarker>,
4168                        >,
4169                        fdomain_client::fidl::FDomainResourceDialect
4170                    )
4171                });
4172                fidl::decode!(
4173                    fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<BatchIteratorMarker>>,
4174                    fdomain_client::fidl::FDomainResourceDialect,
4175                    val_ref,
4176                    decoder,
4177                    inner_offset,
4178                    inner_depth
4179                )?;
4180                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4181                {
4182                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4183                }
4184                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4185                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4186                }
4187            }
4188
4189            next_offset += envelope_size;
4190            _next_ordinal_to_read += 1;
4191            if next_offset >= end_offset {
4192                return Ok(());
4193            }
4194
4195            // Decode unknown envelopes for gaps in ordinals.
4196            while _next_ordinal_to_read < 2 {
4197                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4198                _next_ordinal_to_read += 1;
4199                next_offset += envelope_size;
4200            }
4201
4202            let next_out_of_line = decoder.next_out_of_line();
4203            let handles_before = decoder.remaining_handles();
4204            if let Some((inlined, num_bytes, num_handles)) =
4205                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4206            {
4207                let member_inline_size =
4208                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4209                if inlined != (member_inline_size <= 4) {
4210                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4211                }
4212                let inner_offset;
4213                let mut inner_depth = depth.clone();
4214                if inlined {
4215                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4216                    inner_offset = next_offset;
4217                } else {
4218                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4219                    inner_depth.increment()?;
4220                }
4221                let val_ref = self.seconds_since_start.get_or_insert_with(|| {
4222                    fidl::new_empty!(i64, fdomain_client::fidl::FDomainResourceDialect)
4223                });
4224                fidl::decode!(
4225                    i64,
4226                    fdomain_client::fidl::FDomainResourceDialect,
4227                    val_ref,
4228                    decoder,
4229                    inner_offset,
4230                    inner_depth
4231                )?;
4232                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4233                {
4234                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4235                }
4236                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4237                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4238                }
4239            }
4240
4241            next_offset += envelope_size;
4242
4243            // Decode the remaining unknown envelopes.
4244            while next_offset < end_offset {
4245                _next_ordinal_to_read += 1;
4246                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4247                next_offset += envelope_size;
4248            }
4249
4250            Ok(())
4251        }
4252    }
4253
4254    impl fidl::encoding::ResourceTypeMarker for FormattedContent {
4255        type Borrowed<'a> = &'a mut Self;
4256        fn take_or_borrow<'a>(
4257            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4258        ) -> Self::Borrowed<'a> {
4259            value
4260        }
4261    }
4262
4263    unsafe impl fidl::encoding::TypeMarker for FormattedContent {
4264        type Owned = Self;
4265
4266        #[inline(always)]
4267        fn inline_align(_context: fidl::encoding::Context) -> usize {
4268            8
4269        }
4270
4271        #[inline(always)]
4272        fn inline_size(_context: fidl::encoding::Context) -> usize {
4273            16
4274        }
4275    }
4276
4277    unsafe impl
4278        fidl::encoding::Encode<FormattedContent, fdomain_client::fidl::FDomainResourceDialect>
4279        for &mut FormattedContent
4280    {
4281        #[inline]
4282        unsafe fn encode(
4283            self,
4284            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
4285            offset: usize,
4286            _depth: fidl::encoding::Depth,
4287        ) -> fidl::Result<()> {
4288            encoder.debug_check_bounds::<FormattedContent>(offset);
4289            encoder.write_num::<u64>(self.ordinal(), offset);
4290            match self {
4291            FormattedContent::Json(ref mut val) => {
4292                fidl::encoding::encode_in_envelope::<fdomain_fuchsia_mem::Buffer, fdomain_client::fidl::FDomainResourceDialect>(
4293                    <fdomain_fuchsia_mem::Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
4294                    encoder, offset + 8, _depth
4295                )
4296            }
4297            FormattedContent::Cbor(ref mut val) => {
4298                fidl::encoding::encode_in_envelope::<fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect>(
4299                    <fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
4300                    encoder, offset + 8, _depth
4301                )
4302            }
4303            FormattedContent::Fxt(ref mut val) => {
4304                fidl::encoding::encode_in_envelope::<fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect>(
4305                    <fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
4306                    encoder, offset + 8, _depth
4307                )
4308            }
4309            FormattedContent::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
4310        }
4311        }
4312    }
4313
4314    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
4315        for FormattedContent
4316    {
4317        #[inline(always)]
4318        fn new_empty() -> Self {
4319            Self::__SourceBreaking { unknown_ordinal: 0 }
4320        }
4321
4322        #[inline]
4323        unsafe fn decode(
4324            &mut self,
4325            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
4326            offset: usize,
4327            mut depth: fidl::encoding::Depth,
4328        ) -> fidl::Result<()> {
4329            decoder.debug_check_bounds::<Self>(offset);
4330            #[allow(unused_variables)]
4331            let next_out_of_line = decoder.next_out_of_line();
4332            let handles_before = decoder.remaining_handles();
4333            let (ordinal, inlined, num_bytes, num_handles) =
4334                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
4335
4336            let member_inline_size = match ordinal {
4337                1 => <fdomain_fuchsia_mem::Buffer as fidl::encoding::TypeMarker>::inline_size(
4338                    decoder.context,
4339                ),
4340                3 => <fidl::encoding::HandleType<
4341                    fdomain_client::Vmo,
4342                    { fidl::ObjectType::VMO.into_raw() },
4343                    2147483648,
4344                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4345                4 => <fidl::encoding::HandleType<
4346                    fdomain_client::Vmo,
4347                    { fidl::ObjectType::VMO.into_raw() },
4348                    2147483648,
4349                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4350                0 => return Err(fidl::Error::UnknownUnionTag),
4351                _ => num_bytes as usize,
4352            };
4353
4354            if inlined != (member_inline_size <= 4) {
4355                return Err(fidl::Error::InvalidInlineBitInEnvelope);
4356            }
4357            let _inner_offset;
4358            if inlined {
4359                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
4360                _inner_offset = offset + 8;
4361            } else {
4362                depth.increment()?;
4363                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4364            }
4365            match ordinal {
4366                1 => {
4367                    #[allow(irrefutable_let_patterns)]
4368                    if let FormattedContent::Json(_) = self {
4369                        // Do nothing, read the value into the object
4370                    } else {
4371                        // Initialize `self` to the right variant
4372                        *self = FormattedContent::Json(fidl::new_empty!(
4373                            fdomain_fuchsia_mem::Buffer,
4374                            fdomain_client::fidl::FDomainResourceDialect
4375                        ));
4376                    }
4377                    #[allow(irrefutable_let_patterns)]
4378                    if let FormattedContent::Json(ref mut val) = self {
4379                        fidl::decode!(
4380                            fdomain_fuchsia_mem::Buffer,
4381                            fdomain_client::fidl::FDomainResourceDialect,
4382                            val,
4383                            decoder,
4384                            _inner_offset,
4385                            depth
4386                        )?;
4387                    } else {
4388                        unreachable!()
4389                    }
4390                }
4391                3 => {
4392                    #[allow(irrefutable_let_patterns)]
4393                    if let FormattedContent::Cbor(_) = self {
4394                        // Do nothing, read the value into the object
4395                    } else {
4396                        // Initialize `self` to the right variant
4397                        *self = FormattedContent::Cbor(
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::Cbor(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                4 => {
4409                    #[allow(irrefutable_let_patterns)]
4410                    if let FormattedContent::Fxt(_) = self {
4411                        // Do nothing, read the value into the object
4412                    } else {
4413                        // Initialize `self` to the right variant
4414                        *self = FormattedContent::Fxt(
4415                            fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
4416                        );
4417                    }
4418                    #[allow(irrefutable_let_patterns)]
4419                    if let FormattedContent::Fxt(ref mut val) = self {
4420                        fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val, decoder, _inner_offset, depth)?;
4421                    } else {
4422                        unreachable!()
4423                    }
4424                }
4425                #[allow(deprecated)]
4426                ordinal => {
4427                    for _ in 0..num_handles {
4428                        decoder.drop_next_handle()?;
4429                    }
4430                    *self = FormattedContent::__SourceBreaking { unknown_ordinal: ordinal };
4431                }
4432            }
4433            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
4434                return Err(fidl::Error::InvalidNumBytesInEnvelope);
4435            }
4436            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4437                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4438            }
4439            Ok(())
4440        }
4441    }
4442
4443    impl fidl::encoding::ResourceTypeMarker for SampleSinkResult {
4444        type Borrowed<'a> = &'a mut Self;
4445        fn take_or_borrow<'a>(
4446            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4447        ) -> Self::Borrowed<'a> {
4448            value
4449        }
4450    }
4451
4452    unsafe impl fidl::encoding::TypeMarker for SampleSinkResult {
4453        type Owned = Self;
4454
4455        #[inline(always)]
4456        fn inline_align(_context: fidl::encoding::Context) -> usize {
4457            8
4458        }
4459
4460        #[inline(always)]
4461        fn inline_size(_context: fidl::encoding::Context) -> usize {
4462            16
4463        }
4464    }
4465
4466    unsafe impl
4467        fidl::encoding::Encode<SampleSinkResult, fdomain_client::fidl::FDomainResourceDialect>
4468        for &mut SampleSinkResult
4469    {
4470        #[inline]
4471        unsafe fn encode(
4472            self,
4473            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
4474            offset: usize,
4475            _depth: fidl::encoding::Depth,
4476        ) -> fidl::Result<()> {
4477            encoder.debug_check_bounds::<SampleSinkResult>(offset);
4478            encoder.write_num::<u64>(self.ordinal(), offset);
4479            match self {
4480                SampleSinkResult::Ready(ref mut val) => fidl::encoding::encode_in_envelope::<
4481                    SampleReady,
4482                    fdomain_client::fidl::FDomainResourceDialect,
4483                >(
4484                    <SampleReady as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
4485                    encoder,
4486                    offset + 8,
4487                    _depth,
4488                ),
4489                SampleSinkResult::Error(ref val) => fidl::encoding::encode_in_envelope::<
4490                    RuntimeError,
4491                    fdomain_client::fidl::FDomainResourceDialect,
4492                >(
4493                    <RuntimeError as fidl::encoding::ValueTypeMarker>::borrow(val),
4494                    encoder,
4495                    offset + 8,
4496                    _depth,
4497                ),
4498                SampleSinkResult::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
4499            }
4500        }
4501    }
4502
4503    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
4504        for SampleSinkResult
4505    {
4506        #[inline(always)]
4507        fn new_empty() -> Self {
4508            Self::__SourceBreaking { unknown_ordinal: 0 }
4509        }
4510
4511        #[inline]
4512        unsafe fn decode(
4513            &mut self,
4514            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
4515            offset: usize,
4516            mut depth: fidl::encoding::Depth,
4517        ) -> fidl::Result<()> {
4518            decoder.debug_check_bounds::<Self>(offset);
4519            #[allow(unused_variables)]
4520            let next_out_of_line = decoder.next_out_of_line();
4521            let handles_before = decoder.remaining_handles();
4522            let (ordinal, inlined, num_bytes, num_handles) =
4523                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
4524
4525            let member_inline_size = match ordinal {
4526                1 => <SampleReady as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4527                2 => <RuntimeError as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4528                0 => return Err(fidl::Error::UnknownUnionTag),
4529                _ => num_bytes as usize,
4530            };
4531
4532            if inlined != (member_inline_size <= 4) {
4533                return Err(fidl::Error::InvalidInlineBitInEnvelope);
4534            }
4535            let _inner_offset;
4536            if inlined {
4537                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
4538                _inner_offset = offset + 8;
4539            } else {
4540                depth.increment()?;
4541                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4542            }
4543            match ordinal {
4544                1 => {
4545                    #[allow(irrefutable_let_patterns)]
4546                    if let SampleSinkResult::Ready(_) = self {
4547                        // Do nothing, read the value into the object
4548                    } else {
4549                        // Initialize `self` to the right variant
4550                        *self = SampleSinkResult::Ready(fidl::new_empty!(
4551                            SampleReady,
4552                            fdomain_client::fidl::FDomainResourceDialect
4553                        ));
4554                    }
4555                    #[allow(irrefutable_let_patterns)]
4556                    if let SampleSinkResult::Ready(ref mut val) = self {
4557                        fidl::decode!(
4558                            SampleReady,
4559                            fdomain_client::fidl::FDomainResourceDialect,
4560                            val,
4561                            decoder,
4562                            _inner_offset,
4563                            depth
4564                        )?;
4565                    } else {
4566                        unreachable!()
4567                    }
4568                }
4569                2 => {
4570                    #[allow(irrefutable_let_patterns)]
4571                    if let SampleSinkResult::Error(_) = self {
4572                        // Do nothing, read the value into the object
4573                    } else {
4574                        // Initialize `self` to the right variant
4575                        *self = SampleSinkResult::Error(fidl::new_empty!(
4576                            RuntimeError,
4577                            fdomain_client::fidl::FDomainResourceDialect
4578                        ));
4579                    }
4580                    #[allow(irrefutable_let_patterns)]
4581                    if let SampleSinkResult::Error(ref mut val) = self {
4582                        fidl::decode!(
4583                            RuntimeError,
4584                            fdomain_client::fidl::FDomainResourceDialect,
4585                            val,
4586                            decoder,
4587                            _inner_offset,
4588                            depth
4589                        )?;
4590                    } else {
4591                        unreachable!()
4592                    }
4593                }
4594                #[allow(deprecated)]
4595                ordinal => {
4596                    for _ in 0..num_handles {
4597                        decoder.drop_next_handle()?;
4598                    }
4599                    *self = SampleSinkResult::__SourceBreaking { unknown_ordinal: ordinal };
4600                }
4601            }
4602            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
4603                return Err(fidl::Error::InvalidNumBytesInEnvelope);
4604            }
4605            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4606                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4607            }
4608            Ok(())
4609        }
4610    }
4611}