fdomain_fuchsia_diagnostics/
fdomain_fuchsia_diagnostics.rs

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