Skip to main content

fidl_fuchsia_logger/
fidl_fuchsia_logger.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 fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_logger_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct LogListenSafeRequest {
16    pub log_listener: fidl::endpoints::ClientEnd<LogListenerSafeMarker>,
17    pub options: Option<Box<LogFilterOptions>>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for LogListenSafeRequest {}
21
22#[derive(Debug, Default, PartialEq)]
23pub struct LogSinkOnInitRequest {
24    pub buffer: Option<fidl::Iob>,
25    pub interest: Option<fidl_fuchsia_diagnostics_types::Interest>,
26    #[doc(hidden)]
27    pub __source_breaking: fidl::marker::SourceBreaking,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for LogSinkOnInitRequest {}
31
32#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
33pub struct LogMarker;
34
35impl fidl::endpoints::ProtocolMarker for LogMarker {
36    type Proxy = LogProxy;
37    type RequestStream = LogRequestStream;
38    #[cfg(target_os = "fuchsia")]
39    type SynchronousProxy = LogSynchronousProxy;
40
41    const DEBUG_NAME: &'static str = "fuchsia.logger.Log";
42}
43impl fidl::endpoints::DiscoverableProtocolMarker for LogMarker {}
44
45pub trait LogProxyInterface: Send + Sync {
46    fn r#listen_safe(
47        &self,
48        log_listener: fidl::endpoints::ClientEnd<LogListenerSafeMarker>,
49        options: Option<&LogFilterOptions>,
50    ) -> Result<(), fidl::Error>;
51}
52#[derive(Debug)]
53#[cfg(target_os = "fuchsia")]
54pub struct LogSynchronousProxy {
55    client: fidl::client::sync::Client,
56}
57
58#[cfg(target_os = "fuchsia")]
59impl fidl::endpoints::SynchronousProxy for LogSynchronousProxy {
60    type Proxy = LogProxy;
61    type Protocol = LogMarker;
62
63    fn from_channel(inner: fidl::Channel) -> Self {
64        Self::new(inner)
65    }
66
67    fn into_channel(self) -> fidl::Channel {
68        self.client.into_channel()
69    }
70
71    fn as_channel(&self) -> &fidl::Channel {
72        self.client.as_channel()
73    }
74}
75
76#[cfg(target_os = "fuchsia")]
77impl LogSynchronousProxy {
78    pub fn new(channel: fidl::Channel) -> Self {
79        Self { client: fidl::client::sync::Client::new(channel) }
80    }
81
82    pub fn into_channel(self) -> fidl::Channel {
83        self.client.into_channel()
84    }
85
86    /// Waits until an event arrives and returns it. It is safe for other
87    /// threads to make concurrent requests while waiting for an event.
88    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<LogEvent, fidl::Error> {
89        LogEvent::decode(self.client.wait_for_event::<LogMarker>(deadline)?)
90    }
91
92    /// Dumps all cached logs by calling LogMany() in batches followed by Log() for each new log
93    /// message.
94    /// A null `options` indicates no filtering is requested.
95    pub fn r#listen_safe(
96        &self,
97        mut log_listener: fidl::endpoints::ClientEnd<LogListenerSafeMarker>,
98        mut options: Option<&LogFilterOptions>,
99    ) -> Result<(), fidl::Error> {
100        self.client.send::<LogListenSafeRequest>(
101            (log_listener, options),
102            0x4e523b04952a61b1,
103            fidl::encoding::DynamicFlags::empty(),
104        )
105    }
106}
107
108#[cfg(target_os = "fuchsia")]
109impl From<LogSynchronousProxy> for zx::NullableHandle {
110    fn from(value: LogSynchronousProxy) -> Self {
111        value.into_channel().into()
112    }
113}
114
115#[cfg(target_os = "fuchsia")]
116impl From<fidl::Channel> for LogSynchronousProxy {
117    fn from(value: fidl::Channel) -> Self {
118        Self::new(value)
119    }
120}
121
122#[cfg(target_os = "fuchsia")]
123impl fidl::endpoints::FromClient for LogSynchronousProxy {
124    type Protocol = LogMarker;
125
126    fn from_client(value: fidl::endpoints::ClientEnd<LogMarker>) -> Self {
127        Self::new(value.into_channel())
128    }
129}
130
131#[derive(Debug, Clone)]
132pub struct LogProxy {
133    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
134}
135
136impl fidl::endpoints::Proxy for LogProxy {
137    type Protocol = LogMarker;
138
139    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
140        Self::new(inner)
141    }
142
143    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
144        self.client.into_channel().map_err(|client| Self { client })
145    }
146
147    fn as_channel(&self) -> &::fidl::AsyncChannel {
148        self.client.as_channel()
149    }
150}
151
152impl LogProxy {
153    /// Create a new Proxy for fuchsia.logger/Log.
154    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
155        let protocol_name = <LogMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
156        Self { client: fidl::client::Client::new(channel, protocol_name) }
157    }
158
159    /// Get a Stream of events from the remote end of the protocol.
160    ///
161    /// # Panics
162    ///
163    /// Panics if the event stream was already taken.
164    pub fn take_event_stream(&self) -> LogEventStream {
165        LogEventStream { event_receiver: self.client.take_event_receiver() }
166    }
167
168    /// Dumps all cached logs by calling LogMany() in batches followed by Log() for each new log
169    /// message.
170    /// A null `options` indicates no filtering is requested.
171    pub fn r#listen_safe(
172        &self,
173        mut log_listener: fidl::endpoints::ClientEnd<LogListenerSafeMarker>,
174        mut options: Option<&LogFilterOptions>,
175    ) -> Result<(), fidl::Error> {
176        LogProxyInterface::r#listen_safe(self, log_listener, options)
177    }
178}
179
180impl LogProxyInterface for LogProxy {
181    fn r#listen_safe(
182        &self,
183        mut log_listener: fidl::endpoints::ClientEnd<LogListenerSafeMarker>,
184        mut options: Option<&LogFilterOptions>,
185    ) -> Result<(), fidl::Error> {
186        self.client.send::<LogListenSafeRequest>(
187            (log_listener, options),
188            0x4e523b04952a61b1,
189            fidl::encoding::DynamicFlags::empty(),
190        )
191    }
192}
193
194pub struct LogEventStream {
195    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
196}
197
198impl std::marker::Unpin for LogEventStream {}
199
200impl futures::stream::FusedStream for LogEventStream {
201    fn is_terminated(&self) -> bool {
202        self.event_receiver.is_terminated()
203    }
204}
205
206impl futures::Stream for LogEventStream {
207    type Item = Result<LogEvent, fidl::Error>;
208
209    fn poll_next(
210        mut self: std::pin::Pin<&mut Self>,
211        cx: &mut std::task::Context<'_>,
212    ) -> std::task::Poll<Option<Self::Item>> {
213        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
214            &mut self.event_receiver,
215            cx
216        )?) {
217            Some(buf) => std::task::Poll::Ready(Some(LogEvent::decode(buf))),
218            None => std::task::Poll::Ready(None),
219        }
220    }
221}
222
223#[derive(Debug)]
224pub enum LogEvent {}
225
226impl LogEvent {
227    /// Decodes a message buffer as a [`LogEvent`].
228    fn decode(
229        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
230    ) -> Result<LogEvent, fidl::Error> {
231        let (bytes, _handles) = buf.split_mut();
232        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
233        debug_assert_eq!(tx_header.tx_id, 0);
234        match tx_header.ordinal {
235            _ => Err(fidl::Error::UnknownOrdinal {
236                ordinal: tx_header.ordinal,
237                protocol_name: <LogMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
238            }),
239        }
240    }
241}
242
243/// A Stream of incoming requests for fuchsia.logger/Log.
244pub struct LogRequestStream {
245    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
246    is_terminated: bool,
247}
248
249impl std::marker::Unpin for LogRequestStream {}
250
251impl futures::stream::FusedStream for LogRequestStream {
252    fn is_terminated(&self) -> bool {
253        self.is_terminated
254    }
255}
256
257impl fidl::endpoints::RequestStream for LogRequestStream {
258    type Protocol = LogMarker;
259    type ControlHandle = LogControlHandle;
260
261    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
262        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
263    }
264
265    fn control_handle(&self) -> Self::ControlHandle {
266        LogControlHandle { inner: self.inner.clone() }
267    }
268
269    fn into_inner(
270        self,
271    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
272    {
273        (self.inner, self.is_terminated)
274    }
275
276    fn from_inner(
277        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
278        is_terminated: bool,
279    ) -> Self {
280        Self { inner, is_terminated }
281    }
282}
283
284impl futures::Stream for LogRequestStream {
285    type Item = Result<LogRequest, fidl::Error>;
286
287    fn poll_next(
288        mut self: std::pin::Pin<&mut Self>,
289        cx: &mut std::task::Context<'_>,
290    ) -> std::task::Poll<Option<Self::Item>> {
291        let this = &mut *self;
292        if this.inner.check_shutdown(cx) {
293            this.is_terminated = true;
294            return std::task::Poll::Ready(None);
295        }
296        if this.is_terminated {
297            panic!("polled LogRequestStream after completion");
298        }
299        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
300            |bytes, handles| {
301                match this.inner.channel().read_etc(cx, bytes, handles) {
302                    std::task::Poll::Ready(Ok(())) => {}
303                    std::task::Poll::Pending => return std::task::Poll::Pending,
304                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
305                        this.is_terminated = true;
306                        return std::task::Poll::Ready(None);
307                    }
308                    std::task::Poll::Ready(Err(e)) => {
309                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
310                            e.into(),
311                        ))));
312                    }
313                }
314
315                // A message has been received from the channel
316                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
317
318                std::task::Poll::Ready(Some(match header.ordinal {
319                    0x4e523b04952a61b1 => {
320                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
321                        let mut req = fidl::new_empty!(
322                            LogListenSafeRequest,
323                            fidl::encoding::DefaultFuchsiaResourceDialect
324                        );
325                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LogListenSafeRequest>(&header, _body_bytes, handles, &mut req)?;
326                        let control_handle = LogControlHandle { inner: this.inner.clone() };
327                        Ok(LogRequest::ListenSafe {
328                            log_listener: req.log_listener,
329                            options: req.options,
330
331                            control_handle,
332                        })
333                    }
334                    _ => Err(fidl::Error::UnknownOrdinal {
335                        ordinal: header.ordinal,
336                        protocol_name: <LogMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
337                    }),
338                }))
339            },
340        )
341    }
342}
343
344/// Interface for LogListenerSafe to register to listen to logs.
345#[derive(Debug)]
346pub enum LogRequest {
347    /// Dumps all cached logs by calling LogMany() in batches followed by Log() for each new log
348    /// message.
349    /// A null `options` indicates no filtering is requested.
350    ListenSafe {
351        log_listener: fidl::endpoints::ClientEnd<LogListenerSafeMarker>,
352        options: Option<Box<LogFilterOptions>>,
353        control_handle: LogControlHandle,
354    },
355}
356
357impl LogRequest {
358    #[allow(irrefutable_let_patterns)]
359    pub fn into_listen_safe(
360        self,
361    ) -> Option<(
362        fidl::endpoints::ClientEnd<LogListenerSafeMarker>,
363        Option<Box<LogFilterOptions>>,
364        LogControlHandle,
365    )> {
366        if let LogRequest::ListenSafe { log_listener, options, control_handle } = self {
367            Some((log_listener, options, control_handle))
368        } else {
369            None
370        }
371    }
372
373    /// Name of the method defined in FIDL
374    pub fn method_name(&self) -> &'static str {
375        match *self {
376            LogRequest::ListenSafe { .. } => "listen_safe",
377        }
378    }
379}
380
381#[derive(Debug, Clone)]
382pub struct LogControlHandle {
383    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
384}
385
386impl LogControlHandle {
387    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
388        self.inner.shutdown_with_epitaph(status.into())
389    }
390}
391
392impl fidl::endpoints::ControlHandle for LogControlHandle {
393    fn shutdown(&self) {
394        self.inner.shutdown()
395    }
396
397    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
398        self.inner.shutdown_with_epitaph(status)
399    }
400
401    fn is_closed(&self) -> bool {
402        self.inner.channel().is_closed()
403    }
404    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
405        self.inner.channel().on_closed()
406    }
407
408    #[cfg(target_os = "fuchsia")]
409    fn signal_peer(
410        &self,
411        clear_mask: zx::Signals,
412        set_mask: zx::Signals,
413    ) -> Result<(), zx_status::Status> {
414        use fidl::Peered;
415        self.inner.channel().signal_peer(clear_mask, set_mask)
416    }
417}
418
419impl LogControlHandle {}
420
421#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
422pub struct LogListenerSafeMarker;
423
424impl fidl::endpoints::ProtocolMarker for LogListenerSafeMarker {
425    type Proxy = LogListenerSafeProxy;
426    type RequestStream = LogListenerSafeRequestStream;
427    #[cfg(target_os = "fuchsia")]
428    type SynchronousProxy = LogListenerSafeSynchronousProxy;
429
430    const DEBUG_NAME: &'static str = "(anonymous) LogListenerSafe";
431}
432
433pub trait LogListenerSafeProxyInterface: Send + Sync {
434    type LogResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
435    fn r#log(&self, log: &LogMessage) -> Self::LogResponseFut;
436    type LogManyResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
437    fn r#log_many(&self, log: &[LogMessage]) -> Self::LogManyResponseFut;
438    fn r#done(&self) -> Result<(), fidl::Error>;
439}
440#[derive(Debug)]
441#[cfg(target_os = "fuchsia")]
442pub struct LogListenerSafeSynchronousProxy {
443    client: fidl::client::sync::Client,
444}
445
446#[cfg(target_os = "fuchsia")]
447impl fidl::endpoints::SynchronousProxy for LogListenerSafeSynchronousProxy {
448    type Proxy = LogListenerSafeProxy;
449    type Protocol = LogListenerSafeMarker;
450
451    fn from_channel(inner: fidl::Channel) -> Self {
452        Self::new(inner)
453    }
454
455    fn into_channel(self) -> fidl::Channel {
456        self.client.into_channel()
457    }
458
459    fn as_channel(&self) -> &fidl::Channel {
460        self.client.as_channel()
461    }
462}
463
464#[cfg(target_os = "fuchsia")]
465impl LogListenerSafeSynchronousProxy {
466    pub fn new(channel: fidl::Channel) -> Self {
467        Self { client: fidl::client::sync::Client::new(channel) }
468    }
469
470    pub fn into_channel(self) -> fidl::Channel {
471        self.client.into_channel()
472    }
473
474    /// Waits until an event arrives and returns it. It is safe for other
475    /// threads to make concurrent requests while waiting for an event.
476    pub fn wait_for_event(
477        &self,
478        deadline: zx::MonotonicInstant,
479    ) -> Result<LogListenerSafeEvent, fidl::Error> {
480        LogListenerSafeEvent::decode(self.client.wait_for_event::<LogListenerSafeMarker>(deadline)?)
481    }
482
483    /// Called for single messages.
484    ///
485    /// The return value is used for flow control, and implementers should acknowledge receipt of
486    /// each message in order to continue receiving future messages.
487    pub fn r#log(
488        &self,
489        mut log: &LogMessage,
490        ___deadline: zx::MonotonicInstant,
491    ) -> Result<(), fidl::Error> {
492        let _response = self.client.send_query::<
493            LogListenerSafeLogRequest,
494            fidl::encoding::EmptyPayload,
495            LogListenerSafeMarker,
496        >(
497            (log,),
498            0x51a39de355d5bd0a,
499            fidl::encoding::DynamicFlags::empty(),
500            ___deadline,
501        )?;
502        Ok(_response)
503    }
504
505    /// Called when serving cached logs.
506    ///
507    /// Max logs size per call is `MAX_LOG_MANY_SIZE_BYTES` bytes.
508    ///
509    /// The return value is used for flow control, and implementers should acknowledge receipt of
510    /// each batch in order to continue receiving future messages.
511    pub fn r#log_many(
512        &self,
513        mut log: &[LogMessage],
514        ___deadline: zx::MonotonicInstant,
515    ) -> Result<(), fidl::Error> {
516        let _response = self.client.send_query::<
517            LogListenerSafeLogManyRequest,
518            fidl::encoding::EmptyPayload,
519            LogListenerSafeMarker,
520        >(
521            (log,),
522            0x1f056431bcd626a,
523            fidl::encoding::DynamicFlags::empty(),
524            ___deadline,
525        )?;
526        Ok(_response)
527    }
528
529    /// Called when this listener was passed to `DumpLogsSafe()` and all cached logs have been sent.
530    pub fn r#done(&self) -> Result<(), fidl::Error> {
531        self.client.send::<fidl::encoding::EmptyPayload>(
532            (),
533            0x34986151fcb584b8,
534            fidl::encoding::DynamicFlags::empty(),
535        )
536    }
537}
538
539#[cfg(target_os = "fuchsia")]
540impl From<LogListenerSafeSynchronousProxy> for zx::NullableHandle {
541    fn from(value: LogListenerSafeSynchronousProxy) -> Self {
542        value.into_channel().into()
543    }
544}
545
546#[cfg(target_os = "fuchsia")]
547impl From<fidl::Channel> for LogListenerSafeSynchronousProxy {
548    fn from(value: fidl::Channel) -> Self {
549        Self::new(value)
550    }
551}
552
553#[cfg(target_os = "fuchsia")]
554impl fidl::endpoints::FromClient for LogListenerSafeSynchronousProxy {
555    type Protocol = LogListenerSafeMarker;
556
557    fn from_client(value: fidl::endpoints::ClientEnd<LogListenerSafeMarker>) -> Self {
558        Self::new(value.into_channel())
559    }
560}
561
562#[derive(Debug, Clone)]
563pub struct LogListenerSafeProxy {
564    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
565}
566
567impl fidl::endpoints::Proxy for LogListenerSafeProxy {
568    type Protocol = LogListenerSafeMarker;
569
570    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
571        Self::new(inner)
572    }
573
574    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
575        self.client.into_channel().map_err(|client| Self { client })
576    }
577
578    fn as_channel(&self) -> &::fidl::AsyncChannel {
579        self.client.as_channel()
580    }
581}
582
583impl LogListenerSafeProxy {
584    /// Create a new Proxy for fuchsia.logger/LogListenerSafe.
585    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
586        let protocol_name = <LogListenerSafeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
587        Self { client: fidl::client::Client::new(channel, protocol_name) }
588    }
589
590    /// Get a Stream of events from the remote end of the protocol.
591    ///
592    /// # Panics
593    ///
594    /// Panics if the event stream was already taken.
595    pub fn take_event_stream(&self) -> LogListenerSafeEventStream {
596        LogListenerSafeEventStream { event_receiver: self.client.take_event_receiver() }
597    }
598
599    /// Called for single messages.
600    ///
601    /// The return value is used for flow control, and implementers should acknowledge receipt of
602    /// each message in order to continue receiving future messages.
603    pub fn r#log(
604        &self,
605        mut log: &LogMessage,
606    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
607        LogListenerSafeProxyInterface::r#log(self, log)
608    }
609
610    /// Called when serving cached logs.
611    ///
612    /// Max logs size per call is `MAX_LOG_MANY_SIZE_BYTES` bytes.
613    ///
614    /// The return value is used for flow control, and implementers should acknowledge receipt of
615    /// each batch in order to continue receiving future messages.
616    pub fn r#log_many(
617        &self,
618        mut log: &[LogMessage],
619    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
620        LogListenerSafeProxyInterface::r#log_many(self, log)
621    }
622
623    /// Called when this listener was passed to `DumpLogsSafe()` and all cached logs have been sent.
624    pub fn r#done(&self) -> Result<(), fidl::Error> {
625        LogListenerSafeProxyInterface::r#done(self)
626    }
627}
628
629impl LogListenerSafeProxyInterface for LogListenerSafeProxy {
630    type LogResponseFut =
631        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
632    fn r#log(&self, mut log: &LogMessage) -> Self::LogResponseFut {
633        fn _decode(
634            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
635        ) -> Result<(), fidl::Error> {
636            let _response = fidl::client::decode_transaction_body::<
637                fidl::encoding::EmptyPayload,
638                fidl::encoding::DefaultFuchsiaResourceDialect,
639                0x51a39de355d5bd0a,
640            >(_buf?)?;
641            Ok(_response)
642        }
643        self.client.send_query_and_decode::<LogListenerSafeLogRequest, ()>(
644            (log,),
645            0x51a39de355d5bd0a,
646            fidl::encoding::DynamicFlags::empty(),
647            _decode,
648        )
649    }
650
651    type LogManyResponseFut =
652        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
653    fn r#log_many(&self, mut log: &[LogMessage]) -> Self::LogManyResponseFut {
654        fn _decode(
655            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
656        ) -> Result<(), fidl::Error> {
657            let _response = fidl::client::decode_transaction_body::<
658                fidl::encoding::EmptyPayload,
659                fidl::encoding::DefaultFuchsiaResourceDialect,
660                0x1f056431bcd626a,
661            >(_buf?)?;
662            Ok(_response)
663        }
664        self.client.send_query_and_decode::<LogListenerSafeLogManyRequest, ()>(
665            (log,),
666            0x1f056431bcd626a,
667            fidl::encoding::DynamicFlags::empty(),
668            _decode,
669        )
670    }
671
672    fn r#done(&self) -> Result<(), fidl::Error> {
673        self.client.send::<fidl::encoding::EmptyPayload>(
674            (),
675            0x34986151fcb584b8,
676            fidl::encoding::DynamicFlags::empty(),
677        )
678    }
679}
680
681pub struct LogListenerSafeEventStream {
682    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
683}
684
685impl std::marker::Unpin for LogListenerSafeEventStream {}
686
687impl futures::stream::FusedStream for LogListenerSafeEventStream {
688    fn is_terminated(&self) -> bool {
689        self.event_receiver.is_terminated()
690    }
691}
692
693impl futures::Stream for LogListenerSafeEventStream {
694    type Item = Result<LogListenerSafeEvent, fidl::Error>;
695
696    fn poll_next(
697        mut self: std::pin::Pin<&mut Self>,
698        cx: &mut std::task::Context<'_>,
699    ) -> std::task::Poll<Option<Self::Item>> {
700        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
701            &mut self.event_receiver,
702            cx
703        )?) {
704            Some(buf) => std::task::Poll::Ready(Some(LogListenerSafeEvent::decode(buf))),
705            None => std::task::Poll::Ready(None),
706        }
707    }
708}
709
710#[derive(Debug)]
711pub enum LogListenerSafeEvent {}
712
713impl LogListenerSafeEvent {
714    /// Decodes a message buffer as a [`LogListenerSafeEvent`].
715    fn decode(
716        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
717    ) -> Result<LogListenerSafeEvent, fidl::Error> {
718        let (bytes, _handles) = buf.split_mut();
719        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
720        debug_assert_eq!(tx_header.tx_id, 0);
721        match tx_header.ordinal {
722            _ => Err(fidl::Error::UnknownOrdinal {
723                ordinal: tx_header.ordinal,
724                protocol_name:
725                    <LogListenerSafeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
726            }),
727        }
728    }
729}
730
731/// A Stream of incoming requests for fuchsia.logger/LogListenerSafe.
732pub struct LogListenerSafeRequestStream {
733    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
734    is_terminated: bool,
735}
736
737impl std::marker::Unpin for LogListenerSafeRequestStream {}
738
739impl futures::stream::FusedStream for LogListenerSafeRequestStream {
740    fn is_terminated(&self) -> bool {
741        self.is_terminated
742    }
743}
744
745impl fidl::endpoints::RequestStream for LogListenerSafeRequestStream {
746    type Protocol = LogListenerSafeMarker;
747    type ControlHandle = LogListenerSafeControlHandle;
748
749    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
750        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
751    }
752
753    fn control_handle(&self) -> Self::ControlHandle {
754        LogListenerSafeControlHandle { inner: self.inner.clone() }
755    }
756
757    fn into_inner(
758        self,
759    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
760    {
761        (self.inner, self.is_terminated)
762    }
763
764    fn from_inner(
765        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
766        is_terminated: bool,
767    ) -> Self {
768        Self { inner, is_terminated }
769    }
770}
771
772impl futures::Stream for LogListenerSafeRequestStream {
773    type Item = Result<LogListenerSafeRequest, fidl::Error>;
774
775    fn poll_next(
776        mut self: std::pin::Pin<&mut Self>,
777        cx: &mut std::task::Context<'_>,
778    ) -> std::task::Poll<Option<Self::Item>> {
779        let this = &mut *self;
780        if this.inner.check_shutdown(cx) {
781            this.is_terminated = true;
782            return std::task::Poll::Ready(None);
783        }
784        if this.is_terminated {
785            panic!("polled LogListenerSafeRequestStream after completion");
786        }
787        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
788            |bytes, handles| {
789                match this.inner.channel().read_etc(cx, bytes, handles) {
790                    std::task::Poll::Ready(Ok(())) => {}
791                    std::task::Poll::Pending => return std::task::Poll::Pending,
792                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
793                        this.is_terminated = true;
794                        return std::task::Poll::Ready(None);
795                    }
796                    std::task::Poll::Ready(Err(e)) => {
797                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
798                            e.into(),
799                        ))));
800                    }
801                }
802
803                // A message has been received from the channel
804                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
805
806                std::task::Poll::Ready(Some(match header.ordinal {
807                    0x51a39de355d5bd0a => {
808                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
809                        let mut req = fidl::new_empty!(
810                            LogListenerSafeLogRequest,
811                            fidl::encoding::DefaultFuchsiaResourceDialect
812                        );
813                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LogListenerSafeLogRequest>(&header, _body_bytes, handles, &mut req)?;
814                        let control_handle =
815                            LogListenerSafeControlHandle { inner: this.inner.clone() };
816                        Ok(LogListenerSafeRequest::Log {
817                            log: req.log,
818
819                            responder: LogListenerSafeLogResponder {
820                                control_handle: std::mem::ManuallyDrop::new(control_handle),
821                                tx_id: header.tx_id,
822                            },
823                        })
824                    }
825                    0x1f056431bcd626a => {
826                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
827                        let mut req = fidl::new_empty!(
828                            LogListenerSafeLogManyRequest,
829                            fidl::encoding::DefaultFuchsiaResourceDialect
830                        );
831                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LogListenerSafeLogManyRequest>(&header, _body_bytes, handles, &mut req)?;
832                        let control_handle =
833                            LogListenerSafeControlHandle { inner: this.inner.clone() };
834                        Ok(LogListenerSafeRequest::LogMany {
835                            log: req.log,
836
837                            responder: LogListenerSafeLogManyResponder {
838                                control_handle: std::mem::ManuallyDrop::new(control_handle),
839                                tx_id: header.tx_id,
840                            },
841                        })
842                    }
843                    0x34986151fcb584b8 => {
844                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
845                        let mut req = fidl::new_empty!(
846                            fidl::encoding::EmptyPayload,
847                            fidl::encoding::DefaultFuchsiaResourceDialect
848                        );
849                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
850                        let control_handle =
851                            LogListenerSafeControlHandle { inner: this.inner.clone() };
852                        Ok(LogListenerSafeRequest::Done { control_handle })
853                    }
854                    _ => Err(fidl::Error::UnknownOrdinal {
855                        ordinal: header.ordinal,
856                        protocol_name:
857                            <LogListenerSafeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
858                    }),
859                }))
860            },
861        )
862    }
863}
864
865/// A listener who will notify the `Log` of the receipt of each message.
866#[derive(Debug)]
867pub enum LogListenerSafeRequest {
868    /// Called for single messages.
869    ///
870    /// The return value is used for flow control, and implementers should acknowledge receipt of
871    /// each message in order to continue receiving future messages.
872    Log { log: LogMessage, responder: LogListenerSafeLogResponder },
873    /// Called when serving cached logs.
874    ///
875    /// Max logs size per call is `MAX_LOG_MANY_SIZE_BYTES` bytes.
876    ///
877    /// The return value is used for flow control, and implementers should acknowledge receipt of
878    /// each batch in order to continue receiving future messages.
879    LogMany { log: Vec<LogMessage>, responder: LogListenerSafeLogManyResponder },
880    /// Called when this listener was passed to `DumpLogsSafe()` and all cached logs have been sent.
881    Done { control_handle: LogListenerSafeControlHandle },
882}
883
884impl LogListenerSafeRequest {
885    #[allow(irrefutable_let_patterns)]
886    pub fn into_log(self) -> Option<(LogMessage, LogListenerSafeLogResponder)> {
887        if let LogListenerSafeRequest::Log { log, responder } = self {
888            Some((log, responder))
889        } else {
890            None
891        }
892    }
893
894    #[allow(irrefutable_let_patterns)]
895    pub fn into_log_many(self) -> Option<(Vec<LogMessage>, LogListenerSafeLogManyResponder)> {
896        if let LogListenerSafeRequest::LogMany { log, responder } = self {
897            Some((log, responder))
898        } else {
899            None
900        }
901    }
902
903    #[allow(irrefutable_let_patterns)]
904    pub fn into_done(self) -> Option<(LogListenerSafeControlHandle)> {
905        if let LogListenerSafeRequest::Done { control_handle } = self {
906            Some((control_handle))
907        } else {
908            None
909        }
910    }
911
912    /// Name of the method defined in FIDL
913    pub fn method_name(&self) -> &'static str {
914        match *self {
915            LogListenerSafeRequest::Log { .. } => "log",
916            LogListenerSafeRequest::LogMany { .. } => "log_many",
917            LogListenerSafeRequest::Done { .. } => "done",
918        }
919    }
920}
921
922#[derive(Debug, Clone)]
923pub struct LogListenerSafeControlHandle {
924    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
925}
926
927impl LogListenerSafeControlHandle {
928    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
929        self.inner.shutdown_with_epitaph(status.into())
930    }
931}
932
933impl fidl::endpoints::ControlHandle for LogListenerSafeControlHandle {
934    fn shutdown(&self) {
935        self.inner.shutdown()
936    }
937
938    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
939        self.inner.shutdown_with_epitaph(status)
940    }
941
942    fn is_closed(&self) -> bool {
943        self.inner.channel().is_closed()
944    }
945    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
946        self.inner.channel().on_closed()
947    }
948
949    #[cfg(target_os = "fuchsia")]
950    fn signal_peer(
951        &self,
952        clear_mask: zx::Signals,
953        set_mask: zx::Signals,
954    ) -> Result<(), zx_status::Status> {
955        use fidl::Peered;
956        self.inner.channel().signal_peer(clear_mask, set_mask)
957    }
958}
959
960impl LogListenerSafeControlHandle {}
961
962#[must_use = "FIDL methods require a response to be sent"]
963#[derive(Debug)]
964pub struct LogListenerSafeLogResponder {
965    control_handle: std::mem::ManuallyDrop<LogListenerSafeControlHandle>,
966    tx_id: u32,
967}
968
969/// Set the the channel to be shutdown (see [`LogListenerSafeControlHandle::shutdown`])
970/// if the responder is dropped without sending a response, so that the client
971/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
972impl std::ops::Drop for LogListenerSafeLogResponder {
973    fn drop(&mut self) {
974        self.control_handle.shutdown();
975        // Safety: drops once, never accessed again
976        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
977    }
978}
979
980impl fidl::endpoints::Responder for LogListenerSafeLogResponder {
981    type ControlHandle = LogListenerSafeControlHandle;
982
983    fn control_handle(&self) -> &LogListenerSafeControlHandle {
984        &self.control_handle
985    }
986
987    fn drop_without_shutdown(mut self) {
988        // Safety: drops once, never accessed again due to mem::forget
989        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
990        // Prevent Drop from running (which would shut down the channel)
991        std::mem::forget(self);
992    }
993}
994
995impl LogListenerSafeLogResponder {
996    /// Sends a response to the FIDL transaction.
997    ///
998    /// Sets the channel to shutdown if an error occurs.
999    pub fn send(self) -> Result<(), fidl::Error> {
1000        let _result = self.send_raw();
1001        if _result.is_err() {
1002            self.control_handle.shutdown();
1003        }
1004        self.drop_without_shutdown();
1005        _result
1006    }
1007
1008    /// Similar to "send" but does not shutdown the channel if an error occurs.
1009    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1010        let _result = self.send_raw();
1011        self.drop_without_shutdown();
1012        _result
1013    }
1014
1015    fn send_raw(&self) -> Result<(), fidl::Error> {
1016        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1017            (),
1018            self.tx_id,
1019            0x51a39de355d5bd0a,
1020            fidl::encoding::DynamicFlags::empty(),
1021        )
1022    }
1023}
1024
1025#[must_use = "FIDL methods require a response to be sent"]
1026#[derive(Debug)]
1027pub struct LogListenerSafeLogManyResponder {
1028    control_handle: std::mem::ManuallyDrop<LogListenerSafeControlHandle>,
1029    tx_id: u32,
1030}
1031
1032/// Set the the channel to be shutdown (see [`LogListenerSafeControlHandle::shutdown`])
1033/// if the responder is dropped without sending a response, so that the client
1034/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1035impl std::ops::Drop for LogListenerSafeLogManyResponder {
1036    fn drop(&mut self) {
1037        self.control_handle.shutdown();
1038        // Safety: drops once, never accessed again
1039        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1040    }
1041}
1042
1043impl fidl::endpoints::Responder for LogListenerSafeLogManyResponder {
1044    type ControlHandle = LogListenerSafeControlHandle;
1045
1046    fn control_handle(&self) -> &LogListenerSafeControlHandle {
1047        &self.control_handle
1048    }
1049
1050    fn drop_without_shutdown(mut self) {
1051        // Safety: drops once, never accessed again due to mem::forget
1052        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1053        // Prevent Drop from running (which would shut down the channel)
1054        std::mem::forget(self);
1055    }
1056}
1057
1058impl LogListenerSafeLogManyResponder {
1059    /// Sends a response to the FIDL transaction.
1060    ///
1061    /// Sets the channel to shutdown if an error occurs.
1062    pub fn send(self) -> Result<(), fidl::Error> {
1063        let _result = self.send_raw();
1064        if _result.is_err() {
1065            self.control_handle.shutdown();
1066        }
1067        self.drop_without_shutdown();
1068        _result
1069    }
1070
1071    /// Similar to "send" but does not shutdown the channel if an error occurs.
1072    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1073        let _result = self.send_raw();
1074        self.drop_without_shutdown();
1075        _result
1076    }
1077
1078    fn send_raw(&self) -> Result<(), fidl::Error> {
1079        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1080            (),
1081            self.tx_id,
1082            0x1f056431bcd626a,
1083            fidl::encoding::DynamicFlags::empty(),
1084        )
1085    }
1086}
1087
1088#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1089pub struct LogSinkMarker;
1090
1091impl fidl::endpoints::ProtocolMarker for LogSinkMarker {
1092    type Proxy = LogSinkProxy;
1093    type RequestStream = LogSinkRequestStream;
1094    #[cfg(target_os = "fuchsia")]
1095    type SynchronousProxy = LogSinkSynchronousProxy;
1096
1097    const DEBUG_NAME: &'static str = "fuchsia.logger.LogSink";
1098}
1099impl fidl::endpoints::DiscoverableProtocolMarker for LogSinkMarker {}
1100pub type LogSinkWaitForInterestChangeResult =
1101    Result<fidl_fuchsia_diagnostics_types::Interest, InterestChangeError>;
1102
1103pub trait LogSinkProxyInterface: Send + Sync {
1104    type WaitForInterestChangeResponseFut: std::future::Future<Output = Result<LogSinkWaitForInterestChangeResult, fidl::Error>>
1105        + Send;
1106    fn r#wait_for_interest_change(&self) -> Self::WaitForInterestChangeResponseFut;
1107}
1108#[derive(Debug)]
1109#[cfg(target_os = "fuchsia")]
1110pub struct LogSinkSynchronousProxy {
1111    client: fidl::client::sync::Client,
1112}
1113
1114#[cfg(target_os = "fuchsia")]
1115impl fidl::endpoints::SynchronousProxy for LogSinkSynchronousProxy {
1116    type Proxy = LogSinkProxy;
1117    type Protocol = LogSinkMarker;
1118
1119    fn from_channel(inner: fidl::Channel) -> Self {
1120        Self::new(inner)
1121    }
1122
1123    fn into_channel(self) -> fidl::Channel {
1124        self.client.into_channel()
1125    }
1126
1127    fn as_channel(&self) -> &fidl::Channel {
1128        self.client.as_channel()
1129    }
1130}
1131
1132#[cfg(target_os = "fuchsia")]
1133impl LogSinkSynchronousProxy {
1134    pub fn new(channel: fidl::Channel) -> Self {
1135        Self { client: fidl::client::sync::Client::new(channel) }
1136    }
1137
1138    pub fn into_channel(self) -> fidl::Channel {
1139        self.client.into_channel()
1140    }
1141
1142    /// Waits until an event arrives and returns it. It is safe for other
1143    /// threads to make concurrent requests while waiting for an event.
1144    pub fn wait_for_event(
1145        &self,
1146        deadline: zx::MonotonicInstant,
1147    ) -> Result<LogSinkEvent, fidl::Error> {
1148        LogSinkEvent::decode(self.client.wait_for_event::<LogSinkMarker>(deadline)?)
1149    }
1150
1151    /// LogSink implementers will return to this hanging-get whenever the scope of
1152    /// their interest changes. Clients are expected to emit messages based on
1153    /// the registered Interest. In the event that an empty interest is
1154    /// conveyed, clients should emit messages based on their default
1155    /// e.g. compile time configuration. Each client may only poll this once at a time.
1156    /// Invoking WaitForInterestChange a second time before the first call returns will
1157    /// result in an error being returned.
1158    pub fn r#wait_for_interest_change(
1159        &self,
1160        ___deadline: zx::MonotonicInstant,
1161    ) -> Result<LogSinkWaitForInterestChangeResult, fidl::Error> {
1162        let _response =
1163            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
1164                LogSinkWaitForInterestChangeResponse,
1165                InterestChangeError,
1166            >, LogSinkMarker>(
1167                (),
1168                0x1dad20560c197242,
1169                fidl::encoding::DynamicFlags::empty(),
1170                ___deadline,
1171            )?;
1172        Ok(_response.map(|x| x.data))
1173    }
1174}
1175
1176#[cfg(target_os = "fuchsia")]
1177impl From<LogSinkSynchronousProxy> for zx::NullableHandle {
1178    fn from(value: LogSinkSynchronousProxy) -> Self {
1179        value.into_channel().into()
1180    }
1181}
1182
1183#[cfg(target_os = "fuchsia")]
1184impl From<fidl::Channel> for LogSinkSynchronousProxy {
1185    fn from(value: fidl::Channel) -> Self {
1186        Self::new(value)
1187    }
1188}
1189
1190#[cfg(target_os = "fuchsia")]
1191impl fidl::endpoints::FromClient for LogSinkSynchronousProxy {
1192    type Protocol = LogSinkMarker;
1193
1194    fn from_client(value: fidl::endpoints::ClientEnd<LogSinkMarker>) -> Self {
1195        Self::new(value.into_channel())
1196    }
1197}
1198
1199#[derive(Debug, Clone)]
1200pub struct LogSinkProxy {
1201    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1202}
1203
1204impl fidl::endpoints::Proxy for LogSinkProxy {
1205    type Protocol = LogSinkMarker;
1206
1207    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1208        Self::new(inner)
1209    }
1210
1211    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1212        self.client.into_channel().map_err(|client| Self { client })
1213    }
1214
1215    fn as_channel(&self) -> &::fidl::AsyncChannel {
1216        self.client.as_channel()
1217    }
1218}
1219
1220impl LogSinkProxy {
1221    /// Create a new Proxy for fuchsia.logger/LogSink.
1222    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1223        let protocol_name = <LogSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1224        Self { client: fidl::client::Client::new(channel, protocol_name) }
1225    }
1226
1227    /// Get a Stream of events from the remote end of the protocol.
1228    ///
1229    /// # Panics
1230    ///
1231    /// Panics if the event stream was already taken.
1232    pub fn take_event_stream(&self) -> LogSinkEventStream {
1233        LogSinkEventStream { event_receiver: self.client.take_event_receiver() }
1234    }
1235
1236    /// LogSink implementers will return to this hanging-get whenever the scope of
1237    /// their interest changes. Clients are expected to emit messages based on
1238    /// the registered Interest. In the event that an empty interest is
1239    /// conveyed, clients should emit messages based on their default
1240    /// e.g. compile time configuration. Each client may only poll this once at a time.
1241    /// Invoking WaitForInterestChange a second time before the first call returns will
1242    /// result in an error being returned.
1243    pub fn r#wait_for_interest_change(
1244        &self,
1245    ) -> fidl::client::QueryResponseFut<
1246        LogSinkWaitForInterestChangeResult,
1247        fidl::encoding::DefaultFuchsiaResourceDialect,
1248    > {
1249        LogSinkProxyInterface::r#wait_for_interest_change(self)
1250    }
1251}
1252
1253impl LogSinkProxyInterface for LogSinkProxy {
1254    type WaitForInterestChangeResponseFut = fidl::client::QueryResponseFut<
1255        LogSinkWaitForInterestChangeResult,
1256        fidl::encoding::DefaultFuchsiaResourceDialect,
1257    >;
1258    fn r#wait_for_interest_change(&self) -> Self::WaitForInterestChangeResponseFut {
1259        fn _decode(
1260            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1261        ) -> Result<LogSinkWaitForInterestChangeResult, fidl::Error> {
1262            let _response = fidl::client::decode_transaction_body::<
1263                fidl::encoding::ResultType<
1264                    LogSinkWaitForInterestChangeResponse,
1265                    InterestChangeError,
1266                >,
1267                fidl::encoding::DefaultFuchsiaResourceDialect,
1268                0x1dad20560c197242,
1269            >(_buf?)?;
1270            Ok(_response.map(|x| x.data))
1271        }
1272        self.client.send_query_and_decode::<
1273            fidl::encoding::EmptyPayload,
1274            LogSinkWaitForInterestChangeResult,
1275        >(
1276            (),
1277            0x1dad20560c197242,
1278            fidl::encoding::DynamicFlags::empty(),
1279            _decode,
1280        )
1281    }
1282}
1283
1284pub struct LogSinkEventStream {
1285    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1286}
1287
1288impl std::marker::Unpin for LogSinkEventStream {}
1289
1290impl futures::stream::FusedStream for LogSinkEventStream {
1291    fn is_terminated(&self) -> bool {
1292        self.event_receiver.is_terminated()
1293    }
1294}
1295
1296impl futures::Stream for LogSinkEventStream {
1297    type Item = Result<LogSinkEvent, fidl::Error>;
1298
1299    fn poll_next(
1300        mut self: std::pin::Pin<&mut Self>,
1301        cx: &mut std::task::Context<'_>,
1302    ) -> std::task::Poll<Option<Self::Item>> {
1303        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1304            &mut self.event_receiver,
1305            cx
1306        )?) {
1307            Some(buf) => std::task::Poll::Ready(Some(LogSinkEvent::decode(buf))),
1308            None => std::task::Poll::Ready(None),
1309        }
1310    }
1311}
1312
1313#[derive(Debug)]
1314pub enum LogSinkEvent {
1315    OnInit {
1316        payload: LogSinkOnInitRequest,
1317    },
1318    #[non_exhaustive]
1319    _UnknownEvent {
1320        /// Ordinal of the event that was sent.
1321        ordinal: u64,
1322    },
1323}
1324
1325impl LogSinkEvent {
1326    #[allow(irrefutable_let_patterns)]
1327    pub fn into_on_init(self) -> Option<LogSinkOnInitRequest> {
1328        if let LogSinkEvent::OnInit { payload } = self { Some((payload)) } else { None }
1329    }
1330
1331    /// Decodes a message buffer as a [`LogSinkEvent`].
1332    fn decode(
1333        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1334    ) -> Result<LogSinkEvent, fidl::Error> {
1335        let (bytes, _handles) = buf.split_mut();
1336        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1337        debug_assert_eq!(tx_header.tx_id, 0);
1338        match tx_header.ordinal {
1339            0x61e0ad0e16df6aba => {
1340                let mut out = fidl::new_empty!(
1341                    LogSinkOnInitRequest,
1342                    fidl::encoding::DefaultFuchsiaResourceDialect
1343                );
1344                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LogSinkOnInitRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1345                Ok((LogSinkEvent::OnInit { payload: out }))
1346            }
1347            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1348                Ok(LogSinkEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1349            }
1350            _ => Err(fidl::Error::UnknownOrdinal {
1351                ordinal: tx_header.ordinal,
1352                protocol_name: <LogSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1353            }),
1354        }
1355    }
1356}
1357
1358/// A Stream of incoming requests for fuchsia.logger/LogSink.
1359pub struct LogSinkRequestStream {
1360    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1361    is_terminated: bool,
1362}
1363
1364impl std::marker::Unpin for LogSinkRequestStream {}
1365
1366impl futures::stream::FusedStream for LogSinkRequestStream {
1367    fn is_terminated(&self) -> bool {
1368        self.is_terminated
1369    }
1370}
1371
1372impl fidl::endpoints::RequestStream for LogSinkRequestStream {
1373    type Protocol = LogSinkMarker;
1374    type ControlHandle = LogSinkControlHandle;
1375
1376    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1377        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1378    }
1379
1380    fn control_handle(&self) -> Self::ControlHandle {
1381        LogSinkControlHandle { inner: self.inner.clone() }
1382    }
1383
1384    fn into_inner(
1385        self,
1386    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1387    {
1388        (self.inner, self.is_terminated)
1389    }
1390
1391    fn from_inner(
1392        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1393        is_terminated: bool,
1394    ) -> Self {
1395        Self { inner, is_terminated }
1396    }
1397}
1398
1399impl futures::Stream for LogSinkRequestStream {
1400    type Item = Result<LogSinkRequest, fidl::Error>;
1401
1402    fn poll_next(
1403        mut self: std::pin::Pin<&mut Self>,
1404        cx: &mut std::task::Context<'_>,
1405    ) -> std::task::Poll<Option<Self::Item>> {
1406        let this = &mut *self;
1407        if this.inner.check_shutdown(cx) {
1408            this.is_terminated = true;
1409            return std::task::Poll::Ready(None);
1410        }
1411        if this.is_terminated {
1412            panic!("polled LogSinkRequestStream after completion");
1413        }
1414        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1415            |bytes, handles| {
1416                match this.inner.channel().read_etc(cx, bytes, handles) {
1417                    std::task::Poll::Ready(Ok(())) => {}
1418                    std::task::Poll::Pending => return std::task::Poll::Pending,
1419                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1420                        this.is_terminated = true;
1421                        return std::task::Poll::Ready(None);
1422                    }
1423                    std::task::Poll::Ready(Err(e)) => {
1424                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1425                            e.into(),
1426                        ))));
1427                    }
1428                }
1429
1430                // A message has been received from the channel
1431                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1432
1433                std::task::Poll::Ready(Some(match header.ordinal {
1434                    0x1dad20560c197242 => {
1435                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1436                        let mut req = fidl::new_empty!(
1437                            fidl::encoding::EmptyPayload,
1438                            fidl::encoding::DefaultFuchsiaResourceDialect
1439                        );
1440                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1441                        let control_handle = LogSinkControlHandle { inner: this.inner.clone() };
1442                        Ok(LogSinkRequest::WaitForInterestChange {
1443                            responder: LogSinkWaitForInterestChangeResponder {
1444                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1445                                tx_id: header.tx_id,
1446                            },
1447                        })
1448                    }
1449                    _ if header.tx_id == 0
1450                        && header
1451                            .dynamic_flags()
1452                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1453                    {
1454                        Ok(LogSinkRequest::_UnknownMethod {
1455                            ordinal: header.ordinal,
1456                            control_handle: LogSinkControlHandle { inner: this.inner.clone() },
1457                            method_type: fidl::MethodType::OneWay,
1458                        })
1459                    }
1460                    _ if header
1461                        .dynamic_flags()
1462                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1463                    {
1464                        this.inner.send_framework_err(
1465                            fidl::encoding::FrameworkErr::UnknownMethod,
1466                            header.tx_id,
1467                            header.ordinal,
1468                            header.dynamic_flags(),
1469                            (bytes, handles),
1470                        )?;
1471                        Ok(LogSinkRequest::_UnknownMethod {
1472                            ordinal: header.ordinal,
1473                            control_handle: LogSinkControlHandle { inner: this.inner.clone() },
1474                            method_type: fidl::MethodType::TwoWay,
1475                        })
1476                    }
1477                    _ => Err(fidl::Error::UnknownOrdinal {
1478                        ordinal: header.ordinal,
1479                        protocol_name:
1480                            <LogSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1481                    }),
1482                }))
1483            },
1484        )
1485    }
1486}
1487
1488/// Drains a program's logs.
1489#[derive(Debug)]
1490pub enum LogSinkRequest {
1491    /// LogSink implementers will return to this hanging-get whenever the scope of
1492    /// their interest changes. Clients are expected to emit messages based on
1493    /// the registered Interest. In the event that an empty interest is
1494    /// conveyed, clients should emit messages based on their default
1495    /// e.g. compile time configuration. Each client may only poll this once at a time.
1496    /// Invoking WaitForInterestChange a second time before the first call returns will
1497    /// result in an error being returned.
1498    WaitForInterestChange { responder: LogSinkWaitForInterestChangeResponder },
1499    /// An interaction was received which does not match any known method.
1500    #[non_exhaustive]
1501    _UnknownMethod {
1502        /// Ordinal of the method that was called.
1503        ordinal: u64,
1504        control_handle: LogSinkControlHandle,
1505        method_type: fidl::MethodType,
1506    },
1507}
1508
1509impl LogSinkRequest {
1510    #[allow(irrefutable_let_patterns)]
1511    pub fn into_wait_for_interest_change(self) -> Option<(LogSinkWaitForInterestChangeResponder)> {
1512        if let LogSinkRequest::WaitForInterestChange { responder } = self {
1513            Some((responder))
1514        } else {
1515            None
1516        }
1517    }
1518
1519    /// Name of the method defined in FIDL
1520    pub fn method_name(&self) -> &'static str {
1521        match *self {
1522            LogSinkRequest::WaitForInterestChange { .. } => "wait_for_interest_change",
1523            LogSinkRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1524                "unknown one-way method"
1525            }
1526            LogSinkRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1527                "unknown two-way method"
1528            }
1529        }
1530    }
1531}
1532
1533#[derive(Debug, Clone)]
1534pub struct LogSinkControlHandle {
1535    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1536}
1537
1538impl LogSinkControlHandle {
1539    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1540        self.inner.shutdown_with_epitaph(status.into())
1541    }
1542}
1543
1544impl fidl::endpoints::ControlHandle for LogSinkControlHandle {
1545    fn shutdown(&self) {
1546        self.inner.shutdown()
1547    }
1548
1549    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1550        self.inner.shutdown_with_epitaph(status)
1551    }
1552
1553    fn is_closed(&self) -> bool {
1554        self.inner.channel().is_closed()
1555    }
1556    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1557        self.inner.channel().on_closed()
1558    }
1559
1560    #[cfg(target_os = "fuchsia")]
1561    fn signal_peer(
1562        &self,
1563        clear_mask: zx::Signals,
1564        set_mask: zx::Signals,
1565    ) -> Result<(), zx_status::Status> {
1566        use fidl::Peered;
1567        self.inner.channel().signal_peer(clear_mask, set_mask)
1568    }
1569}
1570
1571impl LogSinkControlHandle {
1572    pub fn send_on_init(&self, mut payload: LogSinkOnInitRequest) -> Result<(), fidl::Error> {
1573        self.inner.send::<LogSinkOnInitRequest>(
1574            &mut payload,
1575            0,
1576            0x61e0ad0e16df6aba,
1577            fidl::encoding::DynamicFlags::FLEXIBLE,
1578        )
1579    }
1580}
1581
1582#[must_use = "FIDL methods require a response to be sent"]
1583#[derive(Debug)]
1584pub struct LogSinkWaitForInterestChangeResponder {
1585    control_handle: std::mem::ManuallyDrop<LogSinkControlHandle>,
1586    tx_id: u32,
1587}
1588
1589/// Set the the channel to be shutdown (see [`LogSinkControlHandle::shutdown`])
1590/// if the responder is dropped without sending a response, so that the client
1591/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1592impl std::ops::Drop for LogSinkWaitForInterestChangeResponder {
1593    fn drop(&mut self) {
1594        self.control_handle.shutdown();
1595        // Safety: drops once, never accessed again
1596        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1597    }
1598}
1599
1600impl fidl::endpoints::Responder for LogSinkWaitForInterestChangeResponder {
1601    type ControlHandle = LogSinkControlHandle;
1602
1603    fn control_handle(&self) -> &LogSinkControlHandle {
1604        &self.control_handle
1605    }
1606
1607    fn drop_without_shutdown(mut self) {
1608        // Safety: drops once, never accessed again due to mem::forget
1609        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1610        // Prevent Drop from running (which would shut down the channel)
1611        std::mem::forget(self);
1612    }
1613}
1614
1615impl LogSinkWaitForInterestChangeResponder {
1616    /// Sends a response to the FIDL transaction.
1617    ///
1618    /// Sets the channel to shutdown if an error occurs.
1619    pub fn send(
1620        self,
1621        mut result: Result<&fidl_fuchsia_diagnostics_types::Interest, InterestChangeError>,
1622    ) -> Result<(), fidl::Error> {
1623        let _result = self.send_raw(result);
1624        if _result.is_err() {
1625            self.control_handle.shutdown();
1626        }
1627        self.drop_without_shutdown();
1628        _result
1629    }
1630
1631    /// Similar to "send" but does not shutdown the channel if an error occurs.
1632    pub fn send_no_shutdown_on_err(
1633        self,
1634        mut result: Result<&fidl_fuchsia_diagnostics_types::Interest, InterestChangeError>,
1635    ) -> Result<(), fidl::Error> {
1636        let _result = self.send_raw(result);
1637        self.drop_without_shutdown();
1638        _result
1639    }
1640
1641    fn send_raw(
1642        &self,
1643        mut result: Result<&fidl_fuchsia_diagnostics_types::Interest, InterestChangeError>,
1644    ) -> Result<(), fidl::Error> {
1645        self.control_handle.inner.send::<fidl::encoding::ResultType<
1646            LogSinkWaitForInterestChangeResponse,
1647            InterestChangeError,
1648        >>(
1649            result.map(|data| (data,)),
1650            self.tx_id,
1651            0x1dad20560c197242,
1652            fidl::encoding::DynamicFlags::empty(),
1653        )
1654    }
1655}
1656
1657mod internal {
1658    use super::*;
1659
1660    impl fidl::encoding::ResourceTypeMarker for LogListenSafeRequest {
1661        type Borrowed<'a> = &'a mut Self;
1662        fn take_or_borrow<'a>(
1663            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1664        ) -> Self::Borrowed<'a> {
1665            value
1666        }
1667    }
1668
1669    unsafe impl fidl::encoding::TypeMarker for LogListenSafeRequest {
1670        type Owned = Self;
1671
1672        #[inline(always)]
1673        fn inline_align(_context: fidl::encoding::Context) -> usize {
1674            8
1675        }
1676
1677        #[inline(always)]
1678        fn inline_size(_context: fidl::encoding::Context) -> usize {
1679            16
1680        }
1681    }
1682
1683    unsafe impl
1684        fidl::encoding::Encode<LogListenSafeRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1685        for &mut LogListenSafeRequest
1686    {
1687        #[inline]
1688        unsafe fn encode(
1689            self,
1690            encoder: &mut fidl::encoding::Encoder<
1691                '_,
1692                fidl::encoding::DefaultFuchsiaResourceDialect,
1693            >,
1694            offset: usize,
1695            _depth: fidl::encoding::Depth,
1696        ) -> fidl::Result<()> {
1697            encoder.debug_check_bounds::<LogListenSafeRequest>(offset);
1698            // Delegate to tuple encoding.
1699            fidl::encoding::Encode::<LogListenSafeRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1700                (
1701                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LogListenerSafeMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.log_listener),
1702                    <fidl::encoding::Boxed<LogFilterOptions> as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
1703                ),
1704                encoder, offset, _depth
1705            )
1706        }
1707    }
1708    unsafe impl<
1709        T0: fidl::encoding::Encode<
1710                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LogListenerSafeMarker>>,
1711                fidl::encoding::DefaultFuchsiaResourceDialect,
1712            >,
1713        T1: fidl::encoding::Encode<
1714                fidl::encoding::Boxed<LogFilterOptions>,
1715                fidl::encoding::DefaultFuchsiaResourceDialect,
1716            >,
1717    >
1718        fidl::encoding::Encode<LogListenSafeRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1719        for (T0, T1)
1720    {
1721        #[inline]
1722        unsafe fn encode(
1723            self,
1724            encoder: &mut fidl::encoding::Encoder<
1725                '_,
1726                fidl::encoding::DefaultFuchsiaResourceDialect,
1727            >,
1728            offset: usize,
1729            depth: fidl::encoding::Depth,
1730        ) -> fidl::Result<()> {
1731            encoder.debug_check_bounds::<LogListenSafeRequest>(offset);
1732            // Zero out padding regions. There's no need to apply masks
1733            // because the unmasked parts will be overwritten by fields.
1734            unsafe {
1735                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1736                (ptr as *mut u64).write_unaligned(0);
1737            }
1738            // Write the fields.
1739            self.0.encode(encoder, offset + 0, depth)?;
1740            self.1.encode(encoder, offset + 8, depth)?;
1741            Ok(())
1742        }
1743    }
1744
1745    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1746        for LogListenSafeRequest
1747    {
1748        #[inline(always)]
1749        fn new_empty() -> Self {
1750            Self {
1751                log_listener: fidl::new_empty!(
1752                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LogListenerSafeMarker>>,
1753                    fidl::encoding::DefaultFuchsiaResourceDialect
1754                ),
1755                options: fidl::new_empty!(
1756                    fidl::encoding::Boxed<LogFilterOptions>,
1757                    fidl::encoding::DefaultFuchsiaResourceDialect
1758                ),
1759            }
1760        }
1761
1762        #[inline]
1763        unsafe fn decode(
1764            &mut self,
1765            decoder: &mut fidl::encoding::Decoder<
1766                '_,
1767                fidl::encoding::DefaultFuchsiaResourceDialect,
1768            >,
1769            offset: usize,
1770            _depth: fidl::encoding::Depth,
1771        ) -> fidl::Result<()> {
1772            decoder.debug_check_bounds::<Self>(offset);
1773            // Verify that padding bytes are zero.
1774            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1775            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1776            let mask = 0xffffffff00000000u64;
1777            let maskedval = padval & mask;
1778            if maskedval != 0 {
1779                return Err(fidl::Error::NonZeroPadding {
1780                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1781                });
1782            }
1783            fidl::decode!(
1784                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LogListenerSafeMarker>>,
1785                fidl::encoding::DefaultFuchsiaResourceDialect,
1786                &mut self.log_listener,
1787                decoder,
1788                offset + 0,
1789                _depth
1790            )?;
1791            fidl::decode!(
1792                fidl::encoding::Boxed<LogFilterOptions>,
1793                fidl::encoding::DefaultFuchsiaResourceDialect,
1794                &mut self.options,
1795                decoder,
1796                offset + 8,
1797                _depth
1798            )?;
1799            Ok(())
1800        }
1801    }
1802
1803    impl LogSinkOnInitRequest {
1804        #[inline(always)]
1805        fn max_ordinal_present(&self) -> u64 {
1806            if let Some(_) = self.interest {
1807                return 2;
1808            }
1809            if let Some(_) = self.buffer {
1810                return 1;
1811            }
1812            0
1813        }
1814    }
1815
1816    impl fidl::encoding::ResourceTypeMarker for LogSinkOnInitRequest {
1817        type Borrowed<'a> = &'a mut Self;
1818        fn take_or_borrow<'a>(
1819            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1820        ) -> Self::Borrowed<'a> {
1821            value
1822        }
1823    }
1824
1825    unsafe impl fidl::encoding::TypeMarker for LogSinkOnInitRequest {
1826        type Owned = Self;
1827
1828        #[inline(always)]
1829        fn inline_align(_context: fidl::encoding::Context) -> usize {
1830            8
1831        }
1832
1833        #[inline(always)]
1834        fn inline_size(_context: fidl::encoding::Context) -> usize {
1835            16
1836        }
1837    }
1838
1839    unsafe impl
1840        fidl::encoding::Encode<LogSinkOnInitRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1841        for &mut LogSinkOnInitRequest
1842    {
1843        unsafe fn encode(
1844            self,
1845            encoder: &mut fidl::encoding::Encoder<
1846                '_,
1847                fidl::encoding::DefaultFuchsiaResourceDialect,
1848            >,
1849            offset: usize,
1850            mut depth: fidl::encoding::Depth,
1851        ) -> fidl::Result<()> {
1852            encoder.debug_check_bounds::<LogSinkOnInitRequest>(offset);
1853            // Vector header
1854            let max_ordinal: u64 = self.max_ordinal_present();
1855            encoder.write_num(max_ordinal, offset);
1856            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1857            // Calling encoder.out_of_line_offset(0) is not allowed.
1858            if max_ordinal == 0 {
1859                return Ok(());
1860            }
1861            depth.increment()?;
1862            let envelope_size = 8;
1863            let bytes_len = max_ordinal as usize * envelope_size;
1864            #[allow(unused_variables)]
1865            let offset = encoder.out_of_line_offset(bytes_len);
1866            let mut _prev_end_offset: usize = 0;
1867            if 1 > max_ordinal {
1868                return Ok(());
1869            }
1870
1871            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1872            // are envelope_size bytes.
1873            let cur_offset: usize = (1 - 1) * envelope_size;
1874
1875            // Zero reserved fields.
1876            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1877
1878            // Safety:
1879            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1880            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1881            //   envelope_size bytes, there is always sufficient room.
1882            fidl::encoding::encode_in_envelope_optional::<
1883                fidl::encoding::HandleType<
1884                    fidl::Iob,
1885                    { fidl::ObjectType::IOB.into_raw() },
1886                    2147483648,
1887                >,
1888                fidl::encoding::DefaultFuchsiaResourceDialect,
1889            >(
1890                self.buffer.as_mut().map(
1891                    <fidl::encoding::HandleType<
1892                        fidl::Iob,
1893                        { fidl::ObjectType::IOB.into_raw() },
1894                        2147483648,
1895                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1896                ),
1897                encoder,
1898                offset + cur_offset,
1899                depth,
1900            )?;
1901
1902            _prev_end_offset = cur_offset + envelope_size;
1903            if 2 > max_ordinal {
1904                return Ok(());
1905            }
1906
1907            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1908            // are envelope_size bytes.
1909            let cur_offset: usize = (2 - 1) * envelope_size;
1910
1911            // Zero reserved fields.
1912            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1913
1914            // Safety:
1915            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1916            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1917            //   envelope_size bytes, there is always sufficient room.
1918            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_diagnostics_types::Interest, fidl::encoding::DefaultFuchsiaResourceDialect>(
1919            self.interest.as_ref().map(<fidl_fuchsia_diagnostics_types::Interest as fidl::encoding::ValueTypeMarker>::borrow),
1920            encoder, offset + cur_offset, depth
1921        )?;
1922
1923            _prev_end_offset = cur_offset + envelope_size;
1924
1925            Ok(())
1926        }
1927    }
1928
1929    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1930        for LogSinkOnInitRequest
1931    {
1932        #[inline(always)]
1933        fn new_empty() -> Self {
1934            Self::default()
1935        }
1936
1937        unsafe fn decode(
1938            &mut self,
1939            decoder: &mut fidl::encoding::Decoder<
1940                '_,
1941                fidl::encoding::DefaultFuchsiaResourceDialect,
1942            >,
1943            offset: usize,
1944            mut depth: fidl::encoding::Depth,
1945        ) -> fidl::Result<()> {
1946            decoder.debug_check_bounds::<Self>(offset);
1947            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1948                None => return Err(fidl::Error::NotNullable),
1949                Some(len) => len,
1950            };
1951            // Calling decoder.out_of_line_offset(0) is not allowed.
1952            if len == 0 {
1953                return Ok(());
1954            };
1955            depth.increment()?;
1956            let envelope_size = 8;
1957            let bytes_len = len * envelope_size;
1958            let offset = decoder.out_of_line_offset(bytes_len)?;
1959            // Decode the envelope for each type.
1960            let mut _next_ordinal_to_read = 0;
1961            let mut next_offset = offset;
1962            let end_offset = offset + bytes_len;
1963            _next_ordinal_to_read += 1;
1964            if next_offset >= end_offset {
1965                return Ok(());
1966            }
1967
1968            // Decode unknown envelopes for gaps in ordinals.
1969            while _next_ordinal_to_read < 1 {
1970                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1971                _next_ordinal_to_read += 1;
1972                next_offset += envelope_size;
1973            }
1974
1975            let next_out_of_line = decoder.next_out_of_line();
1976            let handles_before = decoder.remaining_handles();
1977            if let Some((inlined, num_bytes, num_handles)) =
1978                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1979            {
1980                let member_inline_size = <fidl::encoding::HandleType<
1981                    fidl::Iob,
1982                    { fidl::ObjectType::IOB.into_raw() },
1983                    2147483648,
1984                > as fidl::encoding::TypeMarker>::inline_size(
1985                    decoder.context
1986                );
1987                if inlined != (member_inline_size <= 4) {
1988                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1989                }
1990                let inner_offset;
1991                let mut inner_depth = depth.clone();
1992                if inlined {
1993                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1994                    inner_offset = next_offset;
1995                } else {
1996                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1997                    inner_depth.increment()?;
1998                }
1999                let val_ref =
2000                self.buffer.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Iob, { fidl::ObjectType::IOB.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2001                fidl::decode!(fidl::encoding::HandleType<fidl::Iob, { fidl::ObjectType::IOB.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2002                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2003                {
2004                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2005                }
2006                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2007                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2008                }
2009            }
2010
2011            next_offset += envelope_size;
2012            _next_ordinal_to_read += 1;
2013            if next_offset >= end_offset {
2014                return Ok(());
2015            }
2016
2017            // Decode unknown envelopes for gaps in ordinals.
2018            while _next_ordinal_to_read < 2 {
2019                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2020                _next_ordinal_to_read += 1;
2021                next_offset += envelope_size;
2022            }
2023
2024            let next_out_of_line = decoder.next_out_of_line();
2025            let handles_before = decoder.remaining_handles();
2026            if let Some((inlined, num_bytes, num_handles)) =
2027                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2028            {
2029                let member_inline_size = <fidl_fuchsia_diagnostics_types::Interest as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2030                if inlined != (member_inline_size <= 4) {
2031                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2032                }
2033                let inner_offset;
2034                let mut inner_depth = depth.clone();
2035                if inlined {
2036                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2037                    inner_offset = next_offset;
2038                } else {
2039                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2040                    inner_depth.increment()?;
2041                }
2042                let val_ref = self.interest.get_or_insert_with(|| {
2043                    fidl::new_empty!(
2044                        fidl_fuchsia_diagnostics_types::Interest,
2045                        fidl::encoding::DefaultFuchsiaResourceDialect
2046                    )
2047                });
2048                fidl::decode!(
2049                    fidl_fuchsia_diagnostics_types::Interest,
2050                    fidl::encoding::DefaultFuchsiaResourceDialect,
2051                    val_ref,
2052                    decoder,
2053                    inner_offset,
2054                    inner_depth
2055                )?;
2056                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2057                {
2058                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2059                }
2060                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2061                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2062                }
2063            }
2064
2065            next_offset += envelope_size;
2066
2067            // Decode the remaining unknown envelopes.
2068            while next_offset < end_offset {
2069                _next_ordinal_to_read += 1;
2070                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2071                next_offset += envelope_size;
2072            }
2073
2074            Ok(())
2075        }
2076    }
2077}