Skip to main content

fidl_fuchsia_hardware_interconnect/
fidl_fuchsia_hardware_interconnect.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_hardware_interconnect_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DeviceMarker;
16
17impl fidl::endpoints::ProtocolMarker for DeviceMarker {
18    type Proxy = DeviceProxy;
19    type RequestStream = DeviceRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = DeviceSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.hardware.interconnect.Device";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
26pub type DeviceSetNodesBandwidthResult = Result<Vec<AggregatedBandwidth>, i32>;
27
28pub trait DeviceProxyInterface: Send + Sync {
29    type SetNodesBandwidthResponseFut: std::future::Future<Output = Result<DeviceSetNodesBandwidthResult, fidl::Error>>
30        + Send;
31    fn r#set_nodes_bandwidth(&self, nodes: &[NodeBandwidth]) -> Self::SetNodesBandwidthResponseFut;
32    type GetNodeGraphResponseFut: std::future::Future<Output = Result<(Vec<Node>, Vec<Edge>), fidl::Error>>
33        + Send;
34    fn r#get_node_graph(&self) -> Self::GetNodeGraphResponseFut;
35    type GetPathEndpointsResponseFut: std::future::Future<Output = Result<Vec<PathEndpoints>, fidl::Error>>
36        + Send;
37    fn r#get_path_endpoints(&self) -> Self::GetPathEndpointsResponseFut;
38}
39#[derive(Debug)]
40#[cfg(target_os = "fuchsia")]
41pub struct DeviceSynchronousProxy {
42    client: fidl::client::sync::Client,
43}
44
45#[cfg(target_os = "fuchsia")]
46impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
47    type Proxy = DeviceProxy;
48    type Protocol = DeviceMarker;
49
50    fn from_channel(inner: fidl::Channel) -> Self {
51        Self::new(inner)
52    }
53
54    fn into_channel(self) -> fidl::Channel {
55        self.client.into_channel()
56    }
57
58    fn as_channel(&self) -> &fidl::Channel {
59        self.client.as_channel()
60    }
61}
62
63#[cfg(target_os = "fuchsia")]
64impl DeviceSynchronousProxy {
65    pub fn new(channel: fidl::Channel) -> Self {
66        Self { client: fidl::client::sync::Client::new(channel) }
67    }
68
69    pub fn into_channel(self) -> fidl::Channel {
70        self.client.into_channel()
71    }
72
73    /// Waits until an event arrives and returns it. It is safe for other
74    /// threads to make concurrent requests while waiting for an event.
75    pub fn wait_for_event(
76        &self,
77        deadline: zx::MonotonicInstant,
78    ) -> Result<DeviceEvent, fidl::Error> {
79        DeviceEvent::decode(self.client.wait_for_event::<DeviceMarker>(deadline)?)
80    }
81
82    pub fn r#set_nodes_bandwidth(
83        &self,
84        mut nodes: &[NodeBandwidth],
85        ___deadline: zx::MonotonicInstant,
86    ) -> Result<DeviceSetNodesBandwidthResult, fidl::Error> {
87        let _response = self.client.send_query::<
88            DeviceSetNodesBandwidthRequest,
89            fidl::encoding::FlexibleResultType<DeviceSetNodesBandwidthResponse, i32>,
90            DeviceMarker,
91        >(
92            (nodes,),
93            0x3bb98f59dd645c14,
94            fidl::encoding::DynamicFlags::FLEXIBLE,
95            ___deadline,
96        )?
97        .into_result::<DeviceMarker>("set_nodes_bandwidth")?;
98        Ok(_response.map(|x| x.aggregated_bandwidth))
99    }
100
101    /// Returns a list of all nodes and edges between those nodes.
102    /// Edges are directional, so if an interconnect allows bidirectional traffic,
103    /// it should be listed twice, once for each direction of traffic flow.
104    /// Edges must only be specified for directly adjacent nodes.
105    pub fn r#get_node_graph(
106        &self,
107        ___deadline: zx::MonotonicInstant,
108    ) -> Result<(Vec<Node>, Vec<Edge>), fidl::Error> {
109        let _response = self.client.send_query::<
110            fidl::encoding::EmptyPayload,
111            fidl::encoding::FlexibleType<DeviceGetNodeGraphResponse>,
112            DeviceMarker,
113        >(
114            (),
115            0x2f676c9ef41b8306,
116            fidl::encoding::DynamicFlags::FLEXIBLE,
117            ___deadline,
118        )?
119        .into_result::<DeviceMarker>("get_node_graph")?;
120        Ok((_response.nodes, _response.edges))
121    }
122
123    /// The paths within the interconnect node graph which see bus traffic
124    /// and need to have constraints applied to by drivers. Each path will have
125    /// a device node instantiated for it.
126    pub fn r#get_path_endpoints(
127        &self,
128        ___deadline: zx::MonotonicInstant,
129    ) -> Result<Vec<PathEndpoints>, fidl::Error> {
130        let _response = self.client.send_query::<
131            fidl::encoding::EmptyPayload,
132            fidl::encoding::FlexibleType<DeviceGetPathEndpointsResponse>,
133            DeviceMarker,
134        >(
135            (),
136            0x656ae602a096765b,
137            fidl::encoding::DynamicFlags::FLEXIBLE,
138            ___deadline,
139        )?
140        .into_result::<DeviceMarker>("get_path_endpoints")?;
141        Ok(_response.paths)
142    }
143}
144
145#[cfg(target_os = "fuchsia")]
146impl From<DeviceSynchronousProxy> for zx::NullableHandle {
147    fn from(value: DeviceSynchronousProxy) -> Self {
148        value.into_channel().into()
149    }
150}
151
152#[cfg(target_os = "fuchsia")]
153impl From<fidl::Channel> for DeviceSynchronousProxy {
154    fn from(value: fidl::Channel) -> Self {
155        Self::new(value)
156    }
157}
158
159#[cfg(target_os = "fuchsia")]
160impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
161    type Protocol = DeviceMarker;
162
163    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
164        Self::new(value.into_channel())
165    }
166}
167
168#[derive(Debug, Clone)]
169pub struct DeviceProxy {
170    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
171}
172
173impl fidl::endpoints::Proxy for DeviceProxy {
174    type Protocol = DeviceMarker;
175
176    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
177        Self::new(inner)
178    }
179
180    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
181        self.client.into_channel().map_err(|client| Self { client })
182    }
183
184    fn as_channel(&self) -> &::fidl::AsyncChannel {
185        self.client.as_channel()
186    }
187}
188
189impl DeviceProxy {
190    /// Create a new Proxy for fuchsia.hardware.interconnect/Device.
191    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
192        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
193        Self { client: fidl::client::Client::new(channel, protocol_name) }
194    }
195
196    /// Get a Stream of events from the remote end of the protocol.
197    ///
198    /// # Panics
199    ///
200    /// Panics if the event stream was already taken.
201    pub fn take_event_stream(&self) -> DeviceEventStream {
202        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
203    }
204
205    pub fn r#set_nodes_bandwidth(
206        &self,
207        mut nodes: &[NodeBandwidth],
208    ) -> fidl::client::QueryResponseFut<
209        DeviceSetNodesBandwidthResult,
210        fidl::encoding::DefaultFuchsiaResourceDialect,
211    > {
212        DeviceProxyInterface::r#set_nodes_bandwidth(self, nodes)
213    }
214
215    /// Returns a list of all nodes and edges between those nodes.
216    /// Edges are directional, so if an interconnect allows bidirectional traffic,
217    /// it should be listed twice, once for each direction of traffic flow.
218    /// Edges must only be specified for directly adjacent nodes.
219    pub fn r#get_node_graph(
220        &self,
221    ) -> fidl::client::QueryResponseFut<
222        (Vec<Node>, Vec<Edge>),
223        fidl::encoding::DefaultFuchsiaResourceDialect,
224    > {
225        DeviceProxyInterface::r#get_node_graph(self)
226    }
227
228    /// The paths within the interconnect node graph which see bus traffic
229    /// and need to have constraints applied to by drivers. Each path will have
230    /// a device node instantiated for it.
231    pub fn r#get_path_endpoints(
232        &self,
233    ) -> fidl::client::QueryResponseFut<
234        Vec<PathEndpoints>,
235        fidl::encoding::DefaultFuchsiaResourceDialect,
236    > {
237        DeviceProxyInterface::r#get_path_endpoints(self)
238    }
239}
240
241impl DeviceProxyInterface for DeviceProxy {
242    type SetNodesBandwidthResponseFut = fidl::client::QueryResponseFut<
243        DeviceSetNodesBandwidthResult,
244        fidl::encoding::DefaultFuchsiaResourceDialect,
245    >;
246    fn r#set_nodes_bandwidth(
247        &self,
248        mut nodes: &[NodeBandwidth],
249    ) -> Self::SetNodesBandwidthResponseFut {
250        fn _decode(
251            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
252        ) -> Result<DeviceSetNodesBandwidthResult, fidl::Error> {
253            let _response = fidl::client::decode_transaction_body::<
254                fidl::encoding::FlexibleResultType<DeviceSetNodesBandwidthResponse, i32>,
255                fidl::encoding::DefaultFuchsiaResourceDialect,
256                0x3bb98f59dd645c14,
257            >(_buf?)?
258            .into_result::<DeviceMarker>("set_nodes_bandwidth")?;
259            Ok(_response.map(|x| x.aggregated_bandwidth))
260        }
261        self.client
262            .send_query_and_decode::<DeviceSetNodesBandwidthRequest, DeviceSetNodesBandwidthResult>(
263                (nodes,),
264                0x3bb98f59dd645c14,
265                fidl::encoding::DynamicFlags::FLEXIBLE,
266                _decode,
267            )
268    }
269
270    type GetNodeGraphResponseFut = fidl::client::QueryResponseFut<
271        (Vec<Node>, Vec<Edge>),
272        fidl::encoding::DefaultFuchsiaResourceDialect,
273    >;
274    fn r#get_node_graph(&self) -> Self::GetNodeGraphResponseFut {
275        fn _decode(
276            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
277        ) -> Result<(Vec<Node>, Vec<Edge>), fidl::Error> {
278            let _response = fidl::client::decode_transaction_body::<
279                fidl::encoding::FlexibleType<DeviceGetNodeGraphResponse>,
280                fidl::encoding::DefaultFuchsiaResourceDialect,
281                0x2f676c9ef41b8306,
282            >(_buf?)?
283            .into_result::<DeviceMarker>("get_node_graph")?;
284            Ok((_response.nodes, _response.edges))
285        }
286        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (Vec<Node>, Vec<Edge>)>(
287            (),
288            0x2f676c9ef41b8306,
289            fidl::encoding::DynamicFlags::FLEXIBLE,
290            _decode,
291        )
292    }
293
294    type GetPathEndpointsResponseFut = fidl::client::QueryResponseFut<
295        Vec<PathEndpoints>,
296        fidl::encoding::DefaultFuchsiaResourceDialect,
297    >;
298    fn r#get_path_endpoints(&self) -> Self::GetPathEndpointsResponseFut {
299        fn _decode(
300            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
301        ) -> Result<Vec<PathEndpoints>, fidl::Error> {
302            let _response = fidl::client::decode_transaction_body::<
303                fidl::encoding::FlexibleType<DeviceGetPathEndpointsResponse>,
304                fidl::encoding::DefaultFuchsiaResourceDialect,
305                0x656ae602a096765b,
306            >(_buf?)?
307            .into_result::<DeviceMarker>("get_path_endpoints")?;
308            Ok(_response.paths)
309        }
310        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<PathEndpoints>>(
311            (),
312            0x656ae602a096765b,
313            fidl::encoding::DynamicFlags::FLEXIBLE,
314            _decode,
315        )
316    }
317}
318
319pub struct DeviceEventStream {
320    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
321}
322
323impl std::marker::Unpin for DeviceEventStream {}
324
325impl futures::stream::FusedStream for DeviceEventStream {
326    fn is_terminated(&self) -> bool {
327        self.event_receiver.is_terminated()
328    }
329}
330
331impl futures::Stream for DeviceEventStream {
332    type Item = Result<DeviceEvent, fidl::Error>;
333
334    fn poll_next(
335        mut self: std::pin::Pin<&mut Self>,
336        cx: &mut std::task::Context<'_>,
337    ) -> std::task::Poll<Option<Self::Item>> {
338        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
339            &mut self.event_receiver,
340            cx
341        )?) {
342            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
343            None => std::task::Poll::Ready(None),
344        }
345    }
346}
347
348#[derive(Debug)]
349pub enum DeviceEvent {
350    #[non_exhaustive]
351    _UnknownEvent {
352        /// Ordinal of the event that was sent.
353        ordinal: u64,
354    },
355}
356
357impl DeviceEvent {
358    /// Decodes a message buffer as a [`DeviceEvent`].
359    fn decode(
360        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
361    ) -> Result<DeviceEvent, fidl::Error> {
362        let (bytes, _handles) = buf.split_mut();
363        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
364        debug_assert_eq!(tx_header.tx_id, 0);
365        match tx_header.ordinal {
366            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
367                Ok(DeviceEvent::_UnknownEvent { ordinal: tx_header.ordinal })
368            }
369            _ => Err(fidl::Error::UnknownOrdinal {
370                ordinal: tx_header.ordinal,
371                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
372            }),
373        }
374    }
375}
376
377/// A Stream of incoming requests for fuchsia.hardware.interconnect/Device.
378pub struct DeviceRequestStream {
379    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
380    is_terminated: bool,
381}
382
383impl std::marker::Unpin for DeviceRequestStream {}
384
385impl futures::stream::FusedStream for DeviceRequestStream {
386    fn is_terminated(&self) -> bool {
387        self.is_terminated
388    }
389}
390
391impl fidl::endpoints::RequestStream for DeviceRequestStream {
392    type Protocol = DeviceMarker;
393    type ControlHandle = DeviceControlHandle;
394
395    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
396        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
397    }
398
399    fn control_handle(&self) -> Self::ControlHandle {
400        DeviceControlHandle { inner: self.inner.clone() }
401    }
402
403    fn into_inner(
404        self,
405    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
406    {
407        (self.inner, self.is_terminated)
408    }
409
410    fn from_inner(
411        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
412        is_terminated: bool,
413    ) -> Self {
414        Self { inner, is_terminated }
415    }
416}
417
418impl futures::Stream for DeviceRequestStream {
419    type Item = Result<DeviceRequest, fidl::Error>;
420
421    fn poll_next(
422        mut self: std::pin::Pin<&mut Self>,
423        cx: &mut std::task::Context<'_>,
424    ) -> std::task::Poll<Option<Self::Item>> {
425        let this = &mut *self;
426        if this.inner.check_shutdown(cx) {
427            this.is_terminated = true;
428            return std::task::Poll::Ready(None);
429        }
430        if this.is_terminated {
431            panic!("polled DeviceRequestStream after completion");
432        }
433        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
434            |bytes, handles| {
435                match this.inner.channel().read_etc(cx, bytes, handles) {
436                    std::task::Poll::Ready(Ok(())) => {}
437                    std::task::Poll::Pending => return std::task::Poll::Pending,
438                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
439                        this.is_terminated = true;
440                        return std::task::Poll::Ready(None);
441                    }
442                    std::task::Poll::Ready(Err(e)) => {
443                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
444                            e.into(),
445                        ))));
446                    }
447                }
448
449                // A message has been received from the channel
450                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
451
452                std::task::Poll::Ready(Some(match header.ordinal {
453                    0x3bb98f59dd645c14 => {
454                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
455                        let mut req = fidl::new_empty!(
456                            DeviceSetNodesBandwidthRequest,
457                            fidl::encoding::DefaultFuchsiaResourceDialect
458                        );
459                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetNodesBandwidthRequest>(&header, _body_bytes, handles, &mut req)?;
460                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
461                        Ok(DeviceRequest::SetNodesBandwidth {
462                            nodes: req.nodes,
463
464                            responder: DeviceSetNodesBandwidthResponder {
465                                control_handle: std::mem::ManuallyDrop::new(control_handle),
466                                tx_id: header.tx_id,
467                            },
468                        })
469                    }
470                    0x2f676c9ef41b8306 => {
471                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
472                        let mut req = fidl::new_empty!(
473                            fidl::encoding::EmptyPayload,
474                            fidl::encoding::DefaultFuchsiaResourceDialect
475                        );
476                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
477                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
478                        Ok(DeviceRequest::GetNodeGraph {
479                            responder: DeviceGetNodeGraphResponder {
480                                control_handle: std::mem::ManuallyDrop::new(control_handle),
481                                tx_id: header.tx_id,
482                            },
483                        })
484                    }
485                    0x656ae602a096765b => {
486                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
487                        let mut req = fidl::new_empty!(
488                            fidl::encoding::EmptyPayload,
489                            fidl::encoding::DefaultFuchsiaResourceDialect
490                        );
491                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
492                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
493                        Ok(DeviceRequest::GetPathEndpoints {
494                            responder: DeviceGetPathEndpointsResponder {
495                                control_handle: std::mem::ManuallyDrop::new(control_handle),
496                                tx_id: header.tx_id,
497                            },
498                        })
499                    }
500                    _ if header.tx_id == 0
501                        && header
502                            .dynamic_flags()
503                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
504                    {
505                        Ok(DeviceRequest::_UnknownMethod {
506                            ordinal: header.ordinal,
507                            control_handle: DeviceControlHandle { inner: this.inner.clone() },
508                            method_type: fidl::MethodType::OneWay,
509                        })
510                    }
511                    _ if header
512                        .dynamic_flags()
513                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
514                    {
515                        this.inner.send_framework_err(
516                            fidl::encoding::FrameworkErr::UnknownMethod,
517                            header.tx_id,
518                            header.ordinal,
519                            header.dynamic_flags(),
520                            (bytes, handles),
521                        )?;
522                        Ok(DeviceRequest::_UnknownMethod {
523                            ordinal: header.ordinal,
524                            control_handle: DeviceControlHandle { inner: this.inner.clone() },
525                            method_type: fidl::MethodType::TwoWay,
526                        })
527                    }
528                    _ => Err(fidl::Error::UnknownOrdinal {
529                        ordinal: header.ordinal,
530                        protocol_name:
531                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
532                    }),
533                }))
534            },
535        )
536    }
537}
538
539#[derive(Debug)]
540pub enum DeviceRequest {
541    SetNodesBandwidth {
542        nodes: Vec<NodeBandwidth>,
543        responder: DeviceSetNodesBandwidthResponder,
544    },
545    /// Returns a list of all nodes and edges between those nodes.
546    /// Edges are directional, so if an interconnect allows bidirectional traffic,
547    /// it should be listed twice, once for each direction of traffic flow.
548    /// Edges must only be specified for directly adjacent nodes.
549    GetNodeGraph {
550        responder: DeviceGetNodeGraphResponder,
551    },
552    /// The paths within the interconnect node graph which see bus traffic
553    /// and need to have constraints applied to by drivers. Each path will have
554    /// a device node instantiated for it.
555    GetPathEndpoints {
556        responder: DeviceGetPathEndpointsResponder,
557    },
558    /// An interaction was received which does not match any known method.
559    #[non_exhaustive]
560    _UnknownMethod {
561        /// Ordinal of the method that was called.
562        ordinal: u64,
563        control_handle: DeviceControlHandle,
564        method_type: fidl::MethodType,
565    },
566}
567
568impl DeviceRequest {
569    #[allow(irrefutable_let_patterns)]
570    pub fn into_set_nodes_bandwidth(
571        self,
572    ) -> Option<(Vec<NodeBandwidth>, DeviceSetNodesBandwidthResponder)> {
573        if let DeviceRequest::SetNodesBandwidth { nodes, responder } = self {
574            Some((nodes, responder))
575        } else {
576            None
577        }
578    }
579
580    #[allow(irrefutable_let_patterns)]
581    pub fn into_get_node_graph(self) -> Option<(DeviceGetNodeGraphResponder)> {
582        if let DeviceRequest::GetNodeGraph { responder } = self { Some((responder)) } else { None }
583    }
584
585    #[allow(irrefutable_let_patterns)]
586    pub fn into_get_path_endpoints(self) -> Option<(DeviceGetPathEndpointsResponder)> {
587        if let DeviceRequest::GetPathEndpoints { responder } = self {
588            Some((responder))
589        } else {
590            None
591        }
592    }
593
594    /// Name of the method defined in FIDL
595    pub fn method_name(&self) -> &'static str {
596        match *self {
597            DeviceRequest::SetNodesBandwidth { .. } => "set_nodes_bandwidth",
598            DeviceRequest::GetNodeGraph { .. } => "get_node_graph",
599            DeviceRequest::GetPathEndpoints { .. } => "get_path_endpoints",
600            DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
601                "unknown one-way method"
602            }
603            DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
604                "unknown two-way method"
605            }
606        }
607    }
608}
609
610#[derive(Debug, Clone)]
611pub struct DeviceControlHandle {
612    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
613}
614
615impl DeviceControlHandle {
616    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
617        self.inner.shutdown_with_epitaph(status.into())
618    }
619}
620
621impl fidl::endpoints::ControlHandle for DeviceControlHandle {
622    fn shutdown(&self) {
623        self.inner.shutdown()
624    }
625
626    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
627        self.inner.shutdown_with_epitaph(status)
628    }
629
630    fn is_closed(&self) -> bool {
631        self.inner.channel().is_closed()
632    }
633    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
634        self.inner.channel().on_closed()
635    }
636
637    #[cfg(target_os = "fuchsia")]
638    fn signal_peer(
639        &self,
640        clear_mask: zx::Signals,
641        set_mask: zx::Signals,
642    ) -> Result<(), zx_status::Status> {
643        use fidl::Peered;
644        self.inner.channel().signal_peer(clear_mask, set_mask)
645    }
646}
647
648impl DeviceControlHandle {}
649
650#[must_use = "FIDL methods require a response to be sent"]
651#[derive(Debug)]
652pub struct DeviceSetNodesBandwidthResponder {
653    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
654    tx_id: u32,
655}
656
657/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
658/// if the responder is dropped without sending a response, so that the client
659/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
660impl std::ops::Drop for DeviceSetNodesBandwidthResponder {
661    fn drop(&mut self) {
662        self.control_handle.shutdown();
663        // Safety: drops once, never accessed again
664        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
665    }
666}
667
668impl fidl::endpoints::Responder for DeviceSetNodesBandwidthResponder {
669    type ControlHandle = DeviceControlHandle;
670
671    fn control_handle(&self) -> &DeviceControlHandle {
672        &self.control_handle
673    }
674
675    fn drop_without_shutdown(mut self) {
676        // Safety: drops once, never accessed again due to mem::forget
677        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
678        // Prevent Drop from running (which would shut down the channel)
679        std::mem::forget(self);
680    }
681}
682
683impl DeviceSetNodesBandwidthResponder {
684    /// Sends a response to the FIDL transaction.
685    ///
686    /// Sets the channel to shutdown if an error occurs.
687    pub fn send(self, mut result: Result<&[AggregatedBandwidth], i32>) -> Result<(), fidl::Error> {
688        let _result = self.send_raw(result);
689        if _result.is_err() {
690            self.control_handle.shutdown();
691        }
692        self.drop_without_shutdown();
693        _result
694    }
695
696    /// Similar to "send" but does not shutdown the channel if an error occurs.
697    pub fn send_no_shutdown_on_err(
698        self,
699        mut result: Result<&[AggregatedBandwidth], i32>,
700    ) -> Result<(), fidl::Error> {
701        let _result = self.send_raw(result);
702        self.drop_without_shutdown();
703        _result
704    }
705
706    fn send_raw(&self, mut result: Result<&[AggregatedBandwidth], i32>) -> Result<(), fidl::Error> {
707        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
708            DeviceSetNodesBandwidthResponse,
709            i32,
710        >>(
711            fidl::encoding::FlexibleResult::new(
712                result.map(|aggregated_bandwidth| (aggregated_bandwidth,)),
713            ),
714            self.tx_id,
715            0x3bb98f59dd645c14,
716            fidl::encoding::DynamicFlags::FLEXIBLE,
717        )
718    }
719}
720
721#[must_use = "FIDL methods require a response to be sent"]
722#[derive(Debug)]
723pub struct DeviceGetNodeGraphResponder {
724    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
725    tx_id: u32,
726}
727
728/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
729/// if the responder is dropped without sending a response, so that the client
730/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
731impl std::ops::Drop for DeviceGetNodeGraphResponder {
732    fn drop(&mut self) {
733        self.control_handle.shutdown();
734        // Safety: drops once, never accessed again
735        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
736    }
737}
738
739impl fidl::endpoints::Responder for DeviceGetNodeGraphResponder {
740    type ControlHandle = DeviceControlHandle;
741
742    fn control_handle(&self) -> &DeviceControlHandle {
743        &self.control_handle
744    }
745
746    fn drop_without_shutdown(mut self) {
747        // Safety: drops once, never accessed again due to mem::forget
748        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
749        // Prevent Drop from running (which would shut down the channel)
750        std::mem::forget(self);
751    }
752}
753
754impl DeviceGetNodeGraphResponder {
755    /// Sends a response to the FIDL transaction.
756    ///
757    /// Sets the channel to shutdown if an error occurs.
758    pub fn send(self, mut nodes: &[Node], mut edges: &[Edge]) -> Result<(), fidl::Error> {
759        let _result = self.send_raw(nodes, edges);
760        if _result.is_err() {
761            self.control_handle.shutdown();
762        }
763        self.drop_without_shutdown();
764        _result
765    }
766
767    /// Similar to "send" but does not shutdown the channel if an error occurs.
768    pub fn send_no_shutdown_on_err(
769        self,
770        mut nodes: &[Node],
771        mut edges: &[Edge],
772    ) -> Result<(), fidl::Error> {
773        let _result = self.send_raw(nodes, edges);
774        self.drop_without_shutdown();
775        _result
776    }
777
778    fn send_raw(&self, mut nodes: &[Node], mut edges: &[Edge]) -> Result<(), fidl::Error> {
779        self.control_handle.inner.send::<fidl::encoding::FlexibleType<DeviceGetNodeGraphResponse>>(
780            fidl::encoding::Flexible::new((nodes, edges)),
781            self.tx_id,
782            0x2f676c9ef41b8306,
783            fidl::encoding::DynamicFlags::FLEXIBLE,
784        )
785    }
786}
787
788#[must_use = "FIDL methods require a response to be sent"]
789#[derive(Debug)]
790pub struct DeviceGetPathEndpointsResponder {
791    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
792    tx_id: u32,
793}
794
795/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
796/// if the responder is dropped without sending a response, so that the client
797/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
798impl std::ops::Drop for DeviceGetPathEndpointsResponder {
799    fn drop(&mut self) {
800        self.control_handle.shutdown();
801        // Safety: drops once, never accessed again
802        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
803    }
804}
805
806impl fidl::endpoints::Responder for DeviceGetPathEndpointsResponder {
807    type ControlHandle = DeviceControlHandle;
808
809    fn control_handle(&self) -> &DeviceControlHandle {
810        &self.control_handle
811    }
812
813    fn drop_without_shutdown(mut self) {
814        // Safety: drops once, never accessed again due to mem::forget
815        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
816        // Prevent Drop from running (which would shut down the channel)
817        std::mem::forget(self);
818    }
819}
820
821impl DeviceGetPathEndpointsResponder {
822    /// Sends a response to the FIDL transaction.
823    ///
824    /// Sets the channel to shutdown if an error occurs.
825    pub fn send(self, mut paths: &[PathEndpoints]) -> Result<(), fidl::Error> {
826        let _result = self.send_raw(paths);
827        if _result.is_err() {
828            self.control_handle.shutdown();
829        }
830        self.drop_without_shutdown();
831        _result
832    }
833
834    /// Similar to "send" but does not shutdown the channel if an error occurs.
835    pub fn send_no_shutdown_on_err(self, mut paths: &[PathEndpoints]) -> Result<(), fidl::Error> {
836        let _result = self.send_raw(paths);
837        self.drop_without_shutdown();
838        _result
839    }
840
841    fn send_raw(&self, mut paths: &[PathEndpoints]) -> Result<(), fidl::Error> {
842        self.control_handle
843            .inner
844            .send::<fidl::encoding::FlexibleType<DeviceGetPathEndpointsResponse>>(
845                fidl::encoding::Flexible::new((paths,)),
846                self.tx_id,
847                0x656ae602a096765b,
848                fidl::encoding::DynamicFlags::FLEXIBLE,
849            )
850    }
851}
852
853#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
854pub struct PathMarker;
855
856impl fidl::endpoints::ProtocolMarker for PathMarker {
857    type Proxy = PathProxy;
858    type RequestStream = PathRequestStream;
859    #[cfg(target_os = "fuchsia")]
860    type SynchronousProxy = PathSynchronousProxy;
861
862    const DEBUG_NAME: &'static str = "fuchsia.hardware.interconnect.Path";
863}
864impl fidl::endpoints::DiscoverableProtocolMarker for PathMarker {}
865pub type PathSetBandwidthResult = Result<(), i32>;
866
867pub trait PathProxyInterface: Send + Sync {
868    type SetBandwidthResponseFut: std::future::Future<Output = Result<PathSetBandwidthResult, fidl::Error>>
869        + Send;
870    fn r#set_bandwidth(&self, payload: &BandwidthRequest) -> Self::SetBandwidthResponseFut;
871}
872#[derive(Debug)]
873#[cfg(target_os = "fuchsia")]
874pub struct PathSynchronousProxy {
875    client: fidl::client::sync::Client,
876}
877
878#[cfg(target_os = "fuchsia")]
879impl fidl::endpoints::SynchronousProxy for PathSynchronousProxy {
880    type Proxy = PathProxy;
881    type Protocol = PathMarker;
882
883    fn from_channel(inner: fidl::Channel) -> Self {
884        Self::new(inner)
885    }
886
887    fn into_channel(self) -> fidl::Channel {
888        self.client.into_channel()
889    }
890
891    fn as_channel(&self) -> &fidl::Channel {
892        self.client.as_channel()
893    }
894}
895
896#[cfg(target_os = "fuchsia")]
897impl PathSynchronousProxy {
898    pub fn new(channel: fidl::Channel) -> Self {
899        Self { client: fidl::client::sync::Client::new(channel) }
900    }
901
902    pub fn into_channel(self) -> fidl::Channel {
903        self.client.into_channel()
904    }
905
906    /// Waits until an event arrives and returns it. It is safe for other
907    /// threads to make concurrent requests while waiting for an event.
908    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<PathEvent, fidl::Error> {
909        PathEvent::decode(self.client.wait_for_event::<PathMarker>(deadline)?)
910    }
911
912    /// Sets the bandwidth interconnect path.
913    pub fn r#set_bandwidth(
914        &self,
915        mut payload: &BandwidthRequest,
916        ___deadline: zx::MonotonicInstant,
917    ) -> Result<PathSetBandwidthResult, fidl::Error> {
918        let _response = self.client.send_query::<
919            BandwidthRequest,
920            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
921            PathMarker,
922        >(
923            payload,
924            0xd366c6e86f69d1d,
925            fidl::encoding::DynamicFlags::FLEXIBLE,
926            ___deadline,
927        )?
928        .into_result::<PathMarker>("set_bandwidth")?;
929        Ok(_response.map(|x| x))
930    }
931}
932
933#[cfg(target_os = "fuchsia")]
934impl From<PathSynchronousProxy> for zx::NullableHandle {
935    fn from(value: PathSynchronousProxy) -> Self {
936        value.into_channel().into()
937    }
938}
939
940#[cfg(target_os = "fuchsia")]
941impl From<fidl::Channel> for PathSynchronousProxy {
942    fn from(value: fidl::Channel) -> Self {
943        Self::new(value)
944    }
945}
946
947#[cfg(target_os = "fuchsia")]
948impl fidl::endpoints::FromClient for PathSynchronousProxy {
949    type Protocol = PathMarker;
950
951    fn from_client(value: fidl::endpoints::ClientEnd<PathMarker>) -> Self {
952        Self::new(value.into_channel())
953    }
954}
955
956#[derive(Debug, Clone)]
957pub struct PathProxy {
958    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
959}
960
961impl fidl::endpoints::Proxy for PathProxy {
962    type Protocol = PathMarker;
963
964    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
965        Self::new(inner)
966    }
967
968    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
969        self.client.into_channel().map_err(|client| Self { client })
970    }
971
972    fn as_channel(&self) -> &::fidl::AsyncChannel {
973        self.client.as_channel()
974    }
975}
976
977impl PathProxy {
978    /// Create a new Proxy for fuchsia.hardware.interconnect/Path.
979    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
980        let protocol_name = <PathMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
981        Self { client: fidl::client::Client::new(channel, protocol_name) }
982    }
983
984    /// Get a Stream of events from the remote end of the protocol.
985    ///
986    /// # Panics
987    ///
988    /// Panics if the event stream was already taken.
989    pub fn take_event_stream(&self) -> PathEventStream {
990        PathEventStream { event_receiver: self.client.take_event_receiver() }
991    }
992
993    /// Sets the bandwidth interconnect path.
994    pub fn r#set_bandwidth(
995        &self,
996        mut payload: &BandwidthRequest,
997    ) -> fidl::client::QueryResponseFut<
998        PathSetBandwidthResult,
999        fidl::encoding::DefaultFuchsiaResourceDialect,
1000    > {
1001        PathProxyInterface::r#set_bandwidth(self, payload)
1002    }
1003}
1004
1005impl PathProxyInterface for PathProxy {
1006    type SetBandwidthResponseFut = fidl::client::QueryResponseFut<
1007        PathSetBandwidthResult,
1008        fidl::encoding::DefaultFuchsiaResourceDialect,
1009    >;
1010    fn r#set_bandwidth(&self, mut payload: &BandwidthRequest) -> Self::SetBandwidthResponseFut {
1011        fn _decode(
1012            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1013        ) -> Result<PathSetBandwidthResult, fidl::Error> {
1014            let _response = fidl::client::decode_transaction_body::<
1015                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1016                fidl::encoding::DefaultFuchsiaResourceDialect,
1017                0xd366c6e86f69d1d,
1018            >(_buf?)?
1019            .into_result::<PathMarker>("set_bandwidth")?;
1020            Ok(_response.map(|x| x))
1021        }
1022        self.client.send_query_and_decode::<BandwidthRequest, PathSetBandwidthResult>(
1023            payload,
1024            0xd366c6e86f69d1d,
1025            fidl::encoding::DynamicFlags::FLEXIBLE,
1026            _decode,
1027        )
1028    }
1029}
1030
1031pub struct PathEventStream {
1032    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1033}
1034
1035impl std::marker::Unpin for PathEventStream {}
1036
1037impl futures::stream::FusedStream for PathEventStream {
1038    fn is_terminated(&self) -> bool {
1039        self.event_receiver.is_terminated()
1040    }
1041}
1042
1043impl futures::Stream for PathEventStream {
1044    type Item = Result<PathEvent, fidl::Error>;
1045
1046    fn poll_next(
1047        mut self: std::pin::Pin<&mut Self>,
1048        cx: &mut std::task::Context<'_>,
1049    ) -> std::task::Poll<Option<Self::Item>> {
1050        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1051            &mut self.event_receiver,
1052            cx
1053        )?) {
1054            Some(buf) => std::task::Poll::Ready(Some(PathEvent::decode(buf))),
1055            None => std::task::Poll::Ready(None),
1056        }
1057    }
1058}
1059
1060#[derive(Debug)]
1061pub enum PathEvent {
1062    #[non_exhaustive]
1063    _UnknownEvent {
1064        /// Ordinal of the event that was sent.
1065        ordinal: u64,
1066    },
1067}
1068
1069impl PathEvent {
1070    /// Decodes a message buffer as a [`PathEvent`].
1071    fn decode(
1072        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1073    ) -> Result<PathEvent, fidl::Error> {
1074        let (bytes, _handles) = buf.split_mut();
1075        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1076        debug_assert_eq!(tx_header.tx_id, 0);
1077        match tx_header.ordinal {
1078            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1079                Ok(PathEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1080            }
1081            _ => Err(fidl::Error::UnknownOrdinal {
1082                ordinal: tx_header.ordinal,
1083                protocol_name: <PathMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1084            }),
1085        }
1086    }
1087}
1088
1089/// A Stream of incoming requests for fuchsia.hardware.interconnect/Path.
1090pub struct PathRequestStream {
1091    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1092    is_terminated: bool,
1093}
1094
1095impl std::marker::Unpin for PathRequestStream {}
1096
1097impl futures::stream::FusedStream for PathRequestStream {
1098    fn is_terminated(&self) -> bool {
1099        self.is_terminated
1100    }
1101}
1102
1103impl fidl::endpoints::RequestStream for PathRequestStream {
1104    type Protocol = PathMarker;
1105    type ControlHandle = PathControlHandle;
1106
1107    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1108        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1109    }
1110
1111    fn control_handle(&self) -> Self::ControlHandle {
1112        PathControlHandle { inner: self.inner.clone() }
1113    }
1114
1115    fn into_inner(
1116        self,
1117    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1118    {
1119        (self.inner, self.is_terminated)
1120    }
1121
1122    fn from_inner(
1123        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1124        is_terminated: bool,
1125    ) -> Self {
1126        Self { inner, is_terminated }
1127    }
1128}
1129
1130impl futures::Stream for PathRequestStream {
1131    type Item = Result<PathRequest, fidl::Error>;
1132
1133    fn poll_next(
1134        mut self: std::pin::Pin<&mut Self>,
1135        cx: &mut std::task::Context<'_>,
1136    ) -> std::task::Poll<Option<Self::Item>> {
1137        let this = &mut *self;
1138        if this.inner.check_shutdown(cx) {
1139            this.is_terminated = true;
1140            return std::task::Poll::Ready(None);
1141        }
1142        if this.is_terminated {
1143            panic!("polled PathRequestStream after completion");
1144        }
1145        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1146            |bytes, handles| {
1147                match this.inner.channel().read_etc(cx, bytes, handles) {
1148                    std::task::Poll::Ready(Ok(())) => {}
1149                    std::task::Poll::Pending => return std::task::Poll::Pending,
1150                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1151                        this.is_terminated = true;
1152                        return std::task::Poll::Ready(None);
1153                    }
1154                    std::task::Poll::Ready(Err(e)) => {
1155                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1156                            e.into(),
1157                        ))));
1158                    }
1159                }
1160
1161                // A message has been received from the channel
1162                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1163
1164                std::task::Poll::Ready(Some(match header.ordinal {
1165                    0xd366c6e86f69d1d => {
1166                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1167                        let mut req = fidl::new_empty!(
1168                            BandwidthRequest,
1169                            fidl::encoding::DefaultFuchsiaResourceDialect
1170                        );
1171                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BandwidthRequest>(&header, _body_bytes, handles, &mut req)?;
1172                        let control_handle = PathControlHandle { inner: this.inner.clone() };
1173                        Ok(PathRequest::SetBandwidth {
1174                            payload: req,
1175                            responder: PathSetBandwidthResponder {
1176                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1177                                tx_id: header.tx_id,
1178                            },
1179                        })
1180                    }
1181                    _ if header.tx_id == 0
1182                        && header
1183                            .dynamic_flags()
1184                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1185                    {
1186                        Ok(PathRequest::_UnknownMethod {
1187                            ordinal: header.ordinal,
1188                            control_handle: PathControlHandle { inner: this.inner.clone() },
1189                            method_type: fidl::MethodType::OneWay,
1190                        })
1191                    }
1192                    _ if header
1193                        .dynamic_flags()
1194                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1195                    {
1196                        this.inner.send_framework_err(
1197                            fidl::encoding::FrameworkErr::UnknownMethod,
1198                            header.tx_id,
1199                            header.ordinal,
1200                            header.dynamic_flags(),
1201                            (bytes, handles),
1202                        )?;
1203                        Ok(PathRequest::_UnknownMethod {
1204                            ordinal: header.ordinal,
1205                            control_handle: PathControlHandle { inner: this.inner.clone() },
1206                            method_type: fidl::MethodType::TwoWay,
1207                        })
1208                    }
1209                    _ => Err(fidl::Error::UnknownOrdinal {
1210                        ordinal: header.ordinal,
1211                        protocol_name: <PathMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1212                    }),
1213                }))
1214            },
1215        )
1216    }
1217}
1218
1219/// Represents a path from a node in one interconnect to another.
1220#[derive(Debug)]
1221pub enum PathRequest {
1222    /// Sets the bandwidth interconnect path.
1223    SetBandwidth { payload: BandwidthRequest, responder: PathSetBandwidthResponder },
1224    /// An interaction was received which does not match any known method.
1225    #[non_exhaustive]
1226    _UnknownMethod {
1227        /// Ordinal of the method that was called.
1228        ordinal: u64,
1229        control_handle: PathControlHandle,
1230        method_type: fidl::MethodType,
1231    },
1232}
1233
1234impl PathRequest {
1235    #[allow(irrefutable_let_patterns)]
1236    pub fn into_set_bandwidth(self) -> Option<(BandwidthRequest, PathSetBandwidthResponder)> {
1237        if let PathRequest::SetBandwidth { payload, responder } = self {
1238            Some((payload, responder))
1239        } else {
1240            None
1241        }
1242    }
1243
1244    /// Name of the method defined in FIDL
1245    pub fn method_name(&self) -> &'static str {
1246        match *self {
1247            PathRequest::SetBandwidth { .. } => "set_bandwidth",
1248            PathRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1249                "unknown one-way method"
1250            }
1251            PathRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1252                "unknown two-way method"
1253            }
1254        }
1255    }
1256}
1257
1258#[derive(Debug, Clone)]
1259pub struct PathControlHandle {
1260    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1261}
1262
1263impl PathControlHandle {
1264    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1265        self.inner.shutdown_with_epitaph(status.into())
1266    }
1267}
1268
1269impl fidl::endpoints::ControlHandle for PathControlHandle {
1270    fn shutdown(&self) {
1271        self.inner.shutdown()
1272    }
1273
1274    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1275        self.inner.shutdown_with_epitaph(status)
1276    }
1277
1278    fn is_closed(&self) -> bool {
1279        self.inner.channel().is_closed()
1280    }
1281    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1282        self.inner.channel().on_closed()
1283    }
1284
1285    #[cfg(target_os = "fuchsia")]
1286    fn signal_peer(
1287        &self,
1288        clear_mask: zx::Signals,
1289        set_mask: zx::Signals,
1290    ) -> Result<(), zx_status::Status> {
1291        use fidl::Peered;
1292        self.inner.channel().signal_peer(clear_mask, set_mask)
1293    }
1294}
1295
1296impl PathControlHandle {}
1297
1298#[must_use = "FIDL methods require a response to be sent"]
1299#[derive(Debug)]
1300pub struct PathSetBandwidthResponder {
1301    control_handle: std::mem::ManuallyDrop<PathControlHandle>,
1302    tx_id: u32,
1303}
1304
1305/// Set the the channel to be shutdown (see [`PathControlHandle::shutdown`])
1306/// if the responder is dropped without sending a response, so that the client
1307/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1308impl std::ops::Drop for PathSetBandwidthResponder {
1309    fn drop(&mut self) {
1310        self.control_handle.shutdown();
1311        // Safety: drops once, never accessed again
1312        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1313    }
1314}
1315
1316impl fidl::endpoints::Responder for PathSetBandwidthResponder {
1317    type ControlHandle = PathControlHandle;
1318
1319    fn control_handle(&self) -> &PathControlHandle {
1320        &self.control_handle
1321    }
1322
1323    fn drop_without_shutdown(mut self) {
1324        // Safety: drops once, never accessed again due to mem::forget
1325        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1326        // Prevent Drop from running (which would shut down the channel)
1327        std::mem::forget(self);
1328    }
1329}
1330
1331impl PathSetBandwidthResponder {
1332    /// Sends a response to the FIDL transaction.
1333    ///
1334    /// Sets the channel to shutdown if an error occurs.
1335    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1336        let _result = self.send_raw(result);
1337        if _result.is_err() {
1338            self.control_handle.shutdown();
1339        }
1340        self.drop_without_shutdown();
1341        _result
1342    }
1343
1344    /// Similar to "send" but does not shutdown the channel if an error occurs.
1345    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1346        let _result = self.send_raw(result);
1347        self.drop_without_shutdown();
1348        _result
1349    }
1350
1351    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1352        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1353            fidl::encoding::EmptyStruct,
1354            i32,
1355        >>(
1356            fidl::encoding::FlexibleResult::new(result),
1357            self.tx_id,
1358            0xd366c6e86f69d1d,
1359            fidl::encoding::DynamicFlags::FLEXIBLE,
1360        )
1361    }
1362}
1363
1364#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1365pub struct PathServiceMarker;
1366
1367#[cfg(target_os = "fuchsia")]
1368impl fidl::endpoints::ServiceMarker for PathServiceMarker {
1369    type Proxy = PathServiceProxy;
1370    type Request = PathServiceRequest;
1371    const SERVICE_NAME: &'static str = "fuchsia.hardware.interconnect.PathService";
1372}
1373
1374/// A request for one of the member protocols of PathService.
1375///
1376#[cfg(target_os = "fuchsia")]
1377pub enum PathServiceRequest {
1378    Path(PathRequestStream),
1379}
1380
1381#[cfg(target_os = "fuchsia")]
1382impl fidl::endpoints::ServiceRequest for PathServiceRequest {
1383    type Service = PathServiceMarker;
1384
1385    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1386        match name {
1387            "path" => Self::Path(
1388                <PathRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1389            ),
1390            _ => panic!("no such member protocol name for service PathService"),
1391        }
1392    }
1393
1394    fn member_names() -> &'static [&'static str] {
1395        &["path"]
1396    }
1397}
1398#[cfg(target_os = "fuchsia")]
1399pub struct PathServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1400
1401#[cfg(target_os = "fuchsia")]
1402impl fidl::endpoints::ServiceProxy for PathServiceProxy {
1403    type Service = PathServiceMarker;
1404
1405    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1406        Self(opener)
1407    }
1408}
1409
1410#[cfg(target_os = "fuchsia")]
1411impl PathServiceProxy {
1412    pub fn connect_to_path(&self) -> Result<PathProxy, fidl::Error> {
1413        let (proxy, server_end) = fidl::endpoints::create_proxy::<PathMarker>();
1414        self.connect_channel_to_path(server_end)?;
1415        Ok(proxy)
1416    }
1417
1418    /// Like `connect_to_path`, but returns a sync proxy.
1419    /// See [`Self::connect_to_path`] for more details.
1420    pub fn connect_to_path_sync(&self) -> Result<PathSynchronousProxy, fidl::Error> {
1421        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<PathMarker>();
1422        self.connect_channel_to_path(server_end)?;
1423        Ok(proxy)
1424    }
1425
1426    /// Like `connect_to_path`, but accepts a server end.
1427    /// See [`Self::connect_to_path`] for more details.
1428    pub fn connect_channel_to_path(
1429        &self,
1430        server_end: fidl::endpoints::ServerEnd<PathMarker>,
1431    ) -> Result<(), fidl::Error> {
1432        self.0.open_member("path", server_end.into_channel())
1433    }
1434
1435    pub fn instance_name(&self) -> &str {
1436        self.0.instance_name()
1437    }
1438}
1439
1440#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1441pub struct ServiceMarker;
1442
1443#[cfg(target_os = "fuchsia")]
1444impl fidl::endpoints::ServiceMarker for ServiceMarker {
1445    type Proxy = ServiceProxy;
1446    type Request = ServiceRequest;
1447    const SERVICE_NAME: &'static str = "fuchsia.hardware.interconnect.Service";
1448}
1449
1450/// A request for one of the member protocols of Service.
1451///
1452#[cfg(target_os = "fuchsia")]
1453pub enum ServiceRequest {
1454    Device(DeviceRequestStream),
1455}
1456
1457#[cfg(target_os = "fuchsia")]
1458impl fidl::endpoints::ServiceRequest for ServiceRequest {
1459    type Service = ServiceMarker;
1460
1461    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1462        match name {
1463            "device" => Self::Device(
1464                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1465            ),
1466            _ => panic!("no such member protocol name for service Service"),
1467        }
1468    }
1469
1470    fn member_names() -> &'static [&'static str] {
1471        &["device"]
1472    }
1473}
1474#[cfg(target_os = "fuchsia")]
1475pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1476
1477#[cfg(target_os = "fuchsia")]
1478impl fidl::endpoints::ServiceProxy for ServiceProxy {
1479    type Service = ServiceMarker;
1480
1481    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1482        Self(opener)
1483    }
1484}
1485
1486#[cfg(target_os = "fuchsia")]
1487impl ServiceProxy {
1488    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
1489        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1490        self.connect_channel_to_device(server_end)?;
1491        Ok(proxy)
1492    }
1493
1494    /// Like `connect_to_device`, but returns a sync proxy.
1495    /// See [`Self::connect_to_device`] for more details.
1496    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1497        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1498        self.connect_channel_to_device(server_end)?;
1499        Ok(proxy)
1500    }
1501
1502    /// Like `connect_to_device`, but accepts a server end.
1503    /// See [`Self::connect_to_device`] for more details.
1504    pub fn connect_channel_to_device(
1505        &self,
1506        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1507    ) -> Result<(), fidl::Error> {
1508        self.0.open_member("device", server_end.into_channel())
1509    }
1510
1511    pub fn instance_name(&self) -> &str {
1512        self.0.instance_name()
1513    }
1514}
1515
1516mod internal {
1517    use super::*;
1518}