fidl_fuchsia_net_stack_common/
fidl_fuchsia_net_stack_common.rs1#![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 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}
63
64mod internal {
65 use super::*;
66 unsafe impl fidl::encoding::TypeMarker for Error {
67 type Owned = Self;
68
69 #[inline(always)]
70 fn inline_align(_context: fidl::encoding::Context) -> usize {
71 std::mem::align_of::<u32>()
72 }
73
74 #[inline(always)]
75 fn inline_size(_context: fidl::encoding::Context) -> usize {
76 std::mem::size_of::<u32>()
77 }
78
79 #[inline(always)]
80 fn encode_is_copy() -> bool {
81 true
82 }
83
84 #[inline(always)]
85 fn decode_is_copy() -> bool {
86 false
87 }
88 }
89
90 impl fidl::encoding::ValueTypeMarker for Error {
91 type Borrowed<'a> = Self;
92 #[inline(always)]
93 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
94 *value
95 }
96 }
97
98 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
99 #[inline]
100 unsafe fn encode(
101 self,
102 encoder: &mut fidl::encoding::Encoder<'_, D>,
103 offset: usize,
104 _depth: fidl::encoding::Depth,
105 ) -> fidl::Result<()> {
106 encoder.debug_check_bounds::<Self>(offset);
107 encoder.write_num(self.into_primitive(), offset);
108 Ok(())
109 }
110 }
111
112 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
113 #[inline(always)]
114 fn new_empty() -> Self {
115 Self::Internal
116 }
117
118 #[inline]
119 unsafe fn decode(
120 &mut self,
121 decoder: &mut fidl::encoding::Decoder<'_, D>,
122 offset: usize,
123 _depth: fidl::encoding::Depth,
124 ) -> fidl::Result<()> {
125 decoder.debug_check_bounds::<Self>(offset);
126 let prim = decoder.read_num::<u32>(offset);
127
128 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
129 Ok(())
130 }
131 }
132
133 impl fidl::encoding::ValueTypeMarker for LogSetLogPacketsRequest {
134 type Borrowed<'a> = &'a Self;
135 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
136 value
137 }
138 }
139
140 unsafe impl fidl::encoding::TypeMarker for LogSetLogPacketsRequest {
141 type Owned = Self;
142
143 #[inline(always)]
144 fn inline_align(_context: fidl::encoding::Context) -> usize {
145 1
146 }
147
148 #[inline(always)]
149 fn inline_size(_context: fidl::encoding::Context) -> usize {
150 1
151 }
152 }
153
154 unsafe impl<D: fidl::encoding::ResourceDialect>
155 fidl::encoding::Encode<LogSetLogPacketsRequest, D> for &LogSetLogPacketsRequest
156 {
157 #[inline]
158 unsafe fn encode(
159 self,
160 encoder: &mut fidl::encoding::Encoder<'_, D>,
161 offset: usize,
162 _depth: fidl::encoding::Depth,
163 ) -> fidl::Result<()> {
164 encoder.debug_check_bounds::<LogSetLogPacketsRequest>(offset);
165 fidl::encoding::Encode::<LogSetLogPacketsRequest, D>::encode(
167 (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enabled),),
168 encoder,
169 offset,
170 _depth,
171 )
172 }
173 }
174 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
175 fidl::encoding::Encode<LogSetLogPacketsRequest, D> for (T0,)
176 {
177 #[inline]
178 unsafe fn encode(
179 self,
180 encoder: &mut fidl::encoding::Encoder<'_, D>,
181 offset: usize,
182 depth: fidl::encoding::Depth,
183 ) -> fidl::Result<()> {
184 encoder.debug_check_bounds::<LogSetLogPacketsRequest>(offset);
185 self.0.encode(encoder, offset + 0, depth)?;
189 Ok(())
190 }
191 }
192
193 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
194 for LogSetLogPacketsRequest
195 {
196 #[inline(always)]
197 fn new_empty() -> Self {
198 Self { enabled: fidl::new_empty!(bool, D) }
199 }
200
201 #[inline]
202 unsafe fn decode(
203 &mut self,
204 decoder: &mut fidl::encoding::Decoder<'_, D>,
205 offset: usize,
206 _depth: fidl::encoding::Depth,
207 ) -> fidl::Result<()> {
208 decoder.debug_check_bounds::<Self>(offset);
209 fidl::decode!(bool, D, &mut self.enabled, decoder, offset + 0, _depth)?;
211 Ok(())
212 }
213 }
214}