Skip to main content

fidl_fuchsia_hardware_qualcomm_router/
fidl_fuchsia_hardware_qualcomm_router.rs

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