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