fidl_test_pkgdir_common/
fidl_test_pkgdir_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#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
12#[repr(C)]
13pub struct PkgDirOpenPackageDirectoryRequest {
14    pub meta_far: [u8; 32],
15}
16
17impl fidl::Persistable for PkgDirOpenPackageDirectoryRequest {}
18
19mod internal {
20    use super::*;
21
22    impl fidl::encoding::ValueTypeMarker for PkgDirOpenPackageDirectoryRequest {
23        type Borrowed<'a> = &'a Self;
24        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
25            value
26        }
27    }
28
29    unsafe impl fidl::encoding::TypeMarker for PkgDirOpenPackageDirectoryRequest {
30        type Owned = Self;
31
32        #[inline(always)]
33        fn inline_align(_context: fidl::encoding::Context) -> usize {
34            1
35        }
36
37        #[inline(always)]
38        fn inline_size(_context: fidl::encoding::Context) -> usize {
39            32
40        }
41        #[inline(always)]
42        fn encode_is_copy() -> bool {
43            true
44        }
45
46        #[inline(always)]
47        fn decode_is_copy() -> bool {
48            true
49        }
50    }
51
52    unsafe impl<D: fidl::encoding::ResourceDialect>
53        fidl::encoding::Encode<PkgDirOpenPackageDirectoryRequest, D>
54        for &PkgDirOpenPackageDirectoryRequest
55    {
56        #[inline]
57        unsafe fn encode(
58            self,
59            encoder: &mut fidl::encoding::Encoder<'_, D>,
60            offset: usize,
61            _depth: fidl::encoding::Depth,
62        ) -> fidl::Result<()> {
63            encoder.debug_check_bounds::<PkgDirOpenPackageDirectoryRequest>(offset);
64            unsafe {
65                // Copy the object into the buffer.
66                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
67                (buf_ptr as *mut PkgDirOpenPackageDirectoryRequest)
68                    .write_unaligned((self as *const PkgDirOpenPackageDirectoryRequest).read());
69                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
70                // done second because the memcpy will write garbage to these bytes.
71            }
72            Ok(())
73        }
74    }
75    unsafe impl<
76            D: fidl::encoding::ResourceDialect,
77            T0: fidl::encoding::Encode<fidl::encoding::Array<u8, 32>, D>,
78        > fidl::encoding::Encode<PkgDirOpenPackageDirectoryRequest, D> for (T0,)
79    {
80        #[inline]
81        unsafe fn encode(
82            self,
83            encoder: &mut fidl::encoding::Encoder<'_, D>,
84            offset: usize,
85            depth: fidl::encoding::Depth,
86        ) -> fidl::Result<()> {
87            encoder.debug_check_bounds::<PkgDirOpenPackageDirectoryRequest>(offset);
88            // Zero out padding regions. There's no need to apply masks
89            // because the unmasked parts will be overwritten by fields.
90            // Write the fields.
91            self.0.encode(encoder, offset + 0, depth)?;
92            Ok(())
93        }
94    }
95
96    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
97        for PkgDirOpenPackageDirectoryRequest
98    {
99        #[inline(always)]
100        fn new_empty() -> Self {
101            Self { meta_far: fidl::new_empty!(fidl::encoding::Array<u8, 32>, D) }
102        }
103
104        #[inline]
105        unsafe fn decode(
106            &mut self,
107            decoder: &mut fidl::encoding::Decoder<'_, D>,
108            offset: usize,
109            _depth: fidl::encoding::Depth,
110        ) -> fidl::Result<()> {
111            decoder.debug_check_bounds::<Self>(offset);
112            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
113            // Verify that padding bytes are zero.
114            // Copy from the buffer into the object.
115            unsafe {
116                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 32);
117            }
118            Ok(())
119        }
120    }
121}