Skip to main content

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