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