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