fidl_fuchsia_vsock__common/
fidl_fuchsia_vsock__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
11pub const SIGNAL_STREAM_INCOMING: u32 = USER_SIGNAL_0 as u32;
12
13pub const USER_SIGNAL_0: u32 = 16777216;
14
15pub const VMADDR_CID_ANY: u32 = fidl_fuchsia_hardware_vsock__common::VMADDR_CID_ANY as u32;
16
17pub const VMADDR_CID_HOST: u32 = fidl_fuchsia_hardware_vsock__common::VMADDR_CID_HOST as u32;
18
19pub const VMADDR_CID_HYPERVISOR: u32 =
20    fidl_fuchsia_hardware_vsock__common::VMADDR_CID_HYPERVISOR as u32;
21
22pub const VMADDR_CID_LOCAL: u32 = fidl_fuchsia_hardware_vsock__common::VMADDR_CID_LOCAL as u32;
23
24#[derive(Clone, Debug, PartialEq)]
25pub struct AcceptorAcceptRequest {
26    pub addr: fidl_fuchsia_hardware_vsock__common::Addr,
27}
28
29impl fidl::Persistable for AcceptorAcceptRequest {}
30
31#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
32#[repr(C)]
33pub struct ConnectorGetCidResponse {
34    pub local_cid: u32,
35}
36
37impl fidl::Persistable for ConnectorGetCidResponse {}
38
39#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
40#[repr(C)]
41pub struct ConnectorConnectResponse {
42    pub local_port: u32,
43}
44
45impl fidl::Persistable for ConnectorConnectResponse {}
46
47#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
48#[repr(C)]
49pub struct ListenerListenRequest {
50    /// The maximum length to which the queue of pending connections waiting to
51    /// be accepted.
52    pub backlog: u32,
53}
54
55impl fidl::Persistable for ListenerListenRequest {}
56
57#[derive(Clone, Debug, PartialEq)]
58pub struct ListenerAcceptResponse {
59    pub addr: fidl_fuchsia_hardware_vsock__common::Addr,
60}
61
62impl fidl::Persistable for ListenerAcceptResponse {}
63
64pub mod acceptor_ordinals {
65    pub const ACCEPT: u64 = 0x21fd057ad9c9f443;
66}
67
68pub mod connection_ordinals {
69    pub const SHUTDOWN: u64 = 0x40da7ca487466971;
70}
71
72pub mod connector_ordinals {
73    pub const CONNECT: u64 = 0xdf55c5e6a6a4117;
74    pub const LISTEN: u64 = 0x17c1371908bacf73;
75    pub const BIND: u64 = 0x6e50cd8c895f2e0;
76    pub const GET_CID: u64 = 0x60b3cfa0b40bdd7c;
77}
78
79pub mod listener_ordinals {
80    pub const LISTEN: u64 = 0x53042f6a15d94464;
81    pub const ACCEPT: u64 = 0x4b71e6389d92d322;
82}
83
84mod internal {
85    use super::*;
86
87    impl fidl::encoding::ValueTypeMarker for AcceptorAcceptRequest {
88        type Borrowed<'a> = &'a Self;
89        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
90            value
91        }
92    }
93
94    unsafe impl fidl::encoding::TypeMarker for AcceptorAcceptRequest {
95        type Owned = Self;
96
97        #[inline(always)]
98        fn inline_align(_context: fidl::encoding::Context) -> usize {
99            4
100        }
101
102        #[inline(always)]
103        fn inline_size(_context: fidl::encoding::Context) -> usize {
104            12
105        }
106    }
107
108    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<AcceptorAcceptRequest, D>
109        for &AcceptorAcceptRequest
110    {
111        #[inline]
112        unsafe fn encode(
113            self,
114            encoder: &mut fidl::encoding::Encoder<'_, D>,
115            offset: usize,
116            _depth: fidl::encoding::Depth,
117        ) -> fidl::Result<()> {
118            encoder.debug_check_bounds::<AcceptorAcceptRequest>(offset);
119            // Delegate to tuple encoding.
120            fidl::encoding::Encode::<AcceptorAcceptRequest, D>::encode(
121                (
122                    <fidl_fuchsia_hardware_vsock__common::Addr as fidl::encoding::ValueTypeMarker>::borrow(&self.addr),
123                ),
124                encoder, offset, _depth
125            )
126        }
127    }
128    unsafe impl<
129            D: fidl::encoding::ResourceDialect,
130            T0: fidl::encoding::Encode<fidl_fuchsia_hardware_vsock__common::Addr, D>,
131        > fidl::encoding::Encode<AcceptorAcceptRequest, D> for (T0,)
132    {
133        #[inline]
134        unsafe fn encode(
135            self,
136            encoder: &mut fidl::encoding::Encoder<'_, D>,
137            offset: usize,
138            depth: fidl::encoding::Depth,
139        ) -> fidl::Result<()> {
140            encoder.debug_check_bounds::<AcceptorAcceptRequest>(offset);
141            // Zero out padding regions. There's no need to apply masks
142            // because the unmasked parts will be overwritten by fields.
143            // Write the fields.
144            self.0.encode(encoder, offset + 0, depth)?;
145            Ok(())
146        }
147    }
148
149    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for AcceptorAcceptRequest {
150        #[inline(always)]
151        fn new_empty() -> Self {
152            Self { addr: fidl::new_empty!(fidl_fuchsia_hardware_vsock__common::Addr, D) }
153        }
154
155        #[inline]
156        unsafe fn decode(
157            &mut self,
158            decoder: &mut fidl::encoding::Decoder<'_, D>,
159            offset: usize,
160            _depth: fidl::encoding::Depth,
161        ) -> fidl::Result<()> {
162            decoder.debug_check_bounds::<Self>(offset);
163            // Verify that padding bytes are zero.
164            fidl::decode!(
165                fidl_fuchsia_hardware_vsock__common::Addr,
166                D,
167                &mut self.addr,
168                decoder,
169                offset + 0,
170                _depth
171            )?;
172            Ok(())
173        }
174    }
175
176    impl fidl::encoding::ValueTypeMarker for ConnectorGetCidResponse {
177        type Borrowed<'a> = &'a Self;
178        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
179            value
180        }
181    }
182
183    unsafe impl fidl::encoding::TypeMarker for ConnectorGetCidResponse {
184        type Owned = Self;
185
186        #[inline(always)]
187        fn inline_align(_context: fidl::encoding::Context) -> usize {
188            4
189        }
190
191        #[inline(always)]
192        fn inline_size(_context: fidl::encoding::Context) -> usize {
193            4
194        }
195        #[inline(always)]
196        fn encode_is_copy() -> bool {
197            true
198        }
199
200        #[inline(always)]
201        fn decode_is_copy() -> bool {
202            true
203        }
204    }
205
206    unsafe impl<D: fidl::encoding::ResourceDialect>
207        fidl::encoding::Encode<ConnectorGetCidResponse, D> for &ConnectorGetCidResponse
208    {
209        #[inline]
210        unsafe fn encode(
211            self,
212            encoder: &mut fidl::encoding::Encoder<'_, D>,
213            offset: usize,
214            _depth: fidl::encoding::Depth,
215        ) -> fidl::Result<()> {
216            encoder.debug_check_bounds::<ConnectorGetCidResponse>(offset);
217            unsafe {
218                // Copy the object into the buffer.
219                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
220                (buf_ptr as *mut ConnectorGetCidResponse)
221                    .write_unaligned((self as *const ConnectorGetCidResponse).read());
222                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
223                // done second because the memcpy will write garbage to these bytes.
224            }
225            Ok(())
226        }
227    }
228    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
229        fidl::encoding::Encode<ConnectorGetCidResponse, D> for (T0,)
230    {
231        #[inline]
232        unsafe fn encode(
233            self,
234            encoder: &mut fidl::encoding::Encoder<'_, D>,
235            offset: usize,
236            depth: fidl::encoding::Depth,
237        ) -> fidl::Result<()> {
238            encoder.debug_check_bounds::<ConnectorGetCidResponse>(offset);
239            // Zero out padding regions. There's no need to apply masks
240            // because the unmasked parts will be overwritten by fields.
241            // Write the fields.
242            self.0.encode(encoder, offset + 0, depth)?;
243            Ok(())
244        }
245    }
246
247    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
248        for ConnectorGetCidResponse
249    {
250        #[inline(always)]
251        fn new_empty() -> Self {
252            Self { local_cid: fidl::new_empty!(u32, D) }
253        }
254
255        #[inline]
256        unsafe fn decode(
257            &mut self,
258            decoder: &mut fidl::encoding::Decoder<'_, D>,
259            offset: usize,
260            _depth: fidl::encoding::Depth,
261        ) -> fidl::Result<()> {
262            decoder.debug_check_bounds::<Self>(offset);
263            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
264            // Verify that padding bytes are zero.
265            // Copy from the buffer into the object.
266            unsafe {
267                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
268            }
269            Ok(())
270        }
271    }
272
273    impl fidl::encoding::ValueTypeMarker for ConnectorConnectResponse {
274        type Borrowed<'a> = &'a Self;
275        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
276            value
277        }
278    }
279
280    unsafe impl fidl::encoding::TypeMarker for ConnectorConnectResponse {
281        type Owned = Self;
282
283        #[inline(always)]
284        fn inline_align(_context: fidl::encoding::Context) -> usize {
285            4
286        }
287
288        #[inline(always)]
289        fn inline_size(_context: fidl::encoding::Context) -> usize {
290            4
291        }
292        #[inline(always)]
293        fn encode_is_copy() -> bool {
294            true
295        }
296
297        #[inline(always)]
298        fn decode_is_copy() -> bool {
299            true
300        }
301    }
302
303    unsafe impl<D: fidl::encoding::ResourceDialect>
304        fidl::encoding::Encode<ConnectorConnectResponse, D> for &ConnectorConnectResponse
305    {
306        #[inline]
307        unsafe fn encode(
308            self,
309            encoder: &mut fidl::encoding::Encoder<'_, D>,
310            offset: usize,
311            _depth: fidl::encoding::Depth,
312        ) -> fidl::Result<()> {
313            encoder.debug_check_bounds::<ConnectorConnectResponse>(offset);
314            unsafe {
315                // Copy the object into the buffer.
316                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
317                (buf_ptr as *mut ConnectorConnectResponse)
318                    .write_unaligned((self as *const ConnectorConnectResponse).read());
319                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
320                // done second because the memcpy will write garbage to these bytes.
321            }
322            Ok(())
323        }
324    }
325    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
326        fidl::encoding::Encode<ConnectorConnectResponse, D> for (T0,)
327    {
328        #[inline]
329        unsafe fn encode(
330            self,
331            encoder: &mut fidl::encoding::Encoder<'_, D>,
332            offset: usize,
333            depth: fidl::encoding::Depth,
334        ) -> fidl::Result<()> {
335            encoder.debug_check_bounds::<ConnectorConnectResponse>(offset);
336            // Zero out padding regions. There's no need to apply masks
337            // because the unmasked parts will be overwritten by fields.
338            // Write the fields.
339            self.0.encode(encoder, offset + 0, depth)?;
340            Ok(())
341        }
342    }
343
344    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
345        for ConnectorConnectResponse
346    {
347        #[inline(always)]
348        fn new_empty() -> Self {
349            Self { local_port: fidl::new_empty!(u32, D) }
350        }
351
352        #[inline]
353        unsafe fn decode(
354            &mut self,
355            decoder: &mut fidl::encoding::Decoder<'_, D>,
356            offset: usize,
357            _depth: fidl::encoding::Depth,
358        ) -> fidl::Result<()> {
359            decoder.debug_check_bounds::<Self>(offset);
360            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
361            // Verify that padding bytes are zero.
362            // Copy from the buffer into the object.
363            unsafe {
364                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
365            }
366            Ok(())
367        }
368    }
369
370    impl fidl::encoding::ValueTypeMarker for ListenerListenRequest {
371        type Borrowed<'a> = &'a Self;
372        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
373            value
374        }
375    }
376
377    unsafe impl fidl::encoding::TypeMarker for ListenerListenRequest {
378        type Owned = Self;
379
380        #[inline(always)]
381        fn inline_align(_context: fidl::encoding::Context) -> usize {
382            4
383        }
384
385        #[inline(always)]
386        fn inline_size(_context: fidl::encoding::Context) -> usize {
387            4
388        }
389        #[inline(always)]
390        fn encode_is_copy() -> bool {
391            true
392        }
393
394        #[inline(always)]
395        fn decode_is_copy() -> bool {
396            true
397        }
398    }
399
400    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ListenerListenRequest, D>
401        for &ListenerListenRequest
402    {
403        #[inline]
404        unsafe fn encode(
405            self,
406            encoder: &mut fidl::encoding::Encoder<'_, D>,
407            offset: usize,
408            _depth: fidl::encoding::Depth,
409        ) -> fidl::Result<()> {
410            encoder.debug_check_bounds::<ListenerListenRequest>(offset);
411            unsafe {
412                // Copy the object into the buffer.
413                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
414                (buf_ptr as *mut ListenerListenRequest)
415                    .write_unaligned((self as *const ListenerListenRequest).read());
416                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
417                // done second because the memcpy will write garbage to these bytes.
418            }
419            Ok(())
420        }
421    }
422    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
423        fidl::encoding::Encode<ListenerListenRequest, D> for (T0,)
424    {
425        #[inline]
426        unsafe fn encode(
427            self,
428            encoder: &mut fidl::encoding::Encoder<'_, D>,
429            offset: usize,
430            depth: fidl::encoding::Depth,
431        ) -> fidl::Result<()> {
432            encoder.debug_check_bounds::<ListenerListenRequest>(offset);
433            // Zero out padding regions. There's no need to apply masks
434            // because the unmasked parts will be overwritten by fields.
435            // Write the fields.
436            self.0.encode(encoder, offset + 0, depth)?;
437            Ok(())
438        }
439    }
440
441    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ListenerListenRequest {
442        #[inline(always)]
443        fn new_empty() -> Self {
444            Self { backlog: fidl::new_empty!(u32, D) }
445        }
446
447        #[inline]
448        unsafe fn decode(
449            &mut self,
450            decoder: &mut fidl::encoding::Decoder<'_, D>,
451            offset: usize,
452            _depth: fidl::encoding::Depth,
453        ) -> fidl::Result<()> {
454            decoder.debug_check_bounds::<Self>(offset);
455            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
456            // Verify that padding bytes are zero.
457            // Copy from the buffer into the object.
458            unsafe {
459                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
460            }
461            Ok(())
462        }
463    }
464
465    impl fidl::encoding::ValueTypeMarker for ListenerAcceptResponse {
466        type Borrowed<'a> = &'a Self;
467        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
468            value
469        }
470    }
471
472    unsafe impl fidl::encoding::TypeMarker for ListenerAcceptResponse {
473        type Owned = Self;
474
475        #[inline(always)]
476        fn inline_align(_context: fidl::encoding::Context) -> usize {
477            4
478        }
479
480        #[inline(always)]
481        fn inline_size(_context: fidl::encoding::Context) -> usize {
482            12
483        }
484    }
485
486    unsafe impl<D: fidl::encoding::ResourceDialect>
487        fidl::encoding::Encode<ListenerAcceptResponse, D> for &ListenerAcceptResponse
488    {
489        #[inline]
490        unsafe fn encode(
491            self,
492            encoder: &mut fidl::encoding::Encoder<'_, D>,
493            offset: usize,
494            _depth: fidl::encoding::Depth,
495        ) -> fidl::Result<()> {
496            encoder.debug_check_bounds::<ListenerAcceptResponse>(offset);
497            // Delegate to tuple encoding.
498            fidl::encoding::Encode::<ListenerAcceptResponse, D>::encode(
499                (
500                    <fidl_fuchsia_hardware_vsock__common::Addr as fidl::encoding::ValueTypeMarker>::borrow(&self.addr),
501                ),
502                encoder, offset, _depth
503            )
504        }
505    }
506    unsafe impl<
507            D: fidl::encoding::ResourceDialect,
508            T0: fidl::encoding::Encode<fidl_fuchsia_hardware_vsock__common::Addr, D>,
509        > fidl::encoding::Encode<ListenerAcceptResponse, D> for (T0,)
510    {
511        #[inline]
512        unsafe fn encode(
513            self,
514            encoder: &mut fidl::encoding::Encoder<'_, D>,
515            offset: usize,
516            depth: fidl::encoding::Depth,
517        ) -> fidl::Result<()> {
518            encoder.debug_check_bounds::<ListenerAcceptResponse>(offset);
519            // Zero out padding regions. There's no need to apply masks
520            // because the unmasked parts will be overwritten by fields.
521            // Write the fields.
522            self.0.encode(encoder, offset + 0, depth)?;
523            Ok(())
524        }
525    }
526
527    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
528        for ListenerAcceptResponse
529    {
530        #[inline(always)]
531        fn new_empty() -> Self {
532            Self { addr: fidl::new_empty!(fidl_fuchsia_hardware_vsock__common::Addr, D) }
533        }
534
535        #[inline]
536        unsafe fn decode(
537            &mut self,
538            decoder: &mut fidl::encoding::Decoder<'_, D>,
539            offset: usize,
540            _depth: fidl::encoding::Depth,
541        ) -> fidl::Result<()> {
542            decoder.debug_check_bounds::<Self>(offset);
543            // Verify that padding bytes are zero.
544            fidl::decode!(
545                fidl_fuchsia_hardware_vsock__common::Addr,
546                D,
547                &mut self.addr,
548                decoder,
549                offset + 0,
550                _depth
551            )?;
552            Ok(())
553        }
554    }
555}