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