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