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<(), 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<fidl::encoding::EmptyStruct, 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))
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<fidl::encoding::EmptyStruct, i32>,
253                fidl::encoding::DefaultFuchsiaResourceDialect,
254                0x3bb98f59dd645c14,
255            >(_buf?)?
256            .into_result::<DeviceMarker>("set_nodes_bandwidth")?;
257            Ok(_response.map(|x| x))
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 {
581            Some((responder))
582        } else {
583            None
584        }
585    }
586
587    #[allow(irrefutable_let_patterns)]
588    pub fn into_get_path_endpoints(self) -> Option<(DeviceGetPathEndpointsResponder)> {
589        if let DeviceRequest::GetPathEndpoints { responder } = self {
590            Some((responder))
591        } else {
592            None
593        }
594    }
595
596    /// Name of the method defined in FIDL
597    pub fn method_name(&self) -> &'static str {
598        match *self {
599            DeviceRequest::SetNodesBandwidth { .. } => "set_nodes_bandwidth",
600            DeviceRequest::GetNodeGraph { .. } => "get_node_graph",
601            DeviceRequest::GetPathEndpoints { .. } => "get_path_endpoints",
602            DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
603                "unknown one-way method"
604            }
605            DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
606                "unknown two-way method"
607            }
608        }
609    }
610}
611
612#[derive(Debug, Clone)]
613pub struct DeviceControlHandle {
614    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
615}
616
617impl fidl::endpoints::ControlHandle for DeviceControlHandle {
618    fn shutdown(&self) {
619        self.inner.shutdown()
620    }
621    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
622        self.inner.shutdown_with_epitaph(status)
623    }
624
625    fn is_closed(&self) -> bool {
626        self.inner.channel().is_closed()
627    }
628    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
629        self.inner.channel().on_closed()
630    }
631
632    #[cfg(target_os = "fuchsia")]
633    fn signal_peer(
634        &self,
635        clear_mask: zx::Signals,
636        set_mask: zx::Signals,
637    ) -> Result<(), zx_status::Status> {
638        use fidl::Peered;
639        self.inner.channel().signal_peer(clear_mask, set_mask)
640    }
641}
642
643impl DeviceControlHandle {}
644
645#[must_use = "FIDL methods require a response to be sent"]
646#[derive(Debug)]
647pub struct DeviceSetNodesBandwidthResponder {
648    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
649    tx_id: u32,
650}
651
652/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
653/// if the responder is dropped without sending a response, so that the client
654/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
655impl std::ops::Drop for DeviceSetNodesBandwidthResponder {
656    fn drop(&mut self) {
657        self.control_handle.shutdown();
658        // Safety: drops once, never accessed again
659        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
660    }
661}
662
663impl fidl::endpoints::Responder for DeviceSetNodesBandwidthResponder {
664    type ControlHandle = DeviceControlHandle;
665
666    fn control_handle(&self) -> &DeviceControlHandle {
667        &self.control_handle
668    }
669
670    fn drop_without_shutdown(mut self) {
671        // Safety: drops once, never accessed again due to mem::forget
672        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
673        // Prevent Drop from running (which would shut down the channel)
674        std::mem::forget(self);
675    }
676}
677
678impl DeviceSetNodesBandwidthResponder {
679    /// Sends a response to the FIDL transaction.
680    ///
681    /// Sets the channel to shutdown if an error occurs.
682    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
683        let _result = self.send_raw(result);
684        if _result.is_err() {
685            self.control_handle.shutdown();
686        }
687        self.drop_without_shutdown();
688        _result
689    }
690
691    /// Similar to "send" but does not shutdown the channel if an error occurs.
692    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
693        let _result = self.send_raw(result);
694        self.drop_without_shutdown();
695        _result
696    }
697
698    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
699        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
700            fidl::encoding::EmptyStruct,
701            i32,
702        >>(
703            fidl::encoding::FlexibleResult::new(result),
704            self.tx_id,
705            0x3bb98f59dd645c14,
706            fidl::encoding::DynamicFlags::FLEXIBLE,
707        )
708    }
709}
710
711#[must_use = "FIDL methods require a response to be sent"]
712#[derive(Debug)]
713pub struct DeviceGetNodeGraphResponder {
714    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
715    tx_id: u32,
716}
717
718/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
719/// if the responder is dropped without sending a response, so that the client
720/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
721impl std::ops::Drop for DeviceGetNodeGraphResponder {
722    fn drop(&mut self) {
723        self.control_handle.shutdown();
724        // Safety: drops once, never accessed again
725        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
726    }
727}
728
729impl fidl::endpoints::Responder for DeviceGetNodeGraphResponder {
730    type ControlHandle = DeviceControlHandle;
731
732    fn control_handle(&self) -> &DeviceControlHandle {
733        &self.control_handle
734    }
735
736    fn drop_without_shutdown(mut self) {
737        // Safety: drops once, never accessed again due to mem::forget
738        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
739        // Prevent Drop from running (which would shut down the channel)
740        std::mem::forget(self);
741    }
742}
743
744impl DeviceGetNodeGraphResponder {
745    /// Sends a response to the FIDL transaction.
746    ///
747    /// Sets the channel to shutdown if an error occurs.
748    pub fn send(self, mut nodes: &[Node], mut edges: &[Edge]) -> Result<(), fidl::Error> {
749        let _result = self.send_raw(nodes, edges);
750        if _result.is_err() {
751            self.control_handle.shutdown();
752        }
753        self.drop_without_shutdown();
754        _result
755    }
756
757    /// Similar to "send" but does not shutdown the channel if an error occurs.
758    pub fn send_no_shutdown_on_err(
759        self,
760        mut nodes: &[Node],
761        mut edges: &[Edge],
762    ) -> Result<(), fidl::Error> {
763        let _result = self.send_raw(nodes, edges);
764        self.drop_without_shutdown();
765        _result
766    }
767
768    fn send_raw(&self, mut nodes: &[Node], mut edges: &[Edge]) -> Result<(), fidl::Error> {
769        self.control_handle.inner.send::<fidl::encoding::FlexibleType<DeviceGetNodeGraphResponse>>(
770            fidl::encoding::Flexible::new((nodes, edges)),
771            self.tx_id,
772            0x2f676c9ef41b8306,
773            fidl::encoding::DynamicFlags::FLEXIBLE,
774        )
775    }
776}
777
778#[must_use = "FIDL methods require a response to be sent"]
779#[derive(Debug)]
780pub struct DeviceGetPathEndpointsResponder {
781    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
782    tx_id: u32,
783}
784
785/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
786/// if the responder is dropped without sending a response, so that the client
787/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
788impl std::ops::Drop for DeviceGetPathEndpointsResponder {
789    fn drop(&mut self) {
790        self.control_handle.shutdown();
791        // Safety: drops once, never accessed again
792        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
793    }
794}
795
796impl fidl::endpoints::Responder for DeviceGetPathEndpointsResponder {
797    type ControlHandle = DeviceControlHandle;
798
799    fn control_handle(&self) -> &DeviceControlHandle {
800        &self.control_handle
801    }
802
803    fn drop_without_shutdown(mut self) {
804        // Safety: drops once, never accessed again due to mem::forget
805        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
806        // Prevent Drop from running (which would shut down the channel)
807        std::mem::forget(self);
808    }
809}
810
811impl DeviceGetPathEndpointsResponder {
812    /// Sends a response to the FIDL transaction.
813    ///
814    /// Sets the channel to shutdown if an error occurs.
815    pub fn send(self, mut paths: &[PathEndpoints]) -> Result<(), fidl::Error> {
816        let _result = self.send_raw(paths);
817        if _result.is_err() {
818            self.control_handle.shutdown();
819        }
820        self.drop_without_shutdown();
821        _result
822    }
823
824    /// Similar to "send" but does not shutdown the channel if an error occurs.
825    pub fn send_no_shutdown_on_err(self, mut paths: &[PathEndpoints]) -> Result<(), fidl::Error> {
826        let _result = self.send_raw(paths);
827        self.drop_without_shutdown();
828        _result
829    }
830
831    fn send_raw(&self, mut paths: &[PathEndpoints]) -> Result<(), fidl::Error> {
832        self.control_handle
833            .inner
834            .send::<fidl::encoding::FlexibleType<DeviceGetPathEndpointsResponse>>(
835                fidl::encoding::Flexible::new((paths,)),
836                self.tx_id,
837                0x656ae602a096765b,
838                fidl::encoding::DynamicFlags::FLEXIBLE,
839            )
840    }
841}
842
843#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
844pub struct PathMarker;
845
846impl fidl::endpoints::ProtocolMarker for PathMarker {
847    type Proxy = PathProxy;
848    type RequestStream = PathRequestStream;
849    #[cfg(target_os = "fuchsia")]
850    type SynchronousProxy = PathSynchronousProxy;
851
852    const DEBUG_NAME: &'static str = "fuchsia.hardware.interconnect.Path";
853}
854impl fidl::endpoints::DiscoverableProtocolMarker for PathMarker {}
855pub type PathSetBandwidthResult = Result<(), i32>;
856
857pub trait PathProxyInterface: Send + Sync {
858    type SetBandwidthResponseFut: std::future::Future<Output = Result<PathSetBandwidthResult, fidl::Error>>
859        + Send;
860    fn r#set_bandwidth(&self, payload: &BandwidthRequest) -> Self::SetBandwidthResponseFut;
861}
862#[derive(Debug)]
863#[cfg(target_os = "fuchsia")]
864pub struct PathSynchronousProxy {
865    client: fidl::client::sync::Client,
866}
867
868#[cfg(target_os = "fuchsia")]
869impl fidl::endpoints::SynchronousProxy for PathSynchronousProxy {
870    type Proxy = PathProxy;
871    type Protocol = PathMarker;
872
873    fn from_channel(inner: fidl::Channel) -> Self {
874        Self::new(inner)
875    }
876
877    fn into_channel(self) -> fidl::Channel {
878        self.client.into_channel()
879    }
880
881    fn as_channel(&self) -> &fidl::Channel {
882        self.client.as_channel()
883    }
884}
885
886#[cfg(target_os = "fuchsia")]
887impl PathSynchronousProxy {
888    pub fn new(channel: fidl::Channel) -> Self {
889        let protocol_name = <PathMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
890        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
891    }
892
893    pub fn into_channel(self) -> fidl::Channel {
894        self.client.into_channel()
895    }
896
897    /// Waits until an event arrives and returns it. It is safe for other
898    /// threads to make concurrent requests while waiting for an event.
899    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<PathEvent, fidl::Error> {
900        PathEvent::decode(self.client.wait_for_event(deadline)?)
901    }
902
903    /// Sets the bandwidth interconnect path.
904    pub fn r#set_bandwidth(
905        &self,
906        mut payload: &BandwidthRequest,
907        ___deadline: zx::MonotonicInstant,
908    ) -> Result<PathSetBandwidthResult, fidl::Error> {
909        let _response = self.client.send_query::<
910            BandwidthRequest,
911            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
912        >(
913            payload,
914            0xd366c6e86f69d1d,
915            fidl::encoding::DynamicFlags::FLEXIBLE,
916            ___deadline,
917        )?
918        .into_result::<PathMarker>("set_bandwidth")?;
919        Ok(_response.map(|x| x))
920    }
921}
922
923#[cfg(target_os = "fuchsia")]
924impl From<PathSynchronousProxy> for zx::Handle {
925    fn from(value: PathSynchronousProxy) -> Self {
926        value.into_channel().into()
927    }
928}
929
930#[cfg(target_os = "fuchsia")]
931impl From<fidl::Channel> for PathSynchronousProxy {
932    fn from(value: fidl::Channel) -> Self {
933        Self::new(value)
934    }
935}
936
937#[cfg(target_os = "fuchsia")]
938impl fidl::endpoints::FromClient for PathSynchronousProxy {
939    type Protocol = PathMarker;
940
941    fn from_client(value: fidl::endpoints::ClientEnd<PathMarker>) -> Self {
942        Self::new(value.into_channel())
943    }
944}
945
946#[derive(Debug, Clone)]
947pub struct PathProxy {
948    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
949}
950
951impl fidl::endpoints::Proxy for PathProxy {
952    type Protocol = PathMarker;
953
954    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
955        Self::new(inner)
956    }
957
958    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
959        self.client.into_channel().map_err(|client| Self { client })
960    }
961
962    fn as_channel(&self) -> &::fidl::AsyncChannel {
963        self.client.as_channel()
964    }
965}
966
967impl PathProxy {
968    /// Create a new Proxy for fuchsia.hardware.interconnect/Path.
969    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
970        let protocol_name = <PathMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
971        Self { client: fidl::client::Client::new(channel, protocol_name) }
972    }
973
974    /// Get a Stream of events from the remote end of the protocol.
975    ///
976    /// # Panics
977    ///
978    /// Panics if the event stream was already taken.
979    pub fn take_event_stream(&self) -> PathEventStream {
980        PathEventStream { event_receiver: self.client.take_event_receiver() }
981    }
982
983    /// Sets the bandwidth interconnect path.
984    pub fn r#set_bandwidth(
985        &self,
986        mut payload: &BandwidthRequest,
987    ) -> fidl::client::QueryResponseFut<
988        PathSetBandwidthResult,
989        fidl::encoding::DefaultFuchsiaResourceDialect,
990    > {
991        PathProxyInterface::r#set_bandwidth(self, payload)
992    }
993}
994
995impl PathProxyInterface for PathProxy {
996    type SetBandwidthResponseFut = fidl::client::QueryResponseFut<
997        PathSetBandwidthResult,
998        fidl::encoding::DefaultFuchsiaResourceDialect,
999    >;
1000    fn r#set_bandwidth(&self, mut payload: &BandwidthRequest) -> Self::SetBandwidthResponseFut {
1001        fn _decode(
1002            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1003        ) -> Result<PathSetBandwidthResult, fidl::Error> {
1004            let _response = fidl::client::decode_transaction_body::<
1005                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1006                fidl::encoding::DefaultFuchsiaResourceDialect,
1007                0xd366c6e86f69d1d,
1008            >(_buf?)?
1009            .into_result::<PathMarker>("set_bandwidth")?;
1010            Ok(_response.map(|x| x))
1011        }
1012        self.client.send_query_and_decode::<BandwidthRequest, PathSetBandwidthResult>(
1013            payload,
1014            0xd366c6e86f69d1d,
1015            fidl::encoding::DynamicFlags::FLEXIBLE,
1016            _decode,
1017        )
1018    }
1019}
1020
1021pub struct PathEventStream {
1022    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1023}
1024
1025impl std::marker::Unpin for PathEventStream {}
1026
1027impl futures::stream::FusedStream for PathEventStream {
1028    fn is_terminated(&self) -> bool {
1029        self.event_receiver.is_terminated()
1030    }
1031}
1032
1033impl futures::Stream for PathEventStream {
1034    type Item = Result<PathEvent, fidl::Error>;
1035
1036    fn poll_next(
1037        mut self: std::pin::Pin<&mut Self>,
1038        cx: &mut std::task::Context<'_>,
1039    ) -> std::task::Poll<Option<Self::Item>> {
1040        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1041            &mut self.event_receiver,
1042            cx
1043        )?) {
1044            Some(buf) => std::task::Poll::Ready(Some(PathEvent::decode(buf))),
1045            None => std::task::Poll::Ready(None),
1046        }
1047    }
1048}
1049
1050#[derive(Debug)]
1051pub enum PathEvent {
1052    #[non_exhaustive]
1053    _UnknownEvent {
1054        /// Ordinal of the event that was sent.
1055        ordinal: u64,
1056    },
1057}
1058
1059impl PathEvent {
1060    /// Decodes a message buffer as a [`PathEvent`].
1061    fn decode(
1062        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1063    ) -> Result<PathEvent, fidl::Error> {
1064        let (bytes, _handles) = buf.split_mut();
1065        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1066        debug_assert_eq!(tx_header.tx_id, 0);
1067        match tx_header.ordinal {
1068            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1069                Ok(PathEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1070            }
1071            _ => Err(fidl::Error::UnknownOrdinal {
1072                ordinal: tx_header.ordinal,
1073                protocol_name: <PathMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1074            }),
1075        }
1076    }
1077}
1078
1079/// A Stream of incoming requests for fuchsia.hardware.interconnect/Path.
1080pub struct PathRequestStream {
1081    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1082    is_terminated: bool,
1083}
1084
1085impl std::marker::Unpin for PathRequestStream {}
1086
1087impl futures::stream::FusedStream for PathRequestStream {
1088    fn is_terminated(&self) -> bool {
1089        self.is_terminated
1090    }
1091}
1092
1093impl fidl::endpoints::RequestStream for PathRequestStream {
1094    type Protocol = PathMarker;
1095    type ControlHandle = PathControlHandle;
1096
1097    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1098        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1099    }
1100
1101    fn control_handle(&self) -> Self::ControlHandle {
1102        PathControlHandle { inner: self.inner.clone() }
1103    }
1104
1105    fn into_inner(
1106        self,
1107    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1108    {
1109        (self.inner, self.is_terminated)
1110    }
1111
1112    fn from_inner(
1113        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1114        is_terminated: bool,
1115    ) -> Self {
1116        Self { inner, is_terminated }
1117    }
1118}
1119
1120impl futures::Stream for PathRequestStream {
1121    type Item = Result<PathRequest, fidl::Error>;
1122
1123    fn poll_next(
1124        mut self: std::pin::Pin<&mut Self>,
1125        cx: &mut std::task::Context<'_>,
1126    ) -> std::task::Poll<Option<Self::Item>> {
1127        let this = &mut *self;
1128        if this.inner.check_shutdown(cx) {
1129            this.is_terminated = true;
1130            return std::task::Poll::Ready(None);
1131        }
1132        if this.is_terminated {
1133            panic!("polled PathRequestStream after completion");
1134        }
1135        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1136            |bytes, handles| {
1137                match this.inner.channel().read_etc(cx, bytes, handles) {
1138                    std::task::Poll::Ready(Ok(())) => {}
1139                    std::task::Poll::Pending => return std::task::Poll::Pending,
1140                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1141                        this.is_terminated = true;
1142                        return std::task::Poll::Ready(None);
1143                    }
1144                    std::task::Poll::Ready(Err(e)) => {
1145                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1146                            e.into(),
1147                        ))))
1148                    }
1149                }
1150
1151                // A message has been received from the channel
1152                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1153
1154                std::task::Poll::Ready(Some(match header.ordinal {
1155                    0xd366c6e86f69d1d => {
1156                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1157                        let mut req = fidl::new_empty!(
1158                            BandwidthRequest,
1159                            fidl::encoding::DefaultFuchsiaResourceDialect
1160                        );
1161                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BandwidthRequest>(&header, _body_bytes, handles, &mut req)?;
1162                        let control_handle = PathControlHandle { inner: this.inner.clone() };
1163                        Ok(PathRequest::SetBandwidth {
1164                            payload: req,
1165                            responder: PathSetBandwidthResponder {
1166                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1167                                tx_id: header.tx_id,
1168                            },
1169                        })
1170                    }
1171                    _ if header.tx_id == 0
1172                        && header
1173                            .dynamic_flags()
1174                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1175                    {
1176                        Ok(PathRequest::_UnknownMethod {
1177                            ordinal: header.ordinal,
1178                            control_handle: PathControlHandle { inner: this.inner.clone() },
1179                            method_type: fidl::MethodType::OneWay,
1180                        })
1181                    }
1182                    _ if header
1183                        .dynamic_flags()
1184                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1185                    {
1186                        this.inner.send_framework_err(
1187                            fidl::encoding::FrameworkErr::UnknownMethod,
1188                            header.tx_id,
1189                            header.ordinal,
1190                            header.dynamic_flags(),
1191                            (bytes, handles),
1192                        )?;
1193                        Ok(PathRequest::_UnknownMethod {
1194                            ordinal: header.ordinal,
1195                            control_handle: PathControlHandle { inner: this.inner.clone() },
1196                            method_type: fidl::MethodType::TwoWay,
1197                        })
1198                    }
1199                    _ => Err(fidl::Error::UnknownOrdinal {
1200                        ordinal: header.ordinal,
1201                        protocol_name: <PathMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1202                    }),
1203                }))
1204            },
1205        )
1206    }
1207}
1208
1209/// Represents a path from a node in one interconnect to another.
1210#[derive(Debug)]
1211pub enum PathRequest {
1212    /// Sets the bandwidth interconnect path.
1213    SetBandwidth { payload: BandwidthRequest, responder: PathSetBandwidthResponder },
1214    /// An interaction was received which does not match any known method.
1215    #[non_exhaustive]
1216    _UnknownMethod {
1217        /// Ordinal of the method that was called.
1218        ordinal: u64,
1219        control_handle: PathControlHandle,
1220        method_type: fidl::MethodType,
1221    },
1222}
1223
1224impl PathRequest {
1225    #[allow(irrefutable_let_patterns)]
1226    pub fn into_set_bandwidth(self) -> Option<(BandwidthRequest, PathSetBandwidthResponder)> {
1227        if let PathRequest::SetBandwidth { payload, responder } = self {
1228            Some((payload, responder))
1229        } else {
1230            None
1231        }
1232    }
1233
1234    /// Name of the method defined in FIDL
1235    pub fn method_name(&self) -> &'static str {
1236        match *self {
1237            PathRequest::SetBandwidth { .. } => "set_bandwidth",
1238            PathRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1239                "unknown one-way method"
1240            }
1241            PathRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1242                "unknown two-way method"
1243            }
1244        }
1245    }
1246}
1247
1248#[derive(Debug, Clone)]
1249pub struct PathControlHandle {
1250    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1251}
1252
1253impl fidl::endpoints::ControlHandle for PathControlHandle {
1254    fn shutdown(&self) {
1255        self.inner.shutdown()
1256    }
1257    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1258        self.inner.shutdown_with_epitaph(status)
1259    }
1260
1261    fn is_closed(&self) -> bool {
1262        self.inner.channel().is_closed()
1263    }
1264    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1265        self.inner.channel().on_closed()
1266    }
1267
1268    #[cfg(target_os = "fuchsia")]
1269    fn signal_peer(
1270        &self,
1271        clear_mask: zx::Signals,
1272        set_mask: zx::Signals,
1273    ) -> Result<(), zx_status::Status> {
1274        use fidl::Peered;
1275        self.inner.channel().signal_peer(clear_mask, set_mask)
1276    }
1277}
1278
1279impl PathControlHandle {}
1280
1281#[must_use = "FIDL methods require a response to be sent"]
1282#[derive(Debug)]
1283pub struct PathSetBandwidthResponder {
1284    control_handle: std::mem::ManuallyDrop<PathControlHandle>,
1285    tx_id: u32,
1286}
1287
1288/// Set the the channel to be shutdown (see [`PathControlHandle::shutdown`])
1289/// if the responder is dropped without sending a response, so that the client
1290/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1291impl std::ops::Drop for PathSetBandwidthResponder {
1292    fn drop(&mut self) {
1293        self.control_handle.shutdown();
1294        // Safety: drops once, never accessed again
1295        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1296    }
1297}
1298
1299impl fidl::endpoints::Responder for PathSetBandwidthResponder {
1300    type ControlHandle = PathControlHandle;
1301
1302    fn control_handle(&self) -> &PathControlHandle {
1303        &self.control_handle
1304    }
1305
1306    fn drop_without_shutdown(mut self) {
1307        // Safety: drops once, never accessed again due to mem::forget
1308        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1309        // Prevent Drop from running (which would shut down the channel)
1310        std::mem::forget(self);
1311    }
1312}
1313
1314impl PathSetBandwidthResponder {
1315    /// Sends a response to the FIDL transaction.
1316    ///
1317    /// Sets the channel to shutdown if an error occurs.
1318    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1319        let _result = self.send_raw(result);
1320        if _result.is_err() {
1321            self.control_handle.shutdown();
1322        }
1323        self.drop_without_shutdown();
1324        _result
1325    }
1326
1327    /// Similar to "send" but does not shutdown the channel if an error occurs.
1328    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1329        let _result = self.send_raw(result);
1330        self.drop_without_shutdown();
1331        _result
1332    }
1333
1334    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1335        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1336            fidl::encoding::EmptyStruct,
1337            i32,
1338        >>(
1339            fidl::encoding::FlexibleResult::new(result),
1340            self.tx_id,
1341            0xd366c6e86f69d1d,
1342            fidl::encoding::DynamicFlags::FLEXIBLE,
1343        )
1344    }
1345}
1346
1347#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1348pub struct PathServiceMarker;
1349
1350#[cfg(target_os = "fuchsia")]
1351impl fidl::endpoints::ServiceMarker for PathServiceMarker {
1352    type Proxy = PathServiceProxy;
1353    type Request = PathServiceRequest;
1354    const SERVICE_NAME: &'static str = "fuchsia.hardware.interconnect.PathService";
1355}
1356
1357/// A request for one of the member protocols of PathService.
1358///
1359#[cfg(target_os = "fuchsia")]
1360pub enum PathServiceRequest {
1361    Path(PathRequestStream),
1362}
1363
1364#[cfg(target_os = "fuchsia")]
1365impl fidl::endpoints::ServiceRequest for PathServiceRequest {
1366    type Service = PathServiceMarker;
1367
1368    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1369        match name {
1370            "path" => Self::Path(
1371                <PathRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1372            ),
1373            _ => panic!("no such member protocol name for service PathService"),
1374        }
1375    }
1376
1377    fn member_names() -> &'static [&'static str] {
1378        &["path"]
1379    }
1380}
1381#[cfg(target_os = "fuchsia")]
1382pub struct PathServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1383
1384#[cfg(target_os = "fuchsia")]
1385impl fidl::endpoints::ServiceProxy for PathServiceProxy {
1386    type Service = PathServiceMarker;
1387
1388    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1389        Self(opener)
1390    }
1391}
1392
1393#[cfg(target_os = "fuchsia")]
1394impl PathServiceProxy {
1395    pub fn connect_to_path(&self) -> Result<PathProxy, fidl::Error> {
1396        let (proxy, server_end) = fidl::endpoints::create_proxy::<PathMarker>();
1397        self.connect_channel_to_path(server_end)?;
1398        Ok(proxy)
1399    }
1400
1401    /// Like `connect_to_path`, but returns a sync proxy.
1402    /// See [`Self::connect_to_path`] for more details.
1403    pub fn connect_to_path_sync(&self) -> Result<PathSynchronousProxy, fidl::Error> {
1404        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<PathMarker>();
1405        self.connect_channel_to_path(server_end)?;
1406        Ok(proxy)
1407    }
1408
1409    /// Like `connect_to_path`, but accepts a server end.
1410    /// See [`Self::connect_to_path`] for more details.
1411    pub fn connect_channel_to_path(
1412        &self,
1413        server_end: fidl::endpoints::ServerEnd<PathMarker>,
1414    ) -> Result<(), fidl::Error> {
1415        self.0.open_member("path", server_end.into_channel())
1416    }
1417
1418    pub fn instance_name(&self) -> &str {
1419        self.0.instance_name()
1420    }
1421}
1422
1423#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1424pub struct ServiceMarker;
1425
1426#[cfg(target_os = "fuchsia")]
1427impl fidl::endpoints::ServiceMarker for ServiceMarker {
1428    type Proxy = ServiceProxy;
1429    type Request = ServiceRequest;
1430    const SERVICE_NAME: &'static str = "fuchsia.hardware.interconnect.Service";
1431}
1432
1433/// A request for one of the member protocols of Service.
1434///
1435#[cfg(target_os = "fuchsia")]
1436pub enum ServiceRequest {
1437    Device(DeviceRequestStream),
1438}
1439
1440#[cfg(target_os = "fuchsia")]
1441impl fidl::endpoints::ServiceRequest for ServiceRequest {
1442    type Service = ServiceMarker;
1443
1444    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1445        match name {
1446            "device" => Self::Device(
1447                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1448            ),
1449            _ => panic!("no such member protocol name for service Service"),
1450        }
1451    }
1452
1453    fn member_names() -> &'static [&'static str] {
1454        &["device"]
1455    }
1456}
1457#[cfg(target_os = "fuchsia")]
1458pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1459
1460#[cfg(target_os = "fuchsia")]
1461impl fidl::endpoints::ServiceProxy for ServiceProxy {
1462    type Service = ServiceMarker;
1463
1464    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1465        Self(opener)
1466    }
1467}
1468
1469#[cfg(target_os = "fuchsia")]
1470impl ServiceProxy {
1471    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
1472        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1473        self.connect_channel_to_device(server_end)?;
1474        Ok(proxy)
1475    }
1476
1477    /// Like `connect_to_device`, but returns a sync proxy.
1478    /// See [`Self::connect_to_device`] for more details.
1479    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1480        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1481        self.connect_channel_to_device(server_end)?;
1482        Ok(proxy)
1483    }
1484
1485    /// Like `connect_to_device`, but accepts a server end.
1486    /// See [`Self::connect_to_device`] for more details.
1487    pub fn connect_channel_to_device(
1488        &self,
1489        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1490    ) -> Result<(), fidl::Error> {
1491        self.0.open_member("device", server_end.into_channel())
1492    }
1493
1494    pub fn instance_name(&self) -> &str {
1495        self.0.instance_name()
1496    }
1497}
1498
1499mod internal {
1500    use super::*;
1501}