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