Skip to main content

fidl_fuchsia_hardware_qualcomm_router__common/
fidl_fuchsia_hardware_qualcomm_router__common.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::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11/// Network Cluster Id, used for QRTR frame forwarding among transports.
12pub type NetId = u32;
13
14pub type NodeId = u32;
15
16pub type PortId = u32;
17
18pub const NET_ID_DEFAULT_VALUE: u32 = 0;
19
20/// Signal asserted on event handle when the [`QrtrClientConnection.Read`] method
21/// can return data.
22pub const SIGNAL_READABLE: u32 = 16777216;
23
24/// Signal asserted on event handle when the [`QrtrClientConnection.Write`] method
25/// can accept data.
26pub const SIGNAL_WRITABLE: u32 = 33554432;
27
28/// Error codes for QRTR operations.
29#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
30pub enum Error {
31    /// Internal error in QRTR.
32    InternalError,
33    /// Returned by blocking [`QrtrClientConnection.Read`] and
34    /// [`QrtrClientConnection.Write`] due to resource constraints.
35    AlreadyPending,
36    /// Remote node unavailable.
37    RemoteNodeUnavailable,
38    /// Port is already bound.
39    AlreadyBound,
40    /// Operation is not supported.
41    NotSupported,
42    /// Returned by non-blocking [`QrtrClientConnection.Read`] and
43    /// [`QrtrClientConnection.Write`].
44    WouldBlock,
45    /// No resources.
46    NoResources,
47    /// Invalid args.
48    InvalidArgs,
49    #[doc(hidden)]
50    __SourceBreaking { unknown_ordinal: u32 },
51}
52
53/// Pattern that matches an unknown `Error` member.
54#[macro_export]
55macro_rules! ErrorUnknown {
56    () => {
57        _
58    };
59}
60
61impl Error {
62    #[inline]
63    pub fn from_primitive(prim: u32) -> Option<Self> {
64        match prim {
65            1 => Some(Self::InternalError),
66            2 => Some(Self::AlreadyPending),
67            3 => Some(Self::RemoteNodeUnavailable),
68            4 => Some(Self::AlreadyBound),
69            5 => Some(Self::NotSupported),
70            6 => Some(Self::WouldBlock),
71            7 => Some(Self::NoResources),
72            8 => Some(Self::InvalidArgs),
73            _ => None,
74        }
75    }
76
77    #[inline]
78    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
79        match prim {
80            1 => Self::InternalError,
81            2 => Self::AlreadyPending,
82            3 => Self::RemoteNodeUnavailable,
83            4 => Self::AlreadyBound,
84            5 => Self::NotSupported,
85            6 => Self::WouldBlock,
86            7 => Self::NoResources,
87            8 => Self::InvalidArgs,
88            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
89        }
90    }
91
92    #[inline]
93    pub fn unknown() -> Self {
94        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
95    }
96
97    #[inline]
98    pub const fn into_primitive(self) -> u32 {
99        match self {
100            Self::InternalError => 1,
101            Self::AlreadyPending => 2,
102            Self::RemoteNodeUnavailable => 3,
103            Self::AlreadyBound => 4,
104            Self::NotSupported => 5,
105            Self::WouldBlock => 6,
106            Self::NoResources => 7,
107            Self::InvalidArgs => 8,
108            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
109        }
110    }
111
112    #[inline]
113    pub fn is_unknown(&self) -> bool {
114        match self {
115            Self::__SourceBreaking { unknown_ordinal: _ } => true,
116            _ => false,
117        }
118    }
119}
120
121#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
122pub struct QrtrClientConnectionWriteRequest {
123    pub dst_node_id: u32,
124    pub dst_port: u32,
125    pub data: Vec<u8>,
126}
127
128impl fidl::Persistable for QrtrClientConnectionWriteRequest {}
129
130#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
131#[repr(C)]
132pub struct QrtrClientConnectionGetNodeIdResponse {
133    pub node_id: u32,
134}
135
136impl fidl::Persistable for QrtrClientConnectionGetNodeIdResponse {}
137
138#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
139#[repr(C)]
140pub struct QrtrClientConnectionGetPortIdResponse {
141    pub port_id: u32,
142}
143
144impl fidl::Persistable for QrtrClientConnectionGetPortIdResponse {}
145
146#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
147pub struct QrtrClientConnectionReadResponse {
148    pub src_node_id: u32,
149    pub src_port: u32,
150    pub data: Vec<u8>,
151}
152
153impl fidl::Persistable for QrtrClientConnectionReadResponse {}
154
155#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
156pub struct QrtrTransportChannelWriteRequest {
157    pub data: Vec<u8>,
158}
159
160impl fidl::Persistable for QrtrTransportChannelWriteRequest {}
161
162#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
163pub struct QrtrTransportChannelReadResponse {
164    pub data: Vec<u8>,
165}
166
167impl fidl::Persistable for QrtrTransportChannelReadResponse {}
168
169/// Connection Options used by QrtrConnector.
170#[derive(Clone, Debug, Default, PartialEq)]
171pub struct ConnectionOptions {
172    /// Blocking mode
173    ///
174    /// Optional. Interpreted as true if absent.
175    pub blocking: Option<bool>,
176    /// Request to reserve a Port when creating the connection.
177    ///
178    /// Optional.
179    pub port: Option<u32>,
180    #[doc(hidden)]
181    pub __source_breaking: fidl::marker::SourceBreaking,
182}
183
184impl fidl::Persistable for ConnectionOptions {}
185
186#[derive(Clone, Debug, Default, PartialEq)]
187pub struct TransportConnectionOptions {
188    /// Network Cluster ID
189    ///
190    /// Optional. Interpreted as `NET_ID_DEFAULT_VALUE` if absent.
191    pub net_id: Option<u32>,
192    #[doc(hidden)]
193    pub __source_breaking: fidl::marker::SourceBreaking,
194}
195
196impl fidl::Persistable for TransportConnectionOptions {}
197
198pub mod qrtr_client_connection_ordinals {
199    pub const READ: u64 = 0x1647cf125346d619;
200    pub const WRITE: u64 = 0x777f5423e2e75f51;
201    pub const GET_SIGNALS: u64 = 0x6a71227b57862ad7;
202    pub const GET_PORT_ID: u64 = 0xb66d6d257f16ad2;
203    pub const GET_NODE_ID: u64 = 0x2ddd28cdb89d2c44;
204    pub const CLOSE_CONNECTION: u64 = 0x4645ccec1b86380f;
205}
206
207pub mod qrtr_connector_ordinals {
208    pub const GET_CONNECTION: u64 = 0x1df578179c1f2445;
209}
210
211pub mod qrtr_transport_channel_ordinals {
212    pub const READ: u64 = 0x1ea3f950c311b3e9;
213    pub const WRITE: u64 = 0xba66b9de6960dd2;
214}
215
216pub mod qrtr_transport_connector_ordinals {
217    pub const ESTABLISH_CONNECTION: u64 = 0xd19f34bea9b6c17;
218}
219
220mod internal {
221    use super::*;
222    unsafe impl fidl::encoding::TypeMarker for Error {
223        type Owned = Self;
224
225        #[inline(always)]
226        fn inline_align(_context: fidl::encoding::Context) -> usize {
227            std::mem::align_of::<u32>()
228        }
229
230        #[inline(always)]
231        fn inline_size(_context: fidl::encoding::Context) -> usize {
232            std::mem::size_of::<u32>()
233        }
234
235        #[inline(always)]
236        fn encode_is_copy() -> bool {
237            false
238        }
239
240        #[inline(always)]
241        fn decode_is_copy() -> bool {
242            false
243        }
244    }
245
246    impl fidl::encoding::ValueTypeMarker for Error {
247        type Borrowed<'a> = Self;
248        #[inline(always)]
249        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
250            *value
251        }
252    }
253
254    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
255        #[inline]
256        unsafe fn encode(
257            self,
258            encoder: &mut fidl::encoding::Encoder<'_, D>,
259            offset: usize,
260            _depth: fidl::encoding::Depth,
261        ) -> fidl::Result<()> {
262            encoder.debug_check_bounds::<Self>(offset);
263            encoder.write_num(self.into_primitive(), offset);
264            Ok(())
265        }
266    }
267
268    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
269        #[inline(always)]
270        fn new_empty() -> Self {
271            Self::unknown()
272        }
273
274        #[inline]
275        unsafe fn decode(
276            &mut self,
277            decoder: &mut fidl::encoding::Decoder<'_, D>,
278            offset: usize,
279            _depth: fidl::encoding::Depth,
280        ) -> fidl::Result<()> {
281            decoder.debug_check_bounds::<Self>(offset);
282            let prim = decoder.read_num::<u32>(offset);
283
284            *self = Self::from_primitive_allow_unknown(prim);
285            Ok(())
286        }
287    }
288
289    impl fidl::encoding::ValueTypeMarker for QrtrClientConnectionWriteRequest {
290        type Borrowed<'a> = &'a Self;
291        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
292            value
293        }
294    }
295
296    unsafe impl fidl::encoding::TypeMarker for QrtrClientConnectionWriteRequest {
297        type Owned = Self;
298
299        #[inline(always)]
300        fn inline_align(_context: fidl::encoding::Context) -> usize {
301            8
302        }
303
304        #[inline(always)]
305        fn inline_size(_context: fidl::encoding::Context) -> usize {
306            24
307        }
308    }
309
310    unsafe impl<D: fidl::encoding::ResourceDialect>
311        fidl::encoding::Encode<QrtrClientConnectionWriteRequest, D>
312        for &QrtrClientConnectionWriteRequest
313    {
314        #[inline]
315        unsafe fn encode(
316            self,
317            encoder: &mut fidl::encoding::Encoder<'_, D>,
318            offset: usize,
319            _depth: fidl::encoding::Depth,
320        ) -> fidl::Result<()> {
321            encoder.debug_check_bounds::<QrtrClientConnectionWriteRequest>(offset);
322            // Delegate to tuple encoding.
323            fidl::encoding::Encode::<QrtrClientConnectionWriteRequest, D>::encode(
324                (
325                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.dst_node_id),
326                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.dst_port),
327                    <fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(&self.data),
328                ),
329                encoder, offset, _depth
330            )
331        }
332    }
333    unsafe impl<
334        D: fidl::encoding::ResourceDialect,
335        T0: fidl::encoding::Encode<u32, D>,
336        T1: fidl::encoding::Encode<u32, D>,
337        T2: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
338    > fidl::encoding::Encode<QrtrClientConnectionWriteRequest, D> for (T0, T1, T2)
339    {
340        #[inline]
341        unsafe fn encode(
342            self,
343            encoder: &mut fidl::encoding::Encoder<'_, D>,
344            offset: usize,
345            depth: fidl::encoding::Depth,
346        ) -> fidl::Result<()> {
347            encoder.debug_check_bounds::<QrtrClientConnectionWriteRequest>(offset);
348            // Zero out padding regions. There's no need to apply masks
349            // because the unmasked parts will be overwritten by fields.
350            // Write the fields.
351            self.0.encode(encoder, offset + 0, depth)?;
352            self.1.encode(encoder, offset + 4, depth)?;
353            self.2.encode(encoder, offset + 8, depth)?;
354            Ok(())
355        }
356    }
357
358    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
359        for QrtrClientConnectionWriteRequest
360    {
361        #[inline(always)]
362        fn new_empty() -> Self {
363            Self {
364                dst_node_id: fidl::new_empty!(u32, D),
365                dst_port: fidl::new_empty!(u32, D),
366                data: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D),
367            }
368        }
369
370        #[inline]
371        unsafe fn decode(
372            &mut self,
373            decoder: &mut fidl::encoding::Decoder<'_, D>,
374            offset: usize,
375            _depth: fidl::encoding::Depth,
376        ) -> fidl::Result<()> {
377            decoder.debug_check_bounds::<Self>(offset);
378            // Verify that padding bytes are zero.
379            fidl::decode!(u32, D, &mut self.dst_node_id, decoder, offset + 0, _depth)?;
380            fidl::decode!(u32, D, &mut self.dst_port, decoder, offset + 4, _depth)?;
381            fidl::decode!(
382                fidl::encoding::UnboundedVector<u8>,
383                D,
384                &mut self.data,
385                decoder,
386                offset + 8,
387                _depth
388            )?;
389            Ok(())
390        }
391    }
392
393    impl fidl::encoding::ValueTypeMarker for QrtrClientConnectionGetNodeIdResponse {
394        type Borrowed<'a> = &'a Self;
395        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
396            value
397        }
398    }
399
400    unsafe impl fidl::encoding::TypeMarker for QrtrClientConnectionGetNodeIdResponse {
401        type Owned = Self;
402
403        #[inline(always)]
404        fn inline_align(_context: fidl::encoding::Context) -> usize {
405            4
406        }
407
408        #[inline(always)]
409        fn inline_size(_context: fidl::encoding::Context) -> usize {
410            4
411        }
412        #[inline(always)]
413        fn encode_is_copy() -> bool {
414            true
415        }
416
417        #[inline(always)]
418        fn decode_is_copy() -> bool {
419            true
420        }
421    }
422
423    unsafe impl<D: fidl::encoding::ResourceDialect>
424        fidl::encoding::Encode<QrtrClientConnectionGetNodeIdResponse, D>
425        for &QrtrClientConnectionGetNodeIdResponse
426    {
427        #[inline]
428        unsafe fn encode(
429            self,
430            encoder: &mut fidl::encoding::Encoder<'_, D>,
431            offset: usize,
432            _depth: fidl::encoding::Depth,
433        ) -> fidl::Result<()> {
434            encoder.debug_check_bounds::<QrtrClientConnectionGetNodeIdResponse>(offset);
435            unsafe {
436                // Copy the object into the buffer.
437                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
438                (buf_ptr as *mut QrtrClientConnectionGetNodeIdResponse)
439                    .write_unaligned((self as *const QrtrClientConnectionGetNodeIdResponse).read());
440                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
441                // done second because the memcpy will write garbage to these bytes.
442            }
443            Ok(())
444        }
445    }
446    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
447        fidl::encoding::Encode<QrtrClientConnectionGetNodeIdResponse, D> for (T0,)
448    {
449        #[inline]
450        unsafe fn encode(
451            self,
452            encoder: &mut fidl::encoding::Encoder<'_, D>,
453            offset: usize,
454            depth: fidl::encoding::Depth,
455        ) -> fidl::Result<()> {
456            encoder.debug_check_bounds::<QrtrClientConnectionGetNodeIdResponse>(offset);
457            // Zero out padding regions. There's no need to apply masks
458            // because the unmasked parts will be overwritten by fields.
459            // Write the fields.
460            self.0.encode(encoder, offset + 0, depth)?;
461            Ok(())
462        }
463    }
464
465    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
466        for QrtrClientConnectionGetNodeIdResponse
467    {
468        #[inline(always)]
469        fn new_empty() -> Self {
470            Self { node_id: fidl::new_empty!(u32, D) }
471        }
472
473        #[inline]
474        unsafe fn decode(
475            &mut self,
476            decoder: &mut fidl::encoding::Decoder<'_, D>,
477            offset: usize,
478            _depth: fidl::encoding::Depth,
479        ) -> fidl::Result<()> {
480            decoder.debug_check_bounds::<Self>(offset);
481            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
482            // Verify that padding bytes are zero.
483            // Copy from the buffer into the object.
484            unsafe {
485                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
486            }
487            Ok(())
488        }
489    }
490
491    impl fidl::encoding::ValueTypeMarker for QrtrClientConnectionGetPortIdResponse {
492        type Borrowed<'a> = &'a Self;
493        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
494            value
495        }
496    }
497
498    unsafe impl fidl::encoding::TypeMarker for QrtrClientConnectionGetPortIdResponse {
499        type Owned = Self;
500
501        #[inline(always)]
502        fn inline_align(_context: fidl::encoding::Context) -> usize {
503            4
504        }
505
506        #[inline(always)]
507        fn inline_size(_context: fidl::encoding::Context) -> usize {
508            4
509        }
510        #[inline(always)]
511        fn encode_is_copy() -> bool {
512            true
513        }
514
515        #[inline(always)]
516        fn decode_is_copy() -> bool {
517            true
518        }
519    }
520
521    unsafe impl<D: fidl::encoding::ResourceDialect>
522        fidl::encoding::Encode<QrtrClientConnectionGetPortIdResponse, D>
523        for &QrtrClientConnectionGetPortIdResponse
524    {
525        #[inline]
526        unsafe fn encode(
527            self,
528            encoder: &mut fidl::encoding::Encoder<'_, D>,
529            offset: usize,
530            _depth: fidl::encoding::Depth,
531        ) -> fidl::Result<()> {
532            encoder.debug_check_bounds::<QrtrClientConnectionGetPortIdResponse>(offset);
533            unsafe {
534                // Copy the object into the buffer.
535                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
536                (buf_ptr as *mut QrtrClientConnectionGetPortIdResponse)
537                    .write_unaligned((self as *const QrtrClientConnectionGetPortIdResponse).read());
538                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
539                // done second because the memcpy will write garbage to these bytes.
540            }
541            Ok(())
542        }
543    }
544    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
545        fidl::encoding::Encode<QrtrClientConnectionGetPortIdResponse, D> for (T0,)
546    {
547        #[inline]
548        unsafe fn encode(
549            self,
550            encoder: &mut fidl::encoding::Encoder<'_, D>,
551            offset: usize,
552            depth: fidl::encoding::Depth,
553        ) -> fidl::Result<()> {
554            encoder.debug_check_bounds::<QrtrClientConnectionGetPortIdResponse>(offset);
555            // Zero out padding regions. There's no need to apply masks
556            // because the unmasked parts will be overwritten by fields.
557            // Write the fields.
558            self.0.encode(encoder, offset + 0, depth)?;
559            Ok(())
560        }
561    }
562
563    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
564        for QrtrClientConnectionGetPortIdResponse
565    {
566        #[inline(always)]
567        fn new_empty() -> Self {
568            Self { port_id: fidl::new_empty!(u32, D) }
569        }
570
571        #[inline]
572        unsafe fn decode(
573            &mut self,
574            decoder: &mut fidl::encoding::Decoder<'_, D>,
575            offset: usize,
576            _depth: fidl::encoding::Depth,
577        ) -> fidl::Result<()> {
578            decoder.debug_check_bounds::<Self>(offset);
579            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
580            // Verify that padding bytes are zero.
581            // Copy from the buffer into the object.
582            unsafe {
583                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
584            }
585            Ok(())
586        }
587    }
588
589    impl fidl::encoding::ValueTypeMarker for QrtrClientConnectionReadResponse {
590        type Borrowed<'a> = &'a Self;
591        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
592            value
593        }
594    }
595
596    unsafe impl fidl::encoding::TypeMarker for QrtrClientConnectionReadResponse {
597        type Owned = Self;
598
599        #[inline(always)]
600        fn inline_align(_context: fidl::encoding::Context) -> usize {
601            8
602        }
603
604        #[inline(always)]
605        fn inline_size(_context: fidl::encoding::Context) -> usize {
606            24
607        }
608    }
609
610    unsafe impl<D: fidl::encoding::ResourceDialect>
611        fidl::encoding::Encode<QrtrClientConnectionReadResponse, D>
612        for &QrtrClientConnectionReadResponse
613    {
614        #[inline]
615        unsafe fn encode(
616            self,
617            encoder: &mut fidl::encoding::Encoder<'_, D>,
618            offset: usize,
619            _depth: fidl::encoding::Depth,
620        ) -> fidl::Result<()> {
621            encoder.debug_check_bounds::<QrtrClientConnectionReadResponse>(offset);
622            // Delegate to tuple encoding.
623            fidl::encoding::Encode::<QrtrClientConnectionReadResponse, D>::encode(
624                (
625                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.src_node_id),
626                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.src_port),
627                    <fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(&self.data),
628                ),
629                encoder, offset, _depth
630            )
631        }
632    }
633    unsafe impl<
634        D: fidl::encoding::ResourceDialect,
635        T0: fidl::encoding::Encode<u32, D>,
636        T1: fidl::encoding::Encode<u32, D>,
637        T2: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
638    > fidl::encoding::Encode<QrtrClientConnectionReadResponse, D> for (T0, T1, T2)
639    {
640        #[inline]
641        unsafe fn encode(
642            self,
643            encoder: &mut fidl::encoding::Encoder<'_, D>,
644            offset: usize,
645            depth: fidl::encoding::Depth,
646        ) -> fidl::Result<()> {
647            encoder.debug_check_bounds::<QrtrClientConnectionReadResponse>(offset);
648            // Zero out padding regions. There's no need to apply masks
649            // because the unmasked parts will be overwritten by fields.
650            // Write the fields.
651            self.0.encode(encoder, offset + 0, depth)?;
652            self.1.encode(encoder, offset + 4, depth)?;
653            self.2.encode(encoder, offset + 8, depth)?;
654            Ok(())
655        }
656    }
657
658    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
659        for QrtrClientConnectionReadResponse
660    {
661        #[inline(always)]
662        fn new_empty() -> Self {
663            Self {
664                src_node_id: fidl::new_empty!(u32, D),
665                src_port: fidl::new_empty!(u32, D),
666                data: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D),
667            }
668        }
669
670        #[inline]
671        unsafe fn decode(
672            &mut self,
673            decoder: &mut fidl::encoding::Decoder<'_, D>,
674            offset: usize,
675            _depth: fidl::encoding::Depth,
676        ) -> fidl::Result<()> {
677            decoder.debug_check_bounds::<Self>(offset);
678            // Verify that padding bytes are zero.
679            fidl::decode!(u32, D, &mut self.src_node_id, decoder, offset + 0, _depth)?;
680            fidl::decode!(u32, D, &mut self.src_port, decoder, offset + 4, _depth)?;
681            fidl::decode!(
682                fidl::encoding::UnboundedVector<u8>,
683                D,
684                &mut self.data,
685                decoder,
686                offset + 8,
687                _depth
688            )?;
689            Ok(())
690        }
691    }
692
693    impl fidl::encoding::ValueTypeMarker for QrtrTransportChannelWriteRequest {
694        type Borrowed<'a> = &'a Self;
695        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
696            value
697        }
698    }
699
700    unsafe impl fidl::encoding::TypeMarker for QrtrTransportChannelWriteRequest {
701        type Owned = Self;
702
703        #[inline(always)]
704        fn inline_align(_context: fidl::encoding::Context) -> usize {
705            8
706        }
707
708        #[inline(always)]
709        fn inline_size(_context: fidl::encoding::Context) -> usize {
710            16
711        }
712    }
713
714    unsafe impl<D: fidl::encoding::ResourceDialect>
715        fidl::encoding::Encode<QrtrTransportChannelWriteRequest, D>
716        for &QrtrTransportChannelWriteRequest
717    {
718        #[inline]
719        unsafe fn encode(
720            self,
721            encoder: &mut fidl::encoding::Encoder<'_, D>,
722            offset: usize,
723            _depth: fidl::encoding::Depth,
724        ) -> fidl::Result<()> {
725            encoder.debug_check_bounds::<QrtrTransportChannelWriteRequest>(offset);
726            // Delegate to tuple encoding.
727            fidl::encoding::Encode::<QrtrTransportChannelWriteRequest, D>::encode(
728                (<fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(
729                    &self.data,
730                ),),
731                encoder,
732                offset,
733                _depth,
734            )
735        }
736    }
737    unsafe impl<
738        D: fidl::encoding::ResourceDialect,
739        T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
740    > fidl::encoding::Encode<QrtrTransportChannelWriteRequest, D> for (T0,)
741    {
742        #[inline]
743        unsafe fn encode(
744            self,
745            encoder: &mut fidl::encoding::Encoder<'_, D>,
746            offset: usize,
747            depth: fidl::encoding::Depth,
748        ) -> fidl::Result<()> {
749            encoder.debug_check_bounds::<QrtrTransportChannelWriteRequest>(offset);
750            // Zero out padding regions. There's no need to apply masks
751            // because the unmasked parts will be overwritten by fields.
752            // Write the fields.
753            self.0.encode(encoder, offset + 0, depth)?;
754            Ok(())
755        }
756    }
757
758    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
759        for QrtrTransportChannelWriteRequest
760    {
761        #[inline(always)]
762        fn new_empty() -> Self {
763            Self { data: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D) }
764        }
765
766        #[inline]
767        unsafe fn decode(
768            &mut self,
769            decoder: &mut fidl::encoding::Decoder<'_, D>,
770            offset: usize,
771            _depth: fidl::encoding::Depth,
772        ) -> fidl::Result<()> {
773            decoder.debug_check_bounds::<Self>(offset);
774            // Verify that padding bytes are zero.
775            fidl::decode!(
776                fidl::encoding::UnboundedVector<u8>,
777                D,
778                &mut self.data,
779                decoder,
780                offset + 0,
781                _depth
782            )?;
783            Ok(())
784        }
785    }
786
787    impl fidl::encoding::ValueTypeMarker for QrtrTransportChannelReadResponse {
788        type Borrowed<'a> = &'a Self;
789        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
790            value
791        }
792    }
793
794    unsafe impl fidl::encoding::TypeMarker for QrtrTransportChannelReadResponse {
795        type Owned = Self;
796
797        #[inline(always)]
798        fn inline_align(_context: fidl::encoding::Context) -> usize {
799            8
800        }
801
802        #[inline(always)]
803        fn inline_size(_context: fidl::encoding::Context) -> usize {
804            16
805        }
806    }
807
808    unsafe impl<D: fidl::encoding::ResourceDialect>
809        fidl::encoding::Encode<QrtrTransportChannelReadResponse, D>
810        for &QrtrTransportChannelReadResponse
811    {
812        #[inline]
813        unsafe fn encode(
814            self,
815            encoder: &mut fidl::encoding::Encoder<'_, D>,
816            offset: usize,
817            _depth: fidl::encoding::Depth,
818        ) -> fidl::Result<()> {
819            encoder.debug_check_bounds::<QrtrTransportChannelReadResponse>(offset);
820            // Delegate to tuple encoding.
821            fidl::encoding::Encode::<QrtrTransportChannelReadResponse, D>::encode(
822                (<fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(
823                    &self.data,
824                ),),
825                encoder,
826                offset,
827                _depth,
828            )
829        }
830    }
831    unsafe impl<
832        D: fidl::encoding::ResourceDialect,
833        T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
834    > fidl::encoding::Encode<QrtrTransportChannelReadResponse, D> for (T0,)
835    {
836        #[inline]
837        unsafe fn encode(
838            self,
839            encoder: &mut fidl::encoding::Encoder<'_, D>,
840            offset: usize,
841            depth: fidl::encoding::Depth,
842        ) -> fidl::Result<()> {
843            encoder.debug_check_bounds::<QrtrTransportChannelReadResponse>(offset);
844            // Zero out padding regions. There's no need to apply masks
845            // because the unmasked parts will be overwritten by fields.
846            // Write the fields.
847            self.0.encode(encoder, offset + 0, depth)?;
848            Ok(())
849        }
850    }
851
852    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
853        for QrtrTransportChannelReadResponse
854    {
855        #[inline(always)]
856        fn new_empty() -> Self {
857            Self { data: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D) }
858        }
859
860        #[inline]
861        unsafe fn decode(
862            &mut self,
863            decoder: &mut fidl::encoding::Decoder<'_, D>,
864            offset: usize,
865            _depth: fidl::encoding::Depth,
866        ) -> fidl::Result<()> {
867            decoder.debug_check_bounds::<Self>(offset);
868            // Verify that padding bytes are zero.
869            fidl::decode!(
870                fidl::encoding::UnboundedVector<u8>,
871                D,
872                &mut self.data,
873                decoder,
874                offset + 0,
875                _depth
876            )?;
877            Ok(())
878        }
879    }
880
881    impl ConnectionOptions {
882        #[inline(always)]
883        fn max_ordinal_present(&self) -> u64 {
884            if let Some(_) = self.port {
885                return 2;
886            }
887            if let Some(_) = self.blocking {
888                return 1;
889            }
890            0
891        }
892    }
893
894    impl fidl::encoding::ValueTypeMarker for ConnectionOptions {
895        type Borrowed<'a> = &'a Self;
896        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
897            value
898        }
899    }
900
901    unsafe impl fidl::encoding::TypeMarker for ConnectionOptions {
902        type Owned = Self;
903
904        #[inline(always)]
905        fn inline_align(_context: fidl::encoding::Context) -> usize {
906            8
907        }
908
909        #[inline(always)]
910        fn inline_size(_context: fidl::encoding::Context) -> usize {
911            16
912        }
913    }
914
915    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ConnectionOptions, D>
916        for &ConnectionOptions
917    {
918        unsafe fn encode(
919            self,
920            encoder: &mut fidl::encoding::Encoder<'_, D>,
921            offset: usize,
922            mut depth: fidl::encoding::Depth,
923        ) -> fidl::Result<()> {
924            encoder.debug_check_bounds::<ConnectionOptions>(offset);
925            // Vector header
926            let max_ordinal: u64 = self.max_ordinal_present();
927            encoder.write_num(max_ordinal, offset);
928            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
929            // Calling encoder.out_of_line_offset(0) is not allowed.
930            if max_ordinal == 0 {
931                return Ok(());
932            }
933            depth.increment()?;
934            let envelope_size = 8;
935            let bytes_len = max_ordinal as usize * envelope_size;
936            #[allow(unused_variables)]
937            let offset = encoder.out_of_line_offset(bytes_len);
938            let mut _prev_end_offset: usize = 0;
939            if 1 > max_ordinal {
940                return Ok(());
941            }
942
943            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
944            // are envelope_size bytes.
945            let cur_offset: usize = (1 - 1) * envelope_size;
946
947            // Zero reserved fields.
948            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
949
950            // Safety:
951            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
952            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
953            //   envelope_size bytes, there is always sufficient room.
954            fidl::encoding::encode_in_envelope_optional::<bool, D>(
955                self.blocking.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
956                encoder,
957                offset + cur_offset,
958                depth,
959            )?;
960
961            _prev_end_offset = cur_offset + envelope_size;
962            if 2 > max_ordinal {
963                return Ok(());
964            }
965
966            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
967            // are envelope_size bytes.
968            let cur_offset: usize = (2 - 1) * envelope_size;
969
970            // Zero reserved fields.
971            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
972
973            // Safety:
974            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
975            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
976            //   envelope_size bytes, there is always sufficient room.
977            fidl::encoding::encode_in_envelope_optional::<u32, D>(
978                self.port.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
979                encoder,
980                offset + cur_offset,
981                depth,
982            )?;
983
984            _prev_end_offset = cur_offset + envelope_size;
985
986            Ok(())
987        }
988    }
989
990    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ConnectionOptions {
991        #[inline(always)]
992        fn new_empty() -> Self {
993            Self::default()
994        }
995
996        unsafe fn decode(
997            &mut self,
998            decoder: &mut fidl::encoding::Decoder<'_, D>,
999            offset: usize,
1000            mut depth: fidl::encoding::Depth,
1001        ) -> fidl::Result<()> {
1002            decoder.debug_check_bounds::<Self>(offset);
1003            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1004                None => return Err(fidl::Error::NotNullable),
1005                Some(len) => len,
1006            };
1007            // Calling decoder.out_of_line_offset(0) is not allowed.
1008            if len == 0 {
1009                return Ok(());
1010            };
1011            depth.increment()?;
1012            let envelope_size = 8;
1013            let bytes_len = len * envelope_size;
1014            let offset = decoder.out_of_line_offset(bytes_len)?;
1015            // Decode the envelope for each type.
1016            let mut _next_ordinal_to_read = 0;
1017            let mut next_offset = offset;
1018            let end_offset = offset + bytes_len;
1019            _next_ordinal_to_read += 1;
1020            if next_offset >= end_offset {
1021                return Ok(());
1022            }
1023
1024            // Decode unknown envelopes for gaps in ordinals.
1025            while _next_ordinal_to_read < 1 {
1026                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1027                _next_ordinal_to_read += 1;
1028                next_offset += envelope_size;
1029            }
1030
1031            let next_out_of_line = decoder.next_out_of_line();
1032            let handles_before = decoder.remaining_handles();
1033            if let Some((inlined, num_bytes, num_handles)) =
1034                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1035            {
1036                let member_inline_size =
1037                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1038                if inlined != (member_inline_size <= 4) {
1039                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1040                }
1041                let inner_offset;
1042                let mut inner_depth = depth.clone();
1043                if inlined {
1044                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1045                    inner_offset = next_offset;
1046                } else {
1047                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1048                    inner_depth.increment()?;
1049                }
1050                let val_ref = self.blocking.get_or_insert_with(|| fidl::new_empty!(bool, D));
1051                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1052                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1053                {
1054                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1055                }
1056                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1057                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1058                }
1059            }
1060
1061            next_offset += envelope_size;
1062            _next_ordinal_to_read += 1;
1063            if next_offset >= end_offset {
1064                return Ok(());
1065            }
1066
1067            // Decode unknown envelopes for gaps in ordinals.
1068            while _next_ordinal_to_read < 2 {
1069                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1070                _next_ordinal_to_read += 1;
1071                next_offset += envelope_size;
1072            }
1073
1074            let next_out_of_line = decoder.next_out_of_line();
1075            let handles_before = decoder.remaining_handles();
1076            if let Some((inlined, num_bytes, num_handles)) =
1077                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1078            {
1079                let member_inline_size =
1080                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1081                if inlined != (member_inline_size <= 4) {
1082                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1083                }
1084                let inner_offset;
1085                let mut inner_depth = depth.clone();
1086                if inlined {
1087                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1088                    inner_offset = next_offset;
1089                } else {
1090                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1091                    inner_depth.increment()?;
1092                }
1093                let val_ref = self.port.get_or_insert_with(|| fidl::new_empty!(u32, D));
1094                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1095                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1096                {
1097                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1098                }
1099                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1100                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1101                }
1102            }
1103
1104            next_offset += envelope_size;
1105
1106            // Decode the remaining unknown envelopes.
1107            while next_offset < end_offset {
1108                _next_ordinal_to_read += 1;
1109                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1110                next_offset += envelope_size;
1111            }
1112
1113            Ok(())
1114        }
1115    }
1116
1117    impl TransportConnectionOptions {
1118        #[inline(always)]
1119        fn max_ordinal_present(&self) -> u64 {
1120            if let Some(_) = self.net_id {
1121                return 1;
1122            }
1123            0
1124        }
1125    }
1126
1127    impl fidl::encoding::ValueTypeMarker for TransportConnectionOptions {
1128        type Borrowed<'a> = &'a Self;
1129        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1130            value
1131        }
1132    }
1133
1134    unsafe impl fidl::encoding::TypeMarker for TransportConnectionOptions {
1135        type Owned = Self;
1136
1137        #[inline(always)]
1138        fn inline_align(_context: fidl::encoding::Context) -> usize {
1139            8
1140        }
1141
1142        #[inline(always)]
1143        fn inline_size(_context: fidl::encoding::Context) -> usize {
1144            16
1145        }
1146    }
1147
1148    unsafe impl<D: fidl::encoding::ResourceDialect>
1149        fidl::encoding::Encode<TransportConnectionOptions, D> for &TransportConnectionOptions
1150    {
1151        unsafe fn encode(
1152            self,
1153            encoder: &mut fidl::encoding::Encoder<'_, D>,
1154            offset: usize,
1155            mut depth: fidl::encoding::Depth,
1156        ) -> fidl::Result<()> {
1157            encoder.debug_check_bounds::<TransportConnectionOptions>(offset);
1158            // Vector header
1159            let max_ordinal: u64 = self.max_ordinal_present();
1160            encoder.write_num(max_ordinal, offset);
1161            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1162            // Calling encoder.out_of_line_offset(0) is not allowed.
1163            if max_ordinal == 0 {
1164                return Ok(());
1165            }
1166            depth.increment()?;
1167            let envelope_size = 8;
1168            let bytes_len = max_ordinal as usize * envelope_size;
1169            #[allow(unused_variables)]
1170            let offset = encoder.out_of_line_offset(bytes_len);
1171            let mut _prev_end_offset: usize = 0;
1172            if 1 > max_ordinal {
1173                return Ok(());
1174            }
1175
1176            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1177            // are envelope_size bytes.
1178            let cur_offset: usize = (1 - 1) * envelope_size;
1179
1180            // Zero reserved fields.
1181            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1182
1183            // Safety:
1184            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1185            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1186            //   envelope_size bytes, there is always sufficient room.
1187            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1188                self.net_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1189                encoder,
1190                offset + cur_offset,
1191                depth,
1192            )?;
1193
1194            _prev_end_offset = cur_offset + envelope_size;
1195
1196            Ok(())
1197        }
1198    }
1199
1200    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1201        for TransportConnectionOptions
1202    {
1203        #[inline(always)]
1204        fn new_empty() -> Self {
1205            Self::default()
1206        }
1207
1208        unsafe fn decode(
1209            &mut self,
1210            decoder: &mut fidl::encoding::Decoder<'_, D>,
1211            offset: usize,
1212            mut depth: fidl::encoding::Depth,
1213        ) -> fidl::Result<()> {
1214            decoder.debug_check_bounds::<Self>(offset);
1215            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1216                None => return Err(fidl::Error::NotNullable),
1217                Some(len) => len,
1218            };
1219            // Calling decoder.out_of_line_offset(0) is not allowed.
1220            if len == 0 {
1221                return Ok(());
1222            };
1223            depth.increment()?;
1224            let envelope_size = 8;
1225            let bytes_len = len * envelope_size;
1226            let offset = decoder.out_of_line_offset(bytes_len)?;
1227            // Decode the envelope for each type.
1228            let mut _next_ordinal_to_read = 0;
1229            let mut next_offset = offset;
1230            let end_offset = offset + bytes_len;
1231            _next_ordinal_to_read += 1;
1232            if next_offset >= end_offset {
1233                return Ok(());
1234            }
1235
1236            // Decode unknown envelopes for gaps in ordinals.
1237            while _next_ordinal_to_read < 1 {
1238                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1239                _next_ordinal_to_read += 1;
1240                next_offset += envelope_size;
1241            }
1242
1243            let next_out_of_line = decoder.next_out_of_line();
1244            let handles_before = decoder.remaining_handles();
1245            if let Some((inlined, num_bytes, num_handles)) =
1246                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1247            {
1248                let member_inline_size =
1249                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1250                if inlined != (member_inline_size <= 4) {
1251                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1252                }
1253                let inner_offset;
1254                let mut inner_depth = depth.clone();
1255                if inlined {
1256                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1257                    inner_offset = next_offset;
1258                } else {
1259                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1260                    inner_depth.increment()?;
1261                }
1262                let val_ref = self.net_id.get_or_insert_with(|| fidl::new_empty!(u32, D));
1263                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1264                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1265                {
1266                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1267                }
1268                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1269                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1270                }
1271            }
1272
1273            next_offset += envelope_size;
1274
1275            // Decode the remaining unknown envelopes.
1276            while next_offset < end_offset {
1277                _next_ordinal_to_read += 1;
1278                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1279                next_offset += envelope_size;
1280            }
1281
1282            Ok(())
1283        }
1284    }
1285}