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