fidl_fuchsia_net_root__common/
fidl_fuchsia_net_root__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(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
12#[repr(u32)]
13pub enum InterfacesGetMacError {
14    /// `id` does not identify an interface.
15    NotFound = 1,
16}
17
18impl InterfacesGetMacError {
19    #[inline]
20    pub fn from_primitive(prim: u32) -> Option<Self> {
21        match prim {
22            1 => Some(Self::NotFound),
23            _ => None,
24        }
25    }
26
27    #[inline]
28    pub const fn into_primitive(self) -> u32 {
29        self as u32
30    }
31}
32
33#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
34#[repr(C)]
35pub struct InterfacesGetMacRequest {
36    pub id: u64,
37}
38
39impl fidl::Persistable for InterfacesGetMacRequest {}
40
41#[derive(Clone, Debug, PartialEq)]
42pub struct InterfacesGetMacResponse {
43    pub mac: Option<Box<fidl_fuchsia_net__common::MacAddress>>,
44}
45
46impl fidl::Persistable for InterfacesGetMacResponse {}
47
48mod internal {
49    use super::*;
50    unsafe impl fidl::encoding::TypeMarker for InterfacesGetMacError {
51        type Owned = Self;
52
53        #[inline(always)]
54        fn inline_align(_context: fidl::encoding::Context) -> usize {
55            std::mem::align_of::<u32>()
56        }
57
58        #[inline(always)]
59        fn inline_size(_context: fidl::encoding::Context) -> usize {
60            std::mem::size_of::<u32>()
61        }
62
63        #[inline(always)]
64        fn encode_is_copy() -> bool {
65            true
66        }
67
68        #[inline(always)]
69        fn decode_is_copy() -> bool {
70            false
71        }
72    }
73
74    impl fidl::encoding::ValueTypeMarker for InterfacesGetMacError {
75        type Borrowed<'a> = Self;
76        #[inline(always)]
77        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
78            *value
79        }
80    }
81
82    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
83        for InterfacesGetMacError
84    {
85        #[inline]
86        unsafe fn encode(
87            self,
88            encoder: &mut fidl::encoding::Encoder<'_, D>,
89            offset: usize,
90            _depth: fidl::encoding::Depth,
91        ) -> fidl::Result<()> {
92            encoder.debug_check_bounds::<Self>(offset);
93            encoder.write_num(self.into_primitive(), offset);
94            Ok(())
95        }
96    }
97
98    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InterfacesGetMacError {
99        #[inline(always)]
100        fn new_empty() -> Self {
101            Self::NotFound
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 prim = decoder.read_num::<u32>(offset);
113
114            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
115            Ok(())
116        }
117    }
118
119    impl fidl::encoding::ValueTypeMarker for InterfacesGetMacRequest {
120        type Borrowed<'a> = &'a Self;
121        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
122            value
123        }
124    }
125
126    unsafe impl fidl::encoding::TypeMarker for InterfacesGetMacRequest {
127        type Owned = Self;
128
129        #[inline(always)]
130        fn inline_align(_context: fidl::encoding::Context) -> usize {
131            8
132        }
133
134        #[inline(always)]
135        fn inline_size(_context: fidl::encoding::Context) -> usize {
136            8
137        }
138        #[inline(always)]
139        fn encode_is_copy() -> bool {
140            true
141        }
142
143        #[inline(always)]
144        fn decode_is_copy() -> bool {
145            true
146        }
147    }
148
149    unsafe impl<D: fidl::encoding::ResourceDialect>
150        fidl::encoding::Encode<InterfacesGetMacRequest, D> for &InterfacesGetMacRequest
151    {
152        #[inline]
153        unsafe fn encode(
154            self,
155            encoder: &mut fidl::encoding::Encoder<'_, D>,
156            offset: usize,
157            _depth: fidl::encoding::Depth,
158        ) -> fidl::Result<()> {
159            encoder.debug_check_bounds::<InterfacesGetMacRequest>(offset);
160            unsafe {
161                // Copy the object into the buffer.
162                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
163                (buf_ptr as *mut InterfacesGetMacRequest)
164                    .write_unaligned((self as *const InterfacesGetMacRequest).read());
165                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
166                // done second because the memcpy will write garbage to these bytes.
167            }
168            Ok(())
169        }
170    }
171    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
172        fidl::encoding::Encode<InterfacesGetMacRequest, D> for (T0,)
173    {
174        #[inline]
175        unsafe fn encode(
176            self,
177            encoder: &mut fidl::encoding::Encoder<'_, D>,
178            offset: usize,
179            depth: fidl::encoding::Depth,
180        ) -> fidl::Result<()> {
181            encoder.debug_check_bounds::<InterfacesGetMacRequest>(offset);
182            // Zero out padding regions. There's no need to apply masks
183            // because the unmasked parts will be overwritten by fields.
184            // Write the fields.
185            self.0.encode(encoder, offset + 0, depth)?;
186            Ok(())
187        }
188    }
189
190    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
191        for InterfacesGetMacRequest
192    {
193        #[inline(always)]
194        fn new_empty() -> Self {
195            Self { id: fidl::new_empty!(u64, D) }
196        }
197
198        #[inline]
199        unsafe fn decode(
200            &mut self,
201            decoder: &mut fidl::encoding::Decoder<'_, D>,
202            offset: usize,
203            _depth: fidl::encoding::Depth,
204        ) -> fidl::Result<()> {
205            decoder.debug_check_bounds::<Self>(offset);
206            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
207            // Verify that padding bytes are zero.
208            // Copy from the buffer into the object.
209            unsafe {
210                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
211            }
212            Ok(())
213        }
214    }
215
216    impl fidl::encoding::ValueTypeMarker for InterfacesGetMacResponse {
217        type Borrowed<'a> = &'a Self;
218        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
219            value
220        }
221    }
222
223    unsafe impl fidl::encoding::TypeMarker for InterfacesGetMacResponse {
224        type Owned = Self;
225
226        #[inline(always)]
227        fn inline_align(_context: fidl::encoding::Context) -> usize {
228            8
229        }
230
231        #[inline(always)]
232        fn inline_size(_context: fidl::encoding::Context) -> usize {
233            8
234        }
235    }
236
237    unsafe impl<D: fidl::encoding::ResourceDialect>
238        fidl::encoding::Encode<InterfacesGetMacResponse, D> for &InterfacesGetMacResponse
239    {
240        #[inline]
241        unsafe fn encode(
242            self,
243            encoder: &mut fidl::encoding::Encoder<'_, D>,
244            offset: usize,
245            _depth: fidl::encoding::Depth,
246        ) -> fidl::Result<()> {
247            encoder.debug_check_bounds::<InterfacesGetMacResponse>(offset);
248            // Delegate to tuple encoding.
249            fidl::encoding::Encode::<InterfacesGetMacResponse, D>::encode(
250                (
251                    <fidl::encoding::Boxed<fidl_fuchsia_net__common::MacAddress> as fidl::encoding::ValueTypeMarker>::borrow(&self.mac),
252                ),
253                encoder, offset, _depth
254            )
255        }
256    }
257    unsafe impl<
258            D: fidl::encoding::ResourceDialect,
259            T0: fidl::encoding::Encode<fidl::encoding::Boxed<fidl_fuchsia_net__common::MacAddress>, D>,
260        > fidl::encoding::Encode<InterfacesGetMacResponse, D> for (T0,)
261    {
262        #[inline]
263        unsafe fn encode(
264            self,
265            encoder: &mut fidl::encoding::Encoder<'_, D>,
266            offset: usize,
267            depth: fidl::encoding::Depth,
268        ) -> fidl::Result<()> {
269            encoder.debug_check_bounds::<InterfacesGetMacResponse>(offset);
270            // Zero out padding regions. There's no need to apply masks
271            // because the unmasked parts will be overwritten by fields.
272            // Write the fields.
273            self.0.encode(encoder, offset + 0, depth)?;
274            Ok(())
275        }
276    }
277
278    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
279        for InterfacesGetMacResponse
280    {
281        #[inline(always)]
282        fn new_empty() -> Self {
283            Self {
284                mac: fidl::new_empty!(
285                    fidl::encoding::Boxed<fidl_fuchsia_net__common::MacAddress>,
286                    D
287                ),
288            }
289        }
290
291        #[inline]
292        unsafe fn decode(
293            &mut self,
294            decoder: &mut fidl::encoding::Decoder<'_, D>,
295            offset: usize,
296            _depth: fidl::encoding::Depth,
297        ) -> fidl::Result<()> {
298            decoder.debug_check_bounds::<Self>(offset);
299            // Verify that padding bytes are zero.
300            fidl::decode!(
301                fidl::encoding::Boxed<fidl_fuchsia_net__common::MacAddress>,
302                D,
303                &mut self.mac,
304                decoder,
305                offset + 0,
306                _depth
307            )?;
308            Ok(())
309        }
310    }
311}