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