fidl_fuchsia_netemul_test_common/
fidl_fuchsia_netemul_test_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 CounterIncrementResponse {
14    pub value: u32,
15}
16
17impl fidl::Persistable for CounterIncrementResponse {}
18
19#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
20pub struct CounterTryOpenDirectoryRequest {
21    pub path: String,
22}
23
24impl fidl::Persistable for CounterTryOpenDirectoryRequest {}
25
26mod internal {
27    use super::*;
28
29    impl fidl::encoding::ValueTypeMarker for CounterIncrementResponse {
30        type Borrowed<'a> = &'a Self;
31        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
32            value
33        }
34    }
35
36    unsafe impl fidl::encoding::TypeMarker for CounterIncrementResponse {
37        type Owned = Self;
38
39        #[inline(always)]
40        fn inline_align(_context: fidl::encoding::Context) -> usize {
41            4
42        }
43
44        #[inline(always)]
45        fn inline_size(_context: fidl::encoding::Context) -> usize {
46            4
47        }
48        #[inline(always)]
49        fn encode_is_copy() -> bool {
50            true
51        }
52
53        #[inline(always)]
54        fn decode_is_copy() -> bool {
55            true
56        }
57    }
58
59    unsafe impl<D: fidl::encoding::ResourceDialect>
60        fidl::encoding::Encode<CounterIncrementResponse, D> for &CounterIncrementResponse
61    {
62        #[inline]
63        unsafe fn encode(
64            self,
65            encoder: &mut fidl::encoding::Encoder<'_, D>,
66            offset: usize,
67            _depth: fidl::encoding::Depth,
68        ) -> fidl::Result<()> {
69            encoder.debug_check_bounds::<CounterIncrementResponse>(offset);
70            unsafe {
71                // Copy the object into the buffer.
72                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
73                (buf_ptr as *mut CounterIncrementResponse)
74                    .write_unaligned((self as *const CounterIncrementResponse).read());
75                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
76                // done second because the memcpy will write garbage to these bytes.
77            }
78            Ok(())
79        }
80    }
81    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
82        fidl::encoding::Encode<CounterIncrementResponse, D> for (T0,)
83    {
84        #[inline]
85        unsafe fn encode(
86            self,
87            encoder: &mut fidl::encoding::Encoder<'_, D>,
88            offset: usize,
89            depth: fidl::encoding::Depth,
90        ) -> fidl::Result<()> {
91            encoder.debug_check_bounds::<CounterIncrementResponse>(offset);
92            // Zero out padding regions. There's no need to apply masks
93            // because the unmasked parts will be overwritten by fields.
94            // Write the fields.
95            self.0.encode(encoder, offset + 0, depth)?;
96            Ok(())
97        }
98    }
99
100    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
101        for CounterIncrementResponse
102    {
103        #[inline(always)]
104        fn new_empty() -> Self {
105            Self { value: fidl::new_empty!(u32, D) }
106        }
107
108        #[inline]
109        unsafe fn decode(
110            &mut self,
111            decoder: &mut fidl::encoding::Decoder<'_, D>,
112            offset: usize,
113            _depth: fidl::encoding::Depth,
114        ) -> fidl::Result<()> {
115            decoder.debug_check_bounds::<Self>(offset);
116            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
117            // Verify that padding bytes are zero.
118            // Copy from the buffer into the object.
119            unsafe {
120                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
121            }
122            Ok(())
123        }
124    }
125
126    impl fidl::encoding::ValueTypeMarker for CounterTryOpenDirectoryRequest {
127        type Borrowed<'a> = &'a Self;
128        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
129            value
130        }
131    }
132
133    unsafe impl fidl::encoding::TypeMarker for CounterTryOpenDirectoryRequest {
134        type Owned = Self;
135
136        #[inline(always)]
137        fn inline_align(_context: fidl::encoding::Context) -> usize {
138            8
139        }
140
141        #[inline(always)]
142        fn inline_size(_context: fidl::encoding::Context) -> usize {
143            16
144        }
145    }
146
147    unsafe impl<D: fidl::encoding::ResourceDialect>
148        fidl::encoding::Encode<CounterTryOpenDirectoryRequest, D>
149        for &CounterTryOpenDirectoryRequest
150    {
151        #[inline]
152        unsafe fn encode(
153            self,
154            encoder: &mut fidl::encoding::Encoder<'_, D>,
155            offset: usize,
156            _depth: fidl::encoding::Depth,
157        ) -> fidl::Result<()> {
158            encoder.debug_check_bounds::<CounterTryOpenDirectoryRequest>(offset);
159            // Delegate to tuple encoding.
160            fidl::encoding::Encode::<CounterTryOpenDirectoryRequest, D>::encode(
161                (<fidl::encoding::BoundedString<4095> as fidl::encoding::ValueTypeMarker>::borrow(
162                    &self.path,
163                ),),
164                encoder,
165                offset,
166                _depth,
167            )
168        }
169    }
170    unsafe impl<
171            D: fidl::encoding::ResourceDialect,
172            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<4095>, D>,
173        > fidl::encoding::Encode<CounterTryOpenDirectoryRequest, D> for (T0,)
174    {
175        #[inline]
176        unsafe fn encode(
177            self,
178            encoder: &mut fidl::encoding::Encoder<'_, D>,
179            offset: usize,
180            depth: fidl::encoding::Depth,
181        ) -> fidl::Result<()> {
182            encoder.debug_check_bounds::<CounterTryOpenDirectoryRequest>(offset);
183            // Zero out padding regions. There's no need to apply masks
184            // because the unmasked parts will be overwritten by fields.
185            // Write the fields.
186            self.0.encode(encoder, offset + 0, depth)?;
187            Ok(())
188        }
189    }
190
191    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
192        for CounterTryOpenDirectoryRequest
193    {
194        #[inline(always)]
195        fn new_empty() -> Self {
196            Self { path: fidl::new_empty!(fidl::encoding::BoundedString<4095>, D) }
197        }
198
199        #[inline]
200        unsafe fn decode(
201            &mut self,
202            decoder: &mut fidl::encoding::Decoder<'_, D>,
203            offset: usize,
204            _depth: fidl::encoding::Depth,
205        ) -> fidl::Result<()> {
206            decoder.debug_check_bounds::<Self>(offset);
207            // Verify that padding bytes are zero.
208            fidl::decode!(
209                fidl::encoding::BoundedString<4095>,
210                D,
211                &mut self.path,
212                decoder,
213                offset + 0,
214                _depth
215            )?;
216            Ok(())
217        }
218    }
219}