Skip to main content

fidl_fuchsia_hardware_qualcomm_router/
fidl_fuchsia_hardware_qualcomm_router.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_qualcomm_router_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct QrtrClientConnectionGetSignalsResponse {
16    pub signals: fidl::EventPair,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for QrtrClientConnectionGetSignalsResponse
21{
22}
23
24#[derive(Debug, PartialEq)]
25pub struct QrtrConnectorGetConnectionRequest {
26    pub options: ConnectionOptions,
27    pub proxy: fidl::endpoints::ServerEnd<QrtrClientConnectionMarker>,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for QrtrConnectorGetConnectionRequest
32{
33}
34
35#[derive(Debug, PartialEq)]
36pub struct QrtrTransportConnectorEstablishConnectionRequest {
37    pub options: TransportConnectionOptions,
38    pub proxy: fidl::endpoints::ClientEnd<QrtrTransportChannelMarker>,
39}
40
41impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
42    for QrtrTransportConnectorEstablishConnectionRequest
43{
44}
45
46#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
47pub struct QrtrClientConnectionMarker;
48
49impl fidl::endpoints::ProtocolMarker for QrtrClientConnectionMarker {
50    type Proxy = QrtrClientConnectionProxy;
51    type RequestStream = QrtrClientConnectionRequestStream;
52    #[cfg(target_os = "fuchsia")]
53    type SynchronousProxy = QrtrClientConnectionSynchronousProxy;
54
55    const DEBUG_NAME: &'static str = "(anonymous) QrtrClientConnection";
56}
57pub type QrtrClientConnectionReadResult = Result<(u32, u32, Vec<u8>), Error>;
58pub type QrtrClientConnectionWriteResult = Result<(), Error>;
59
60pub trait QrtrClientConnectionProxyInterface: Send + Sync {
61    type ReadResponseFut: std::future::Future<Output = Result<QrtrClientConnectionReadResult, fidl::Error>>
62        + Send;
63    fn r#read(&self) -> Self::ReadResponseFut;
64    type WriteResponseFut: std::future::Future<Output = Result<QrtrClientConnectionWriteResult, fidl::Error>>
65        + Send;
66    fn r#write(&self, dst_node_id: u32, dst_port: u32, data: &[u8]) -> Self::WriteResponseFut;
67    type GetSignalsResponseFut: std::future::Future<Output = Result<fidl::EventPair, fidl::Error>>
68        + Send;
69    fn r#get_signals(&self) -> Self::GetSignalsResponseFut;
70    type GetPortIdResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
71    fn r#get_port_id(&self) -> Self::GetPortIdResponseFut;
72    type GetNodeIdResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
73    fn r#get_node_id(&self) -> Self::GetNodeIdResponseFut;
74    type CloseConnectionResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
75    fn r#close_connection(&self) -> Self::CloseConnectionResponseFut;
76}
77#[derive(Debug)]
78#[cfg(target_os = "fuchsia")]
79pub struct QrtrClientConnectionSynchronousProxy {
80    client: fidl::client::sync::Client,
81}
82
83#[cfg(target_os = "fuchsia")]
84impl fidl::endpoints::SynchronousProxy for QrtrClientConnectionSynchronousProxy {
85    type Proxy = QrtrClientConnectionProxy;
86    type Protocol = QrtrClientConnectionMarker;
87
88    fn from_channel(inner: fidl::Channel) -> Self {
89        Self::new(inner)
90    }
91
92    fn into_channel(self) -> fidl::Channel {
93        self.client.into_channel()
94    }
95
96    fn as_channel(&self) -> &fidl::Channel {
97        self.client.as_channel()
98    }
99}
100
101#[cfg(target_os = "fuchsia")]
102impl QrtrClientConnectionSynchronousProxy {
103    pub fn new(channel: fidl::Channel) -> Self {
104        Self { client: fidl::client::sync::Client::new(channel) }
105    }
106
107    pub fn into_channel(self) -> fidl::Channel {
108        self.client.into_channel()
109    }
110
111    /// Waits until an event arrives and returns it. It is safe for other
112    /// threads to make concurrent requests while waiting for an event.
113    pub fn wait_for_event(
114        &self,
115        deadline: zx::MonotonicInstant,
116    ) -> Result<QrtrClientConnectionEvent, fidl::Error> {
117        QrtrClientConnectionEvent::decode(
118            self.client.wait_for_event::<QrtrClientConnectionMarker>(deadline)?,
119        )
120    }
121
122    /// Reads a QRTR frame via the connection.
123    ///
124    /// Only one read request can be performed at a time.
125    /// - `src_node_id`: Source node ID of the QRTR frame.
126    /// - `src_port`: Source port of the QRTR frame.
127    /// - `data`: QRTR payload.
128    /// * Errors:
129    ///   - `WOULD_BLOCK`: Cannot read; should wait in non-blocking mode.
130    ///   - `ALREADY_PENDING`: More than one read operation is pending in blocking mode.
131    ///   - `INTERNAL_ERROR`: Unexpected QRTR error.
132    pub fn r#read(
133        &self,
134        ___deadline: zx::MonotonicInstant,
135    ) -> Result<QrtrClientConnectionReadResult, fidl::Error> {
136        let _response = self.client.send_query::<
137            fidl::encoding::EmptyPayload,
138            fidl::encoding::FlexibleResultType<QrtrClientConnectionReadResponse, Error>,
139            QrtrClientConnectionMarker,
140        >(
141            (),
142            0x1647cf125346d619,
143            fidl::encoding::DynamicFlags::FLEXIBLE,
144            ___deadline,
145        )?
146        .into_result::<QrtrClientConnectionMarker>("read")?;
147        Ok(_response.map(|x| (x.src_node_id, x.src_port, x.data)))
148    }
149
150    /// Writes a QRTR frame.
151    ///
152    /// Only one write request can be performed at a time.
153    /// * Errors:
154    ///   - `WOULD_BLOCK`: Cannot write; should wait in non-blocking mode.
155    ///   - `ALREADY_PENDING`: More than one write operation is pending in blocking mode.
156    ///   - `REMOTE_NODE_UNAVAILABLE`: Target node unavailable.
157    ///   - `INTERNAL_ERROR`: Unexpected QRTR error.
158    pub fn r#write(
159        &self,
160        mut dst_node_id: u32,
161        mut dst_port: u32,
162        mut data: &[u8],
163        ___deadline: zx::MonotonicInstant,
164    ) -> Result<QrtrClientConnectionWriteResult, fidl::Error> {
165        let _response = self.client.send_query::<
166            QrtrClientConnectionWriteRequest,
167            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
168            QrtrClientConnectionMarker,
169        >(
170            (dst_node_id, dst_port, data,),
171            0x777f5423e2e75f51,
172            fidl::encoding::DynamicFlags::FLEXIBLE,
173            ___deadline,
174        )?
175        .into_result::<QrtrClientConnectionMarker>("write")?;
176        Ok(_response.map(|x| x))
177    }
178
179    /// Retrieves the signals eventpair.
180    ///
181    /// - response `signals` an eventpair that is signalled with
182    ///            `SIGNAL_READABLE` and `SIGNAL_WRITABLE` when
183    ///            read and write buffers are available, respectively.
184    pub fn r#get_signals(
185        &self,
186        ___deadline: zx::MonotonicInstant,
187    ) -> Result<fidl::EventPair, fidl::Error> {
188        let _response = self.client.send_query::<
189            fidl::encoding::EmptyPayload,
190            fidl::encoding::FlexibleType<QrtrClientConnectionGetSignalsResponse>,
191            QrtrClientConnectionMarker,
192        >(
193            (),
194            0x6a71227b57862ad7,
195            fidl::encoding::DynamicFlags::FLEXIBLE,
196            ___deadline,
197        )?
198        .into_result::<QrtrClientConnectionMarker>("get_signals")?;
199        Ok(_response.signals)
200    }
201
202    /// Retrieves the port id.
203    pub fn r#get_port_id(&self, ___deadline: zx::MonotonicInstant) -> Result<u32, fidl::Error> {
204        let _response = self.client.send_query::<
205            fidl::encoding::EmptyPayload,
206            fidl::encoding::FlexibleType<QrtrClientConnectionGetPortIdResponse>,
207            QrtrClientConnectionMarker,
208        >(
209            (),
210            0xb66d6d257f16ad2,
211            fidl::encoding::DynamicFlags::FLEXIBLE,
212            ___deadline,
213        )?
214        .into_result::<QrtrClientConnectionMarker>("get_port_id")?;
215        Ok(_response.port_id)
216    }
217
218    /// Retrieves the node id of AP.
219    pub fn r#get_node_id(&self, ___deadline: zx::MonotonicInstant) -> Result<u32, fidl::Error> {
220        let _response = self.client.send_query::<
221            fidl::encoding::EmptyPayload,
222            fidl::encoding::FlexibleType<QrtrClientConnectionGetNodeIdResponse>,
223            QrtrClientConnectionMarker,
224        >(
225            (),
226            0x2ddd28cdb89d2c44,
227            fidl::encoding::DynamicFlags::FLEXIBLE,
228            ___deadline,
229        )?
230        .into_result::<QrtrClientConnectionMarker>("get_node_id")?;
231        Ok(_response.node_id)
232    }
233
234    /// Close the connection.
235    ///
236    /// Server end drops its end of the channel after replying. This can be
237    /// used for synchronous resource release.
238    pub fn r#close_connection(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
239        let _response = self.client.send_query::<
240            fidl::encoding::EmptyPayload,
241            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
242            QrtrClientConnectionMarker,
243        >(
244            (),
245            0x4645ccec1b86380f,
246            fidl::encoding::DynamicFlags::FLEXIBLE,
247            ___deadline,
248        )?
249        .into_result::<QrtrClientConnectionMarker>("close_connection")?;
250        Ok(_response)
251    }
252}
253
254#[cfg(target_os = "fuchsia")]
255impl From<QrtrClientConnectionSynchronousProxy> for zx::NullableHandle {
256    fn from(value: QrtrClientConnectionSynchronousProxy) -> Self {
257        value.into_channel().into()
258    }
259}
260
261#[cfg(target_os = "fuchsia")]
262impl From<fidl::Channel> for QrtrClientConnectionSynchronousProxy {
263    fn from(value: fidl::Channel) -> Self {
264        Self::new(value)
265    }
266}
267
268#[cfg(target_os = "fuchsia")]
269impl fidl::endpoints::FromClient for QrtrClientConnectionSynchronousProxy {
270    type Protocol = QrtrClientConnectionMarker;
271
272    fn from_client(value: fidl::endpoints::ClientEnd<QrtrClientConnectionMarker>) -> Self {
273        Self::new(value.into_channel())
274    }
275}
276
277#[derive(Debug, Clone)]
278pub struct QrtrClientConnectionProxy {
279    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
280}
281
282impl fidl::endpoints::Proxy for QrtrClientConnectionProxy {
283    type Protocol = QrtrClientConnectionMarker;
284
285    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
286        Self::new(inner)
287    }
288
289    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
290        self.client.into_channel().map_err(|client| Self { client })
291    }
292
293    fn as_channel(&self) -> &::fidl::AsyncChannel {
294        self.client.as_channel()
295    }
296}
297
298impl QrtrClientConnectionProxy {
299    /// Create a new Proxy for fuchsia.hardware.qualcomm.router/QrtrClientConnection.
300    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
301        let protocol_name =
302            <QrtrClientConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
303        Self { client: fidl::client::Client::new(channel, protocol_name) }
304    }
305
306    /// Get a Stream of events from the remote end of the protocol.
307    ///
308    /// # Panics
309    ///
310    /// Panics if the event stream was already taken.
311    pub fn take_event_stream(&self) -> QrtrClientConnectionEventStream {
312        QrtrClientConnectionEventStream { event_receiver: self.client.take_event_receiver() }
313    }
314
315    /// Reads a QRTR frame via the connection.
316    ///
317    /// Only one read request can be performed at a time.
318    /// - `src_node_id`: Source node ID of the QRTR frame.
319    /// - `src_port`: Source port of the QRTR frame.
320    /// - `data`: QRTR payload.
321    /// * Errors:
322    ///   - `WOULD_BLOCK`: Cannot read; should wait in non-blocking mode.
323    ///   - `ALREADY_PENDING`: More than one read operation is pending in blocking mode.
324    ///   - `INTERNAL_ERROR`: Unexpected QRTR error.
325    pub fn r#read(
326        &self,
327    ) -> fidl::client::QueryResponseFut<
328        QrtrClientConnectionReadResult,
329        fidl::encoding::DefaultFuchsiaResourceDialect,
330    > {
331        QrtrClientConnectionProxyInterface::r#read(self)
332    }
333
334    /// Writes a QRTR frame.
335    ///
336    /// Only one write request can be performed at a time.
337    /// * Errors:
338    ///   - `WOULD_BLOCK`: Cannot write; should wait in non-blocking mode.
339    ///   - `ALREADY_PENDING`: More than one write operation is pending in blocking mode.
340    ///   - `REMOTE_NODE_UNAVAILABLE`: Target node unavailable.
341    ///   - `INTERNAL_ERROR`: Unexpected QRTR error.
342    pub fn r#write(
343        &self,
344        mut dst_node_id: u32,
345        mut dst_port: u32,
346        mut data: &[u8],
347    ) -> fidl::client::QueryResponseFut<
348        QrtrClientConnectionWriteResult,
349        fidl::encoding::DefaultFuchsiaResourceDialect,
350    > {
351        QrtrClientConnectionProxyInterface::r#write(self, dst_node_id, dst_port, data)
352    }
353
354    /// Retrieves the signals eventpair.
355    ///
356    /// - response `signals` an eventpair that is signalled with
357    ///            `SIGNAL_READABLE` and `SIGNAL_WRITABLE` when
358    ///            read and write buffers are available, respectively.
359    pub fn r#get_signals(
360        &self,
361    ) -> fidl::client::QueryResponseFut<
362        fidl::EventPair,
363        fidl::encoding::DefaultFuchsiaResourceDialect,
364    > {
365        QrtrClientConnectionProxyInterface::r#get_signals(self)
366    }
367
368    /// Retrieves the port id.
369    pub fn r#get_port_id(
370        &self,
371    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
372        QrtrClientConnectionProxyInterface::r#get_port_id(self)
373    }
374
375    /// Retrieves the node id of AP.
376    pub fn r#get_node_id(
377        &self,
378    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
379        QrtrClientConnectionProxyInterface::r#get_node_id(self)
380    }
381
382    /// Close the connection.
383    ///
384    /// Server end drops its end of the channel after replying. This can be
385    /// used for synchronous resource release.
386    pub fn r#close_connection(
387        &self,
388    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
389        QrtrClientConnectionProxyInterface::r#close_connection(self)
390    }
391}
392
393impl QrtrClientConnectionProxyInterface for QrtrClientConnectionProxy {
394    type ReadResponseFut = fidl::client::QueryResponseFut<
395        QrtrClientConnectionReadResult,
396        fidl::encoding::DefaultFuchsiaResourceDialect,
397    >;
398    fn r#read(&self) -> Self::ReadResponseFut {
399        fn _decode(
400            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
401        ) -> Result<QrtrClientConnectionReadResult, fidl::Error> {
402            let _response = fidl::client::decode_transaction_body::<
403                fidl::encoding::FlexibleResultType<QrtrClientConnectionReadResponse, Error>,
404                fidl::encoding::DefaultFuchsiaResourceDialect,
405                0x1647cf125346d619,
406            >(_buf?)?
407            .into_result::<QrtrClientConnectionMarker>("read")?;
408            Ok(_response.map(|x| (x.src_node_id, x.src_port, x.data)))
409        }
410        self.client
411            .send_query_and_decode::<fidl::encoding::EmptyPayload, QrtrClientConnectionReadResult>(
412                (),
413                0x1647cf125346d619,
414                fidl::encoding::DynamicFlags::FLEXIBLE,
415                _decode,
416            )
417    }
418
419    type WriteResponseFut = fidl::client::QueryResponseFut<
420        QrtrClientConnectionWriteResult,
421        fidl::encoding::DefaultFuchsiaResourceDialect,
422    >;
423    fn r#write(
424        &self,
425        mut dst_node_id: u32,
426        mut dst_port: u32,
427        mut data: &[u8],
428    ) -> Self::WriteResponseFut {
429        fn _decode(
430            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
431        ) -> Result<QrtrClientConnectionWriteResult, fidl::Error> {
432            let _response = fidl::client::decode_transaction_body::<
433                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
434                fidl::encoding::DefaultFuchsiaResourceDialect,
435                0x777f5423e2e75f51,
436            >(_buf?)?
437            .into_result::<QrtrClientConnectionMarker>("write")?;
438            Ok(_response.map(|x| x))
439        }
440        self.client.send_query_and_decode::<
441            QrtrClientConnectionWriteRequest,
442            QrtrClientConnectionWriteResult,
443        >(
444            (dst_node_id, dst_port, data,),
445            0x777f5423e2e75f51,
446            fidl::encoding::DynamicFlags::FLEXIBLE,
447            _decode,
448        )
449    }
450
451    type GetSignalsResponseFut = fidl::client::QueryResponseFut<
452        fidl::EventPair,
453        fidl::encoding::DefaultFuchsiaResourceDialect,
454    >;
455    fn r#get_signals(&self) -> Self::GetSignalsResponseFut {
456        fn _decode(
457            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
458        ) -> Result<fidl::EventPair, fidl::Error> {
459            let _response = fidl::client::decode_transaction_body::<
460                fidl::encoding::FlexibleType<QrtrClientConnectionGetSignalsResponse>,
461                fidl::encoding::DefaultFuchsiaResourceDialect,
462                0x6a71227b57862ad7,
463            >(_buf?)?
464            .into_result::<QrtrClientConnectionMarker>("get_signals")?;
465            Ok(_response.signals)
466        }
467        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::EventPair>(
468            (),
469            0x6a71227b57862ad7,
470            fidl::encoding::DynamicFlags::FLEXIBLE,
471            _decode,
472        )
473    }
474
475    type GetPortIdResponseFut =
476        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
477    fn r#get_port_id(&self) -> Self::GetPortIdResponseFut {
478        fn _decode(
479            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
480        ) -> Result<u32, fidl::Error> {
481            let _response = fidl::client::decode_transaction_body::<
482                fidl::encoding::FlexibleType<QrtrClientConnectionGetPortIdResponse>,
483                fidl::encoding::DefaultFuchsiaResourceDialect,
484                0xb66d6d257f16ad2,
485            >(_buf?)?
486            .into_result::<QrtrClientConnectionMarker>("get_port_id")?;
487            Ok(_response.port_id)
488        }
489        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
490            (),
491            0xb66d6d257f16ad2,
492            fidl::encoding::DynamicFlags::FLEXIBLE,
493            _decode,
494        )
495    }
496
497    type GetNodeIdResponseFut =
498        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
499    fn r#get_node_id(&self) -> Self::GetNodeIdResponseFut {
500        fn _decode(
501            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
502        ) -> Result<u32, fidl::Error> {
503            let _response = fidl::client::decode_transaction_body::<
504                fidl::encoding::FlexibleType<QrtrClientConnectionGetNodeIdResponse>,
505                fidl::encoding::DefaultFuchsiaResourceDialect,
506                0x2ddd28cdb89d2c44,
507            >(_buf?)?
508            .into_result::<QrtrClientConnectionMarker>("get_node_id")?;
509            Ok(_response.node_id)
510        }
511        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
512            (),
513            0x2ddd28cdb89d2c44,
514            fidl::encoding::DynamicFlags::FLEXIBLE,
515            _decode,
516        )
517    }
518
519    type CloseConnectionResponseFut =
520        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
521    fn r#close_connection(&self) -> Self::CloseConnectionResponseFut {
522        fn _decode(
523            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
524        ) -> Result<(), fidl::Error> {
525            let _response = fidl::client::decode_transaction_body::<
526                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
527                fidl::encoding::DefaultFuchsiaResourceDialect,
528                0x4645ccec1b86380f,
529            >(_buf?)?
530            .into_result::<QrtrClientConnectionMarker>("close_connection")?;
531            Ok(_response)
532        }
533        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
534            (),
535            0x4645ccec1b86380f,
536            fidl::encoding::DynamicFlags::FLEXIBLE,
537            _decode,
538        )
539    }
540}
541
542pub struct QrtrClientConnectionEventStream {
543    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
544}
545
546impl std::marker::Unpin for QrtrClientConnectionEventStream {}
547
548impl futures::stream::FusedStream for QrtrClientConnectionEventStream {
549    fn is_terminated(&self) -> bool {
550        self.event_receiver.is_terminated()
551    }
552}
553
554impl futures::Stream for QrtrClientConnectionEventStream {
555    type Item = Result<QrtrClientConnectionEvent, fidl::Error>;
556
557    fn poll_next(
558        mut self: std::pin::Pin<&mut Self>,
559        cx: &mut std::task::Context<'_>,
560    ) -> std::task::Poll<Option<Self::Item>> {
561        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
562            &mut self.event_receiver,
563            cx
564        )?) {
565            Some(buf) => std::task::Poll::Ready(Some(QrtrClientConnectionEvent::decode(buf))),
566            None => std::task::Poll::Ready(None),
567        }
568    }
569}
570
571#[derive(Debug)]
572pub enum QrtrClientConnectionEvent {
573    #[non_exhaustive]
574    _UnknownEvent {
575        /// Ordinal of the event that was sent.
576        ordinal: u64,
577    },
578}
579
580impl QrtrClientConnectionEvent {
581    /// Decodes a message buffer as a [`QrtrClientConnectionEvent`].
582    fn decode(
583        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
584    ) -> Result<QrtrClientConnectionEvent, fidl::Error> {
585        let (bytes, _handles) = buf.split_mut();
586        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
587        debug_assert_eq!(tx_header.tx_id, 0);
588        match tx_header.ordinal {
589            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
590                Ok(QrtrClientConnectionEvent::_UnknownEvent { ordinal: tx_header.ordinal })
591            }
592            _ => Err(fidl::Error::UnknownOrdinal {
593                ordinal: tx_header.ordinal,
594                protocol_name:
595                    <QrtrClientConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
596            }),
597        }
598    }
599}
600
601/// A Stream of incoming requests for fuchsia.hardware.qualcomm.router/QrtrClientConnection.
602pub struct QrtrClientConnectionRequestStream {
603    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
604    is_terminated: bool,
605}
606
607impl std::marker::Unpin for QrtrClientConnectionRequestStream {}
608
609impl futures::stream::FusedStream for QrtrClientConnectionRequestStream {
610    fn is_terminated(&self) -> bool {
611        self.is_terminated
612    }
613}
614
615impl fidl::endpoints::RequestStream for QrtrClientConnectionRequestStream {
616    type Protocol = QrtrClientConnectionMarker;
617    type ControlHandle = QrtrClientConnectionControlHandle;
618
619    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
620        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
621    }
622
623    fn control_handle(&self) -> Self::ControlHandle {
624        QrtrClientConnectionControlHandle { inner: self.inner.clone() }
625    }
626
627    fn into_inner(
628        self,
629    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
630    {
631        (self.inner, self.is_terminated)
632    }
633
634    fn from_inner(
635        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
636        is_terminated: bool,
637    ) -> Self {
638        Self { inner, is_terminated }
639    }
640}
641
642impl futures::Stream for QrtrClientConnectionRequestStream {
643    type Item = Result<QrtrClientConnectionRequest, fidl::Error>;
644
645    fn poll_next(
646        mut self: std::pin::Pin<&mut Self>,
647        cx: &mut std::task::Context<'_>,
648    ) -> std::task::Poll<Option<Self::Item>> {
649        let this = &mut *self;
650        if this.inner.check_shutdown(cx) {
651            this.is_terminated = true;
652            return std::task::Poll::Ready(None);
653        }
654        if this.is_terminated {
655            panic!("polled QrtrClientConnectionRequestStream after completion");
656        }
657        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
658            |bytes, handles| {
659                match this.inner.channel().read_etc(cx, bytes, handles) {
660                    std::task::Poll::Ready(Ok(())) => {}
661                    std::task::Poll::Pending => return std::task::Poll::Pending,
662                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
663                        this.is_terminated = true;
664                        return std::task::Poll::Ready(None);
665                    }
666                    std::task::Poll::Ready(Err(e)) => {
667                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
668                            e.into(),
669                        ))));
670                    }
671                }
672
673                // A message has been received from the channel
674                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
675
676                std::task::Poll::Ready(Some(match header.ordinal {
677                0x1647cf125346d619 => {
678                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
679                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
680                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
681                    let control_handle = QrtrClientConnectionControlHandle {
682                        inner: this.inner.clone(),
683                    };
684                    Ok(QrtrClientConnectionRequest::Read {
685                        responder: QrtrClientConnectionReadResponder {
686                            control_handle: std::mem::ManuallyDrop::new(control_handle),
687                            tx_id: header.tx_id,
688                        },
689                    })
690                }
691                0x777f5423e2e75f51 => {
692                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
693                    let mut req = fidl::new_empty!(QrtrClientConnectionWriteRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
694                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<QrtrClientConnectionWriteRequest>(&header, _body_bytes, handles, &mut req)?;
695                    let control_handle = QrtrClientConnectionControlHandle {
696                        inner: this.inner.clone(),
697                    };
698                    Ok(QrtrClientConnectionRequest::Write {dst_node_id: req.dst_node_id,
699dst_port: req.dst_port,
700data: req.data,
701
702                        responder: QrtrClientConnectionWriteResponder {
703                            control_handle: std::mem::ManuallyDrop::new(control_handle),
704                            tx_id: header.tx_id,
705                        },
706                    })
707                }
708                0x6a71227b57862ad7 => {
709                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
710                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
711                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
712                    let control_handle = QrtrClientConnectionControlHandle {
713                        inner: this.inner.clone(),
714                    };
715                    Ok(QrtrClientConnectionRequest::GetSignals {
716                        responder: QrtrClientConnectionGetSignalsResponder {
717                            control_handle: std::mem::ManuallyDrop::new(control_handle),
718                            tx_id: header.tx_id,
719                        },
720                    })
721                }
722                0xb66d6d257f16ad2 => {
723                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
724                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
725                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
726                    let control_handle = QrtrClientConnectionControlHandle {
727                        inner: this.inner.clone(),
728                    };
729                    Ok(QrtrClientConnectionRequest::GetPortId {
730                        responder: QrtrClientConnectionGetPortIdResponder {
731                            control_handle: std::mem::ManuallyDrop::new(control_handle),
732                            tx_id: header.tx_id,
733                        },
734                    })
735                }
736                0x2ddd28cdb89d2c44 => {
737                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
738                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
739                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
740                    let control_handle = QrtrClientConnectionControlHandle {
741                        inner: this.inner.clone(),
742                    };
743                    Ok(QrtrClientConnectionRequest::GetNodeId {
744                        responder: QrtrClientConnectionGetNodeIdResponder {
745                            control_handle: std::mem::ManuallyDrop::new(control_handle),
746                            tx_id: header.tx_id,
747                        },
748                    })
749                }
750                0x4645ccec1b86380f => {
751                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
752                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
753                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
754                    let control_handle = QrtrClientConnectionControlHandle {
755                        inner: this.inner.clone(),
756                    };
757                    Ok(QrtrClientConnectionRequest::CloseConnection {
758                        responder: QrtrClientConnectionCloseConnectionResponder {
759                            control_handle: std::mem::ManuallyDrop::new(control_handle),
760                            tx_id: header.tx_id,
761                        },
762                    })
763                }
764                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
765                    Ok(QrtrClientConnectionRequest::_UnknownMethod {
766                        ordinal: header.ordinal,
767                        control_handle: QrtrClientConnectionControlHandle { inner: this.inner.clone() },
768                        method_type: fidl::MethodType::OneWay,
769                    })
770                }
771                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
772                    this.inner.send_framework_err(
773                        fidl::encoding::FrameworkErr::UnknownMethod,
774                        header.tx_id,
775                        header.ordinal,
776                        header.dynamic_flags(),
777                        (bytes, handles),
778                    )?;
779                    Ok(QrtrClientConnectionRequest::_UnknownMethod {
780                        ordinal: header.ordinal,
781                        control_handle: QrtrClientConnectionControlHandle { inner: this.inner.clone() },
782                        method_type: fidl::MethodType::TwoWay,
783                    })
784                }
785                _ => Err(fidl::Error::UnknownOrdinal {
786                    ordinal: header.ordinal,
787                    protocol_name: <QrtrClientConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
788                }),
789            }))
790            },
791        )
792    }
793}
794
795/// The connection used between a QRTR client and the QRTR driver.
796#[derive(Debug)]
797pub enum QrtrClientConnectionRequest {
798    /// Reads a QRTR frame via the connection.
799    ///
800    /// Only one read request can be performed at a time.
801    /// - `src_node_id`: Source node ID of the QRTR frame.
802    /// - `src_port`: Source port of the QRTR frame.
803    /// - `data`: QRTR payload.
804    /// * Errors:
805    ///   - `WOULD_BLOCK`: Cannot read; should wait in non-blocking mode.
806    ///   - `ALREADY_PENDING`: More than one read operation is pending in blocking mode.
807    ///   - `INTERNAL_ERROR`: Unexpected QRTR error.
808    Read { responder: QrtrClientConnectionReadResponder },
809    /// Writes a QRTR frame.
810    ///
811    /// Only one write request can be performed at a time.
812    /// * Errors:
813    ///   - `WOULD_BLOCK`: Cannot write; should wait in non-blocking mode.
814    ///   - `ALREADY_PENDING`: More than one write operation is pending in blocking mode.
815    ///   - `REMOTE_NODE_UNAVAILABLE`: Target node unavailable.
816    ///   - `INTERNAL_ERROR`: Unexpected QRTR error.
817    Write {
818        dst_node_id: u32,
819        dst_port: u32,
820        data: Vec<u8>,
821        responder: QrtrClientConnectionWriteResponder,
822    },
823    /// Retrieves the signals eventpair.
824    ///
825    /// - response `signals` an eventpair that is signalled with
826    ///            `SIGNAL_READABLE` and `SIGNAL_WRITABLE` when
827    ///            read and write buffers are available, respectively.
828    GetSignals { responder: QrtrClientConnectionGetSignalsResponder },
829    /// Retrieves the port id.
830    GetPortId { responder: QrtrClientConnectionGetPortIdResponder },
831    /// Retrieves the node id of AP.
832    GetNodeId { responder: QrtrClientConnectionGetNodeIdResponder },
833    /// Close the connection.
834    ///
835    /// Server end drops its end of the channel after replying. This can be
836    /// used for synchronous resource release.
837    CloseConnection { responder: QrtrClientConnectionCloseConnectionResponder },
838    /// An interaction was received which does not match any known method.
839    #[non_exhaustive]
840    _UnknownMethod {
841        /// Ordinal of the method that was called.
842        ordinal: u64,
843        control_handle: QrtrClientConnectionControlHandle,
844        method_type: fidl::MethodType,
845    },
846}
847
848impl QrtrClientConnectionRequest {
849    #[allow(irrefutable_let_patterns)]
850    pub fn into_read(self) -> Option<(QrtrClientConnectionReadResponder)> {
851        if let QrtrClientConnectionRequest::Read { responder } = self {
852            Some((responder))
853        } else {
854            None
855        }
856    }
857
858    #[allow(irrefutable_let_patterns)]
859    pub fn into_write(self) -> Option<(u32, u32, Vec<u8>, QrtrClientConnectionWriteResponder)> {
860        if let QrtrClientConnectionRequest::Write { dst_node_id, dst_port, data, responder } = self
861        {
862            Some((dst_node_id, dst_port, data, responder))
863        } else {
864            None
865        }
866    }
867
868    #[allow(irrefutable_let_patterns)]
869    pub fn into_get_signals(self) -> Option<(QrtrClientConnectionGetSignalsResponder)> {
870        if let QrtrClientConnectionRequest::GetSignals { responder } = self {
871            Some((responder))
872        } else {
873            None
874        }
875    }
876
877    #[allow(irrefutable_let_patterns)]
878    pub fn into_get_port_id(self) -> Option<(QrtrClientConnectionGetPortIdResponder)> {
879        if let QrtrClientConnectionRequest::GetPortId { responder } = self {
880            Some((responder))
881        } else {
882            None
883        }
884    }
885
886    #[allow(irrefutable_let_patterns)]
887    pub fn into_get_node_id(self) -> Option<(QrtrClientConnectionGetNodeIdResponder)> {
888        if let QrtrClientConnectionRequest::GetNodeId { responder } = self {
889            Some((responder))
890        } else {
891            None
892        }
893    }
894
895    #[allow(irrefutable_let_patterns)]
896    pub fn into_close_connection(self) -> Option<(QrtrClientConnectionCloseConnectionResponder)> {
897        if let QrtrClientConnectionRequest::CloseConnection { responder } = self {
898            Some((responder))
899        } else {
900            None
901        }
902    }
903
904    /// Name of the method defined in FIDL
905    pub fn method_name(&self) -> &'static str {
906        match *self {
907            QrtrClientConnectionRequest::Read { .. } => "read",
908            QrtrClientConnectionRequest::Write { .. } => "write",
909            QrtrClientConnectionRequest::GetSignals { .. } => "get_signals",
910            QrtrClientConnectionRequest::GetPortId { .. } => "get_port_id",
911            QrtrClientConnectionRequest::GetNodeId { .. } => "get_node_id",
912            QrtrClientConnectionRequest::CloseConnection { .. } => "close_connection",
913            QrtrClientConnectionRequest::_UnknownMethod {
914                method_type: fidl::MethodType::OneWay,
915                ..
916            } => "unknown one-way method",
917            QrtrClientConnectionRequest::_UnknownMethod {
918                method_type: fidl::MethodType::TwoWay,
919                ..
920            } => "unknown two-way method",
921        }
922    }
923}
924
925#[derive(Debug, Clone)]
926pub struct QrtrClientConnectionControlHandle {
927    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
928}
929
930impl QrtrClientConnectionControlHandle {
931    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
932        self.inner.shutdown_with_epitaph(status.into())
933    }
934}
935
936impl fidl::endpoints::ControlHandle for QrtrClientConnectionControlHandle {
937    fn shutdown(&self) {
938        self.inner.shutdown()
939    }
940
941    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
942        self.inner.shutdown_with_epitaph(status)
943    }
944
945    fn is_closed(&self) -> bool {
946        self.inner.channel().is_closed()
947    }
948    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
949        self.inner.channel().on_closed()
950    }
951
952    #[cfg(target_os = "fuchsia")]
953    fn signal_peer(
954        &self,
955        clear_mask: zx::Signals,
956        set_mask: zx::Signals,
957    ) -> Result<(), zx_status::Status> {
958        use fidl::Peered;
959        self.inner.channel().signal_peer(clear_mask, set_mask)
960    }
961}
962
963impl QrtrClientConnectionControlHandle {}
964
965#[must_use = "FIDL methods require a response to be sent"]
966#[derive(Debug)]
967pub struct QrtrClientConnectionReadResponder {
968    control_handle: std::mem::ManuallyDrop<QrtrClientConnectionControlHandle>,
969    tx_id: u32,
970}
971
972/// Set the the channel to be shutdown (see [`QrtrClientConnectionControlHandle::shutdown`])
973/// if the responder is dropped without sending a response, so that the client
974/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
975impl std::ops::Drop for QrtrClientConnectionReadResponder {
976    fn drop(&mut self) {
977        self.control_handle.shutdown();
978        // Safety: drops once, never accessed again
979        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
980    }
981}
982
983impl fidl::endpoints::Responder for QrtrClientConnectionReadResponder {
984    type ControlHandle = QrtrClientConnectionControlHandle;
985
986    fn control_handle(&self) -> &QrtrClientConnectionControlHandle {
987        &self.control_handle
988    }
989
990    fn drop_without_shutdown(mut self) {
991        // Safety: drops once, never accessed again due to mem::forget
992        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
993        // Prevent Drop from running (which would shut down the channel)
994        std::mem::forget(self);
995    }
996}
997
998impl QrtrClientConnectionReadResponder {
999    /// Sends a response to the FIDL transaction.
1000    ///
1001    /// Sets the channel to shutdown if an error occurs.
1002    pub fn send(self, mut result: Result<(u32, u32, &[u8]), Error>) -> Result<(), fidl::Error> {
1003        let _result = self.send_raw(result);
1004        if _result.is_err() {
1005            self.control_handle.shutdown();
1006        }
1007        self.drop_without_shutdown();
1008        _result
1009    }
1010
1011    /// Similar to "send" but does not shutdown the channel if an error occurs.
1012    pub fn send_no_shutdown_on_err(
1013        self,
1014        mut result: Result<(u32, u32, &[u8]), Error>,
1015    ) -> Result<(), fidl::Error> {
1016        let _result = self.send_raw(result);
1017        self.drop_without_shutdown();
1018        _result
1019    }
1020
1021    fn send_raw(&self, mut result: Result<(u32, u32, &[u8]), Error>) -> Result<(), fidl::Error> {
1022        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1023            QrtrClientConnectionReadResponse,
1024            Error,
1025        >>(
1026            fidl::encoding::FlexibleResult::new(result),
1027            self.tx_id,
1028            0x1647cf125346d619,
1029            fidl::encoding::DynamicFlags::FLEXIBLE,
1030        )
1031    }
1032}
1033
1034#[must_use = "FIDL methods require a response to be sent"]
1035#[derive(Debug)]
1036pub struct QrtrClientConnectionWriteResponder {
1037    control_handle: std::mem::ManuallyDrop<QrtrClientConnectionControlHandle>,
1038    tx_id: u32,
1039}
1040
1041/// Set the the channel to be shutdown (see [`QrtrClientConnectionControlHandle::shutdown`])
1042/// if the responder is dropped without sending a response, so that the client
1043/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1044impl std::ops::Drop for QrtrClientConnectionWriteResponder {
1045    fn drop(&mut self) {
1046        self.control_handle.shutdown();
1047        // Safety: drops once, never accessed again
1048        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1049    }
1050}
1051
1052impl fidl::endpoints::Responder for QrtrClientConnectionWriteResponder {
1053    type ControlHandle = QrtrClientConnectionControlHandle;
1054
1055    fn control_handle(&self) -> &QrtrClientConnectionControlHandle {
1056        &self.control_handle
1057    }
1058
1059    fn drop_without_shutdown(mut self) {
1060        // Safety: drops once, never accessed again due to mem::forget
1061        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1062        // Prevent Drop from running (which would shut down the channel)
1063        std::mem::forget(self);
1064    }
1065}
1066
1067impl QrtrClientConnectionWriteResponder {
1068    /// Sends a response to the FIDL transaction.
1069    ///
1070    /// Sets the channel to shutdown if an error occurs.
1071    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1072        let _result = self.send_raw(result);
1073        if _result.is_err() {
1074            self.control_handle.shutdown();
1075        }
1076        self.drop_without_shutdown();
1077        _result
1078    }
1079
1080    /// Similar to "send" but does not shutdown the channel if an error occurs.
1081    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1082        let _result = self.send_raw(result);
1083        self.drop_without_shutdown();
1084        _result
1085    }
1086
1087    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1088        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1089            fidl::encoding::EmptyStruct,
1090            Error,
1091        >>(
1092            fidl::encoding::FlexibleResult::new(result),
1093            self.tx_id,
1094            0x777f5423e2e75f51,
1095            fidl::encoding::DynamicFlags::FLEXIBLE,
1096        )
1097    }
1098}
1099
1100#[must_use = "FIDL methods require a response to be sent"]
1101#[derive(Debug)]
1102pub struct QrtrClientConnectionGetSignalsResponder {
1103    control_handle: std::mem::ManuallyDrop<QrtrClientConnectionControlHandle>,
1104    tx_id: u32,
1105}
1106
1107/// Set the the channel to be shutdown (see [`QrtrClientConnectionControlHandle::shutdown`])
1108/// if the responder is dropped without sending a response, so that the client
1109/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1110impl std::ops::Drop for QrtrClientConnectionGetSignalsResponder {
1111    fn drop(&mut self) {
1112        self.control_handle.shutdown();
1113        // Safety: drops once, never accessed again
1114        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1115    }
1116}
1117
1118impl fidl::endpoints::Responder for QrtrClientConnectionGetSignalsResponder {
1119    type ControlHandle = QrtrClientConnectionControlHandle;
1120
1121    fn control_handle(&self) -> &QrtrClientConnectionControlHandle {
1122        &self.control_handle
1123    }
1124
1125    fn drop_without_shutdown(mut self) {
1126        // Safety: drops once, never accessed again due to mem::forget
1127        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1128        // Prevent Drop from running (which would shut down the channel)
1129        std::mem::forget(self);
1130    }
1131}
1132
1133impl QrtrClientConnectionGetSignalsResponder {
1134    /// Sends a response to the FIDL transaction.
1135    ///
1136    /// Sets the channel to shutdown if an error occurs.
1137    pub fn send(self, mut signals: fidl::EventPair) -> Result<(), fidl::Error> {
1138        let _result = self.send_raw(signals);
1139        if _result.is_err() {
1140            self.control_handle.shutdown();
1141        }
1142        self.drop_without_shutdown();
1143        _result
1144    }
1145
1146    /// Similar to "send" but does not shutdown the channel if an error occurs.
1147    pub fn send_no_shutdown_on_err(self, mut signals: fidl::EventPair) -> Result<(), fidl::Error> {
1148        let _result = self.send_raw(signals);
1149        self.drop_without_shutdown();
1150        _result
1151    }
1152
1153    fn send_raw(&self, mut signals: fidl::EventPair) -> Result<(), fidl::Error> {
1154        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1155            QrtrClientConnectionGetSignalsResponse,
1156        >>(
1157            fidl::encoding::Flexible::new((signals,)),
1158            self.tx_id,
1159            0x6a71227b57862ad7,
1160            fidl::encoding::DynamicFlags::FLEXIBLE,
1161        )
1162    }
1163}
1164
1165#[must_use = "FIDL methods require a response to be sent"]
1166#[derive(Debug)]
1167pub struct QrtrClientConnectionGetPortIdResponder {
1168    control_handle: std::mem::ManuallyDrop<QrtrClientConnectionControlHandle>,
1169    tx_id: u32,
1170}
1171
1172/// Set the the channel to be shutdown (see [`QrtrClientConnectionControlHandle::shutdown`])
1173/// if the responder is dropped without sending a response, so that the client
1174/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1175impl std::ops::Drop for QrtrClientConnectionGetPortIdResponder {
1176    fn drop(&mut self) {
1177        self.control_handle.shutdown();
1178        // Safety: drops once, never accessed again
1179        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1180    }
1181}
1182
1183impl fidl::endpoints::Responder for QrtrClientConnectionGetPortIdResponder {
1184    type ControlHandle = QrtrClientConnectionControlHandle;
1185
1186    fn control_handle(&self) -> &QrtrClientConnectionControlHandle {
1187        &self.control_handle
1188    }
1189
1190    fn drop_without_shutdown(mut self) {
1191        // Safety: drops once, never accessed again due to mem::forget
1192        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1193        // Prevent Drop from running (which would shut down the channel)
1194        std::mem::forget(self);
1195    }
1196}
1197
1198impl QrtrClientConnectionGetPortIdResponder {
1199    /// Sends a response to the FIDL transaction.
1200    ///
1201    /// Sets the channel to shutdown if an error occurs.
1202    pub fn send(self, mut port_id: u32) -> Result<(), fidl::Error> {
1203        let _result = self.send_raw(port_id);
1204        if _result.is_err() {
1205            self.control_handle.shutdown();
1206        }
1207        self.drop_without_shutdown();
1208        _result
1209    }
1210
1211    /// Similar to "send" but does not shutdown the channel if an error occurs.
1212    pub fn send_no_shutdown_on_err(self, mut port_id: u32) -> Result<(), fidl::Error> {
1213        let _result = self.send_raw(port_id);
1214        self.drop_without_shutdown();
1215        _result
1216    }
1217
1218    fn send_raw(&self, mut port_id: u32) -> Result<(), fidl::Error> {
1219        self.control_handle
1220            .inner
1221            .send::<fidl::encoding::FlexibleType<QrtrClientConnectionGetPortIdResponse>>(
1222                fidl::encoding::Flexible::new((port_id,)),
1223                self.tx_id,
1224                0xb66d6d257f16ad2,
1225                fidl::encoding::DynamicFlags::FLEXIBLE,
1226            )
1227    }
1228}
1229
1230#[must_use = "FIDL methods require a response to be sent"]
1231#[derive(Debug)]
1232pub struct QrtrClientConnectionGetNodeIdResponder {
1233    control_handle: std::mem::ManuallyDrop<QrtrClientConnectionControlHandle>,
1234    tx_id: u32,
1235}
1236
1237/// Set the the channel to be shutdown (see [`QrtrClientConnectionControlHandle::shutdown`])
1238/// if the responder is dropped without sending a response, so that the client
1239/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1240impl std::ops::Drop for QrtrClientConnectionGetNodeIdResponder {
1241    fn drop(&mut self) {
1242        self.control_handle.shutdown();
1243        // Safety: drops once, never accessed again
1244        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1245    }
1246}
1247
1248impl fidl::endpoints::Responder for QrtrClientConnectionGetNodeIdResponder {
1249    type ControlHandle = QrtrClientConnectionControlHandle;
1250
1251    fn control_handle(&self) -> &QrtrClientConnectionControlHandle {
1252        &self.control_handle
1253    }
1254
1255    fn drop_without_shutdown(mut self) {
1256        // Safety: drops once, never accessed again due to mem::forget
1257        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1258        // Prevent Drop from running (which would shut down the channel)
1259        std::mem::forget(self);
1260    }
1261}
1262
1263impl QrtrClientConnectionGetNodeIdResponder {
1264    /// Sends a response to the FIDL transaction.
1265    ///
1266    /// Sets the channel to shutdown if an error occurs.
1267    pub fn send(self, mut node_id: u32) -> Result<(), fidl::Error> {
1268        let _result = self.send_raw(node_id);
1269        if _result.is_err() {
1270            self.control_handle.shutdown();
1271        }
1272        self.drop_without_shutdown();
1273        _result
1274    }
1275
1276    /// Similar to "send" but does not shutdown the channel if an error occurs.
1277    pub fn send_no_shutdown_on_err(self, mut node_id: u32) -> Result<(), fidl::Error> {
1278        let _result = self.send_raw(node_id);
1279        self.drop_without_shutdown();
1280        _result
1281    }
1282
1283    fn send_raw(&self, mut node_id: u32) -> Result<(), fidl::Error> {
1284        self.control_handle
1285            .inner
1286            .send::<fidl::encoding::FlexibleType<QrtrClientConnectionGetNodeIdResponse>>(
1287                fidl::encoding::Flexible::new((node_id,)),
1288                self.tx_id,
1289                0x2ddd28cdb89d2c44,
1290                fidl::encoding::DynamicFlags::FLEXIBLE,
1291            )
1292    }
1293}
1294
1295#[must_use = "FIDL methods require a response to be sent"]
1296#[derive(Debug)]
1297pub struct QrtrClientConnectionCloseConnectionResponder {
1298    control_handle: std::mem::ManuallyDrop<QrtrClientConnectionControlHandle>,
1299    tx_id: u32,
1300}
1301
1302/// Set the the channel to be shutdown (see [`QrtrClientConnectionControlHandle::shutdown`])
1303/// if the responder is dropped without sending a response, so that the client
1304/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1305impl std::ops::Drop for QrtrClientConnectionCloseConnectionResponder {
1306    fn drop(&mut self) {
1307        self.control_handle.shutdown();
1308        // Safety: drops once, never accessed again
1309        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1310    }
1311}
1312
1313impl fidl::endpoints::Responder for QrtrClientConnectionCloseConnectionResponder {
1314    type ControlHandle = QrtrClientConnectionControlHandle;
1315
1316    fn control_handle(&self) -> &QrtrClientConnectionControlHandle {
1317        &self.control_handle
1318    }
1319
1320    fn drop_without_shutdown(mut self) {
1321        // Safety: drops once, never accessed again due to mem::forget
1322        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1323        // Prevent Drop from running (which would shut down the channel)
1324        std::mem::forget(self);
1325    }
1326}
1327
1328impl QrtrClientConnectionCloseConnectionResponder {
1329    /// Sends a response to the FIDL transaction.
1330    ///
1331    /// Sets the channel to shutdown if an error occurs.
1332    pub fn send(self) -> Result<(), fidl::Error> {
1333        let _result = self.send_raw();
1334        if _result.is_err() {
1335            self.control_handle.shutdown();
1336        }
1337        self.drop_without_shutdown();
1338        _result
1339    }
1340
1341    /// Similar to "send" but does not shutdown the channel if an error occurs.
1342    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1343        let _result = self.send_raw();
1344        self.drop_without_shutdown();
1345        _result
1346    }
1347
1348    fn send_raw(&self) -> Result<(), fidl::Error> {
1349        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
1350            fidl::encoding::Flexible::new(()),
1351            self.tx_id,
1352            0x4645ccec1b86380f,
1353            fidl::encoding::DynamicFlags::FLEXIBLE,
1354        )
1355    }
1356}
1357
1358#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1359pub struct QrtrConnectorMarker;
1360
1361impl fidl::endpoints::ProtocolMarker for QrtrConnectorMarker {
1362    type Proxy = QrtrConnectorProxy;
1363    type RequestStream = QrtrConnectorRequestStream;
1364    #[cfg(target_os = "fuchsia")]
1365    type SynchronousProxy = QrtrConnectorSynchronousProxy;
1366
1367    const DEBUG_NAME: &'static str = "fuchsia.hardware.qualcomm.router.QrtrConnector";
1368}
1369impl fidl::endpoints::DiscoverableProtocolMarker for QrtrConnectorMarker {}
1370pub type QrtrConnectorGetConnectionResult = Result<(), Error>;
1371
1372pub trait QrtrConnectorProxyInterface: Send + Sync {
1373    type GetConnectionResponseFut: std::future::Future<Output = Result<QrtrConnectorGetConnectionResult, fidl::Error>>
1374        + Send;
1375    fn r#get_connection(
1376        &self,
1377        options: &ConnectionOptions,
1378        proxy: fidl::endpoints::ServerEnd<QrtrClientConnectionMarker>,
1379    ) -> Self::GetConnectionResponseFut;
1380}
1381#[derive(Debug)]
1382#[cfg(target_os = "fuchsia")]
1383pub struct QrtrConnectorSynchronousProxy {
1384    client: fidl::client::sync::Client,
1385}
1386
1387#[cfg(target_os = "fuchsia")]
1388impl fidl::endpoints::SynchronousProxy for QrtrConnectorSynchronousProxy {
1389    type Proxy = QrtrConnectorProxy;
1390    type Protocol = QrtrConnectorMarker;
1391
1392    fn from_channel(inner: fidl::Channel) -> Self {
1393        Self::new(inner)
1394    }
1395
1396    fn into_channel(self) -> fidl::Channel {
1397        self.client.into_channel()
1398    }
1399
1400    fn as_channel(&self) -> &fidl::Channel {
1401        self.client.as_channel()
1402    }
1403}
1404
1405#[cfg(target_os = "fuchsia")]
1406impl QrtrConnectorSynchronousProxy {
1407    pub fn new(channel: fidl::Channel) -> Self {
1408        Self { client: fidl::client::sync::Client::new(channel) }
1409    }
1410
1411    pub fn into_channel(self) -> fidl::Channel {
1412        self.client.into_channel()
1413    }
1414
1415    /// Waits until an event arrives and returns it. It is safe for other
1416    /// threads to make concurrent requests while waiting for an event.
1417    pub fn wait_for_event(
1418        &self,
1419        deadline: zx::MonotonicInstant,
1420    ) -> Result<QrtrConnectorEvent, fidl::Error> {
1421        QrtrConnectorEvent::decode(self.client.wait_for_event::<QrtrConnectorMarker>(deadline)?)
1422    }
1423
1424    /// Gets a new connection from QRTR.
1425    ///
1426    /// If `port` is specificed in options, creates a connection with target
1427    /// port. Otherwise, assigns a random port for the connection.
1428    /// * Errors:
1429    ///   - `INTERNAL_ERROR`: Unexpected QRTR error.
1430    ///   - `INVALID_ARGS`: Invalid arguments in `ConnectionOptions`.
1431    ///   - `NO_RESOURCES`: No non-reserved port available.
1432    ///   - `ALREADY_BOUND`: Specified port in `ConnectionOptions` is in use.
1433    pub fn r#get_connection(
1434        &self,
1435        mut options: &ConnectionOptions,
1436        mut proxy: fidl::endpoints::ServerEnd<QrtrClientConnectionMarker>,
1437        ___deadline: zx::MonotonicInstant,
1438    ) -> Result<QrtrConnectorGetConnectionResult, fidl::Error> {
1439        let _response = self.client.send_query::<
1440            QrtrConnectorGetConnectionRequest,
1441            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1442            QrtrConnectorMarker,
1443        >(
1444            (options, proxy,),
1445            0x1df578179c1f2445,
1446            fidl::encoding::DynamicFlags::FLEXIBLE,
1447            ___deadline,
1448        )?
1449        .into_result::<QrtrConnectorMarker>("get_connection")?;
1450        Ok(_response.map(|x| x))
1451    }
1452}
1453
1454#[cfg(target_os = "fuchsia")]
1455impl From<QrtrConnectorSynchronousProxy> for zx::NullableHandle {
1456    fn from(value: QrtrConnectorSynchronousProxy) -> Self {
1457        value.into_channel().into()
1458    }
1459}
1460
1461#[cfg(target_os = "fuchsia")]
1462impl From<fidl::Channel> for QrtrConnectorSynchronousProxy {
1463    fn from(value: fidl::Channel) -> Self {
1464        Self::new(value)
1465    }
1466}
1467
1468#[cfg(target_os = "fuchsia")]
1469impl fidl::endpoints::FromClient for QrtrConnectorSynchronousProxy {
1470    type Protocol = QrtrConnectorMarker;
1471
1472    fn from_client(value: fidl::endpoints::ClientEnd<QrtrConnectorMarker>) -> Self {
1473        Self::new(value.into_channel())
1474    }
1475}
1476
1477#[derive(Debug, Clone)]
1478pub struct QrtrConnectorProxy {
1479    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1480}
1481
1482impl fidl::endpoints::Proxy for QrtrConnectorProxy {
1483    type Protocol = QrtrConnectorMarker;
1484
1485    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1486        Self::new(inner)
1487    }
1488
1489    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1490        self.client.into_channel().map_err(|client| Self { client })
1491    }
1492
1493    fn as_channel(&self) -> &::fidl::AsyncChannel {
1494        self.client.as_channel()
1495    }
1496}
1497
1498impl QrtrConnectorProxy {
1499    /// Create a new Proxy for fuchsia.hardware.qualcomm.router/QrtrConnector.
1500    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1501        let protocol_name = <QrtrConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1502        Self { client: fidl::client::Client::new(channel, protocol_name) }
1503    }
1504
1505    /// Get a Stream of events from the remote end of the protocol.
1506    ///
1507    /// # Panics
1508    ///
1509    /// Panics if the event stream was already taken.
1510    pub fn take_event_stream(&self) -> QrtrConnectorEventStream {
1511        QrtrConnectorEventStream { event_receiver: self.client.take_event_receiver() }
1512    }
1513
1514    /// Gets a new connection from QRTR.
1515    ///
1516    /// If `port` is specificed in options, creates a connection with target
1517    /// port. Otherwise, assigns a random port for the connection.
1518    /// * Errors:
1519    ///   - `INTERNAL_ERROR`: Unexpected QRTR error.
1520    ///   - `INVALID_ARGS`: Invalid arguments in `ConnectionOptions`.
1521    ///   - `NO_RESOURCES`: No non-reserved port available.
1522    ///   - `ALREADY_BOUND`: Specified port in `ConnectionOptions` is in use.
1523    pub fn r#get_connection(
1524        &self,
1525        mut options: &ConnectionOptions,
1526        mut proxy: fidl::endpoints::ServerEnd<QrtrClientConnectionMarker>,
1527    ) -> fidl::client::QueryResponseFut<
1528        QrtrConnectorGetConnectionResult,
1529        fidl::encoding::DefaultFuchsiaResourceDialect,
1530    > {
1531        QrtrConnectorProxyInterface::r#get_connection(self, options, proxy)
1532    }
1533}
1534
1535impl QrtrConnectorProxyInterface for QrtrConnectorProxy {
1536    type GetConnectionResponseFut = fidl::client::QueryResponseFut<
1537        QrtrConnectorGetConnectionResult,
1538        fidl::encoding::DefaultFuchsiaResourceDialect,
1539    >;
1540    fn r#get_connection(
1541        &self,
1542        mut options: &ConnectionOptions,
1543        mut proxy: fidl::endpoints::ServerEnd<QrtrClientConnectionMarker>,
1544    ) -> Self::GetConnectionResponseFut {
1545        fn _decode(
1546            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1547        ) -> Result<QrtrConnectorGetConnectionResult, fidl::Error> {
1548            let _response = fidl::client::decode_transaction_body::<
1549                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1550                fidl::encoding::DefaultFuchsiaResourceDialect,
1551                0x1df578179c1f2445,
1552            >(_buf?)?
1553            .into_result::<QrtrConnectorMarker>("get_connection")?;
1554            Ok(_response.map(|x| x))
1555        }
1556        self.client.send_query_and_decode::<
1557            QrtrConnectorGetConnectionRequest,
1558            QrtrConnectorGetConnectionResult,
1559        >(
1560            (options, proxy,),
1561            0x1df578179c1f2445,
1562            fidl::encoding::DynamicFlags::FLEXIBLE,
1563            _decode,
1564        )
1565    }
1566}
1567
1568pub struct QrtrConnectorEventStream {
1569    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1570}
1571
1572impl std::marker::Unpin for QrtrConnectorEventStream {}
1573
1574impl futures::stream::FusedStream for QrtrConnectorEventStream {
1575    fn is_terminated(&self) -> bool {
1576        self.event_receiver.is_terminated()
1577    }
1578}
1579
1580impl futures::Stream for QrtrConnectorEventStream {
1581    type Item = Result<QrtrConnectorEvent, fidl::Error>;
1582
1583    fn poll_next(
1584        mut self: std::pin::Pin<&mut Self>,
1585        cx: &mut std::task::Context<'_>,
1586    ) -> std::task::Poll<Option<Self::Item>> {
1587        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1588            &mut self.event_receiver,
1589            cx
1590        )?) {
1591            Some(buf) => std::task::Poll::Ready(Some(QrtrConnectorEvent::decode(buf))),
1592            None => std::task::Poll::Ready(None),
1593        }
1594    }
1595}
1596
1597#[derive(Debug)]
1598pub enum QrtrConnectorEvent {
1599    #[non_exhaustive]
1600    _UnknownEvent {
1601        /// Ordinal of the event that was sent.
1602        ordinal: u64,
1603    },
1604}
1605
1606impl QrtrConnectorEvent {
1607    /// Decodes a message buffer as a [`QrtrConnectorEvent`].
1608    fn decode(
1609        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1610    ) -> Result<QrtrConnectorEvent, fidl::Error> {
1611        let (bytes, _handles) = buf.split_mut();
1612        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1613        debug_assert_eq!(tx_header.tx_id, 0);
1614        match tx_header.ordinal {
1615            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1616                Ok(QrtrConnectorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1617            }
1618            _ => Err(fidl::Error::UnknownOrdinal {
1619                ordinal: tx_header.ordinal,
1620                protocol_name: <QrtrConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1621            }),
1622        }
1623    }
1624}
1625
1626/// A Stream of incoming requests for fuchsia.hardware.qualcomm.router/QrtrConnector.
1627pub struct QrtrConnectorRequestStream {
1628    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1629    is_terminated: bool,
1630}
1631
1632impl std::marker::Unpin for QrtrConnectorRequestStream {}
1633
1634impl futures::stream::FusedStream for QrtrConnectorRequestStream {
1635    fn is_terminated(&self) -> bool {
1636        self.is_terminated
1637    }
1638}
1639
1640impl fidl::endpoints::RequestStream for QrtrConnectorRequestStream {
1641    type Protocol = QrtrConnectorMarker;
1642    type ControlHandle = QrtrConnectorControlHandle;
1643
1644    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1645        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1646    }
1647
1648    fn control_handle(&self) -> Self::ControlHandle {
1649        QrtrConnectorControlHandle { inner: self.inner.clone() }
1650    }
1651
1652    fn into_inner(
1653        self,
1654    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1655    {
1656        (self.inner, self.is_terminated)
1657    }
1658
1659    fn from_inner(
1660        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1661        is_terminated: bool,
1662    ) -> Self {
1663        Self { inner, is_terminated }
1664    }
1665}
1666
1667impl futures::Stream for QrtrConnectorRequestStream {
1668    type Item = Result<QrtrConnectorRequest, fidl::Error>;
1669
1670    fn poll_next(
1671        mut self: std::pin::Pin<&mut Self>,
1672        cx: &mut std::task::Context<'_>,
1673    ) -> std::task::Poll<Option<Self::Item>> {
1674        let this = &mut *self;
1675        if this.inner.check_shutdown(cx) {
1676            this.is_terminated = true;
1677            return std::task::Poll::Ready(None);
1678        }
1679        if this.is_terminated {
1680            panic!("polled QrtrConnectorRequestStream after completion");
1681        }
1682        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1683            |bytes, handles| {
1684                match this.inner.channel().read_etc(cx, bytes, handles) {
1685                    std::task::Poll::Ready(Ok(())) => {}
1686                    std::task::Poll::Pending => return std::task::Poll::Pending,
1687                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1688                        this.is_terminated = true;
1689                        return std::task::Poll::Ready(None);
1690                    }
1691                    std::task::Poll::Ready(Err(e)) => {
1692                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1693                            e.into(),
1694                        ))));
1695                    }
1696                }
1697
1698                // A message has been received from the channel
1699                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1700
1701                std::task::Poll::Ready(Some(match header.ordinal {
1702                    0x1df578179c1f2445 => {
1703                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1704                        let mut req = fidl::new_empty!(
1705                            QrtrConnectorGetConnectionRequest,
1706                            fidl::encoding::DefaultFuchsiaResourceDialect
1707                        );
1708                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<QrtrConnectorGetConnectionRequest>(&header, _body_bytes, handles, &mut req)?;
1709                        let control_handle =
1710                            QrtrConnectorControlHandle { inner: this.inner.clone() };
1711                        Ok(QrtrConnectorRequest::GetConnection {
1712                            options: req.options,
1713                            proxy: req.proxy,
1714
1715                            responder: QrtrConnectorGetConnectionResponder {
1716                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1717                                tx_id: header.tx_id,
1718                            },
1719                        })
1720                    }
1721                    _ if header.tx_id == 0
1722                        && header
1723                            .dynamic_flags()
1724                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1725                    {
1726                        Ok(QrtrConnectorRequest::_UnknownMethod {
1727                            ordinal: header.ordinal,
1728                            control_handle: QrtrConnectorControlHandle {
1729                                inner: this.inner.clone(),
1730                            },
1731                            method_type: fidl::MethodType::OneWay,
1732                        })
1733                    }
1734                    _ if header
1735                        .dynamic_flags()
1736                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1737                    {
1738                        this.inner.send_framework_err(
1739                            fidl::encoding::FrameworkErr::UnknownMethod,
1740                            header.tx_id,
1741                            header.ordinal,
1742                            header.dynamic_flags(),
1743                            (bytes, handles),
1744                        )?;
1745                        Ok(QrtrConnectorRequest::_UnknownMethod {
1746                            ordinal: header.ordinal,
1747                            control_handle: QrtrConnectorControlHandle {
1748                                inner: this.inner.clone(),
1749                            },
1750                            method_type: fidl::MethodType::TwoWay,
1751                        })
1752                    }
1753                    _ => Err(fidl::Error::UnknownOrdinal {
1754                        ordinal: header.ordinal,
1755                        protocol_name:
1756                            <QrtrConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1757                    }),
1758                }))
1759            },
1760        )
1761    }
1762}
1763
1764/// Vends client connections with no access constraints in QRTR.
1765#[derive(Debug)]
1766pub enum QrtrConnectorRequest {
1767    /// Gets a new connection from QRTR.
1768    ///
1769    /// If `port` is specificed in options, creates a connection with target
1770    /// port. Otherwise, assigns a random port for the connection.
1771    /// * Errors:
1772    ///   - `INTERNAL_ERROR`: Unexpected QRTR error.
1773    ///   - `INVALID_ARGS`: Invalid arguments in `ConnectionOptions`.
1774    ///   - `NO_RESOURCES`: No non-reserved port available.
1775    ///   - `ALREADY_BOUND`: Specified port in `ConnectionOptions` is in use.
1776    GetConnection {
1777        options: ConnectionOptions,
1778        proxy: fidl::endpoints::ServerEnd<QrtrClientConnectionMarker>,
1779        responder: QrtrConnectorGetConnectionResponder,
1780    },
1781    /// An interaction was received which does not match any known method.
1782    #[non_exhaustive]
1783    _UnknownMethod {
1784        /// Ordinal of the method that was called.
1785        ordinal: u64,
1786        control_handle: QrtrConnectorControlHandle,
1787        method_type: fidl::MethodType,
1788    },
1789}
1790
1791impl QrtrConnectorRequest {
1792    #[allow(irrefutable_let_patterns)]
1793    pub fn into_get_connection(
1794        self,
1795    ) -> Option<(
1796        ConnectionOptions,
1797        fidl::endpoints::ServerEnd<QrtrClientConnectionMarker>,
1798        QrtrConnectorGetConnectionResponder,
1799    )> {
1800        if let QrtrConnectorRequest::GetConnection { options, proxy, responder } = self {
1801            Some((options, proxy, responder))
1802        } else {
1803            None
1804        }
1805    }
1806
1807    /// Name of the method defined in FIDL
1808    pub fn method_name(&self) -> &'static str {
1809        match *self {
1810            QrtrConnectorRequest::GetConnection { .. } => "get_connection",
1811            QrtrConnectorRequest::_UnknownMethod {
1812                method_type: fidl::MethodType::OneWay, ..
1813            } => "unknown one-way method",
1814            QrtrConnectorRequest::_UnknownMethod {
1815                method_type: fidl::MethodType::TwoWay, ..
1816            } => "unknown two-way method",
1817        }
1818    }
1819}
1820
1821#[derive(Debug, Clone)]
1822pub struct QrtrConnectorControlHandle {
1823    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1824}
1825
1826impl QrtrConnectorControlHandle {
1827    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1828        self.inner.shutdown_with_epitaph(status.into())
1829    }
1830}
1831
1832impl fidl::endpoints::ControlHandle for QrtrConnectorControlHandle {
1833    fn shutdown(&self) {
1834        self.inner.shutdown()
1835    }
1836
1837    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1838        self.inner.shutdown_with_epitaph(status)
1839    }
1840
1841    fn is_closed(&self) -> bool {
1842        self.inner.channel().is_closed()
1843    }
1844    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1845        self.inner.channel().on_closed()
1846    }
1847
1848    #[cfg(target_os = "fuchsia")]
1849    fn signal_peer(
1850        &self,
1851        clear_mask: zx::Signals,
1852        set_mask: zx::Signals,
1853    ) -> Result<(), zx_status::Status> {
1854        use fidl::Peered;
1855        self.inner.channel().signal_peer(clear_mask, set_mask)
1856    }
1857}
1858
1859impl QrtrConnectorControlHandle {}
1860
1861#[must_use = "FIDL methods require a response to be sent"]
1862#[derive(Debug)]
1863pub struct QrtrConnectorGetConnectionResponder {
1864    control_handle: std::mem::ManuallyDrop<QrtrConnectorControlHandle>,
1865    tx_id: u32,
1866}
1867
1868/// Set the the channel to be shutdown (see [`QrtrConnectorControlHandle::shutdown`])
1869/// if the responder is dropped without sending a response, so that the client
1870/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1871impl std::ops::Drop for QrtrConnectorGetConnectionResponder {
1872    fn drop(&mut self) {
1873        self.control_handle.shutdown();
1874        // Safety: drops once, never accessed again
1875        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1876    }
1877}
1878
1879impl fidl::endpoints::Responder for QrtrConnectorGetConnectionResponder {
1880    type ControlHandle = QrtrConnectorControlHandle;
1881
1882    fn control_handle(&self) -> &QrtrConnectorControlHandle {
1883        &self.control_handle
1884    }
1885
1886    fn drop_without_shutdown(mut self) {
1887        // Safety: drops once, never accessed again due to mem::forget
1888        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1889        // Prevent Drop from running (which would shut down the channel)
1890        std::mem::forget(self);
1891    }
1892}
1893
1894impl QrtrConnectorGetConnectionResponder {
1895    /// Sends a response to the FIDL transaction.
1896    ///
1897    /// Sets the channel to shutdown if an error occurs.
1898    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1899        let _result = self.send_raw(result);
1900        if _result.is_err() {
1901            self.control_handle.shutdown();
1902        }
1903        self.drop_without_shutdown();
1904        _result
1905    }
1906
1907    /// Similar to "send" but does not shutdown the channel if an error occurs.
1908    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1909        let _result = self.send_raw(result);
1910        self.drop_without_shutdown();
1911        _result
1912    }
1913
1914    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1915        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1916            fidl::encoding::EmptyStruct,
1917            Error,
1918        >>(
1919            fidl::encoding::FlexibleResult::new(result),
1920            self.tx_id,
1921            0x1df578179c1f2445,
1922            fidl::encoding::DynamicFlags::FLEXIBLE,
1923        )
1924    }
1925}
1926
1927#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1928pub struct QrtrTransportChannelMarker;
1929
1930impl fidl::endpoints::ProtocolMarker for QrtrTransportChannelMarker {
1931    type Proxy = QrtrTransportChannelProxy;
1932    type RequestStream = QrtrTransportChannelRequestStream;
1933    #[cfg(target_os = "fuchsia")]
1934    type SynchronousProxy = QrtrTransportChannelSynchronousProxy;
1935
1936    const DEBUG_NAME: &'static str = "(anonymous) QrtrTransportChannel";
1937}
1938pub type QrtrTransportChannelReadResult = Result<Vec<u8>, Error>;
1939pub type QrtrTransportChannelWriteResult = Result<(), Error>;
1940
1941pub trait QrtrTransportChannelProxyInterface: Send + Sync {
1942    type ReadResponseFut: std::future::Future<Output = Result<QrtrTransportChannelReadResult, fidl::Error>>
1943        + Send;
1944    fn r#read(&self) -> Self::ReadResponseFut;
1945    type WriteResponseFut: std::future::Future<Output = Result<QrtrTransportChannelWriteResult, fidl::Error>>
1946        + Send;
1947    fn r#write(&self, data: &[u8]) -> Self::WriteResponseFut;
1948}
1949#[derive(Debug)]
1950#[cfg(target_os = "fuchsia")]
1951pub struct QrtrTransportChannelSynchronousProxy {
1952    client: fidl::client::sync::Client,
1953}
1954
1955#[cfg(target_os = "fuchsia")]
1956impl fidl::endpoints::SynchronousProxy for QrtrTransportChannelSynchronousProxy {
1957    type Proxy = QrtrTransportChannelProxy;
1958    type Protocol = QrtrTransportChannelMarker;
1959
1960    fn from_channel(inner: fidl::Channel) -> Self {
1961        Self::new(inner)
1962    }
1963
1964    fn into_channel(self) -> fidl::Channel {
1965        self.client.into_channel()
1966    }
1967
1968    fn as_channel(&self) -> &fidl::Channel {
1969        self.client.as_channel()
1970    }
1971}
1972
1973#[cfg(target_os = "fuchsia")]
1974impl QrtrTransportChannelSynchronousProxy {
1975    pub fn new(channel: fidl::Channel) -> Self {
1976        Self { client: fidl::client::sync::Client::new(channel) }
1977    }
1978
1979    pub fn into_channel(self) -> fidl::Channel {
1980        self.client.into_channel()
1981    }
1982
1983    /// Waits until an event arrives and returns it. It is safe for other
1984    /// threads to make concurrent requests while waiting for an event.
1985    pub fn wait_for_event(
1986        &self,
1987        deadline: zx::MonotonicInstant,
1988    ) -> Result<QrtrTransportChannelEvent, fidl::Error> {
1989        QrtrTransportChannelEvent::decode(
1990            self.client.wait_for_event::<QrtrTransportChannelMarker>(deadline)?,
1991        )
1992    }
1993
1994    /// Reads a QRTR frame from a transport driver.
1995    ///
1996    /// Blocks until an inbound frame is ready to be consumed.
1997    /// Only one read request can be performed at a time.
1998    /// - `data`: QRTR frame.
1999    /// * Errors:
2000    ///   - `ALREADY_PENDING`: More than one read operation is pending.
2001    ///   - `INTERNAL_ERROR`: Unexpected QRTR error.
2002    pub fn r#read(
2003        &self,
2004        ___deadline: zx::MonotonicInstant,
2005    ) -> Result<QrtrTransportChannelReadResult, fidl::Error> {
2006        let _response = self.client.send_query::<
2007            fidl::encoding::EmptyPayload,
2008            fidl::encoding::FlexibleResultType<QrtrTransportChannelReadResponse, Error>,
2009            QrtrTransportChannelMarker,
2010        >(
2011            (),
2012            0x1ea3f950c311b3e9,
2013            fidl::encoding::DynamicFlags::FLEXIBLE,
2014            ___deadline,
2015        )?
2016        .into_result::<QrtrTransportChannelMarker>("read")?;
2017        Ok(_response.map(|x| x.data))
2018    }
2019
2020    /// Writes a QRTR frame to a transport driver.
2021    ///
2022    /// Only one write request can be performed at a time.
2023    /// * Errors:
2024    ///   - `ALREADY_PENDING`: More than one write operation is pending.
2025    ///   - `INTERNAL_ERROR`: Unexpected QRTR error.
2026    pub fn r#write(
2027        &self,
2028        mut data: &[u8],
2029        ___deadline: zx::MonotonicInstant,
2030    ) -> Result<QrtrTransportChannelWriteResult, fidl::Error> {
2031        let _response = self.client.send_query::<
2032            QrtrTransportChannelWriteRequest,
2033            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2034            QrtrTransportChannelMarker,
2035        >(
2036            (data,),
2037            0xba66b9de6960dd2,
2038            fidl::encoding::DynamicFlags::FLEXIBLE,
2039            ___deadline,
2040        )?
2041        .into_result::<QrtrTransportChannelMarker>("write")?;
2042        Ok(_response.map(|x| x))
2043    }
2044}
2045
2046#[cfg(target_os = "fuchsia")]
2047impl From<QrtrTransportChannelSynchronousProxy> for zx::NullableHandle {
2048    fn from(value: QrtrTransportChannelSynchronousProxy) -> Self {
2049        value.into_channel().into()
2050    }
2051}
2052
2053#[cfg(target_os = "fuchsia")]
2054impl From<fidl::Channel> for QrtrTransportChannelSynchronousProxy {
2055    fn from(value: fidl::Channel) -> Self {
2056        Self::new(value)
2057    }
2058}
2059
2060#[cfg(target_os = "fuchsia")]
2061impl fidl::endpoints::FromClient for QrtrTransportChannelSynchronousProxy {
2062    type Protocol = QrtrTransportChannelMarker;
2063
2064    fn from_client(value: fidl::endpoints::ClientEnd<QrtrTransportChannelMarker>) -> Self {
2065        Self::new(value.into_channel())
2066    }
2067}
2068
2069#[derive(Debug, Clone)]
2070pub struct QrtrTransportChannelProxy {
2071    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2072}
2073
2074impl fidl::endpoints::Proxy for QrtrTransportChannelProxy {
2075    type Protocol = QrtrTransportChannelMarker;
2076
2077    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2078        Self::new(inner)
2079    }
2080
2081    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2082        self.client.into_channel().map_err(|client| Self { client })
2083    }
2084
2085    fn as_channel(&self) -> &::fidl::AsyncChannel {
2086        self.client.as_channel()
2087    }
2088}
2089
2090impl QrtrTransportChannelProxy {
2091    /// Create a new Proxy for fuchsia.hardware.qualcomm.router/QrtrTransportChannel.
2092    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2093        let protocol_name =
2094            <QrtrTransportChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2095        Self { client: fidl::client::Client::new(channel, protocol_name) }
2096    }
2097
2098    /// Get a Stream of events from the remote end of the protocol.
2099    ///
2100    /// # Panics
2101    ///
2102    /// Panics if the event stream was already taken.
2103    pub fn take_event_stream(&self) -> QrtrTransportChannelEventStream {
2104        QrtrTransportChannelEventStream { event_receiver: self.client.take_event_receiver() }
2105    }
2106
2107    /// Reads a QRTR frame from a transport driver.
2108    ///
2109    /// Blocks until an inbound frame is ready to be consumed.
2110    /// Only one read request can be performed at a time.
2111    /// - `data`: QRTR frame.
2112    /// * Errors:
2113    ///   - `ALREADY_PENDING`: More than one read operation is pending.
2114    ///   - `INTERNAL_ERROR`: Unexpected QRTR error.
2115    pub fn r#read(
2116        &self,
2117    ) -> fidl::client::QueryResponseFut<
2118        QrtrTransportChannelReadResult,
2119        fidl::encoding::DefaultFuchsiaResourceDialect,
2120    > {
2121        QrtrTransportChannelProxyInterface::r#read(self)
2122    }
2123
2124    /// Writes a QRTR frame to a transport driver.
2125    ///
2126    /// Only one write request can be performed at a time.
2127    /// * Errors:
2128    ///   - `ALREADY_PENDING`: More than one write operation is pending.
2129    ///   - `INTERNAL_ERROR`: Unexpected QRTR error.
2130    pub fn r#write(
2131        &self,
2132        mut data: &[u8],
2133    ) -> fidl::client::QueryResponseFut<
2134        QrtrTransportChannelWriteResult,
2135        fidl::encoding::DefaultFuchsiaResourceDialect,
2136    > {
2137        QrtrTransportChannelProxyInterface::r#write(self, data)
2138    }
2139}
2140
2141impl QrtrTransportChannelProxyInterface for QrtrTransportChannelProxy {
2142    type ReadResponseFut = fidl::client::QueryResponseFut<
2143        QrtrTransportChannelReadResult,
2144        fidl::encoding::DefaultFuchsiaResourceDialect,
2145    >;
2146    fn r#read(&self) -> Self::ReadResponseFut {
2147        fn _decode(
2148            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2149        ) -> Result<QrtrTransportChannelReadResult, fidl::Error> {
2150            let _response = fidl::client::decode_transaction_body::<
2151                fidl::encoding::FlexibleResultType<QrtrTransportChannelReadResponse, Error>,
2152                fidl::encoding::DefaultFuchsiaResourceDialect,
2153                0x1ea3f950c311b3e9,
2154            >(_buf?)?
2155            .into_result::<QrtrTransportChannelMarker>("read")?;
2156            Ok(_response.map(|x| x.data))
2157        }
2158        self.client
2159            .send_query_and_decode::<fidl::encoding::EmptyPayload, QrtrTransportChannelReadResult>(
2160                (),
2161                0x1ea3f950c311b3e9,
2162                fidl::encoding::DynamicFlags::FLEXIBLE,
2163                _decode,
2164            )
2165    }
2166
2167    type WriteResponseFut = fidl::client::QueryResponseFut<
2168        QrtrTransportChannelWriteResult,
2169        fidl::encoding::DefaultFuchsiaResourceDialect,
2170    >;
2171    fn r#write(&self, mut data: &[u8]) -> Self::WriteResponseFut {
2172        fn _decode(
2173            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2174        ) -> Result<QrtrTransportChannelWriteResult, fidl::Error> {
2175            let _response = fidl::client::decode_transaction_body::<
2176                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2177                fidl::encoding::DefaultFuchsiaResourceDialect,
2178                0xba66b9de6960dd2,
2179            >(_buf?)?
2180            .into_result::<QrtrTransportChannelMarker>("write")?;
2181            Ok(_response.map(|x| x))
2182        }
2183        self.client.send_query_and_decode::<
2184            QrtrTransportChannelWriteRequest,
2185            QrtrTransportChannelWriteResult,
2186        >(
2187            (data,),
2188            0xba66b9de6960dd2,
2189            fidl::encoding::DynamicFlags::FLEXIBLE,
2190            _decode,
2191        )
2192    }
2193}
2194
2195pub struct QrtrTransportChannelEventStream {
2196    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2197}
2198
2199impl std::marker::Unpin for QrtrTransportChannelEventStream {}
2200
2201impl futures::stream::FusedStream for QrtrTransportChannelEventStream {
2202    fn is_terminated(&self) -> bool {
2203        self.event_receiver.is_terminated()
2204    }
2205}
2206
2207impl futures::Stream for QrtrTransportChannelEventStream {
2208    type Item = Result<QrtrTransportChannelEvent, fidl::Error>;
2209
2210    fn poll_next(
2211        mut self: std::pin::Pin<&mut Self>,
2212        cx: &mut std::task::Context<'_>,
2213    ) -> std::task::Poll<Option<Self::Item>> {
2214        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2215            &mut self.event_receiver,
2216            cx
2217        )?) {
2218            Some(buf) => std::task::Poll::Ready(Some(QrtrTransportChannelEvent::decode(buf))),
2219            None => std::task::Poll::Ready(None),
2220        }
2221    }
2222}
2223
2224#[derive(Debug)]
2225pub enum QrtrTransportChannelEvent {
2226    #[non_exhaustive]
2227    _UnknownEvent {
2228        /// Ordinal of the event that was sent.
2229        ordinal: u64,
2230    },
2231}
2232
2233impl QrtrTransportChannelEvent {
2234    /// Decodes a message buffer as a [`QrtrTransportChannelEvent`].
2235    fn decode(
2236        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2237    ) -> Result<QrtrTransportChannelEvent, fidl::Error> {
2238        let (bytes, _handles) = buf.split_mut();
2239        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2240        debug_assert_eq!(tx_header.tx_id, 0);
2241        match tx_header.ordinal {
2242            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2243                Ok(QrtrTransportChannelEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2244            }
2245            _ => Err(fidl::Error::UnknownOrdinal {
2246                ordinal: tx_header.ordinal,
2247                protocol_name:
2248                    <QrtrTransportChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2249            }),
2250        }
2251    }
2252}
2253
2254/// A Stream of incoming requests for fuchsia.hardware.qualcomm.router/QrtrTransportChannel.
2255pub struct QrtrTransportChannelRequestStream {
2256    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2257    is_terminated: bool,
2258}
2259
2260impl std::marker::Unpin for QrtrTransportChannelRequestStream {}
2261
2262impl futures::stream::FusedStream for QrtrTransportChannelRequestStream {
2263    fn is_terminated(&self) -> bool {
2264        self.is_terminated
2265    }
2266}
2267
2268impl fidl::endpoints::RequestStream for QrtrTransportChannelRequestStream {
2269    type Protocol = QrtrTransportChannelMarker;
2270    type ControlHandle = QrtrTransportChannelControlHandle;
2271
2272    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2273        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2274    }
2275
2276    fn control_handle(&self) -> Self::ControlHandle {
2277        QrtrTransportChannelControlHandle { inner: self.inner.clone() }
2278    }
2279
2280    fn into_inner(
2281        self,
2282    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2283    {
2284        (self.inner, self.is_terminated)
2285    }
2286
2287    fn from_inner(
2288        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2289        is_terminated: bool,
2290    ) -> Self {
2291        Self { inner, is_terminated }
2292    }
2293}
2294
2295impl futures::Stream for QrtrTransportChannelRequestStream {
2296    type Item = Result<QrtrTransportChannelRequest, fidl::Error>;
2297
2298    fn poll_next(
2299        mut self: std::pin::Pin<&mut Self>,
2300        cx: &mut std::task::Context<'_>,
2301    ) -> std::task::Poll<Option<Self::Item>> {
2302        let this = &mut *self;
2303        if this.inner.check_shutdown(cx) {
2304            this.is_terminated = true;
2305            return std::task::Poll::Ready(None);
2306        }
2307        if this.is_terminated {
2308            panic!("polled QrtrTransportChannelRequestStream after completion");
2309        }
2310        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2311            |bytes, handles| {
2312                match this.inner.channel().read_etc(cx, bytes, handles) {
2313                    std::task::Poll::Ready(Ok(())) => {}
2314                    std::task::Poll::Pending => return std::task::Poll::Pending,
2315                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2316                        this.is_terminated = true;
2317                        return std::task::Poll::Ready(None);
2318                    }
2319                    std::task::Poll::Ready(Err(e)) => {
2320                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2321                            e.into(),
2322                        ))));
2323                    }
2324                }
2325
2326                // A message has been received from the channel
2327                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2328
2329                std::task::Poll::Ready(Some(match header.ordinal {
2330                0x1ea3f950c311b3e9 => {
2331                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2332                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
2333                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2334                    let control_handle = QrtrTransportChannelControlHandle {
2335                        inner: this.inner.clone(),
2336                    };
2337                    Ok(QrtrTransportChannelRequest::Read {
2338                        responder: QrtrTransportChannelReadResponder {
2339                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2340                            tx_id: header.tx_id,
2341                        },
2342                    })
2343                }
2344                0xba66b9de6960dd2 => {
2345                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2346                    let mut req = fidl::new_empty!(QrtrTransportChannelWriteRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2347                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<QrtrTransportChannelWriteRequest>(&header, _body_bytes, handles, &mut req)?;
2348                    let control_handle = QrtrTransportChannelControlHandle {
2349                        inner: this.inner.clone(),
2350                    };
2351                    Ok(QrtrTransportChannelRequest::Write {data: req.data,
2352
2353                        responder: QrtrTransportChannelWriteResponder {
2354                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2355                            tx_id: header.tx_id,
2356                        },
2357                    })
2358                }
2359                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2360                    Ok(QrtrTransportChannelRequest::_UnknownMethod {
2361                        ordinal: header.ordinal,
2362                        control_handle: QrtrTransportChannelControlHandle { inner: this.inner.clone() },
2363                        method_type: fidl::MethodType::OneWay,
2364                    })
2365                }
2366                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2367                    this.inner.send_framework_err(
2368                        fidl::encoding::FrameworkErr::UnknownMethod,
2369                        header.tx_id,
2370                        header.ordinal,
2371                        header.dynamic_flags(),
2372                        (bytes, handles),
2373                    )?;
2374                    Ok(QrtrTransportChannelRequest::_UnknownMethod {
2375                        ordinal: header.ordinal,
2376                        control_handle: QrtrTransportChannelControlHandle { inner: this.inner.clone() },
2377                        method_type: fidl::MethodType::TwoWay,
2378                    })
2379                }
2380                _ => Err(fidl::Error::UnknownOrdinal {
2381                    ordinal: header.ordinal,
2382                    protocol_name: <QrtrTransportChannelMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2383                }),
2384            }))
2385            },
2386        )
2387    }
2388}
2389
2390/// The channel for a transport driver that communicates with the remote
2391/// processor and the QRTR driver.
2392///
2393/// Every message is preambled by a QRTR header, consult the appropriate
2394/// specification for format.
2395#[derive(Debug)]
2396pub enum QrtrTransportChannelRequest {
2397    /// Reads a QRTR frame from a transport driver.
2398    ///
2399    /// Blocks until an inbound frame is ready to be consumed.
2400    /// Only one read request can be performed at a time.
2401    /// - `data`: QRTR frame.
2402    /// * Errors:
2403    ///   - `ALREADY_PENDING`: More than one read operation is pending.
2404    ///   - `INTERNAL_ERROR`: Unexpected QRTR error.
2405    Read { responder: QrtrTransportChannelReadResponder },
2406    /// Writes a QRTR frame to a transport driver.
2407    ///
2408    /// Only one write request can be performed at a time.
2409    /// * Errors:
2410    ///   - `ALREADY_PENDING`: More than one write operation is pending.
2411    ///   - `INTERNAL_ERROR`: Unexpected QRTR error.
2412    Write { data: Vec<u8>, responder: QrtrTransportChannelWriteResponder },
2413    /// An interaction was received which does not match any known method.
2414    #[non_exhaustive]
2415    _UnknownMethod {
2416        /// Ordinal of the method that was called.
2417        ordinal: u64,
2418        control_handle: QrtrTransportChannelControlHandle,
2419        method_type: fidl::MethodType,
2420    },
2421}
2422
2423impl QrtrTransportChannelRequest {
2424    #[allow(irrefutable_let_patterns)]
2425    pub fn into_read(self) -> Option<(QrtrTransportChannelReadResponder)> {
2426        if let QrtrTransportChannelRequest::Read { responder } = self {
2427            Some((responder))
2428        } else {
2429            None
2430        }
2431    }
2432
2433    #[allow(irrefutable_let_patterns)]
2434    pub fn into_write(self) -> Option<(Vec<u8>, QrtrTransportChannelWriteResponder)> {
2435        if let QrtrTransportChannelRequest::Write { data, responder } = self {
2436            Some((data, responder))
2437        } else {
2438            None
2439        }
2440    }
2441
2442    /// Name of the method defined in FIDL
2443    pub fn method_name(&self) -> &'static str {
2444        match *self {
2445            QrtrTransportChannelRequest::Read { .. } => "read",
2446            QrtrTransportChannelRequest::Write { .. } => "write",
2447            QrtrTransportChannelRequest::_UnknownMethod {
2448                method_type: fidl::MethodType::OneWay,
2449                ..
2450            } => "unknown one-way method",
2451            QrtrTransportChannelRequest::_UnknownMethod {
2452                method_type: fidl::MethodType::TwoWay,
2453                ..
2454            } => "unknown two-way method",
2455        }
2456    }
2457}
2458
2459#[derive(Debug, Clone)]
2460pub struct QrtrTransportChannelControlHandle {
2461    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2462}
2463
2464impl QrtrTransportChannelControlHandle {
2465    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2466        self.inner.shutdown_with_epitaph(status.into())
2467    }
2468}
2469
2470impl fidl::endpoints::ControlHandle for QrtrTransportChannelControlHandle {
2471    fn shutdown(&self) {
2472        self.inner.shutdown()
2473    }
2474
2475    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2476        self.inner.shutdown_with_epitaph(status)
2477    }
2478
2479    fn is_closed(&self) -> bool {
2480        self.inner.channel().is_closed()
2481    }
2482    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2483        self.inner.channel().on_closed()
2484    }
2485
2486    #[cfg(target_os = "fuchsia")]
2487    fn signal_peer(
2488        &self,
2489        clear_mask: zx::Signals,
2490        set_mask: zx::Signals,
2491    ) -> Result<(), zx_status::Status> {
2492        use fidl::Peered;
2493        self.inner.channel().signal_peer(clear_mask, set_mask)
2494    }
2495}
2496
2497impl QrtrTransportChannelControlHandle {}
2498
2499#[must_use = "FIDL methods require a response to be sent"]
2500#[derive(Debug)]
2501pub struct QrtrTransportChannelReadResponder {
2502    control_handle: std::mem::ManuallyDrop<QrtrTransportChannelControlHandle>,
2503    tx_id: u32,
2504}
2505
2506/// Set the the channel to be shutdown (see [`QrtrTransportChannelControlHandle::shutdown`])
2507/// if the responder is dropped without sending a response, so that the client
2508/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2509impl std::ops::Drop for QrtrTransportChannelReadResponder {
2510    fn drop(&mut self) {
2511        self.control_handle.shutdown();
2512        // Safety: drops once, never accessed again
2513        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2514    }
2515}
2516
2517impl fidl::endpoints::Responder for QrtrTransportChannelReadResponder {
2518    type ControlHandle = QrtrTransportChannelControlHandle;
2519
2520    fn control_handle(&self) -> &QrtrTransportChannelControlHandle {
2521        &self.control_handle
2522    }
2523
2524    fn drop_without_shutdown(mut self) {
2525        // Safety: drops once, never accessed again due to mem::forget
2526        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2527        // Prevent Drop from running (which would shut down the channel)
2528        std::mem::forget(self);
2529    }
2530}
2531
2532impl QrtrTransportChannelReadResponder {
2533    /// Sends a response to the FIDL transaction.
2534    ///
2535    /// Sets the channel to shutdown if an error occurs.
2536    pub fn send(self, mut result: Result<&[u8], Error>) -> Result<(), fidl::Error> {
2537        let _result = self.send_raw(result);
2538        if _result.is_err() {
2539            self.control_handle.shutdown();
2540        }
2541        self.drop_without_shutdown();
2542        _result
2543    }
2544
2545    /// Similar to "send" but does not shutdown the channel if an error occurs.
2546    pub fn send_no_shutdown_on_err(
2547        self,
2548        mut result: Result<&[u8], Error>,
2549    ) -> Result<(), fidl::Error> {
2550        let _result = self.send_raw(result);
2551        self.drop_without_shutdown();
2552        _result
2553    }
2554
2555    fn send_raw(&self, mut result: Result<&[u8], Error>) -> Result<(), fidl::Error> {
2556        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2557            QrtrTransportChannelReadResponse,
2558            Error,
2559        >>(
2560            fidl::encoding::FlexibleResult::new(result.map(|data| (data,))),
2561            self.tx_id,
2562            0x1ea3f950c311b3e9,
2563            fidl::encoding::DynamicFlags::FLEXIBLE,
2564        )
2565    }
2566}
2567
2568#[must_use = "FIDL methods require a response to be sent"]
2569#[derive(Debug)]
2570pub struct QrtrTransportChannelWriteResponder {
2571    control_handle: std::mem::ManuallyDrop<QrtrTransportChannelControlHandle>,
2572    tx_id: u32,
2573}
2574
2575/// Set the the channel to be shutdown (see [`QrtrTransportChannelControlHandle::shutdown`])
2576/// if the responder is dropped without sending a response, so that the client
2577/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2578impl std::ops::Drop for QrtrTransportChannelWriteResponder {
2579    fn drop(&mut self) {
2580        self.control_handle.shutdown();
2581        // Safety: drops once, never accessed again
2582        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2583    }
2584}
2585
2586impl fidl::endpoints::Responder for QrtrTransportChannelWriteResponder {
2587    type ControlHandle = QrtrTransportChannelControlHandle;
2588
2589    fn control_handle(&self) -> &QrtrTransportChannelControlHandle {
2590        &self.control_handle
2591    }
2592
2593    fn drop_without_shutdown(mut self) {
2594        // Safety: drops once, never accessed again due to mem::forget
2595        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2596        // Prevent Drop from running (which would shut down the channel)
2597        std::mem::forget(self);
2598    }
2599}
2600
2601impl QrtrTransportChannelWriteResponder {
2602    /// Sends a response to the FIDL transaction.
2603    ///
2604    /// Sets the channel to shutdown if an error occurs.
2605    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2606        let _result = self.send_raw(result);
2607        if _result.is_err() {
2608            self.control_handle.shutdown();
2609        }
2610        self.drop_without_shutdown();
2611        _result
2612    }
2613
2614    /// Similar to "send" but does not shutdown the channel if an error occurs.
2615    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2616        let _result = self.send_raw(result);
2617        self.drop_without_shutdown();
2618        _result
2619    }
2620
2621    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2622        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2623            fidl::encoding::EmptyStruct,
2624            Error,
2625        >>(
2626            fidl::encoding::FlexibleResult::new(result),
2627            self.tx_id,
2628            0xba66b9de6960dd2,
2629            fidl::encoding::DynamicFlags::FLEXIBLE,
2630        )
2631    }
2632}
2633
2634#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2635pub struct QrtrTransportConnectorMarker;
2636
2637impl fidl::endpoints::ProtocolMarker for QrtrTransportConnectorMarker {
2638    type Proxy = QrtrTransportConnectorProxy;
2639    type RequestStream = QrtrTransportConnectorRequestStream;
2640    #[cfg(target_os = "fuchsia")]
2641    type SynchronousProxy = QrtrTransportConnectorSynchronousProxy;
2642
2643    const DEBUG_NAME: &'static str = "fuchsia.hardware.qualcomm.router.QrtrTransportConnector";
2644}
2645impl fidl::endpoints::DiscoverableProtocolMarker for QrtrTransportConnectorMarker {}
2646pub type QrtrTransportConnectorEstablishConnectionResult = Result<(), Error>;
2647
2648pub trait QrtrTransportConnectorProxyInterface: Send + Sync {
2649    type EstablishConnectionResponseFut: std::future::Future<
2650            Output = Result<QrtrTransportConnectorEstablishConnectionResult, fidl::Error>,
2651        > + Send;
2652    fn r#establish_connection(
2653        &self,
2654        options: &TransportConnectionOptions,
2655        proxy: fidl::endpoints::ClientEnd<QrtrTransportChannelMarker>,
2656    ) -> Self::EstablishConnectionResponseFut;
2657}
2658#[derive(Debug)]
2659#[cfg(target_os = "fuchsia")]
2660pub struct QrtrTransportConnectorSynchronousProxy {
2661    client: fidl::client::sync::Client,
2662}
2663
2664#[cfg(target_os = "fuchsia")]
2665impl fidl::endpoints::SynchronousProxy for QrtrTransportConnectorSynchronousProxy {
2666    type Proxy = QrtrTransportConnectorProxy;
2667    type Protocol = QrtrTransportConnectorMarker;
2668
2669    fn from_channel(inner: fidl::Channel) -> Self {
2670        Self::new(inner)
2671    }
2672
2673    fn into_channel(self) -> fidl::Channel {
2674        self.client.into_channel()
2675    }
2676
2677    fn as_channel(&self) -> &fidl::Channel {
2678        self.client.as_channel()
2679    }
2680}
2681
2682#[cfg(target_os = "fuchsia")]
2683impl QrtrTransportConnectorSynchronousProxy {
2684    pub fn new(channel: fidl::Channel) -> Self {
2685        Self { client: fidl::client::sync::Client::new(channel) }
2686    }
2687
2688    pub fn into_channel(self) -> fidl::Channel {
2689        self.client.into_channel()
2690    }
2691
2692    /// Waits until an event arrives and returns it. It is safe for other
2693    /// threads to make concurrent requests while waiting for an event.
2694    pub fn wait_for_event(
2695        &self,
2696        deadline: zx::MonotonicInstant,
2697    ) -> Result<QrtrTransportConnectorEvent, fidl::Error> {
2698        QrtrTransportConnectorEvent::decode(
2699            self.client.wait_for_event::<QrtrTransportConnectorMarker>(deadline)?,
2700        )
2701    }
2702
2703    /// Establishes a channel.
2704    ///
2705    /// Child drivers should only establish one connection to the QRTR driver.
2706    pub fn r#establish_connection(
2707        &self,
2708        mut options: &TransportConnectionOptions,
2709        mut proxy: fidl::endpoints::ClientEnd<QrtrTransportChannelMarker>,
2710        ___deadline: zx::MonotonicInstant,
2711    ) -> Result<QrtrTransportConnectorEstablishConnectionResult, fidl::Error> {
2712        let _response = self.client.send_query::<
2713            QrtrTransportConnectorEstablishConnectionRequest,
2714            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2715            QrtrTransportConnectorMarker,
2716        >(
2717            (options, proxy,),
2718            0xd19f34bea9b6c17,
2719            fidl::encoding::DynamicFlags::FLEXIBLE,
2720            ___deadline,
2721        )?
2722        .into_result::<QrtrTransportConnectorMarker>("establish_connection")?;
2723        Ok(_response.map(|x| x))
2724    }
2725}
2726
2727#[cfg(target_os = "fuchsia")]
2728impl From<QrtrTransportConnectorSynchronousProxy> for zx::NullableHandle {
2729    fn from(value: QrtrTransportConnectorSynchronousProxy) -> Self {
2730        value.into_channel().into()
2731    }
2732}
2733
2734#[cfg(target_os = "fuchsia")]
2735impl From<fidl::Channel> for QrtrTransportConnectorSynchronousProxy {
2736    fn from(value: fidl::Channel) -> Self {
2737        Self::new(value)
2738    }
2739}
2740
2741#[cfg(target_os = "fuchsia")]
2742impl fidl::endpoints::FromClient for QrtrTransportConnectorSynchronousProxy {
2743    type Protocol = QrtrTransportConnectorMarker;
2744
2745    fn from_client(value: fidl::endpoints::ClientEnd<QrtrTransportConnectorMarker>) -> Self {
2746        Self::new(value.into_channel())
2747    }
2748}
2749
2750#[derive(Debug, Clone)]
2751pub struct QrtrTransportConnectorProxy {
2752    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2753}
2754
2755impl fidl::endpoints::Proxy for QrtrTransportConnectorProxy {
2756    type Protocol = QrtrTransportConnectorMarker;
2757
2758    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2759        Self::new(inner)
2760    }
2761
2762    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2763        self.client.into_channel().map_err(|client| Self { client })
2764    }
2765
2766    fn as_channel(&self) -> &::fidl::AsyncChannel {
2767        self.client.as_channel()
2768    }
2769}
2770
2771impl QrtrTransportConnectorProxy {
2772    /// Create a new Proxy for fuchsia.hardware.qualcomm.router/QrtrTransportConnector.
2773    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2774        let protocol_name =
2775            <QrtrTransportConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2776        Self { client: fidl::client::Client::new(channel, protocol_name) }
2777    }
2778
2779    /// Get a Stream of events from the remote end of the protocol.
2780    ///
2781    /// # Panics
2782    ///
2783    /// Panics if the event stream was already taken.
2784    pub fn take_event_stream(&self) -> QrtrTransportConnectorEventStream {
2785        QrtrTransportConnectorEventStream { event_receiver: self.client.take_event_receiver() }
2786    }
2787
2788    /// Establishes a channel.
2789    ///
2790    /// Child drivers should only establish one connection to the QRTR driver.
2791    pub fn r#establish_connection(
2792        &self,
2793        mut options: &TransportConnectionOptions,
2794        mut proxy: fidl::endpoints::ClientEnd<QrtrTransportChannelMarker>,
2795    ) -> fidl::client::QueryResponseFut<
2796        QrtrTransportConnectorEstablishConnectionResult,
2797        fidl::encoding::DefaultFuchsiaResourceDialect,
2798    > {
2799        QrtrTransportConnectorProxyInterface::r#establish_connection(self, options, proxy)
2800    }
2801}
2802
2803impl QrtrTransportConnectorProxyInterface for QrtrTransportConnectorProxy {
2804    type EstablishConnectionResponseFut = fidl::client::QueryResponseFut<
2805        QrtrTransportConnectorEstablishConnectionResult,
2806        fidl::encoding::DefaultFuchsiaResourceDialect,
2807    >;
2808    fn r#establish_connection(
2809        &self,
2810        mut options: &TransportConnectionOptions,
2811        mut proxy: fidl::endpoints::ClientEnd<QrtrTransportChannelMarker>,
2812    ) -> Self::EstablishConnectionResponseFut {
2813        fn _decode(
2814            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2815        ) -> Result<QrtrTransportConnectorEstablishConnectionResult, fidl::Error> {
2816            let _response = fidl::client::decode_transaction_body::<
2817                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2818                fidl::encoding::DefaultFuchsiaResourceDialect,
2819                0xd19f34bea9b6c17,
2820            >(_buf?)?
2821            .into_result::<QrtrTransportConnectorMarker>("establish_connection")?;
2822            Ok(_response.map(|x| x))
2823        }
2824        self.client.send_query_and_decode::<
2825            QrtrTransportConnectorEstablishConnectionRequest,
2826            QrtrTransportConnectorEstablishConnectionResult,
2827        >(
2828            (options, proxy,),
2829            0xd19f34bea9b6c17,
2830            fidl::encoding::DynamicFlags::FLEXIBLE,
2831            _decode,
2832        )
2833    }
2834}
2835
2836pub struct QrtrTransportConnectorEventStream {
2837    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2838}
2839
2840impl std::marker::Unpin for QrtrTransportConnectorEventStream {}
2841
2842impl futures::stream::FusedStream for QrtrTransportConnectorEventStream {
2843    fn is_terminated(&self) -> bool {
2844        self.event_receiver.is_terminated()
2845    }
2846}
2847
2848impl futures::Stream for QrtrTransportConnectorEventStream {
2849    type Item = Result<QrtrTransportConnectorEvent, fidl::Error>;
2850
2851    fn poll_next(
2852        mut self: std::pin::Pin<&mut Self>,
2853        cx: &mut std::task::Context<'_>,
2854    ) -> std::task::Poll<Option<Self::Item>> {
2855        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2856            &mut self.event_receiver,
2857            cx
2858        )?) {
2859            Some(buf) => std::task::Poll::Ready(Some(QrtrTransportConnectorEvent::decode(buf))),
2860            None => std::task::Poll::Ready(None),
2861        }
2862    }
2863}
2864
2865#[derive(Debug)]
2866pub enum QrtrTransportConnectorEvent {
2867    #[non_exhaustive]
2868    _UnknownEvent {
2869        /// Ordinal of the event that was sent.
2870        ordinal: u64,
2871    },
2872}
2873
2874impl QrtrTransportConnectorEvent {
2875    /// Decodes a message buffer as a [`QrtrTransportConnectorEvent`].
2876    fn decode(
2877        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2878    ) -> Result<QrtrTransportConnectorEvent, fidl::Error> {
2879        let (bytes, _handles) = buf.split_mut();
2880        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2881        debug_assert_eq!(tx_header.tx_id, 0);
2882        match tx_header.ordinal {
2883            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2884                Ok(QrtrTransportConnectorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2885            }
2886            _ => Err(fidl::Error::UnknownOrdinal {
2887                ordinal: tx_header.ordinal,
2888                protocol_name:
2889                    <QrtrTransportConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2890            }),
2891        }
2892    }
2893}
2894
2895/// A Stream of incoming requests for fuchsia.hardware.qualcomm.router/QrtrTransportConnector.
2896pub struct QrtrTransportConnectorRequestStream {
2897    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2898    is_terminated: bool,
2899}
2900
2901impl std::marker::Unpin for QrtrTransportConnectorRequestStream {}
2902
2903impl futures::stream::FusedStream for QrtrTransportConnectorRequestStream {
2904    fn is_terminated(&self) -> bool {
2905        self.is_terminated
2906    }
2907}
2908
2909impl fidl::endpoints::RequestStream for QrtrTransportConnectorRequestStream {
2910    type Protocol = QrtrTransportConnectorMarker;
2911    type ControlHandle = QrtrTransportConnectorControlHandle;
2912
2913    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2914        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2915    }
2916
2917    fn control_handle(&self) -> Self::ControlHandle {
2918        QrtrTransportConnectorControlHandle { inner: self.inner.clone() }
2919    }
2920
2921    fn into_inner(
2922        self,
2923    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2924    {
2925        (self.inner, self.is_terminated)
2926    }
2927
2928    fn from_inner(
2929        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2930        is_terminated: bool,
2931    ) -> Self {
2932        Self { inner, is_terminated }
2933    }
2934}
2935
2936impl futures::Stream for QrtrTransportConnectorRequestStream {
2937    type Item = Result<QrtrTransportConnectorRequest, fidl::Error>;
2938
2939    fn poll_next(
2940        mut self: std::pin::Pin<&mut Self>,
2941        cx: &mut std::task::Context<'_>,
2942    ) -> std::task::Poll<Option<Self::Item>> {
2943        let this = &mut *self;
2944        if this.inner.check_shutdown(cx) {
2945            this.is_terminated = true;
2946            return std::task::Poll::Ready(None);
2947        }
2948        if this.is_terminated {
2949            panic!("polled QrtrTransportConnectorRequestStream after completion");
2950        }
2951        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2952            |bytes, handles| {
2953                match this.inner.channel().read_etc(cx, bytes, handles) {
2954                    std::task::Poll::Ready(Ok(())) => {}
2955                    std::task::Poll::Pending => return std::task::Poll::Pending,
2956                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2957                        this.is_terminated = true;
2958                        return std::task::Poll::Ready(None);
2959                    }
2960                    std::task::Poll::Ready(Err(e)) => {
2961                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2962                            e.into(),
2963                        ))));
2964                    }
2965                }
2966
2967                // A message has been received from the channel
2968                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2969
2970                std::task::Poll::Ready(Some(match header.ordinal {
2971                0xd19f34bea9b6c17 => {
2972                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2973                    let mut req = fidl::new_empty!(QrtrTransportConnectorEstablishConnectionRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2974                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<QrtrTransportConnectorEstablishConnectionRequest>(&header, _body_bytes, handles, &mut req)?;
2975                    let control_handle = QrtrTransportConnectorControlHandle {
2976                        inner: this.inner.clone(),
2977                    };
2978                    Ok(QrtrTransportConnectorRequest::EstablishConnection {options: req.options,
2979proxy: req.proxy,
2980
2981                        responder: QrtrTransportConnectorEstablishConnectionResponder {
2982                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2983                            tx_id: header.tx_id,
2984                        },
2985                    })
2986                }
2987                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2988                    Ok(QrtrTransportConnectorRequest::_UnknownMethod {
2989                        ordinal: header.ordinal,
2990                        control_handle: QrtrTransportConnectorControlHandle { inner: this.inner.clone() },
2991                        method_type: fidl::MethodType::OneWay,
2992                    })
2993                }
2994                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2995                    this.inner.send_framework_err(
2996                        fidl::encoding::FrameworkErr::UnknownMethod,
2997                        header.tx_id,
2998                        header.ordinal,
2999                        header.dynamic_flags(),
3000                        (bytes, handles),
3001                    )?;
3002                    Ok(QrtrTransportConnectorRequest::_UnknownMethod {
3003                        ordinal: header.ordinal,
3004                        control_handle: QrtrTransportConnectorControlHandle { inner: this.inner.clone() },
3005                        method_type: fidl::MethodType::TwoWay,
3006                    })
3007                }
3008                _ => Err(fidl::Error::UnknownOrdinal {
3009                    ordinal: header.ordinal,
3010                    protocol_name: <QrtrTransportConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3011                }),
3012            }))
3013            },
3014        )
3015    }
3016}
3017
3018/// Used by a transport driver that communicates with a remote processor
3019/// to establish a new channel to the QRTR driver.
3020#[derive(Debug)]
3021pub enum QrtrTransportConnectorRequest {
3022    /// Establishes a channel.
3023    ///
3024    /// Child drivers should only establish one connection to the QRTR driver.
3025    EstablishConnection {
3026        options: TransportConnectionOptions,
3027        proxy: fidl::endpoints::ClientEnd<QrtrTransportChannelMarker>,
3028        responder: QrtrTransportConnectorEstablishConnectionResponder,
3029    },
3030    /// An interaction was received which does not match any known method.
3031    #[non_exhaustive]
3032    _UnknownMethod {
3033        /// Ordinal of the method that was called.
3034        ordinal: u64,
3035        control_handle: QrtrTransportConnectorControlHandle,
3036        method_type: fidl::MethodType,
3037    },
3038}
3039
3040impl QrtrTransportConnectorRequest {
3041    #[allow(irrefutable_let_patterns)]
3042    pub fn into_establish_connection(
3043        self,
3044    ) -> Option<(
3045        TransportConnectionOptions,
3046        fidl::endpoints::ClientEnd<QrtrTransportChannelMarker>,
3047        QrtrTransportConnectorEstablishConnectionResponder,
3048    )> {
3049        if let QrtrTransportConnectorRequest::EstablishConnection { options, proxy, responder } =
3050            self
3051        {
3052            Some((options, proxy, responder))
3053        } else {
3054            None
3055        }
3056    }
3057
3058    /// Name of the method defined in FIDL
3059    pub fn method_name(&self) -> &'static str {
3060        match *self {
3061            QrtrTransportConnectorRequest::EstablishConnection { .. } => "establish_connection",
3062            QrtrTransportConnectorRequest::_UnknownMethod {
3063                method_type: fidl::MethodType::OneWay,
3064                ..
3065            } => "unknown one-way method",
3066            QrtrTransportConnectorRequest::_UnknownMethod {
3067                method_type: fidl::MethodType::TwoWay,
3068                ..
3069            } => "unknown two-way method",
3070        }
3071    }
3072}
3073
3074#[derive(Debug, Clone)]
3075pub struct QrtrTransportConnectorControlHandle {
3076    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3077}
3078
3079impl QrtrTransportConnectorControlHandle {
3080    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3081        self.inner.shutdown_with_epitaph(status.into())
3082    }
3083}
3084
3085impl fidl::endpoints::ControlHandle for QrtrTransportConnectorControlHandle {
3086    fn shutdown(&self) {
3087        self.inner.shutdown()
3088    }
3089
3090    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3091        self.inner.shutdown_with_epitaph(status)
3092    }
3093
3094    fn is_closed(&self) -> bool {
3095        self.inner.channel().is_closed()
3096    }
3097    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3098        self.inner.channel().on_closed()
3099    }
3100
3101    #[cfg(target_os = "fuchsia")]
3102    fn signal_peer(
3103        &self,
3104        clear_mask: zx::Signals,
3105        set_mask: zx::Signals,
3106    ) -> Result<(), zx_status::Status> {
3107        use fidl::Peered;
3108        self.inner.channel().signal_peer(clear_mask, set_mask)
3109    }
3110}
3111
3112impl QrtrTransportConnectorControlHandle {}
3113
3114#[must_use = "FIDL methods require a response to be sent"]
3115#[derive(Debug)]
3116pub struct QrtrTransportConnectorEstablishConnectionResponder {
3117    control_handle: std::mem::ManuallyDrop<QrtrTransportConnectorControlHandle>,
3118    tx_id: u32,
3119}
3120
3121/// Set the the channel to be shutdown (see [`QrtrTransportConnectorControlHandle::shutdown`])
3122/// if the responder is dropped without sending a response, so that the client
3123/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3124impl std::ops::Drop for QrtrTransportConnectorEstablishConnectionResponder {
3125    fn drop(&mut self) {
3126        self.control_handle.shutdown();
3127        // Safety: drops once, never accessed again
3128        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3129    }
3130}
3131
3132impl fidl::endpoints::Responder for QrtrTransportConnectorEstablishConnectionResponder {
3133    type ControlHandle = QrtrTransportConnectorControlHandle;
3134
3135    fn control_handle(&self) -> &QrtrTransportConnectorControlHandle {
3136        &self.control_handle
3137    }
3138
3139    fn drop_without_shutdown(mut self) {
3140        // Safety: drops once, never accessed again due to mem::forget
3141        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3142        // Prevent Drop from running (which would shut down the channel)
3143        std::mem::forget(self);
3144    }
3145}
3146
3147impl QrtrTransportConnectorEstablishConnectionResponder {
3148    /// Sends a response to the FIDL transaction.
3149    ///
3150    /// Sets the channel to shutdown if an error occurs.
3151    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
3152        let _result = self.send_raw(result);
3153        if _result.is_err() {
3154            self.control_handle.shutdown();
3155        }
3156        self.drop_without_shutdown();
3157        _result
3158    }
3159
3160    /// Similar to "send" but does not shutdown the channel if an error occurs.
3161    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
3162        let _result = self.send_raw(result);
3163        self.drop_without_shutdown();
3164        _result
3165    }
3166
3167    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
3168        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3169            fidl::encoding::EmptyStruct,
3170            Error,
3171        >>(
3172            fidl::encoding::FlexibleResult::new(result),
3173            self.tx_id,
3174            0xd19f34bea9b6c17,
3175            fidl::encoding::DynamicFlags::FLEXIBLE,
3176        )
3177    }
3178}
3179
3180#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3181pub struct ClientServiceMarker;
3182
3183#[cfg(target_os = "fuchsia")]
3184impl fidl::endpoints::ServiceMarker for ClientServiceMarker {
3185    type Proxy = ClientServiceProxy;
3186    type Request = ClientServiceRequest;
3187    const SERVICE_NAME: &'static str = "fuchsia.hardware.qualcomm.router.ClientService";
3188}
3189
3190/// A request for one of the member protocols of ClientService.
3191///
3192#[cfg(target_os = "fuchsia")]
3193pub enum ClientServiceRequest {
3194    QrtrConnector(QrtrConnectorRequestStream),
3195}
3196
3197#[cfg(target_os = "fuchsia")]
3198impl fidl::endpoints::ServiceRequest for ClientServiceRequest {
3199    type Service = ClientServiceMarker;
3200
3201    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
3202        match name {
3203            "qrtr_connector" => Self::QrtrConnector(
3204                <QrtrConnectorRequestStream as fidl::endpoints::RequestStream>::from_channel(
3205                    _channel,
3206                ),
3207            ),
3208            _ => panic!("no such member protocol name for service ClientService"),
3209        }
3210    }
3211
3212    fn member_names() -> &'static [&'static str] {
3213        &["qrtr_connector"]
3214    }
3215}
3216#[cfg(target_os = "fuchsia")]
3217pub struct ClientServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
3218
3219#[cfg(target_os = "fuchsia")]
3220impl fidl::endpoints::ServiceProxy for ClientServiceProxy {
3221    type Service = ClientServiceMarker;
3222
3223    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
3224        Self(opener)
3225    }
3226}
3227
3228#[cfg(target_os = "fuchsia")]
3229impl ClientServiceProxy {
3230    pub fn connect_to_qrtr_connector(&self) -> Result<QrtrConnectorProxy, fidl::Error> {
3231        let (proxy, server_end) = fidl::endpoints::create_proxy::<QrtrConnectorMarker>();
3232        self.connect_channel_to_qrtr_connector(server_end)?;
3233        Ok(proxy)
3234    }
3235
3236    /// Like `connect_to_qrtr_connector`, but returns a sync proxy.
3237    /// See [`Self::connect_to_qrtr_connector`] for more details.
3238    pub fn connect_to_qrtr_connector_sync(
3239        &self,
3240    ) -> Result<QrtrConnectorSynchronousProxy, fidl::Error> {
3241        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<QrtrConnectorMarker>();
3242        self.connect_channel_to_qrtr_connector(server_end)?;
3243        Ok(proxy)
3244    }
3245
3246    /// Like `connect_to_qrtr_connector`, but accepts a server end.
3247    /// See [`Self::connect_to_qrtr_connector`] for more details.
3248    pub fn connect_channel_to_qrtr_connector(
3249        &self,
3250        server_end: fidl::endpoints::ServerEnd<QrtrConnectorMarker>,
3251    ) -> Result<(), fidl::Error> {
3252        self.0.open_member("qrtr_connector", server_end.into_channel())
3253    }
3254
3255    pub fn instance_name(&self) -> &str {
3256        self.0.instance_name()
3257    }
3258}
3259
3260#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3261pub struct TransportServiceMarker;
3262
3263#[cfg(target_os = "fuchsia")]
3264impl fidl::endpoints::ServiceMarker for TransportServiceMarker {
3265    type Proxy = TransportServiceProxy;
3266    type Request = TransportServiceRequest;
3267    const SERVICE_NAME: &'static str = "fuchsia.hardware.qualcomm.router.TransportService";
3268}
3269
3270/// A request for one of the member protocols of TransportService.
3271///
3272#[cfg(target_os = "fuchsia")]
3273pub enum TransportServiceRequest {
3274    QrtrTransportConnector(QrtrTransportConnectorRequestStream),
3275}
3276
3277#[cfg(target_os = "fuchsia")]
3278impl fidl::endpoints::ServiceRequest for TransportServiceRequest {
3279    type Service = TransportServiceMarker;
3280
3281    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
3282        match name {
3283            "qrtr_transport_connector" => Self::QrtrTransportConnector(
3284                <QrtrTransportConnectorRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
3285            ),
3286            _ => panic!("no such member protocol name for service TransportService"),
3287        }
3288    }
3289
3290    fn member_names() -> &'static [&'static str] {
3291        &["qrtr_transport_connector"]
3292    }
3293}
3294#[cfg(target_os = "fuchsia")]
3295pub struct TransportServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
3296
3297#[cfg(target_os = "fuchsia")]
3298impl fidl::endpoints::ServiceProxy for TransportServiceProxy {
3299    type Service = TransportServiceMarker;
3300
3301    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
3302        Self(opener)
3303    }
3304}
3305
3306#[cfg(target_os = "fuchsia")]
3307impl TransportServiceProxy {
3308    pub fn connect_to_qrtr_transport_connector(
3309        &self,
3310    ) -> Result<QrtrTransportConnectorProxy, fidl::Error> {
3311        let (proxy, server_end) = fidl::endpoints::create_proxy::<QrtrTransportConnectorMarker>();
3312        self.connect_channel_to_qrtr_transport_connector(server_end)?;
3313        Ok(proxy)
3314    }
3315
3316    /// Like `connect_to_qrtr_transport_connector`, but returns a sync proxy.
3317    /// See [`Self::connect_to_qrtr_transport_connector`] for more details.
3318    pub fn connect_to_qrtr_transport_connector_sync(
3319        &self,
3320    ) -> Result<QrtrTransportConnectorSynchronousProxy, fidl::Error> {
3321        let (proxy, server_end) =
3322            fidl::endpoints::create_sync_proxy::<QrtrTransportConnectorMarker>();
3323        self.connect_channel_to_qrtr_transport_connector(server_end)?;
3324        Ok(proxy)
3325    }
3326
3327    /// Like `connect_to_qrtr_transport_connector`, but accepts a server end.
3328    /// See [`Self::connect_to_qrtr_transport_connector`] for more details.
3329    pub fn connect_channel_to_qrtr_transport_connector(
3330        &self,
3331        server_end: fidl::endpoints::ServerEnd<QrtrTransportConnectorMarker>,
3332    ) -> Result<(), fidl::Error> {
3333        self.0.open_member("qrtr_transport_connector", server_end.into_channel())
3334    }
3335
3336    pub fn instance_name(&self) -> &str {
3337        self.0.instance_name()
3338    }
3339}
3340
3341mod internal {
3342    use super::*;
3343
3344    impl fidl::encoding::ResourceTypeMarker for QrtrClientConnectionGetSignalsResponse {
3345        type Borrowed<'a> = &'a mut Self;
3346        fn take_or_borrow<'a>(
3347            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3348        ) -> Self::Borrowed<'a> {
3349            value
3350        }
3351    }
3352
3353    unsafe impl fidl::encoding::TypeMarker for QrtrClientConnectionGetSignalsResponse {
3354        type Owned = Self;
3355
3356        #[inline(always)]
3357        fn inline_align(_context: fidl::encoding::Context) -> usize {
3358            4
3359        }
3360
3361        #[inline(always)]
3362        fn inline_size(_context: fidl::encoding::Context) -> usize {
3363            4
3364        }
3365    }
3366
3367    unsafe impl
3368        fidl::encoding::Encode<
3369            QrtrClientConnectionGetSignalsResponse,
3370            fidl::encoding::DefaultFuchsiaResourceDialect,
3371        > for &mut QrtrClientConnectionGetSignalsResponse
3372    {
3373        #[inline]
3374        unsafe fn encode(
3375            self,
3376            encoder: &mut fidl::encoding::Encoder<
3377                '_,
3378                fidl::encoding::DefaultFuchsiaResourceDialect,
3379            >,
3380            offset: usize,
3381            _depth: fidl::encoding::Depth,
3382        ) -> fidl::Result<()> {
3383            encoder.debug_check_bounds::<QrtrClientConnectionGetSignalsResponse>(offset);
3384            // Delegate to tuple encoding.
3385            fidl::encoding::Encode::<
3386                QrtrClientConnectionGetSignalsResponse,
3387                fidl::encoding::DefaultFuchsiaResourceDialect,
3388            >::encode(
3389                (<fidl::encoding::HandleType<
3390                    fidl::EventPair,
3391                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3392                    16387,
3393                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3394                    &mut self.signals
3395                ),),
3396                encoder,
3397                offset,
3398                _depth,
3399            )
3400        }
3401    }
3402    unsafe impl<
3403        T0: fidl::encoding::Encode<
3404                fidl::encoding::HandleType<
3405                    fidl::EventPair,
3406                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3407                    16387,
3408                >,
3409                fidl::encoding::DefaultFuchsiaResourceDialect,
3410            >,
3411    >
3412        fidl::encoding::Encode<
3413            QrtrClientConnectionGetSignalsResponse,
3414            fidl::encoding::DefaultFuchsiaResourceDialect,
3415        > for (T0,)
3416    {
3417        #[inline]
3418        unsafe fn encode(
3419            self,
3420            encoder: &mut fidl::encoding::Encoder<
3421                '_,
3422                fidl::encoding::DefaultFuchsiaResourceDialect,
3423            >,
3424            offset: usize,
3425            depth: fidl::encoding::Depth,
3426        ) -> fidl::Result<()> {
3427            encoder.debug_check_bounds::<QrtrClientConnectionGetSignalsResponse>(offset);
3428            // Zero out padding regions. There's no need to apply masks
3429            // because the unmasked parts will be overwritten by fields.
3430            // Write the fields.
3431            self.0.encode(encoder, offset + 0, depth)?;
3432            Ok(())
3433        }
3434    }
3435
3436    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3437        for QrtrClientConnectionGetSignalsResponse
3438    {
3439        #[inline(always)]
3440        fn new_empty() -> Self {
3441            Self {
3442                signals: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
3443            }
3444        }
3445
3446        #[inline]
3447        unsafe fn decode(
3448            &mut self,
3449            decoder: &mut fidl::encoding::Decoder<
3450                '_,
3451                fidl::encoding::DefaultFuchsiaResourceDialect,
3452            >,
3453            offset: usize,
3454            _depth: fidl::encoding::Depth,
3455        ) -> fidl::Result<()> {
3456            decoder.debug_check_bounds::<Self>(offset);
3457            // Verify that padding bytes are zero.
3458            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.signals, decoder, offset + 0, _depth)?;
3459            Ok(())
3460        }
3461    }
3462
3463    impl fidl::encoding::ResourceTypeMarker for QrtrConnectorGetConnectionRequest {
3464        type Borrowed<'a> = &'a mut Self;
3465        fn take_or_borrow<'a>(
3466            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3467        ) -> Self::Borrowed<'a> {
3468            value
3469        }
3470    }
3471
3472    unsafe impl fidl::encoding::TypeMarker for QrtrConnectorGetConnectionRequest {
3473        type Owned = Self;
3474
3475        #[inline(always)]
3476        fn inline_align(_context: fidl::encoding::Context) -> usize {
3477            8
3478        }
3479
3480        #[inline(always)]
3481        fn inline_size(_context: fidl::encoding::Context) -> usize {
3482            24
3483        }
3484    }
3485
3486    unsafe impl
3487        fidl::encoding::Encode<
3488            QrtrConnectorGetConnectionRequest,
3489            fidl::encoding::DefaultFuchsiaResourceDialect,
3490        > for &mut QrtrConnectorGetConnectionRequest
3491    {
3492        #[inline]
3493        unsafe fn encode(
3494            self,
3495            encoder: &mut fidl::encoding::Encoder<
3496                '_,
3497                fidl::encoding::DefaultFuchsiaResourceDialect,
3498            >,
3499            offset: usize,
3500            _depth: fidl::encoding::Depth,
3501        ) -> fidl::Result<()> {
3502            encoder.debug_check_bounds::<QrtrConnectorGetConnectionRequest>(offset);
3503            // Delegate to tuple encoding.
3504            fidl::encoding::Encode::<
3505                QrtrConnectorGetConnectionRequest,
3506                fidl::encoding::DefaultFuchsiaResourceDialect,
3507            >::encode(
3508                (
3509                    <ConnectionOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
3510                    <fidl::encoding::Endpoint<
3511                        fidl::endpoints::ServerEnd<QrtrClientConnectionMarker>,
3512                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3513                        &mut self.proxy
3514                    ),
3515                ),
3516                encoder,
3517                offset,
3518                _depth,
3519            )
3520        }
3521    }
3522    unsafe impl<
3523        T0: fidl::encoding::Encode<ConnectionOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
3524        T1: fidl::encoding::Encode<
3525                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<QrtrClientConnectionMarker>>,
3526                fidl::encoding::DefaultFuchsiaResourceDialect,
3527            >,
3528    >
3529        fidl::encoding::Encode<
3530            QrtrConnectorGetConnectionRequest,
3531            fidl::encoding::DefaultFuchsiaResourceDialect,
3532        > for (T0, T1)
3533    {
3534        #[inline]
3535        unsafe fn encode(
3536            self,
3537            encoder: &mut fidl::encoding::Encoder<
3538                '_,
3539                fidl::encoding::DefaultFuchsiaResourceDialect,
3540            >,
3541            offset: usize,
3542            depth: fidl::encoding::Depth,
3543        ) -> fidl::Result<()> {
3544            encoder.debug_check_bounds::<QrtrConnectorGetConnectionRequest>(offset);
3545            // Zero out padding regions. There's no need to apply masks
3546            // because the unmasked parts will be overwritten by fields.
3547            unsafe {
3548                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3549                (ptr as *mut u64).write_unaligned(0);
3550            }
3551            // Write the fields.
3552            self.0.encode(encoder, offset + 0, depth)?;
3553            self.1.encode(encoder, offset + 16, depth)?;
3554            Ok(())
3555        }
3556    }
3557
3558    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3559        for QrtrConnectorGetConnectionRequest
3560    {
3561        #[inline(always)]
3562        fn new_empty() -> Self {
3563            Self {
3564                options: fidl::new_empty!(
3565                    ConnectionOptions,
3566                    fidl::encoding::DefaultFuchsiaResourceDialect
3567                ),
3568                proxy: fidl::new_empty!(
3569                    fidl::encoding::Endpoint<
3570                        fidl::endpoints::ServerEnd<QrtrClientConnectionMarker>,
3571                    >,
3572                    fidl::encoding::DefaultFuchsiaResourceDialect
3573                ),
3574            }
3575        }
3576
3577        #[inline]
3578        unsafe fn decode(
3579            &mut self,
3580            decoder: &mut fidl::encoding::Decoder<
3581                '_,
3582                fidl::encoding::DefaultFuchsiaResourceDialect,
3583            >,
3584            offset: usize,
3585            _depth: fidl::encoding::Depth,
3586        ) -> fidl::Result<()> {
3587            decoder.debug_check_bounds::<Self>(offset);
3588            // Verify that padding bytes are zero.
3589            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3590            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3591            let mask = 0xffffffff00000000u64;
3592            let maskedval = padval & mask;
3593            if maskedval != 0 {
3594                return Err(fidl::Error::NonZeroPadding {
3595                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3596                });
3597            }
3598            fidl::decode!(
3599                ConnectionOptions,
3600                fidl::encoding::DefaultFuchsiaResourceDialect,
3601                &mut self.options,
3602                decoder,
3603                offset + 0,
3604                _depth
3605            )?;
3606            fidl::decode!(
3607                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<QrtrClientConnectionMarker>>,
3608                fidl::encoding::DefaultFuchsiaResourceDialect,
3609                &mut self.proxy,
3610                decoder,
3611                offset + 16,
3612                _depth
3613            )?;
3614            Ok(())
3615        }
3616    }
3617
3618    impl fidl::encoding::ResourceTypeMarker for QrtrTransportConnectorEstablishConnectionRequest {
3619        type Borrowed<'a> = &'a mut Self;
3620        fn take_or_borrow<'a>(
3621            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3622        ) -> Self::Borrowed<'a> {
3623            value
3624        }
3625    }
3626
3627    unsafe impl fidl::encoding::TypeMarker for QrtrTransportConnectorEstablishConnectionRequest {
3628        type Owned = Self;
3629
3630        #[inline(always)]
3631        fn inline_align(_context: fidl::encoding::Context) -> usize {
3632            8
3633        }
3634
3635        #[inline(always)]
3636        fn inline_size(_context: fidl::encoding::Context) -> usize {
3637            24
3638        }
3639    }
3640
3641    unsafe impl
3642        fidl::encoding::Encode<
3643            QrtrTransportConnectorEstablishConnectionRequest,
3644            fidl::encoding::DefaultFuchsiaResourceDialect,
3645        > for &mut QrtrTransportConnectorEstablishConnectionRequest
3646    {
3647        #[inline]
3648        unsafe fn encode(
3649            self,
3650            encoder: &mut fidl::encoding::Encoder<
3651                '_,
3652                fidl::encoding::DefaultFuchsiaResourceDialect,
3653            >,
3654            offset: usize,
3655            _depth: fidl::encoding::Depth,
3656        ) -> fidl::Result<()> {
3657            encoder.debug_check_bounds::<QrtrTransportConnectorEstablishConnectionRequest>(offset);
3658            // Delegate to tuple encoding.
3659            fidl::encoding::Encode::<
3660                QrtrTransportConnectorEstablishConnectionRequest,
3661                fidl::encoding::DefaultFuchsiaResourceDialect,
3662            >::encode(
3663                (
3664                    <TransportConnectionOptions as fidl::encoding::ValueTypeMarker>::borrow(
3665                        &self.options,
3666                    ),
3667                    <fidl::encoding::Endpoint<
3668                        fidl::endpoints::ClientEnd<QrtrTransportChannelMarker>,
3669                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3670                        &mut self.proxy
3671                    ),
3672                ),
3673                encoder,
3674                offset,
3675                _depth,
3676            )
3677        }
3678    }
3679    unsafe impl<
3680        T0: fidl::encoding::Encode<
3681                TransportConnectionOptions,
3682                fidl::encoding::DefaultFuchsiaResourceDialect,
3683            >,
3684        T1: fidl::encoding::Encode<
3685                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<QrtrTransportChannelMarker>>,
3686                fidl::encoding::DefaultFuchsiaResourceDialect,
3687            >,
3688    >
3689        fidl::encoding::Encode<
3690            QrtrTransportConnectorEstablishConnectionRequest,
3691            fidl::encoding::DefaultFuchsiaResourceDialect,
3692        > for (T0, T1)
3693    {
3694        #[inline]
3695        unsafe fn encode(
3696            self,
3697            encoder: &mut fidl::encoding::Encoder<
3698                '_,
3699                fidl::encoding::DefaultFuchsiaResourceDialect,
3700            >,
3701            offset: usize,
3702            depth: fidl::encoding::Depth,
3703        ) -> fidl::Result<()> {
3704            encoder.debug_check_bounds::<QrtrTransportConnectorEstablishConnectionRequest>(offset);
3705            // Zero out padding regions. There's no need to apply masks
3706            // because the unmasked parts will be overwritten by fields.
3707            unsafe {
3708                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3709                (ptr as *mut u64).write_unaligned(0);
3710            }
3711            // Write the fields.
3712            self.0.encode(encoder, offset + 0, depth)?;
3713            self.1.encode(encoder, offset + 16, depth)?;
3714            Ok(())
3715        }
3716    }
3717
3718    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3719        for QrtrTransportConnectorEstablishConnectionRequest
3720    {
3721        #[inline(always)]
3722        fn new_empty() -> Self {
3723            Self {
3724                options: fidl::new_empty!(
3725                    TransportConnectionOptions,
3726                    fidl::encoding::DefaultFuchsiaResourceDialect
3727                ),
3728                proxy: fidl::new_empty!(
3729                    fidl::encoding::Endpoint<
3730                        fidl::endpoints::ClientEnd<QrtrTransportChannelMarker>,
3731                    >,
3732                    fidl::encoding::DefaultFuchsiaResourceDialect
3733                ),
3734            }
3735        }
3736
3737        #[inline]
3738        unsafe fn decode(
3739            &mut self,
3740            decoder: &mut fidl::encoding::Decoder<
3741                '_,
3742                fidl::encoding::DefaultFuchsiaResourceDialect,
3743            >,
3744            offset: usize,
3745            _depth: fidl::encoding::Depth,
3746        ) -> fidl::Result<()> {
3747            decoder.debug_check_bounds::<Self>(offset);
3748            // Verify that padding bytes are zero.
3749            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3750            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3751            let mask = 0xffffffff00000000u64;
3752            let maskedval = padval & mask;
3753            if maskedval != 0 {
3754                return Err(fidl::Error::NonZeroPadding {
3755                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3756                });
3757            }
3758            fidl::decode!(
3759                TransportConnectionOptions,
3760                fidl::encoding::DefaultFuchsiaResourceDialect,
3761                &mut self.options,
3762                decoder,
3763                offset + 0,
3764                _depth
3765            )?;
3766            fidl::decode!(
3767                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<QrtrTransportChannelMarker>>,
3768                fidl::encoding::DefaultFuchsiaResourceDialect,
3769                &mut self.proxy,
3770                decoder,
3771                offset + 16,
3772                _depth
3773            )?;
3774            Ok(())
3775        }
3776    }
3777}