Skip to main content

fdomain_fuchsia_diagnostics/
fdomain_fuchsia_diagnostics.rs

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