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