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