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/// A fidl union containing a complete hierarchy of structured diagnostics
43/// data, such that the content can be parsed into a file by itself.
44#[derive(Debug)]
45pub enum FormattedContent {
46    /// A diagnostics schema encoded as json.
47    /// The VMO will contain up to 1mb of diagnostics data.
48    Json(fdomain_fuchsia_mem::Buffer),
49    /// A diagnostics schema encoded as text.
50    /// The VMO will contain up to 1mb of diagnostics data.
51    Text(fdomain_fuchsia_mem::Buffer),
52    /// A diagnostics schema encoded as cbor.
53    /// The VMO will contain up to 1mb of diagnostics data.
54    /// The size will be in ZX_PROP_VMO_CONTENT_SIZE.
55    Cbor(fdomain_client::Vmo),
56    /// A diagnostics schema encoded as FXT.
57    /// This is only valid for logs data.
58    /// The VMO will contain up to PerformanceConfiguration/max_aggregate_content_size_bytes
59    /// of diagnostics data, or 1mb if not specified.
60    /// The size will be in ZX_PROP_VMO_CONTENT_SIZE.
61    Fxt(fdomain_client::Vmo),
62    #[doc(hidden)]
63    __SourceBreaking { unknown_ordinal: u64 },
64}
65
66/// Pattern that matches an unknown `FormattedContent` member.
67#[macro_export]
68macro_rules! FormattedContentUnknown {
69    () => {
70        _
71    };
72}
73
74// Custom PartialEq so that unknown variants are not equal to themselves.
75impl PartialEq for FormattedContent {
76    fn eq(&self, other: &Self) -> bool {
77        match (self, other) {
78            (Self::Json(x), Self::Json(y)) => *x == *y,
79            (Self::Text(x), Self::Text(y)) => *x == *y,
80            (Self::Cbor(x), Self::Cbor(y)) => *x == *y,
81            (Self::Fxt(x), Self::Fxt(y)) => *x == *y,
82            _ => false,
83        }
84    }
85}
86
87impl FormattedContent {
88    #[inline]
89    pub fn ordinal(&self) -> u64 {
90        match *self {
91            Self::Json(_) => 1,
92            Self::Text(_) => 2,
93            Self::Cbor(_) => 3,
94            Self::Fxt(_) => 4,
95            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
96        }
97    }
98
99    #[inline]
100    pub fn unknown_variant_for_testing() -> Self {
101        Self::__SourceBreaking { unknown_ordinal: 0 }
102    }
103
104    #[inline]
105    pub fn is_unknown(&self) -> bool {
106        match self {
107            Self::__SourceBreaking { .. } => true,
108            _ => false,
109        }
110    }
111}
112
113impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for FormattedContent {}
114
115#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
116pub struct ArchiveAccessorMarker;
117
118impl fdomain_client::fidl::ProtocolMarker for ArchiveAccessorMarker {
119    type Proxy = ArchiveAccessorProxy;
120    type RequestStream = ArchiveAccessorRequestStream;
121
122    const DEBUG_NAME: &'static str = "fuchsia.diagnostics.ArchiveAccessor";
123}
124impl fdomain_client::fidl::DiscoverableProtocolMarker for ArchiveAccessorMarker {}
125
126pub trait ArchiveAccessorProxyInterface: Send + Sync {
127    fn r#stream_diagnostics(
128        &self,
129        stream_parameters: &StreamParameters,
130        result_stream: fdomain_client::fidl::ServerEnd<BatchIteratorMarker>,
131    ) -> Result<(), fidl::Error>;
132    type WaitForReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
133    fn r#wait_for_ready(&self) -> Self::WaitForReadyResponseFut;
134}
135
136#[derive(Debug, Clone)]
137pub struct ArchiveAccessorProxy {
138    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
139}
140
141impl fdomain_client::fidl::Proxy for ArchiveAccessorProxy {
142    type Protocol = ArchiveAccessorMarker;
143
144    fn from_channel(inner: fdomain_client::Channel) -> Self {
145        Self::new(inner)
146    }
147
148    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
149        self.client.into_channel().map_err(|client| Self { client })
150    }
151
152    fn as_channel(&self) -> &fdomain_client::Channel {
153        self.client.as_channel()
154    }
155}
156
157impl ArchiveAccessorProxy {
158    /// Create a new Proxy for fuchsia.diagnostics/ArchiveAccessor.
159    pub fn new(channel: fdomain_client::Channel) -> Self {
160        let protocol_name =
161            <ArchiveAccessorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
162        Self { client: fidl::client::Client::new(channel, protocol_name) }
163    }
164
165    /// Get a Stream of events from the remote end of the protocol.
166    ///
167    /// # Panics
168    ///
169    /// Panics if the event stream was already taken.
170    pub fn take_event_stream(&self) -> ArchiveAccessorEventStream {
171        ArchiveAccessorEventStream { event_receiver: self.client.take_event_receiver() }
172    }
173
174    /// Creates an iterator over diagnostics data on the system.
175    ///   * The iterator may be finite by streaming in SNAPSHOT mode, serving only the
176    ///     current state of diagnostics data on the system.
177    ///   * The iterator may be infinite by streaming in either SNAPSHOT_THEN_SUBSCRIBE
178    ///     or SUBSCRIBE mode; the prior first provides iteration over the current state of
179    ///     the sytem, and then both provide ongoing iteration over newly arriving diagnostics
180    ///     data.
181    ///
182    /// + request `result stream` a [fuchsia.diagnostics/BatchIterator] that diagnostic
183    ///   records are exposed to the client over.
184    ///   * epitaphs:
185    ///      - INVALID_ARGS: A required argument in the StreamParameters struct was missing.
186    ///      - WRONG_TYPE: A selector provided by the StreamParameters struct was incorrectly
187    ///                    formatted.
188    ///
189    /// + request `stream_parameters` is a [fuchsia.diagnostics/StreamParameter] which
190    ///   specifies how to configure the stream.
191    pub fn r#stream_diagnostics(
192        &self,
193        mut stream_parameters: &StreamParameters,
194        mut result_stream: fdomain_client::fidl::ServerEnd<BatchIteratorMarker>,
195    ) -> Result<(), fidl::Error> {
196        ArchiveAccessorProxyInterface::r#stream_diagnostics(self, stream_parameters, result_stream)
197    }
198
199    /// Ensures that the connection with the server was established to prevent
200    /// races when using other pipelined methods of this protocol.
201    pub fn r#wait_for_ready(
202        &self,
203    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
204        ArchiveAccessorProxyInterface::r#wait_for_ready(self)
205    }
206}
207
208impl ArchiveAccessorProxyInterface for ArchiveAccessorProxy {
209    fn r#stream_diagnostics(
210        &self,
211        mut stream_parameters: &StreamParameters,
212        mut result_stream: fdomain_client::fidl::ServerEnd<BatchIteratorMarker>,
213    ) -> Result<(), fidl::Error> {
214        self.client.send::<ArchiveAccessorStreamDiagnosticsRequest>(
215            (stream_parameters, result_stream),
216            0x20c73e2ecd653c3e,
217            fidl::encoding::DynamicFlags::FLEXIBLE,
218        )
219    }
220
221    type WaitForReadyResponseFut =
222        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
223    fn r#wait_for_ready(&self) -> Self::WaitForReadyResponseFut {
224        fn _decode(
225            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
226        ) -> Result<(), fidl::Error> {
227            let _response = fidl::client::decode_transaction_body::<
228                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
229                fdomain_client::fidl::FDomainResourceDialect,
230                0x122963198011bd24,
231            >(_buf?)?
232            .into_result_fdomain::<ArchiveAccessorMarker>("wait_for_ready")?;
233            Ok(_response)
234        }
235        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
236            (),
237            0x122963198011bd24,
238            fidl::encoding::DynamicFlags::FLEXIBLE,
239            _decode,
240        )
241    }
242}
243
244pub struct ArchiveAccessorEventStream {
245    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
246}
247
248impl std::marker::Unpin for ArchiveAccessorEventStream {}
249
250impl futures::stream::FusedStream for ArchiveAccessorEventStream {
251    fn is_terminated(&self) -> bool {
252        self.event_receiver.is_terminated()
253    }
254}
255
256impl futures::Stream for ArchiveAccessorEventStream {
257    type Item = Result<ArchiveAccessorEvent, fidl::Error>;
258
259    fn poll_next(
260        mut self: std::pin::Pin<&mut Self>,
261        cx: &mut std::task::Context<'_>,
262    ) -> std::task::Poll<Option<Self::Item>> {
263        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
264            &mut self.event_receiver,
265            cx
266        )?) {
267            Some(buf) => std::task::Poll::Ready(Some(ArchiveAccessorEvent::decode(buf))),
268            None => std::task::Poll::Ready(None),
269        }
270    }
271}
272
273#[derive(Debug)]
274pub enum ArchiveAccessorEvent {
275    #[non_exhaustive]
276    _UnknownEvent {
277        /// Ordinal of the event that was sent.
278        ordinal: u64,
279    },
280}
281
282impl ArchiveAccessorEvent {
283    /// Decodes a message buffer as a [`ArchiveAccessorEvent`].
284    fn decode(
285        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
286    ) -> Result<ArchiveAccessorEvent, fidl::Error> {
287        let (bytes, _handles) = buf.split_mut();
288        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
289        debug_assert_eq!(tx_header.tx_id, 0);
290        match tx_header.ordinal {
291            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
292                Ok(ArchiveAccessorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
293            }
294            _ => Err(fidl::Error::UnknownOrdinal {
295                ordinal: tx_header.ordinal,
296                protocol_name:
297                    <ArchiveAccessorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
298            }),
299        }
300    }
301}
302
303/// A Stream of incoming requests for fuchsia.diagnostics/ArchiveAccessor.
304pub struct ArchiveAccessorRequestStream {
305    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
306    is_terminated: bool,
307}
308
309impl std::marker::Unpin for ArchiveAccessorRequestStream {}
310
311impl futures::stream::FusedStream for ArchiveAccessorRequestStream {
312    fn is_terminated(&self) -> bool {
313        self.is_terminated
314    }
315}
316
317impl fdomain_client::fidl::RequestStream for ArchiveAccessorRequestStream {
318    type Protocol = ArchiveAccessorMarker;
319    type ControlHandle = ArchiveAccessorControlHandle;
320
321    fn from_channel(channel: fdomain_client::Channel) -> Self {
322        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
323    }
324
325    fn control_handle(&self) -> Self::ControlHandle {
326        ArchiveAccessorControlHandle { inner: self.inner.clone() }
327    }
328
329    fn into_inner(
330        self,
331    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
332    {
333        (self.inner, self.is_terminated)
334    }
335
336    fn from_inner(
337        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
338        is_terminated: bool,
339    ) -> Self {
340        Self { inner, is_terminated }
341    }
342}
343
344impl futures::Stream for ArchiveAccessorRequestStream {
345    type Item = Result<ArchiveAccessorRequest, fidl::Error>;
346
347    fn poll_next(
348        mut self: std::pin::Pin<&mut Self>,
349        cx: &mut std::task::Context<'_>,
350    ) -> std::task::Poll<Option<Self::Item>> {
351        let this = &mut *self;
352        if this.inner.check_shutdown(cx) {
353            this.is_terminated = true;
354            return std::task::Poll::Ready(None);
355        }
356        if this.is_terminated {
357            panic!("polled ArchiveAccessorRequestStream after completion");
358        }
359        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
360            |bytes, handles| {
361                match this.inner.channel().read_etc(cx, bytes, handles) {
362                    std::task::Poll::Ready(Ok(())) => {}
363                    std::task::Poll::Pending => return std::task::Poll::Pending,
364                    std::task::Poll::Ready(Err(None)) => {
365                        this.is_terminated = true;
366                        return std::task::Poll::Ready(None);
367                    }
368                    std::task::Poll::Ready(Err(Some(e))) => {
369                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
370                            e.into(),
371                        ))))
372                    }
373                }
374
375                // A message has been received from the channel
376                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
377
378                std::task::Poll::Ready(Some(match header.ordinal {
379                0x20c73e2ecd653c3e => {
380                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
381                    let mut req = fidl::new_empty!(ArchiveAccessorStreamDiagnosticsRequest, fdomain_client::fidl::FDomainResourceDialect);
382                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ArchiveAccessorStreamDiagnosticsRequest>(&header, _body_bytes, handles, &mut req)?;
383                    let control_handle = ArchiveAccessorControlHandle {
384                        inner: this.inner.clone(),
385                    };
386                    Ok(ArchiveAccessorRequest::StreamDiagnostics {stream_parameters: req.stream_parameters,
387result_stream: req.result_stream,
388
389                        control_handle,
390                    })
391                }
392                0x122963198011bd24 => {
393                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
394                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
395                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
396                    let control_handle = ArchiveAccessorControlHandle {
397                        inner: this.inner.clone(),
398                    };
399                    Ok(ArchiveAccessorRequest::WaitForReady {
400                        responder: ArchiveAccessorWaitForReadyResponder {
401                            control_handle: std::mem::ManuallyDrop::new(control_handle),
402                            tx_id: header.tx_id,
403                        },
404                    })
405                }
406                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
407                    Ok(ArchiveAccessorRequest::_UnknownMethod {
408                        ordinal: header.ordinal,
409                        control_handle: ArchiveAccessorControlHandle { inner: this.inner.clone() },
410                        method_type: fidl::MethodType::OneWay,
411                    })
412                }
413                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
414                    this.inner.send_framework_err(
415                        fidl::encoding::FrameworkErr::UnknownMethod,
416                        header.tx_id,
417                        header.ordinal,
418                        header.dynamic_flags(),
419                        (bytes, handles),
420                    )?;
421                    Ok(ArchiveAccessorRequest::_UnknownMethod {
422                        ordinal: header.ordinal,
423                        control_handle: ArchiveAccessorControlHandle { inner: this.inner.clone() },
424                        method_type: fidl::MethodType::TwoWay,
425                    })
426                }
427                _ => Err(fidl::Error::UnknownOrdinal {
428                    ordinal: header.ordinal,
429                    protocol_name: <ArchiveAccessorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
430                }),
431            }))
432            },
433        )
434    }
435}
436
437/// Outer protocol for interacting with the different diagnostics data sources.
438#[derive(Debug)]
439pub enum ArchiveAccessorRequest {
440    /// Creates an iterator over diagnostics data on the system.
441    ///   * The iterator may be finite by streaming in SNAPSHOT mode, serving only the
442    ///     current state of diagnostics data on the system.
443    ///   * The iterator may be infinite by streaming in either SNAPSHOT_THEN_SUBSCRIBE
444    ///     or SUBSCRIBE mode; the prior first provides iteration over the current state of
445    ///     the sytem, and then both provide ongoing iteration over newly arriving diagnostics
446    ///     data.
447    ///
448    /// + request `result stream` a [fuchsia.diagnostics/BatchIterator] that diagnostic
449    ///   records are exposed to the client over.
450    ///   * epitaphs:
451    ///      - INVALID_ARGS: A required argument in the StreamParameters struct was missing.
452    ///      - WRONG_TYPE: A selector provided by the StreamParameters struct was incorrectly
453    ///                    formatted.
454    ///
455    /// + request `stream_parameters` is a [fuchsia.diagnostics/StreamParameter] which
456    ///   specifies how to configure the stream.
457    StreamDiagnostics {
458        stream_parameters: StreamParameters,
459        result_stream: fdomain_client::fidl::ServerEnd<BatchIteratorMarker>,
460        control_handle: ArchiveAccessorControlHandle,
461    },
462    /// Ensures that the connection with the server was established to prevent
463    /// races when using other pipelined methods of this protocol.
464    WaitForReady { responder: ArchiveAccessorWaitForReadyResponder },
465    /// An interaction was received which does not match any known method.
466    #[non_exhaustive]
467    _UnknownMethod {
468        /// Ordinal of the method that was called.
469        ordinal: u64,
470        control_handle: ArchiveAccessorControlHandle,
471        method_type: fidl::MethodType,
472    },
473}
474
475impl ArchiveAccessorRequest {
476    #[allow(irrefutable_let_patterns)]
477    pub fn into_stream_diagnostics(
478        self,
479    ) -> Option<(
480        StreamParameters,
481        fdomain_client::fidl::ServerEnd<BatchIteratorMarker>,
482        ArchiveAccessorControlHandle,
483    )> {
484        if let ArchiveAccessorRequest::StreamDiagnostics {
485            stream_parameters,
486            result_stream,
487            control_handle,
488        } = self
489        {
490            Some((stream_parameters, result_stream, control_handle))
491        } else {
492            None
493        }
494    }
495
496    #[allow(irrefutable_let_patterns)]
497    pub fn into_wait_for_ready(self) -> Option<(ArchiveAccessorWaitForReadyResponder)> {
498        if let ArchiveAccessorRequest::WaitForReady { responder } = self {
499            Some((responder))
500        } else {
501            None
502        }
503    }
504
505    /// Name of the method defined in FIDL
506    pub fn method_name(&self) -> &'static str {
507        match *self {
508            ArchiveAccessorRequest::StreamDiagnostics { .. } => "stream_diagnostics",
509            ArchiveAccessorRequest::WaitForReady { .. } => "wait_for_ready",
510            ArchiveAccessorRequest::_UnknownMethod {
511                method_type: fidl::MethodType::OneWay,
512                ..
513            } => "unknown one-way method",
514            ArchiveAccessorRequest::_UnknownMethod {
515                method_type: fidl::MethodType::TwoWay,
516                ..
517            } => "unknown two-way method",
518        }
519    }
520}
521
522#[derive(Debug, Clone)]
523pub struct ArchiveAccessorControlHandle {
524    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
525}
526
527impl fdomain_client::fidl::ControlHandle for ArchiveAccessorControlHandle {
528    fn shutdown(&self) {
529        self.inner.shutdown()
530    }
531
532    fn is_closed(&self) -> bool {
533        self.inner.channel().is_closed()
534    }
535    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
536        self.inner.channel().on_closed()
537    }
538}
539
540impl ArchiveAccessorControlHandle {}
541
542#[must_use = "FIDL methods require a response to be sent"]
543#[derive(Debug)]
544pub struct ArchiveAccessorWaitForReadyResponder {
545    control_handle: std::mem::ManuallyDrop<ArchiveAccessorControlHandle>,
546    tx_id: u32,
547}
548
549/// Set the the channel to be shutdown (see [`ArchiveAccessorControlHandle::shutdown`])
550/// if the responder is dropped without sending a response, so that the client
551/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
552impl std::ops::Drop for ArchiveAccessorWaitForReadyResponder {
553    fn drop(&mut self) {
554        self.control_handle.shutdown();
555        // Safety: drops once, never accessed again
556        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
557    }
558}
559
560impl fdomain_client::fidl::Responder for ArchiveAccessorWaitForReadyResponder {
561    type ControlHandle = ArchiveAccessorControlHandle;
562
563    fn control_handle(&self) -> &ArchiveAccessorControlHandle {
564        &self.control_handle
565    }
566
567    fn drop_without_shutdown(mut self) {
568        // Safety: drops once, never accessed again due to mem::forget
569        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
570        // Prevent Drop from running (which would shut down the channel)
571        std::mem::forget(self);
572    }
573}
574
575impl ArchiveAccessorWaitForReadyResponder {
576    /// Sends a response to the FIDL transaction.
577    ///
578    /// Sets the channel to shutdown if an error occurs.
579    pub fn send(self) -> Result<(), fidl::Error> {
580        let _result = self.send_raw();
581        if _result.is_err() {
582            self.control_handle.shutdown();
583        }
584        self.drop_without_shutdown();
585        _result
586    }
587
588    /// Similar to "send" but does not shutdown the channel if an error occurs.
589    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
590        let _result = self.send_raw();
591        self.drop_without_shutdown();
592        _result
593    }
594
595    fn send_raw(&self) -> Result<(), fidl::Error> {
596        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
597            fidl::encoding::Flexible::new(()),
598            self.tx_id,
599            0x122963198011bd24,
600            fidl::encoding::DynamicFlags::FLEXIBLE,
601        )
602    }
603}
604
605#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
606pub struct BatchIteratorMarker;
607
608impl fdomain_client::fidl::ProtocolMarker for BatchIteratorMarker {
609    type Proxy = BatchIteratorProxy;
610    type RequestStream = BatchIteratorRequestStream;
611
612    const DEBUG_NAME: &'static str = "(anonymous) BatchIterator";
613}
614pub type BatchIteratorGetNextResult = Result<Vec<FormattedContent>, ReaderError>;
615
616pub trait BatchIteratorProxyInterface: Send + Sync {
617    type GetNextResponseFut: std::future::Future<Output = Result<BatchIteratorGetNextResult, fidl::Error>>
618        + Send;
619    fn r#get_next(&self) -> Self::GetNextResponseFut;
620    type WaitForReadyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
621    fn r#wait_for_ready(&self) -> Self::WaitForReadyResponseFut;
622}
623
624#[derive(Debug, Clone)]
625pub struct BatchIteratorProxy {
626    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
627}
628
629impl fdomain_client::fidl::Proxy for BatchIteratorProxy {
630    type Protocol = BatchIteratorMarker;
631
632    fn from_channel(inner: fdomain_client::Channel) -> Self {
633        Self::new(inner)
634    }
635
636    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
637        self.client.into_channel().map_err(|client| Self { client })
638    }
639
640    fn as_channel(&self) -> &fdomain_client::Channel {
641        self.client.as_channel()
642    }
643}
644
645impl BatchIteratorProxy {
646    /// Create a new Proxy for fuchsia.diagnostics/BatchIterator.
647    pub fn new(channel: fdomain_client::Channel) -> Self {
648        let protocol_name =
649            <BatchIteratorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
650        Self { client: fidl::client::Client::new(channel, protocol_name) }
651    }
652
653    /// Get a Stream of events from the remote end of the protocol.
654    ///
655    /// # Panics
656    ///
657    /// Panics if the event stream was already taken.
658    pub fn take_event_stream(&self) -> BatchIteratorEventStream {
659        BatchIteratorEventStream { event_receiver: self.client.take_event_receiver() }
660    }
661
662    /// Returns a vector of [fuchsia.diagnostics/FormattedContent] structs
663    /// with a format dictated by the format_settings argument provided to the Reader protocol
664    /// which spawned this BatchIterator.
665    ///
666    /// An empty vector implies that the data hierarchy has been fully iterated, and subsequent
667    /// GetNext calls will always return the empty vector.
668    ///
669    /// When the BatchIterator is serving results via subscription model, calls to GetNext will
670    /// hang until there is new data available, it will not return an empty vector.
671    ///
672    /// - returns a vector of FormattedContent structs. Clients connected to a
673    ///   Batch are expected to call GetNext() until an empty vector
674    ///   is returned, denoting that the entire data hierarchy has been read.
675    ///
676    /// * error a [fuchsia.diagnostics/ReaderError]
677    ///   value indicating that there was an issue reading the underlying data hierarchies
678    ///   or formatting those hierarchies to populate the `batch`. Note, these
679    ///   issues do not include a single component's data hierarchy failing to be read.
680    ///   The iterator is tolerant of individual component data sources failing to be read,
681    ///   whether that failure is a timeout or a malformed binary file.
682    ///   In the event that a GetNext call fails, that subset of the data hierarchy results is
683    ///   dropped, but future calls to GetNext will provide new subsets of
684    ///   FormattedDataHierarchies.
685    pub fn r#get_next(
686        &self,
687    ) -> fidl::client::QueryResponseFut<
688        BatchIteratorGetNextResult,
689        fdomain_client::fidl::FDomainResourceDialect,
690    > {
691        BatchIteratorProxyInterface::r#get_next(self)
692    }
693
694    /// Indiciates that the BatchIterator has been connected. If the
695    /// BatchIterator hasn't been connected, this method will hang until it is.
696    pub fn r#wait_for_ready(
697        &self,
698    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
699        BatchIteratorProxyInterface::r#wait_for_ready(self)
700    }
701}
702
703impl BatchIteratorProxyInterface for BatchIteratorProxy {
704    type GetNextResponseFut = fidl::client::QueryResponseFut<
705        BatchIteratorGetNextResult,
706        fdomain_client::fidl::FDomainResourceDialect,
707    >;
708    fn r#get_next(&self) -> Self::GetNextResponseFut {
709        fn _decode(
710            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
711        ) -> Result<BatchIteratorGetNextResult, fidl::Error> {
712            let _response = fidl::client::decode_transaction_body::<
713                fidl::encoding::FlexibleResultType<BatchIteratorGetNextResponse, ReaderError>,
714                fdomain_client::fidl::FDomainResourceDialect,
715                0x781986486c6254a5,
716            >(_buf?)?
717            .into_result_fdomain::<BatchIteratorMarker>("get_next")?;
718            Ok(_response.map(|x| x.batch))
719        }
720        self.client
721            .send_query_and_decode::<fidl::encoding::EmptyPayload, BatchIteratorGetNextResult>(
722                (),
723                0x781986486c6254a5,
724                fidl::encoding::DynamicFlags::FLEXIBLE,
725                _decode,
726            )
727    }
728
729    type WaitForReadyResponseFut =
730        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
731    fn r#wait_for_ready(&self) -> Self::WaitForReadyResponseFut {
732        fn _decode(
733            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
734        ) -> Result<(), fidl::Error> {
735            let _response = fidl::client::decode_transaction_body::<
736                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
737                fdomain_client::fidl::FDomainResourceDialect,
738                0x70598ee271597603,
739            >(_buf?)?
740            .into_result_fdomain::<BatchIteratorMarker>("wait_for_ready")?;
741            Ok(_response)
742        }
743        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
744            (),
745            0x70598ee271597603,
746            fidl::encoding::DynamicFlags::FLEXIBLE,
747            _decode,
748        )
749    }
750}
751
752pub struct BatchIteratorEventStream {
753    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
754}
755
756impl std::marker::Unpin for BatchIteratorEventStream {}
757
758impl futures::stream::FusedStream for BatchIteratorEventStream {
759    fn is_terminated(&self) -> bool {
760        self.event_receiver.is_terminated()
761    }
762}
763
764impl futures::Stream for BatchIteratorEventStream {
765    type Item = Result<BatchIteratorEvent, fidl::Error>;
766
767    fn poll_next(
768        mut self: std::pin::Pin<&mut Self>,
769        cx: &mut std::task::Context<'_>,
770    ) -> std::task::Poll<Option<Self::Item>> {
771        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
772            &mut self.event_receiver,
773            cx
774        )?) {
775            Some(buf) => std::task::Poll::Ready(Some(BatchIteratorEvent::decode(buf))),
776            None => std::task::Poll::Ready(None),
777        }
778    }
779}
780
781#[derive(Debug)]
782pub enum BatchIteratorEvent {
783    #[non_exhaustive]
784    _UnknownEvent {
785        /// Ordinal of the event that was sent.
786        ordinal: u64,
787    },
788}
789
790impl BatchIteratorEvent {
791    /// Decodes a message buffer as a [`BatchIteratorEvent`].
792    fn decode(
793        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
794    ) -> Result<BatchIteratorEvent, fidl::Error> {
795        let (bytes, _handles) = buf.split_mut();
796        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
797        debug_assert_eq!(tx_header.tx_id, 0);
798        match tx_header.ordinal {
799            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
800                Ok(BatchIteratorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
801            }
802            _ => Err(fidl::Error::UnknownOrdinal {
803                ordinal: tx_header.ordinal,
804                protocol_name:
805                    <BatchIteratorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
806            }),
807        }
808    }
809}
810
811/// A Stream of incoming requests for fuchsia.diagnostics/BatchIterator.
812pub struct BatchIteratorRequestStream {
813    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
814    is_terminated: bool,
815}
816
817impl std::marker::Unpin for BatchIteratorRequestStream {}
818
819impl futures::stream::FusedStream for BatchIteratorRequestStream {
820    fn is_terminated(&self) -> bool {
821        self.is_terminated
822    }
823}
824
825impl fdomain_client::fidl::RequestStream for BatchIteratorRequestStream {
826    type Protocol = BatchIteratorMarker;
827    type ControlHandle = BatchIteratorControlHandle;
828
829    fn from_channel(channel: fdomain_client::Channel) -> Self {
830        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
831    }
832
833    fn control_handle(&self) -> Self::ControlHandle {
834        BatchIteratorControlHandle { inner: self.inner.clone() }
835    }
836
837    fn into_inner(
838        self,
839    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
840    {
841        (self.inner, self.is_terminated)
842    }
843
844    fn from_inner(
845        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
846        is_terminated: bool,
847    ) -> Self {
848        Self { inner, is_terminated }
849    }
850}
851
852impl futures::Stream for BatchIteratorRequestStream {
853    type Item = Result<BatchIteratorRequest, fidl::Error>;
854
855    fn poll_next(
856        mut self: std::pin::Pin<&mut Self>,
857        cx: &mut std::task::Context<'_>,
858    ) -> std::task::Poll<Option<Self::Item>> {
859        let this = &mut *self;
860        if this.inner.check_shutdown(cx) {
861            this.is_terminated = true;
862            return std::task::Poll::Ready(None);
863        }
864        if this.is_terminated {
865            panic!("polled BatchIteratorRequestStream after completion");
866        }
867        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
868            |bytes, handles| {
869                match this.inner.channel().read_etc(cx, bytes, handles) {
870                    std::task::Poll::Ready(Ok(())) => {}
871                    std::task::Poll::Pending => return std::task::Poll::Pending,
872                    std::task::Poll::Ready(Err(None)) => {
873                        this.is_terminated = true;
874                        return std::task::Poll::Ready(None);
875                    }
876                    std::task::Poll::Ready(Err(Some(e))) => {
877                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
878                            e.into(),
879                        ))))
880                    }
881                }
882
883                // A message has been received from the channel
884                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
885
886                std::task::Poll::Ready(Some(match header.ordinal {
887                0x781986486c6254a5 => {
888                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
889                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
890                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
891                    let control_handle = BatchIteratorControlHandle {
892                        inner: this.inner.clone(),
893                    };
894                    Ok(BatchIteratorRequest::GetNext {
895                        responder: BatchIteratorGetNextResponder {
896                            control_handle: std::mem::ManuallyDrop::new(control_handle),
897                            tx_id: header.tx_id,
898                        },
899                    })
900                }
901                0x70598ee271597603 => {
902                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
903                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
904                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
905                    let control_handle = BatchIteratorControlHandle {
906                        inner: this.inner.clone(),
907                    };
908                    Ok(BatchIteratorRequest::WaitForReady {
909                        responder: BatchIteratorWaitForReadyResponder {
910                            control_handle: std::mem::ManuallyDrop::new(control_handle),
911                            tx_id: header.tx_id,
912                        },
913                    })
914                }
915                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
916                    Ok(BatchIteratorRequest::_UnknownMethod {
917                        ordinal: header.ordinal,
918                        control_handle: BatchIteratorControlHandle { inner: this.inner.clone() },
919                        method_type: fidl::MethodType::OneWay,
920                    })
921                }
922                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
923                    this.inner.send_framework_err(
924                        fidl::encoding::FrameworkErr::UnknownMethod,
925                        header.tx_id,
926                        header.ordinal,
927                        header.dynamic_flags(),
928                        (bytes, handles),
929                    )?;
930                    Ok(BatchIteratorRequest::_UnknownMethod {
931                        ordinal: header.ordinal,
932                        control_handle: BatchIteratorControlHandle { inner: this.inner.clone() },
933                        method_type: fidl::MethodType::TwoWay,
934                    })
935                }
936                _ => Err(fidl::Error::UnknownOrdinal {
937                    ordinal: header.ordinal,
938                    protocol_name: <BatchIteratorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
939                }),
940            }))
941            },
942        )
943    }
944}
945
946/// Conceptually, a directory iterator, where each element in the iterator is a single
947/// complete file that can be concatenated with other results.
948#[derive(Debug)]
949pub enum BatchIteratorRequest {
950    /// Returns a vector of [fuchsia.diagnostics/FormattedContent] structs
951    /// with a format dictated by the format_settings argument provided to the Reader protocol
952    /// which spawned this BatchIterator.
953    ///
954    /// An empty vector implies that the data hierarchy has been fully iterated, and subsequent
955    /// GetNext calls will always return the empty vector.
956    ///
957    /// When the BatchIterator is serving results via subscription model, calls to GetNext will
958    /// hang until there is new data available, it will not return an empty vector.
959    ///
960    /// - returns a vector of FormattedContent structs. Clients connected to a
961    ///   Batch are expected to call GetNext() until an empty vector
962    ///   is returned, denoting that the entire data hierarchy has been read.
963    ///
964    /// * error a [fuchsia.diagnostics/ReaderError]
965    ///   value indicating that there was an issue reading the underlying data hierarchies
966    ///   or formatting those hierarchies to populate the `batch`. Note, these
967    ///   issues do not include a single component's data hierarchy failing to be read.
968    ///   The iterator is tolerant of individual component data sources failing to be read,
969    ///   whether that failure is a timeout or a malformed binary file.
970    ///   In the event that a GetNext call fails, that subset of the data hierarchy results is
971    ///   dropped, but future calls to GetNext will provide new subsets of
972    ///   FormattedDataHierarchies.
973    GetNext { responder: BatchIteratorGetNextResponder },
974    /// Indiciates that the BatchIterator has been connected. If the
975    /// BatchIterator hasn't been connected, this method will hang until it is.
976    WaitForReady { responder: BatchIteratorWaitForReadyResponder },
977    /// An interaction was received which does not match any known method.
978    #[non_exhaustive]
979    _UnknownMethod {
980        /// Ordinal of the method that was called.
981        ordinal: u64,
982        control_handle: BatchIteratorControlHandle,
983        method_type: fidl::MethodType,
984    },
985}
986
987impl BatchIteratorRequest {
988    #[allow(irrefutable_let_patterns)]
989    pub fn into_get_next(self) -> Option<(BatchIteratorGetNextResponder)> {
990        if let BatchIteratorRequest::GetNext { responder } = self {
991            Some((responder))
992        } else {
993            None
994        }
995    }
996
997    #[allow(irrefutable_let_patterns)]
998    pub fn into_wait_for_ready(self) -> Option<(BatchIteratorWaitForReadyResponder)> {
999        if let BatchIteratorRequest::WaitForReady { responder } = self {
1000            Some((responder))
1001        } else {
1002            None
1003        }
1004    }
1005
1006    /// Name of the method defined in FIDL
1007    pub fn method_name(&self) -> &'static str {
1008        match *self {
1009            BatchIteratorRequest::GetNext { .. } => "get_next",
1010            BatchIteratorRequest::WaitForReady { .. } => "wait_for_ready",
1011            BatchIteratorRequest::_UnknownMethod {
1012                method_type: fidl::MethodType::OneWay, ..
1013            } => "unknown one-way method",
1014            BatchIteratorRequest::_UnknownMethod {
1015                method_type: fidl::MethodType::TwoWay, ..
1016            } => "unknown two-way method",
1017        }
1018    }
1019}
1020
1021#[derive(Debug, Clone)]
1022pub struct BatchIteratorControlHandle {
1023    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1024}
1025
1026impl fdomain_client::fidl::ControlHandle for BatchIteratorControlHandle {
1027    fn shutdown(&self) {
1028        self.inner.shutdown()
1029    }
1030
1031    fn is_closed(&self) -> bool {
1032        self.inner.channel().is_closed()
1033    }
1034    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1035        self.inner.channel().on_closed()
1036    }
1037}
1038
1039impl BatchIteratorControlHandle {}
1040
1041#[must_use = "FIDL methods require a response to be sent"]
1042#[derive(Debug)]
1043pub struct BatchIteratorGetNextResponder {
1044    control_handle: std::mem::ManuallyDrop<BatchIteratorControlHandle>,
1045    tx_id: u32,
1046}
1047
1048/// Set the the channel to be shutdown (see [`BatchIteratorControlHandle::shutdown`])
1049/// if the responder is dropped without sending a response, so that the client
1050/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1051impl std::ops::Drop for BatchIteratorGetNextResponder {
1052    fn drop(&mut self) {
1053        self.control_handle.shutdown();
1054        // Safety: drops once, never accessed again
1055        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1056    }
1057}
1058
1059impl fdomain_client::fidl::Responder for BatchIteratorGetNextResponder {
1060    type ControlHandle = BatchIteratorControlHandle;
1061
1062    fn control_handle(&self) -> &BatchIteratorControlHandle {
1063        &self.control_handle
1064    }
1065
1066    fn drop_without_shutdown(mut self) {
1067        // Safety: drops once, never accessed again due to mem::forget
1068        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1069        // Prevent Drop from running (which would shut down the channel)
1070        std::mem::forget(self);
1071    }
1072}
1073
1074impl BatchIteratorGetNextResponder {
1075    /// Sends a response to the FIDL transaction.
1076    ///
1077    /// Sets the channel to shutdown if an error occurs.
1078    pub fn send(
1079        self,
1080        mut result: Result<Vec<FormattedContent>, ReaderError>,
1081    ) -> Result<(), fidl::Error> {
1082        let _result = self.send_raw(result);
1083        if _result.is_err() {
1084            self.control_handle.shutdown();
1085        }
1086        self.drop_without_shutdown();
1087        _result
1088    }
1089
1090    /// Similar to "send" but does not shutdown the channel if an error occurs.
1091    pub fn send_no_shutdown_on_err(
1092        self,
1093        mut result: Result<Vec<FormattedContent>, ReaderError>,
1094    ) -> Result<(), fidl::Error> {
1095        let _result = self.send_raw(result);
1096        self.drop_without_shutdown();
1097        _result
1098    }
1099
1100    fn send_raw(
1101        &self,
1102        mut result: Result<Vec<FormattedContent>, ReaderError>,
1103    ) -> Result<(), fidl::Error> {
1104        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1105            BatchIteratorGetNextResponse,
1106            ReaderError,
1107        >>(
1108            fidl::encoding::FlexibleResult::new(
1109                result.as_mut().map_err(|e| *e).map(|batch| (batch.as_mut_slice(),)),
1110            ),
1111            self.tx_id,
1112            0x781986486c6254a5,
1113            fidl::encoding::DynamicFlags::FLEXIBLE,
1114        )
1115    }
1116}
1117
1118#[must_use = "FIDL methods require a response to be sent"]
1119#[derive(Debug)]
1120pub struct BatchIteratorWaitForReadyResponder {
1121    control_handle: std::mem::ManuallyDrop<BatchIteratorControlHandle>,
1122    tx_id: u32,
1123}
1124
1125/// Set the the channel to be shutdown (see [`BatchIteratorControlHandle::shutdown`])
1126/// if the responder is dropped without sending a response, so that the client
1127/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1128impl std::ops::Drop for BatchIteratorWaitForReadyResponder {
1129    fn drop(&mut self) {
1130        self.control_handle.shutdown();
1131        // Safety: drops once, never accessed again
1132        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1133    }
1134}
1135
1136impl fdomain_client::fidl::Responder for BatchIteratorWaitForReadyResponder {
1137    type ControlHandle = BatchIteratorControlHandle;
1138
1139    fn control_handle(&self) -> &BatchIteratorControlHandle {
1140        &self.control_handle
1141    }
1142
1143    fn drop_without_shutdown(mut self) {
1144        // Safety: drops once, never accessed again due to mem::forget
1145        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1146        // Prevent Drop from running (which would shut down the channel)
1147        std::mem::forget(self);
1148    }
1149}
1150
1151impl BatchIteratorWaitForReadyResponder {
1152    /// Sends a response to the FIDL transaction.
1153    ///
1154    /// Sets the channel to shutdown if an error occurs.
1155    pub fn send(self) -> Result<(), fidl::Error> {
1156        let _result = self.send_raw();
1157        if _result.is_err() {
1158            self.control_handle.shutdown();
1159        }
1160        self.drop_without_shutdown();
1161        _result
1162    }
1163
1164    /// Similar to "send" but does not shutdown the channel if an error occurs.
1165    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1166        let _result = self.send_raw();
1167        self.drop_without_shutdown();
1168        _result
1169    }
1170
1171    fn send_raw(&self) -> Result<(), fidl::Error> {
1172        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
1173            fidl::encoding::Flexible::new(()),
1174            self.tx_id,
1175            0x70598ee271597603,
1176            fidl::encoding::DynamicFlags::FLEXIBLE,
1177        )
1178    }
1179}
1180
1181#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1182pub struct LogSettingsMarker;
1183
1184impl fdomain_client::fidl::ProtocolMarker for LogSettingsMarker {
1185    type Proxy = LogSettingsProxy;
1186    type RequestStream = LogSettingsRequestStream;
1187
1188    const DEBUG_NAME: &'static str = "fuchsia.diagnostics.LogSettings";
1189}
1190impl fdomain_client::fidl::DiscoverableProtocolMarker for LogSettingsMarker {}
1191
1192pub trait LogSettingsProxyInterface: Send + Sync {
1193    fn r#register_interest(&self, selectors: &[LogInterestSelector]) -> Result<(), fidl::Error>;
1194    type SetInterestResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1195    fn r#set_interest(&self, selectors: &[LogInterestSelector]) -> Self::SetInterestResponseFut;
1196    type SetComponentInterestResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
1197        + Send;
1198    fn r#set_component_interest(
1199        &self,
1200        payload: &LogSettingsSetComponentInterestRequest,
1201    ) -> Self::SetComponentInterestResponseFut;
1202}
1203
1204#[derive(Debug, Clone)]
1205pub struct LogSettingsProxy {
1206    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
1207}
1208
1209impl fdomain_client::fidl::Proxy for LogSettingsProxy {
1210    type Protocol = LogSettingsMarker;
1211
1212    fn from_channel(inner: fdomain_client::Channel) -> Self {
1213        Self::new(inner)
1214    }
1215
1216    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
1217        self.client.into_channel().map_err(|client| Self { client })
1218    }
1219
1220    fn as_channel(&self) -> &fdomain_client::Channel {
1221        self.client.as_channel()
1222    }
1223}
1224
1225impl LogSettingsProxy {
1226    /// Create a new Proxy for fuchsia.diagnostics/LogSettings.
1227    pub fn new(channel: fdomain_client::Channel) -> Self {
1228        let protocol_name = <LogSettingsMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
1229        Self { client: fidl::client::Client::new(channel, protocol_name) }
1230    }
1231
1232    /// Get a Stream of events from the remote end of the protocol.
1233    ///
1234    /// # Panics
1235    ///
1236    /// Panics if the event stream was already taken.
1237    pub fn take_event_stream(&self) -> LogSettingsEventStream {
1238        LogSettingsEventStream { event_receiver: self.client.take_event_receiver() }
1239    }
1240
1241    pub fn r#register_interest(
1242        &self,
1243        mut selectors: &[LogInterestSelector],
1244    ) -> Result<(), fidl::Error> {
1245        LogSettingsProxyInterface::r#register_interest(self, selectors)
1246    }
1247
1248    /// Requests a change in interest for the matched components.
1249    ///
1250    /// Each component holds a set of requested interests.
1251    ///
1252    /// When a new request on LogSettings#SetInterest is received,
1253    /// the sets for matched components receive the new minimum interest.
1254    /// If the interest is less than the previous minimum interest, then a
1255    /// `SetInterest` request is sent with the new minimum interest.
1256    ///
1257    /// If a connection to `LogSettings` sends another `SetInterest`
1258    /// request, its previous interest request will be undone.
1259    ///
1260    /// When the connection to `LogSettings` is finished, the interests are
1261    /// undone. Each matched component minimum interest is updated with the
1262    /// new minimum interest in the set.
1263    pub fn r#set_interest(
1264        &self,
1265        mut selectors: &[LogInterestSelector],
1266    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
1267        LogSettingsProxyInterface::r#set_interest(self, selectors)
1268    }
1269
1270    /// Requests a change in interest for the matched components.
1271    ///
1272    /// Each component holds a set of requested interests.
1273    ///
1274    /// When a new request on LogSettings#SetComponentInterest is received,
1275    /// the sets for matched components receive the new minimum interest.
1276    /// If the interest is less than the previous minimum interest, then a
1277    /// `SetComponentInterest` request is sent with the new minimum interest.
1278    ///
1279    /// If a connection to `LogSettings` sends another `SetComponentInterest`
1280    /// request, its previous interest request will be undone.
1281    ///
1282    /// When the connection to `LogSettings` is finished, the interests are
1283    /// undone, unless persist is set to true. Each matched component minimum
1284    /// interest is updated with the new minimum interest in the set.
1285    pub fn r#set_component_interest(
1286        &self,
1287        mut payload: &LogSettingsSetComponentInterestRequest,
1288    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
1289        LogSettingsProxyInterface::r#set_component_interest(self, payload)
1290    }
1291}
1292
1293impl LogSettingsProxyInterface for LogSettingsProxy {
1294    fn r#register_interest(
1295        &self,
1296        mut selectors: &[LogInterestSelector],
1297    ) -> Result<(), fidl::Error> {
1298        self.client.send::<LogSettingsRegisterInterestRequest>(
1299            (selectors,),
1300            0x49d7c14eec975fb,
1301            fidl::encoding::DynamicFlags::empty(),
1302        )
1303    }
1304
1305    type SetInterestResponseFut =
1306        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
1307    fn r#set_interest(
1308        &self,
1309        mut selectors: &[LogInterestSelector],
1310    ) -> Self::SetInterestResponseFut {
1311        fn _decode(
1312            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1313        ) -> Result<(), fidl::Error> {
1314            let _response = fidl::client::decode_transaction_body::<
1315                fidl::encoding::EmptyPayload,
1316                fdomain_client::fidl::FDomainResourceDialect,
1317                0x71beced9d2411f90,
1318            >(_buf?)?;
1319            Ok(_response)
1320        }
1321        self.client.send_query_and_decode::<LogSettingsSetInterestRequest, ()>(
1322            (selectors,),
1323            0x71beced9d2411f90,
1324            fidl::encoding::DynamicFlags::empty(),
1325            _decode,
1326        )
1327    }
1328
1329    type SetComponentInterestResponseFut =
1330        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
1331    fn r#set_component_interest(
1332        &self,
1333        mut payload: &LogSettingsSetComponentInterestRequest,
1334    ) -> Self::SetComponentInterestResponseFut {
1335        fn _decode(
1336            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1337        ) -> Result<(), fidl::Error> {
1338            let _response = fidl::client::decode_transaction_body::<
1339                fidl::encoding::EmptyPayload,
1340                fdomain_client::fidl::FDomainResourceDialect,
1341                0x35f7004d2367f6c1,
1342            >(_buf?)?;
1343            Ok(_response)
1344        }
1345        self.client.send_query_and_decode::<LogSettingsSetComponentInterestRequest, ()>(
1346            payload,
1347            0x35f7004d2367f6c1,
1348            fidl::encoding::DynamicFlags::empty(),
1349            _decode,
1350        )
1351    }
1352}
1353
1354pub struct LogSettingsEventStream {
1355    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
1356}
1357
1358impl std::marker::Unpin for LogSettingsEventStream {}
1359
1360impl futures::stream::FusedStream for LogSettingsEventStream {
1361    fn is_terminated(&self) -> bool {
1362        self.event_receiver.is_terminated()
1363    }
1364}
1365
1366impl futures::Stream for LogSettingsEventStream {
1367    type Item = Result<LogSettingsEvent, fidl::Error>;
1368
1369    fn poll_next(
1370        mut self: std::pin::Pin<&mut Self>,
1371        cx: &mut std::task::Context<'_>,
1372    ) -> std::task::Poll<Option<Self::Item>> {
1373        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1374            &mut self.event_receiver,
1375            cx
1376        )?) {
1377            Some(buf) => std::task::Poll::Ready(Some(LogSettingsEvent::decode(buf))),
1378            None => std::task::Poll::Ready(None),
1379        }
1380    }
1381}
1382
1383#[derive(Debug)]
1384pub enum LogSettingsEvent {}
1385
1386impl LogSettingsEvent {
1387    /// Decodes a message buffer as a [`LogSettingsEvent`].
1388    fn decode(
1389        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1390    ) -> Result<LogSettingsEvent, fidl::Error> {
1391        let (bytes, _handles) = buf.split_mut();
1392        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1393        debug_assert_eq!(tx_header.tx_id, 0);
1394        match tx_header.ordinal {
1395            _ => Err(fidl::Error::UnknownOrdinal {
1396                ordinal: tx_header.ordinal,
1397                protocol_name:
1398                    <LogSettingsMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1399            }),
1400        }
1401    }
1402}
1403
1404/// A Stream of incoming requests for fuchsia.diagnostics/LogSettings.
1405pub struct LogSettingsRequestStream {
1406    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1407    is_terminated: bool,
1408}
1409
1410impl std::marker::Unpin for LogSettingsRequestStream {}
1411
1412impl futures::stream::FusedStream for LogSettingsRequestStream {
1413    fn is_terminated(&self) -> bool {
1414        self.is_terminated
1415    }
1416}
1417
1418impl fdomain_client::fidl::RequestStream for LogSettingsRequestStream {
1419    type Protocol = LogSettingsMarker;
1420    type ControlHandle = LogSettingsControlHandle;
1421
1422    fn from_channel(channel: fdomain_client::Channel) -> Self {
1423        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1424    }
1425
1426    fn control_handle(&self) -> Self::ControlHandle {
1427        LogSettingsControlHandle { inner: self.inner.clone() }
1428    }
1429
1430    fn into_inner(
1431        self,
1432    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
1433    {
1434        (self.inner, self.is_terminated)
1435    }
1436
1437    fn from_inner(
1438        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1439        is_terminated: bool,
1440    ) -> Self {
1441        Self { inner, is_terminated }
1442    }
1443}
1444
1445impl futures::Stream for LogSettingsRequestStream {
1446    type Item = Result<LogSettingsRequest, fidl::Error>;
1447
1448    fn poll_next(
1449        mut self: std::pin::Pin<&mut Self>,
1450        cx: &mut std::task::Context<'_>,
1451    ) -> std::task::Poll<Option<Self::Item>> {
1452        let this = &mut *self;
1453        if this.inner.check_shutdown(cx) {
1454            this.is_terminated = true;
1455            return std::task::Poll::Ready(None);
1456        }
1457        if this.is_terminated {
1458            panic!("polled LogSettingsRequestStream after completion");
1459        }
1460        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
1461            |bytes, handles| {
1462                match this.inner.channel().read_etc(cx, bytes, handles) {
1463                    std::task::Poll::Ready(Ok(())) => {}
1464                    std::task::Poll::Pending => return std::task::Poll::Pending,
1465                    std::task::Poll::Ready(Err(None)) => {
1466                        this.is_terminated = true;
1467                        return std::task::Poll::Ready(None);
1468                    }
1469                    std::task::Poll::Ready(Err(Some(e))) => {
1470                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1471                            e.into(),
1472                        ))))
1473                    }
1474                }
1475
1476                // A message has been received from the channel
1477                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1478
1479                std::task::Poll::Ready(Some(match header.ordinal {
1480                    0x49d7c14eec975fb => {
1481                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1482                        let mut req = fidl::new_empty!(
1483                            LogSettingsRegisterInterestRequest,
1484                            fdomain_client::fidl::FDomainResourceDialect
1485                        );
1486                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<LogSettingsRegisterInterestRequest>(&header, _body_bytes, handles, &mut req)?;
1487                        let control_handle = LogSettingsControlHandle { inner: this.inner.clone() };
1488                        Ok(LogSettingsRequest::RegisterInterest {
1489                            selectors: req.selectors,
1490
1491                            control_handle,
1492                        })
1493                    }
1494                    0x71beced9d2411f90 => {
1495                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1496                        let mut req = fidl::new_empty!(
1497                            LogSettingsSetInterestRequest,
1498                            fdomain_client::fidl::FDomainResourceDialect
1499                        );
1500                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<LogSettingsSetInterestRequest>(&header, _body_bytes, handles, &mut req)?;
1501                        let control_handle = LogSettingsControlHandle { inner: this.inner.clone() };
1502                        Ok(LogSettingsRequest::SetInterest {
1503                            selectors: req.selectors,
1504
1505                            responder: LogSettingsSetInterestResponder {
1506                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1507                                tx_id: header.tx_id,
1508                            },
1509                        })
1510                    }
1511                    0x35f7004d2367f6c1 => {
1512                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1513                        let mut req = fidl::new_empty!(
1514                            LogSettingsSetComponentInterestRequest,
1515                            fdomain_client::fidl::FDomainResourceDialect
1516                        );
1517                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<LogSettingsSetComponentInterestRequest>(&header, _body_bytes, handles, &mut req)?;
1518                        let control_handle = LogSettingsControlHandle { inner: this.inner.clone() };
1519                        Ok(LogSettingsRequest::SetComponentInterest {
1520                            payload: req,
1521                            responder: LogSettingsSetComponentInterestResponder {
1522                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1523                                tx_id: header.tx_id,
1524                            },
1525                        })
1526                    }
1527                    _ => Err(fidl::Error::UnknownOrdinal {
1528                        ordinal: header.ordinal,
1529                        protocol_name:
1530                            <LogSettingsMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1531                    }),
1532                }))
1533            },
1534        )
1535    }
1536}
1537
1538/// This protocol allows clients to modify the logging behavior of components
1539/// in the system.
1540#[derive(Debug)]
1541pub enum LogSettingsRequest {
1542    RegisterInterest {
1543        selectors: Vec<LogInterestSelector>,
1544        control_handle: LogSettingsControlHandle,
1545    },
1546    /// Requests a change in interest for the matched components.
1547    ///
1548    /// Each component holds a set of requested interests.
1549    ///
1550    /// When a new request on LogSettings#SetInterest is received,
1551    /// the sets for matched components receive the new minimum interest.
1552    /// If the interest is less than the previous minimum interest, then a
1553    /// `SetInterest` request is sent with the new minimum interest.
1554    ///
1555    /// If a connection to `LogSettings` sends another `SetInterest`
1556    /// request, its previous interest request will be undone.
1557    ///
1558    /// When the connection to `LogSettings` is finished, the interests are
1559    /// undone. Each matched component minimum interest is updated with the
1560    /// new minimum interest in the set.
1561    SetInterest { selectors: Vec<LogInterestSelector>, responder: LogSettingsSetInterestResponder },
1562    /// Requests a change in interest for the matched components.
1563    ///
1564    /// Each component holds a set of requested interests.
1565    ///
1566    /// When a new request on LogSettings#SetComponentInterest is received,
1567    /// the sets for matched components receive the new minimum interest.
1568    /// If the interest is less than the previous minimum interest, then a
1569    /// `SetComponentInterest` request is sent with the new minimum interest.
1570    ///
1571    /// If a connection to `LogSettings` sends another `SetComponentInterest`
1572    /// request, its previous interest request will be undone.
1573    ///
1574    /// When the connection to `LogSettings` is finished, the interests are
1575    /// undone, unless persist is set to true. Each matched component minimum
1576    /// interest is updated with the new minimum interest in the set.
1577    SetComponentInterest {
1578        payload: LogSettingsSetComponentInterestRequest,
1579        responder: LogSettingsSetComponentInterestResponder,
1580    },
1581}
1582
1583impl LogSettingsRequest {
1584    #[allow(irrefutable_let_patterns)]
1585    pub fn into_register_interest(
1586        self,
1587    ) -> Option<(Vec<LogInterestSelector>, LogSettingsControlHandle)> {
1588        if let LogSettingsRequest::RegisterInterest { selectors, control_handle } = self {
1589            Some((selectors, control_handle))
1590        } else {
1591            None
1592        }
1593    }
1594
1595    #[allow(irrefutable_let_patterns)]
1596    pub fn into_set_interest(
1597        self,
1598    ) -> Option<(Vec<LogInterestSelector>, LogSettingsSetInterestResponder)> {
1599        if let LogSettingsRequest::SetInterest { selectors, responder } = self {
1600            Some((selectors, responder))
1601        } else {
1602            None
1603        }
1604    }
1605
1606    #[allow(irrefutable_let_patterns)]
1607    pub fn into_set_component_interest(
1608        self,
1609    ) -> Option<(LogSettingsSetComponentInterestRequest, LogSettingsSetComponentInterestResponder)>
1610    {
1611        if let LogSettingsRequest::SetComponentInterest { payload, responder } = self {
1612            Some((payload, responder))
1613        } else {
1614            None
1615        }
1616    }
1617
1618    /// Name of the method defined in FIDL
1619    pub fn method_name(&self) -> &'static str {
1620        match *self {
1621            LogSettingsRequest::RegisterInterest { .. } => "register_interest",
1622            LogSettingsRequest::SetInterest { .. } => "set_interest",
1623            LogSettingsRequest::SetComponentInterest { .. } => "set_component_interest",
1624        }
1625    }
1626}
1627
1628#[derive(Debug, Clone)]
1629pub struct LogSettingsControlHandle {
1630    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1631}
1632
1633impl fdomain_client::fidl::ControlHandle for LogSettingsControlHandle {
1634    fn shutdown(&self) {
1635        self.inner.shutdown()
1636    }
1637
1638    fn is_closed(&self) -> bool {
1639        self.inner.channel().is_closed()
1640    }
1641    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1642        self.inner.channel().on_closed()
1643    }
1644}
1645
1646impl LogSettingsControlHandle {}
1647
1648#[must_use = "FIDL methods require a response to be sent"]
1649#[derive(Debug)]
1650pub struct LogSettingsSetInterestResponder {
1651    control_handle: std::mem::ManuallyDrop<LogSettingsControlHandle>,
1652    tx_id: u32,
1653}
1654
1655/// Set the the channel to be shutdown (see [`LogSettingsControlHandle::shutdown`])
1656/// if the responder is dropped without sending a response, so that the client
1657/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1658impl std::ops::Drop for LogSettingsSetInterestResponder {
1659    fn drop(&mut self) {
1660        self.control_handle.shutdown();
1661        // Safety: drops once, never accessed again
1662        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1663    }
1664}
1665
1666impl fdomain_client::fidl::Responder for LogSettingsSetInterestResponder {
1667    type ControlHandle = LogSettingsControlHandle;
1668
1669    fn control_handle(&self) -> &LogSettingsControlHandle {
1670        &self.control_handle
1671    }
1672
1673    fn drop_without_shutdown(mut self) {
1674        // Safety: drops once, never accessed again due to mem::forget
1675        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1676        // Prevent Drop from running (which would shut down the channel)
1677        std::mem::forget(self);
1678    }
1679}
1680
1681impl LogSettingsSetInterestResponder {
1682    /// Sends a response to the FIDL transaction.
1683    ///
1684    /// Sets the channel to shutdown if an error occurs.
1685    pub fn send(self) -> Result<(), fidl::Error> {
1686        let _result = self.send_raw();
1687        if _result.is_err() {
1688            self.control_handle.shutdown();
1689        }
1690        self.drop_without_shutdown();
1691        _result
1692    }
1693
1694    /// Similar to "send" but does not shutdown the channel if an error occurs.
1695    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1696        let _result = self.send_raw();
1697        self.drop_without_shutdown();
1698        _result
1699    }
1700
1701    fn send_raw(&self) -> Result<(), fidl::Error> {
1702        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1703            (),
1704            self.tx_id,
1705            0x71beced9d2411f90,
1706            fidl::encoding::DynamicFlags::empty(),
1707        )
1708    }
1709}
1710
1711#[must_use = "FIDL methods require a response to be sent"]
1712#[derive(Debug)]
1713pub struct LogSettingsSetComponentInterestResponder {
1714    control_handle: std::mem::ManuallyDrop<LogSettingsControlHandle>,
1715    tx_id: u32,
1716}
1717
1718/// Set the the channel to be shutdown (see [`LogSettingsControlHandle::shutdown`])
1719/// if the responder is dropped without sending a response, so that the client
1720/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1721impl std::ops::Drop for LogSettingsSetComponentInterestResponder {
1722    fn drop(&mut self) {
1723        self.control_handle.shutdown();
1724        // Safety: drops once, never accessed again
1725        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1726    }
1727}
1728
1729impl fdomain_client::fidl::Responder for LogSettingsSetComponentInterestResponder {
1730    type ControlHandle = LogSettingsControlHandle;
1731
1732    fn control_handle(&self) -> &LogSettingsControlHandle {
1733        &self.control_handle
1734    }
1735
1736    fn drop_without_shutdown(mut self) {
1737        // Safety: drops once, never accessed again due to mem::forget
1738        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1739        // Prevent Drop from running (which would shut down the channel)
1740        std::mem::forget(self);
1741    }
1742}
1743
1744impl LogSettingsSetComponentInterestResponder {
1745    /// Sends a response to the FIDL transaction.
1746    ///
1747    /// Sets the channel to shutdown if an error occurs.
1748    pub fn send(self) -> Result<(), fidl::Error> {
1749        let _result = self.send_raw();
1750        if _result.is_err() {
1751            self.control_handle.shutdown();
1752        }
1753        self.drop_without_shutdown();
1754        _result
1755    }
1756
1757    /// Similar to "send" but does not shutdown the channel if an error occurs.
1758    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1759        let _result = self.send_raw();
1760        self.drop_without_shutdown();
1761        _result
1762    }
1763
1764    fn send_raw(&self) -> Result<(), fidl::Error> {
1765        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1766            (),
1767            self.tx_id,
1768            0x35f7004d2367f6c1,
1769            fidl::encoding::DynamicFlags::empty(),
1770        )
1771    }
1772}
1773
1774#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1775pub struct LogStreamMarker;
1776
1777impl fdomain_client::fidl::ProtocolMarker for LogStreamMarker {
1778    type Proxy = LogStreamProxy;
1779    type RequestStream = LogStreamRequestStream;
1780
1781    const DEBUG_NAME: &'static str = "fuchsia.diagnostics.LogStream";
1782}
1783impl fdomain_client::fidl::DiscoverableProtocolMarker for LogStreamMarker {}
1784
1785pub trait LogStreamProxyInterface: Send + Sync {
1786    fn r#connect(
1787        &self,
1788        socket: fdomain_client::Socket,
1789        opts: &LogStreamOptions,
1790    ) -> Result<(), fidl::Error>;
1791}
1792
1793#[derive(Debug, Clone)]
1794pub struct LogStreamProxy {
1795    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
1796}
1797
1798impl fdomain_client::fidl::Proxy for LogStreamProxy {
1799    type Protocol = LogStreamMarker;
1800
1801    fn from_channel(inner: fdomain_client::Channel) -> Self {
1802        Self::new(inner)
1803    }
1804
1805    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
1806        self.client.into_channel().map_err(|client| Self { client })
1807    }
1808
1809    fn as_channel(&self) -> &fdomain_client::Channel {
1810        self.client.as_channel()
1811    }
1812}
1813
1814impl LogStreamProxy {
1815    /// Create a new Proxy for fuchsia.diagnostics/LogStream.
1816    pub fn new(channel: fdomain_client::Channel) -> Self {
1817        let protocol_name = <LogStreamMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
1818        Self { client: fidl::client::Client::new(channel, protocol_name) }
1819    }
1820
1821    /// Get a Stream of events from the remote end of the protocol.
1822    ///
1823    /// # Panics
1824    ///
1825    /// Panics if the event stream was already taken.
1826    pub fn take_event_stream(&self) -> LogStreamEventStream {
1827        LogStreamEventStream { event_receiver: self.client.take_event_receiver() }
1828    }
1829
1830    /// Enables clients to stream all logs stored in the Archivist.
1831    /// Expects a Datagram socket handle that can be written to.
1832    ///
1833    /// Logs will be written in the original FXT format with two additional
1834    /// arguments appended at the end of the record depending on the options
1835    /// passed:
1836    ///
1837    ///     - `$__moniker`: the moniker of the component that emitted the log.
1838    ///     - `$__url`: the URL of the component that emitted the log.
1839    ///     - `$__rolled_out`: the number of logs that were rolled out from the
1840    ///       buffer before this one.
1841    pub fn r#connect(
1842        &self,
1843        mut socket: fdomain_client::Socket,
1844        mut opts: &LogStreamOptions,
1845    ) -> Result<(), fidl::Error> {
1846        LogStreamProxyInterface::r#connect(self, socket, opts)
1847    }
1848}
1849
1850impl LogStreamProxyInterface for LogStreamProxy {
1851    fn r#connect(
1852        &self,
1853        mut socket: fdomain_client::Socket,
1854        mut opts: &LogStreamOptions,
1855    ) -> Result<(), fidl::Error> {
1856        self.client.send::<LogStreamConnectRequest>(
1857            (socket, opts),
1858            0x745eb34f10d51a88,
1859            fidl::encoding::DynamicFlags::FLEXIBLE,
1860        )
1861    }
1862}
1863
1864pub struct LogStreamEventStream {
1865    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
1866}
1867
1868impl std::marker::Unpin for LogStreamEventStream {}
1869
1870impl futures::stream::FusedStream for LogStreamEventStream {
1871    fn is_terminated(&self) -> bool {
1872        self.event_receiver.is_terminated()
1873    }
1874}
1875
1876impl futures::Stream for LogStreamEventStream {
1877    type Item = Result<LogStreamEvent, fidl::Error>;
1878
1879    fn poll_next(
1880        mut self: std::pin::Pin<&mut Self>,
1881        cx: &mut std::task::Context<'_>,
1882    ) -> std::task::Poll<Option<Self::Item>> {
1883        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1884            &mut self.event_receiver,
1885            cx
1886        )?) {
1887            Some(buf) => std::task::Poll::Ready(Some(LogStreamEvent::decode(buf))),
1888            None => std::task::Poll::Ready(None),
1889        }
1890    }
1891}
1892
1893#[derive(Debug)]
1894pub enum LogStreamEvent {
1895    #[non_exhaustive]
1896    _UnknownEvent {
1897        /// Ordinal of the event that was sent.
1898        ordinal: u64,
1899    },
1900}
1901
1902impl LogStreamEvent {
1903    /// Decodes a message buffer as a [`LogStreamEvent`].
1904    fn decode(
1905        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1906    ) -> Result<LogStreamEvent, fidl::Error> {
1907        let (bytes, _handles) = buf.split_mut();
1908        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1909        debug_assert_eq!(tx_header.tx_id, 0);
1910        match tx_header.ordinal {
1911            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1912                Ok(LogStreamEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1913            }
1914            _ => Err(fidl::Error::UnknownOrdinal {
1915                ordinal: tx_header.ordinal,
1916                protocol_name:
1917                    <LogStreamMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1918            }),
1919        }
1920    }
1921}
1922
1923/// A Stream of incoming requests for fuchsia.diagnostics/LogStream.
1924pub struct LogStreamRequestStream {
1925    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1926    is_terminated: bool,
1927}
1928
1929impl std::marker::Unpin for LogStreamRequestStream {}
1930
1931impl futures::stream::FusedStream for LogStreamRequestStream {
1932    fn is_terminated(&self) -> bool {
1933        self.is_terminated
1934    }
1935}
1936
1937impl fdomain_client::fidl::RequestStream for LogStreamRequestStream {
1938    type Protocol = LogStreamMarker;
1939    type ControlHandle = LogStreamControlHandle;
1940
1941    fn from_channel(channel: fdomain_client::Channel) -> Self {
1942        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1943    }
1944
1945    fn control_handle(&self) -> Self::ControlHandle {
1946        LogStreamControlHandle { inner: self.inner.clone() }
1947    }
1948
1949    fn into_inner(
1950        self,
1951    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
1952    {
1953        (self.inner, self.is_terminated)
1954    }
1955
1956    fn from_inner(
1957        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1958        is_terminated: bool,
1959    ) -> Self {
1960        Self { inner, is_terminated }
1961    }
1962}
1963
1964impl futures::Stream for LogStreamRequestStream {
1965    type Item = Result<LogStreamRequest, fidl::Error>;
1966
1967    fn poll_next(
1968        mut self: std::pin::Pin<&mut Self>,
1969        cx: &mut std::task::Context<'_>,
1970    ) -> std::task::Poll<Option<Self::Item>> {
1971        let this = &mut *self;
1972        if this.inner.check_shutdown(cx) {
1973            this.is_terminated = true;
1974            return std::task::Poll::Ready(None);
1975        }
1976        if this.is_terminated {
1977            panic!("polled LogStreamRequestStream after completion");
1978        }
1979        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
1980            |bytes, handles| {
1981                match this.inner.channel().read_etc(cx, bytes, handles) {
1982                    std::task::Poll::Ready(Ok(())) => {}
1983                    std::task::Poll::Pending => return std::task::Poll::Pending,
1984                    std::task::Poll::Ready(Err(None)) => {
1985                        this.is_terminated = true;
1986                        return std::task::Poll::Ready(None);
1987                    }
1988                    std::task::Poll::Ready(Err(Some(e))) => {
1989                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1990                            e.into(),
1991                        ))))
1992                    }
1993                }
1994
1995                // A message has been received from the channel
1996                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1997
1998                std::task::Poll::Ready(Some(match header.ordinal {
1999                    0x745eb34f10d51a88 => {
2000                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2001                        let mut req = fidl::new_empty!(
2002                            LogStreamConnectRequest,
2003                            fdomain_client::fidl::FDomainResourceDialect
2004                        );
2005                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<LogStreamConnectRequest>(&header, _body_bytes, handles, &mut req)?;
2006                        let control_handle = LogStreamControlHandle { inner: this.inner.clone() };
2007                        Ok(LogStreamRequest::Connect {
2008                            socket: req.socket,
2009                            opts: req.opts,
2010
2011                            control_handle,
2012                        })
2013                    }
2014                    _ if header.tx_id == 0
2015                        && header
2016                            .dynamic_flags()
2017                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2018                    {
2019                        Ok(LogStreamRequest::_UnknownMethod {
2020                            ordinal: header.ordinal,
2021                            control_handle: LogStreamControlHandle { inner: this.inner.clone() },
2022                            method_type: fidl::MethodType::OneWay,
2023                        })
2024                    }
2025                    _ if header
2026                        .dynamic_flags()
2027                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2028                    {
2029                        this.inner.send_framework_err(
2030                            fidl::encoding::FrameworkErr::UnknownMethod,
2031                            header.tx_id,
2032                            header.ordinal,
2033                            header.dynamic_flags(),
2034                            (bytes, handles),
2035                        )?;
2036                        Ok(LogStreamRequest::_UnknownMethod {
2037                            ordinal: header.ordinal,
2038                            control_handle: LogStreamControlHandle { inner: this.inner.clone() },
2039                            method_type: fidl::MethodType::TwoWay,
2040                        })
2041                    }
2042                    _ => Err(fidl::Error::UnknownOrdinal {
2043                        ordinal: header.ordinal,
2044                        protocol_name:
2045                            <LogStreamMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2046                    }),
2047                }))
2048            },
2049        )
2050    }
2051}
2052
2053#[derive(Debug)]
2054pub enum LogStreamRequest {
2055    /// Enables clients to stream all logs stored in the Archivist.
2056    /// Expects a Datagram socket handle that can be written to.
2057    ///
2058    /// Logs will be written in the original FXT format with two additional
2059    /// arguments appended at the end of the record depending on the options
2060    /// passed:
2061    ///
2062    ///     - `$__moniker`: the moniker of the component that emitted the log.
2063    ///     - `$__url`: the URL of the component that emitted the log.
2064    ///     - `$__rolled_out`: the number of logs that were rolled out from the
2065    ///       buffer before this one.
2066    Connect {
2067        socket: fdomain_client::Socket,
2068        opts: LogStreamOptions,
2069        control_handle: LogStreamControlHandle,
2070    },
2071    /// An interaction was received which does not match any known method.
2072    #[non_exhaustive]
2073    _UnknownMethod {
2074        /// Ordinal of the method that was called.
2075        ordinal: u64,
2076        control_handle: LogStreamControlHandle,
2077        method_type: fidl::MethodType,
2078    },
2079}
2080
2081impl LogStreamRequest {
2082    #[allow(irrefutable_let_patterns)]
2083    pub fn into_connect(
2084        self,
2085    ) -> Option<(fdomain_client::Socket, LogStreamOptions, LogStreamControlHandle)> {
2086        if let LogStreamRequest::Connect { socket, opts, control_handle } = self {
2087            Some((socket, opts, control_handle))
2088        } else {
2089            None
2090        }
2091    }
2092
2093    /// Name of the method defined in FIDL
2094    pub fn method_name(&self) -> &'static str {
2095        match *self {
2096            LogStreamRequest::Connect { .. } => "connect",
2097            LogStreamRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2098                "unknown one-way method"
2099            }
2100            LogStreamRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2101                "unknown two-way method"
2102            }
2103        }
2104    }
2105}
2106
2107#[derive(Debug, Clone)]
2108pub struct LogStreamControlHandle {
2109    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2110}
2111
2112impl fdomain_client::fidl::ControlHandle for LogStreamControlHandle {
2113    fn shutdown(&self) {
2114        self.inner.shutdown()
2115    }
2116
2117    fn is_closed(&self) -> bool {
2118        self.inner.channel().is_closed()
2119    }
2120    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
2121        self.inner.channel().on_closed()
2122    }
2123}
2124
2125impl LogStreamControlHandle {}
2126
2127mod internal {
2128    use super::*;
2129
2130    impl fidl::encoding::ResourceTypeMarker for ArchiveAccessorStreamDiagnosticsRequest {
2131        type Borrowed<'a> = &'a mut Self;
2132        fn take_or_borrow<'a>(
2133            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2134        ) -> Self::Borrowed<'a> {
2135            value
2136        }
2137    }
2138
2139    unsafe impl fidl::encoding::TypeMarker for ArchiveAccessorStreamDiagnosticsRequest {
2140        type Owned = Self;
2141
2142        #[inline(always)]
2143        fn inline_align(_context: fidl::encoding::Context) -> usize {
2144            8
2145        }
2146
2147        #[inline(always)]
2148        fn inline_size(_context: fidl::encoding::Context) -> usize {
2149            24
2150        }
2151    }
2152
2153    unsafe impl
2154        fidl::encoding::Encode<
2155            ArchiveAccessorStreamDiagnosticsRequest,
2156            fdomain_client::fidl::FDomainResourceDialect,
2157        > for &mut ArchiveAccessorStreamDiagnosticsRequest
2158    {
2159        #[inline]
2160        unsafe fn encode(
2161            self,
2162            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2163            offset: usize,
2164            _depth: fidl::encoding::Depth,
2165        ) -> fidl::Result<()> {
2166            encoder.debug_check_bounds::<ArchiveAccessorStreamDiagnosticsRequest>(offset);
2167            // Delegate to tuple encoding.
2168            fidl::encoding::Encode::<ArchiveAccessorStreamDiagnosticsRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
2169                (
2170                    <StreamParameters as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_parameters),
2171                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BatchIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.result_stream),
2172                ),
2173                encoder, offset, _depth
2174            )
2175        }
2176    }
2177    unsafe impl<
2178            T0: fidl::encoding::Encode<StreamParameters, fdomain_client::fidl::FDomainResourceDialect>,
2179            T1: fidl::encoding::Encode<
2180                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BatchIteratorMarker>>,
2181                fdomain_client::fidl::FDomainResourceDialect,
2182            >,
2183        >
2184        fidl::encoding::Encode<
2185            ArchiveAccessorStreamDiagnosticsRequest,
2186            fdomain_client::fidl::FDomainResourceDialect,
2187        > for (T0, T1)
2188    {
2189        #[inline]
2190        unsafe fn encode(
2191            self,
2192            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2193            offset: usize,
2194            depth: fidl::encoding::Depth,
2195        ) -> fidl::Result<()> {
2196            encoder.debug_check_bounds::<ArchiveAccessorStreamDiagnosticsRequest>(offset);
2197            // Zero out padding regions. There's no need to apply masks
2198            // because the unmasked parts will be overwritten by fields.
2199            unsafe {
2200                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
2201                (ptr as *mut u64).write_unaligned(0);
2202            }
2203            // Write the fields.
2204            self.0.encode(encoder, offset + 0, depth)?;
2205            self.1.encode(encoder, offset + 16, depth)?;
2206            Ok(())
2207        }
2208    }
2209
2210    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
2211        for ArchiveAccessorStreamDiagnosticsRequest
2212    {
2213        #[inline(always)]
2214        fn new_empty() -> Self {
2215            Self {
2216                stream_parameters: fidl::new_empty!(
2217                    StreamParameters,
2218                    fdomain_client::fidl::FDomainResourceDialect
2219                ),
2220                result_stream: fidl::new_empty!(
2221                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BatchIteratorMarker>>,
2222                    fdomain_client::fidl::FDomainResourceDialect
2223                ),
2224            }
2225        }
2226
2227        #[inline]
2228        unsafe fn decode(
2229            &mut self,
2230            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2231            offset: usize,
2232            _depth: fidl::encoding::Depth,
2233        ) -> fidl::Result<()> {
2234            decoder.debug_check_bounds::<Self>(offset);
2235            // Verify that padding bytes are zero.
2236            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
2237            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2238            let mask = 0xffffffff00000000u64;
2239            let maskedval = padval & mask;
2240            if maskedval != 0 {
2241                return Err(fidl::Error::NonZeroPadding {
2242                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
2243                });
2244            }
2245            fidl::decode!(
2246                StreamParameters,
2247                fdomain_client::fidl::FDomainResourceDialect,
2248                &mut self.stream_parameters,
2249                decoder,
2250                offset + 0,
2251                _depth
2252            )?;
2253            fidl::decode!(
2254                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BatchIteratorMarker>>,
2255                fdomain_client::fidl::FDomainResourceDialect,
2256                &mut self.result_stream,
2257                decoder,
2258                offset + 16,
2259                _depth
2260            )?;
2261            Ok(())
2262        }
2263    }
2264
2265    impl fidl::encoding::ResourceTypeMarker for BatchIteratorGetNextResponse {
2266        type Borrowed<'a> = &'a mut Self;
2267        fn take_or_borrow<'a>(
2268            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2269        ) -> Self::Borrowed<'a> {
2270            value
2271        }
2272    }
2273
2274    unsafe impl fidl::encoding::TypeMarker for BatchIteratorGetNextResponse {
2275        type Owned = Self;
2276
2277        #[inline(always)]
2278        fn inline_align(_context: fidl::encoding::Context) -> usize {
2279            8
2280        }
2281
2282        #[inline(always)]
2283        fn inline_size(_context: fidl::encoding::Context) -> usize {
2284            16
2285        }
2286    }
2287
2288    unsafe impl
2289        fidl::encoding::Encode<
2290            BatchIteratorGetNextResponse,
2291            fdomain_client::fidl::FDomainResourceDialect,
2292        > for &mut BatchIteratorGetNextResponse
2293    {
2294        #[inline]
2295        unsafe fn encode(
2296            self,
2297            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2298            offset: usize,
2299            _depth: fidl::encoding::Depth,
2300        ) -> fidl::Result<()> {
2301            encoder.debug_check_bounds::<BatchIteratorGetNextResponse>(offset);
2302            // Delegate to tuple encoding.
2303            fidl::encoding::Encode::<BatchIteratorGetNextResponse, fdomain_client::fidl::FDomainResourceDialect>::encode(
2304                (
2305                    <fidl::encoding::Vector<FormattedContent, 64> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.batch),
2306                ),
2307                encoder, offset, _depth
2308            )
2309        }
2310    }
2311    unsafe impl<
2312            T0: fidl::encoding::Encode<
2313                fidl::encoding::Vector<FormattedContent, 64>,
2314                fdomain_client::fidl::FDomainResourceDialect,
2315            >,
2316        >
2317        fidl::encoding::Encode<
2318            BatchIteratorGetNextResponse,
2319            fdomain_client::fidl::FDomainResourceDialect,
2320        > for (T0,)
2321    {
2322        #[inline]
2323        unsafe fn encode(
2324            self,
2325            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2326            offset: usize,
2327            depth: fidl::encoding::Depth,
2328        ) -> fidl::Result<()> {
2329            encoder.debug_check_bounds::<BatchIteratorGetNextResponse>(offset);
2330            // Zero out padding regions. There's no need to apply masks
2331            // because the unmasked parts will be overwritten by fields.
2332            // Write the fields.
2333            self.0.encode(encoder, offset + 0, depth)?;
2334            Ok(())
2335        }
2336    }
2337
2338    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
2339        for BatchIteratorGetNextResponse
2340    {
2341        #[inline(always)]
2342        fn new_empty() -> Self {
2343            Self {
2344                batch: fidl::new_empty!(fidl::encoding::Vector<FormattedContent, 64>, fdomain_client::fidl::FDomainResourceDialect),
2345            }
2346        }
2347
2348        #[inline]
2349        unsafe fn decode(
2350            &mut self,
2351            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2352            offset: usize,
2353            _depth: fidl::encoding::Depth,
2354        ) -> fidl::Result<()> {
2355            decoder.debug_check_bounds::<Self>(offset);
2356            // Verify that padding bytes are zero.
2357            fidl::decode!(fidl::encoding::Vector<FormattedContent, 64>, fdomain_client::fidl::FDomainResourceDialect, &mut self.batch, decoder, offset + 0, _depth)?;
2358            Ok(())
2359        }
2360    }
2361
2362    impl fidl::encoding::ResourceTypeMarker for LogStreamConnectRequest {
2363        type Borrowed<'a> = &'a mut Self;
2364        fn take_or_borrow<'a>(
2365            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2366        ) -> Self::Borrowed<'a> {
2367            value
2368        }
2369    }
2370
2371    unsafe impl fidl::encoding::TypeMarker for LogStreamConnectRequest {
2372        type Owned = Self;
2373
2374        #[inline(always)]
2375        fn inline_align(_context: fidl::encoding::Context) -> usize {
2376            8
2377        }
2378
2379        #[inline(always)]
2380        fn inline_size(_context: fidl::encoding::Context) -> usize {
2381            24
2382        }
2383    }
2384
2385    unsafe impl
2386        fidl::encoding::Encode<
2387            LogStreamConnectRequest,
2388            fdomain_client::fidl::FDomainResourceDialect,
2389        > for &mut LogStreamConnectRequest
2390    {
2391        #[inline]
2392        unsafe fn encode(
2393            self,
2394            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2395            offset: usize,
2396            _depth: fidl::encoding::Depth,
2397        ) -> fidl::Result<()> {
2398            encoder.debug_check_bounds::<LogStreamConnectRequest>(offset);
2399            // Delegate to tuple encoding.
2400            fidl::encoding::Encode::<
2401                LogStreamConnectRequest,
2402                fdomain_client::fidl::FDomainResourceDialect,
2403            >::encode(
2404                (
2405                    <fidl::encoding::HandleType<
2406                        fdomain_client::Socket,
2407                        { fidl::ObjectType::SOCKET.into_raw() },
2408                        16392,
2409                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2410                        &mut self.socket
2411                    ),
2412                    <LogStreamOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.opts),
2413                ),
2414                encoder,
2415                offset,
2416                _depth,
2417            )
2418        }
2419    }
2420    unsafe impl<
2421            T0: fidl::encoding::Encode<
2422                fidl::encoding::HandleType<
2423                    fdomain_client::Socket,
2424                    { fidl::ObjectType::SOCKET.into_raw() },
2425                    16392,
2426                >,
2427                fdomain_client::fidl::FDomainResourceDialect,
2428            >,
2429            T1: fidl::encoding::Encode<LogStreamOptions, fdomain_client::fidl::FDomainResourceDialect>,
2430        >
2431        fidl::encoding::Encode<
2432            LogStreamConnectRequest,
2433            fdomain_client::fidl::FDomainResourceDialect,
2434        > for (T0, T1)
2435    {
2436        #[inline]
2437        unsafe fn encode(
2438            self,
2439            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2440            offset: usize,
2441            depth: fidl::encoding::Depth,
2442        ) -> fidl::Result<()> {
2443            encoder.debug_check_bounds::<LogStreamConnectRequest>(offset);
2444            // Zero out padding regions. There's no need to apply masks
2445            // because the unmasked parts will be overwritten by fields.
2446            unsafe {
2447                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
2448                (ptr as *mut u64).write_unaligned(0);
2449            }
2450            // Write the fields.
2451            self.0.encode(encoder, offset + 0, depth)?;
2452            self.1.encode(encoder, offset + 8, depth)?;
2453            Ok(())
2454        }
2455    }
2456
2457    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
2458        for LogStreamConnectRequest
2459    {
2460        #[inline(always)]
2461        fn new_empty() -> Self {
2462            Self {
2463                socket: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 16392>, fdomain_client::fidl::FDomainResourceDialect),
2464                opts: fidl::new_empty!(
2465                    LogStreamOptions,
2466                    fdomain_client::fidl::FDomainResourceDialect
2467                ),
2468            }
2469        }
2470
2471        #[inline]
2472        unsafe fn decode(
2473            &mut self,
2474            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2475            offset: usize,
2476            _depth: fidl::encoding::Depth,
2477        ) -> fidl::Result<()> {
2478            decoder.debug_check_bounds::<Self>(offset);
2479            // Verify that padding bytes are zero.
2480            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
2481            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2482            let mask = 0xffffffff00000000u64;
2483            let maskedval = padval & mask;
2484            if maskedval != 0 {
2485                return Err(fidl::Error::NonZeroPadding {
2486                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
2487                });
2488            }
2489            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)?;
2490            fidl::decode!(
2491                LogStreamOptions,
2492                fdomain_client::fidl::FDomainResourceDialect,
2493                &mut self.opts,
2494                decoder,
2495                offset + 8,
2496                _depth
2497            )?;
2498            Ok(())
2499        }
2500    }
2501
2502    impl fidl::encoding::ResourceTypeMarker for FormattedContent {
2503        type Borrowed<'a> = &'a mut Self;
2504        fn take_or_borrow<'a>(
2505            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2506        ) -> Self::Borrowed<'a> {
2507            value
2508        }
2509    }
2510
2511    unsafe impl fidl::encoding::TypeMarker for FormattedContent {
2512        type Owned = Self;
2513
2514        #[inline(always)]
2515        fn inline_align(_context: fidl::encoding::Context) -> usize {
2516            8
2517        }
2518
2519        #[inline(always)]
2520        fn inline_size(_context: fidl::encoding::Context) -> usize {
2521            16
2522        }
2523    }
2524
2525    unsafe impl
2526        fidl::encoding::Encode<FormattedContent, fdomain_client::fidl::FDomainResourceDialect>
2527        for &mut FormattedContent
2528    {
2529        #[inline]
2530        unsafe fn encode(
2531            self,
2532            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2533            offset: usize,
2534            _depth: fidl::encoding::Depth,
2535        ) -> fidl::Result<()> {
2536            encoder.debug_check_bounds::<FormattedContent>(offset);
2537            encoder.write_num::<u64>(self.ordinal(), offset);
2538            match self {
2539            FormattedContent::Json(ref mut val) => {
2540                fidl::encoding::encode_in_envelope::<fdomain_fuchsia_mem::Buffer, fdomain_client::fidl::FDomainResourceDialect>(
2541                    <fdomain_fuchsia_mem::Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2542                    encoder, offset + 8, _depth
2543                )
2544            }
2545            FormattedContent::Text(ref mut val) => {
2546                fidl::encoding::encode_in_envelope::<fdomain_fuchsia_mem::Buffer, fdomain_client::fidl::FDomainResourceDialect>(
2547                    <fdomain_fuchsia_mem::Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2548                    encoder, offset + 8, _depth
2549                )
2550            }
2551            FormattedContent::Cbor(ref mut val) => {
2552                fidl::encoding::encode_in_envelope::<fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect>(
2553                    <fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2554                    encoder, offset + 8, _depth
2555                )
2556            }
2557            FormattedContent::Fxt(ref mut val) => {
2558                fidl::encoding::encode_in_envelope::<fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect>(
2559                    <fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2560                    encoder, offset + 8, _depth
2561                )
2562            }
2563            FormattedContent::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2564        }
2565        }
2566    }
2567
2568    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
2569        for FormattedContent
2570    {
2571        #[inline(always)]
2572        fn new_empty() -> Self {
2573            Self::__SourceBreaking { unknown_ordinal: 0 }
2574        }
2575
2576        #[inline]
2577        unsafe fn decode(
2578            &mut self,
2579            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2580            offset: usize,
2581            mut depth: fidl::encoding::Depth,
2582        ) -> fidl::Result<()> {
2583            decoder.debug_check_bounds::<Self>(offset);
2584            #[allow(unused_variables)]
2585            let next_out_of_line = decoder.next_out_of_line();
2586            let handles_before = decoder.remaining_handles();
2587            let (ordinal, inlined, num_bytes, num_handles) =
2588                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2589
2590            let member_inline_size = match ordinal {
2591                1 => <fdomain_fuchsia_mem::Buffer as fidl::encoding::TypeMarker>::inline_size(
2592                    decoder.context,
2593                ),
2594                2 => <fdomain_fuchsia_mem::Buffer as fidl::encoding::TypeMarker>::inline_size(
2595                    decoder.context,
2596                ),
2597                3 => <fidl::encoding::HandleType<
2598                    fdomain_client::Vmo,
2599                    { fidl::ObjectType::VMO.into_raw() },
2600                    2147483648,
2601                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2602                4 => <fidl::encoding::HandleType<
2603                    fdomain_client::Vmo,
2604                    { fidl::ObjectType::VMO.into_raw() },
2605                    2147483648,
2606                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2607                0 => return Err(fidl::Error::UnknownUnionTag),
2608                _ => num_bytes as usize,
2609            };
2610
2611            if inlined != (member_inline_size <= 4) {
2612                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2613            }
2614            let _inner_offset;
2615            if inlined {
2616                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2617                _inner_offset = offset + 8;
2618            } else {
2619                depth.increment()?;
2620                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2621            }
2622            match ordinal {
2623                1 => {
2624                    #[allow(irrefutable_let_patterns)]
2625                    if let FormattedContent::Json(_) = self {
2626                        // Do nothing, read the value into the object
2627                    } else {
2628                        // Initialize `self` to the right variant
2629                        *self = FormattedContent::Json(fidl::new_empty!(
2630                            fdomain_fuchsia_mem::Buffer,
2631                            fdomain_client::fidl::FDomainResourceDialect
2632                        ));
2633                    }
2634                    #[allow(irrefutable_let_patterns)]
2635                    if let FormattedContent::Json(ref mut val) = self {
2636                        fidl::decode!(
2637                            fdomain_fuchsia_mem::Buffer,
2638                            fdomain_client::fidl::FDomainResourceDialect,
2639                            val,
2640                            decoder,
2641                            _inner_offset,
2642                            depth
2643                        )?;
2644                    } else {
2645                        unreachable!()
2646                    }
2647                }
2648                2 => {
2649                    #[allow(irrefutable_let_patterns)]
2650                    if let FormattedContent::Text(_) = self {
2651                        // Do nothing, read the value into the object
2652                    } else {
2653                        // Initialize `self` to the right variant
2654                        *self = FormattedContent::Text(fidl::new_empty!(
2655                            fdomain_fuchsia_mem::Buffer,
2656                            fdomain_client::fidl::FDomainResourceDialect
2657                        ));
2658                    }
2659                    #[allow(irrefutable_let_patterns)]
2660                    if let FormattedContent::Text(ref mut val) = self {
2661                        fidl::decode!(
2662                            fdomain_fuchsia_mem::Buffer,
2663                            fdomain_client::fidl::FDomainResourceDialect,
2664                            val,
2665                            decoder,
2666                            _inner_offset,
2667                            depth
2668                        )?;
2669                    } else {
2670                        unreachable!()
2671                    }
2672                }
2673                3 => {
2674                    #[allow(irrefutable_let_patterns)]
2675                    if let FormattedContent::Cbor(_) = self {
2676                        // Do nothing, read the value into the object
2677                    } else {
2678                        // Initialize `self` to the right variant
2679                        *self = FormattedContent::Cbor(
2680                            fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
2681                        );
2682                    }
2683                    #[allow(irrefutable_let_patterns)]
2684                    if let FormattedContent::Cbor(ref mut val) = self {
2685                        fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val, decoder, _inner_offset, depth)?;
2686                    } else {
2687                        unreachable!()
2688                    }
2689                }
2690                4 => {
2691                    #[allow(irrefutable_let_patterns)]
2692                    if let FormattedContent::Fxt(_) = self {
2693                        // Do nothing, read the value into the object
2694                    } else {
2695                        // Initialize `self` to the right variant
2696                        *self = FormattedContent::Fxt(
2697                            fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
2698                        );
2699                    }
2700                    #[allow(irrefutable_let_patterns)]
2701                    if let FormattedContent::Fxt(ref mut val) = self {
2702                        fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val, decoder, _inner_offset, depth)?;
2703                    } else {
2704                        unreachable!()
2705                    }
2706                }
2707                #[allow(deprecated)]
2708                ordinal => {
2709                    for _ in 0..num_handles {
2710                        decoder.drop_next_handle()?;
2711                    }
2712                    *self = FormattedContent::__SourceBreaking { unknown_ordinal: ordinal };
2713                }
2714            }
2715            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2716                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2717            }
2718            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2719                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2720            }
2721            Ok(())
2722        }
2723    }
2724}