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