Skip to main content

fidl_fuchsia_net_stack_common/
fidl_fuchsia_net_stack_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/// A path to a device node.
12pub type DevicePath = String;
13
14#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
15#[repr(u32)]
16pub enum Error {
17    Internal = 1,
18    NotSupported = 2,
19    InvalidArgs = 3,
20    BadState = 4,
21    TimeOut = 5,
22    NotFound = 6,
23    AlreadyExists = 7,
24    Io = 8,
25}
26
27impl Error {
28    #[inline]
29    pub fn from_primitive(prim: u32) -> Option<Self> {
30        match prim {
31            1 => Some(Self::Internal),
32            2 => Some(Self::NotSupported),
33            3 => Some(Self::InvalidArgs),
34            4 => Some(Self::BadState),
35            5 => Some(Self::TimeOut),
36            6 => Some(Self::NotFound),
37            7 => Some(Self::AlreadyExists),
38            8 => Some(Self::Io),
39            _ => None,
40        }
41    }
42
43    #[inline]
44    pub const fn into_primitive(self) -> u32 {
45        self as u32
46    }
47}
48
49#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
50pub struct LogSetLogPacketsRequest {
51    pub enabled: bool,
52}
53
54impl fidl::Persistable for LogSetLogPacketsRequest {}
55
56pub mod log_ordinals {
57    pub const SET_LOG_PACKETS: u64 = 0x2176044cba5f378e;
58}
59
60pub mod stack_ordinals {
61    pub const SET_DHCP_CLIENT_ENABLED: u64 = 0x6dead3a6025b0543;
62    pub const BRIDGE_INTERFACES: u64 = 0x60509044a41ac976;
63}
64
65mod internal {
66    use super::*;
67    unsafe impl fidl::encoding::TypeMarker for Error {
68        type Owned = Self;
69
70        #[inline(always)]
71        fn inline_align(_context: fidl::encoding::Context) -> usize {
72            std::mem::align_of::<u32>()
73        }
74
75        #[inline(always)]
76        fn inline_size(_context: fidl::encoding::Context) -> usize {
77            std::mem::size_of::<u32>()
78        }
79
80        #[inline(always)]
81        fn encode_is_copy() -> bool {
82            true
83        }
84
85        #[inline(always)]
86        fn decode_is_copy() -> bool {
87            false
88        }
89    }
90
91    impl fidl::encoding::ValueTypeMarker for Error {
92        type Borrowed<'a> = Self;
93        #[inline(always)]
94        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
95            *value
96        }
97    }
98
99    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
100        #[inline]
101        unsafe fn encode(
102            self,
103            encoder: &mut fidl::encoding::Encoder<'_, D>,
104            offset: usize,
105            _depth: fidl::encoding::Depth,
106        ) -> fidl::Result<()> {
107            encoder.debug_check_bounds::<Self>(offset);
108            encoder.write_num(self.into_primitive(), offset);
109            Ok(())
110        }
111    }
112
113    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
114        #[inline(always)]
115        fn new_empty() -> Self {
116            Self::Internal
117        }
118
119        #[inline]
120        unsafe fn decode(
121            &mut self,
122            decoder: &mut fidl::encoding::Decoder<'_, D>,
123            offset: usize,
124            _depth: fidl::encoding::Depth,
125        ) -> fidl::Result<()> {
126            decoder.debug_check_bounds::<Self>(offset);
127            let prim = decoder.read_num::<u32>(offset);
128
129            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
130            Ok(())
131        }
132    }
133
134    impl fidl::encoding::ValueTypeMarker for LogSetLogPacketsRequest {
135        type Borrowed<'a> = &'a Self;
136        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
137            value
138        }
139    }
140
141    unsafe impl fidl::encoding::TypeMarker for LogSetLogPacketsRequest {
142        type Owned = Self;
143
144        #[inline(always)]
145        fn inline_align(_context: fidl::encoding::Context) -> usize {
146            1
147        }
148
149        #[inline(always)]
150        fn inline_size(_context: fidl::encoding::Context) -> usize {
151            1
152        }
153    }
154
155    unsafe impl<D: fidl::encoding::ResourceDialect>
156        fidl::encoding::Encode<LogSetLogPacketsRequest, D> for &LogSetLogPacketsRequest
157    {
158        #[inline]
159        unsafe fn encode(
160            self,
161            encoder: &mut fidl::encoding::Encoder<'_, D>,
162            offset: usize,
163            _depth: fidl::encoding::Depth,
164        ) -> fidl::Result<()> {
165            encoder.debug_check_bounds::<LogSetLogPacketsRequest>(offset);
166            // Delegate to tuple encoding.
167            fidl::encoding::Encode::<LogSetLogPacketsRequest, D>::encode(
168                (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enabled),),
169                encoder,
170                offset,
171                _depth,
172            )
173        }
174    }
175    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
176        fidl::encoding::Encode<LogSetLogPacketsRequest, D> for (T0,)
177    {
178        #[inline]
179        unsafe fn encode(
180            self,
181            encoder: &mut fidl::encoding::Encoder<'_, D>,
182            offset: usize,
183            depth: fidl::encoding::Depth,
184        ) -> fidl::Result<()> {
185            encoder.debug_check_bounds::<LogSetLogPacketsRequest>(offset);
186            // Zero out padding regions. There's no need to apply masks
187            // because the unmasked parts will be overwritten by fields.
188            // Write the fields.
189            self.0.encode(encoder, offset + 0, depth)?;
190            Ok(())
191        }
192    }
193
194    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
195        for LogSetLogPacketsRequest
196    {
197        #[inline(always)]
198        fn new_empty() -> Self {
199            Self { enabled: fidl::new_empty!(bool, D) }
200        }
201
202        #[inline]
203        unsafe fn decode(
204            &mut self,
205            decoder: &mut fidl::encoding::Decoder<'_, D>,
206            offset: usize,
207            _depth: fidl::encoding::Depth,
208        ) -> fidl::Result<()> {
209            decoder.debug_check_bounds::<Self>(offset);
210            // Verify that padding bytes are zero.
211            fidl::decode!(bool, D, &mut self.enabled, decoder, offset + 0, _depth)?;
212            Ok(())
213        }
214    }
215}