1#![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
14pub const UNSPECIFIED_METRIC: u32 = 0;
16
17#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
18#[repr(u32)]
19pub enum Error {
20 Internal = 1,
21 NotSupported = 2,
22 InvalidArgs = 3,
23 BadState = 4,
24 TimeOut = 5,
25 NotFound = 6,
26 AlreadyExists = 7,
27 Io = 8,
28}
29
30impl Error {
31 #[inline]
32 pub fn from_primitive(prim: u32) -> Option<Self> {
33 match prim {
34 1 => Some(Self::Internal),
35 2 => Some(Self::NotSupported),
36 3 => Some(Self::InvalidArgs),
37 4 => Some(Self::BadState),
38 5 => Some(Self::TimeOut),
39 6 => Some(Self::NotFound),
40 7 => Some(Self::AlreadyExists),
41 8 => Some(Self::Io),
42 _ => None,
43 }
44 }
45
46 #[inline]
47 pub const fn into_primitive(self) -> u32 {
48 self as u32
49 }
50}
51
52#[derive(Clone, Debug, PartialEq)]
56pub struct ForwardingEntry {
57 pub subnet: fidl_fuchsia_net__common::Subnet,
59 pub device_id: u64,
63 pub next_hop: Option<Box<fidl_fuchsia_net__common::IpAddress>>,
65 pub metric: u32,
69}
70
71impl fidl::Persistable for ForwardingEntry {}
72
73#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
74pub struct LogSetLogPacketsRequest {
75 pub enabled: bool,
76}
77
78impl fidl::Persistable for LogSetLogPacketsRequest {}
79
80#[derive(Clone, Debug, PartialEq)]
81pub struct StackAddForwardingEntryRequest {
82 pub entry: ForwardingEntry,
83}
84
85impl fidl::Persistable for StackAddForwardingEntryRequest {}
86
87#[derive(Clone, Debug, PartialEq)]
88pub struct StackDelForwardingEntryRequest {
89 pub entry: ForwardingEntry,
90}
91
92impl fidl::Persistable for StackDelForwardingEntryRequest {}
93
94mod internal {
95 use super::*;
96 unsafe impl fidl::encoding::TypeMarker for Error {
97 type Owned = Self;
98
99 #[inline(always)]
100 fn inline_align(_context: fidl::encoding::Context) -> usize {
101 std::mem::align_of::<u32>()
102 }
103
104 #[inline(always)]
105 fn inline_size(_context: fidl::encoding::Context) -> usize {
106 std::mem::size_of::<u32>()
107 }
108
109 #[inline(always)]
110 fn encode_is_copy() -> bool {
111 true
112 }
113
114 #[inline(always)]
115 fn decode_is_copy() -> bool {
116 false
117 }
118 }
119
120 impl fidl::encoding::ValueTypeMarker for Error {
121 type Borrowed<'a> = Self;
122 #[inline(always)]
123 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
124 *value
125 }
126 }
127
128 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
129 #[inline]
130 unsafe fn encode(
131 self,
132 encoder: &mut fidl::encoding::Encoder<'_, D>,
133 offset: usize,
134 _depth: fidl::encoding::Depth,
135 ) -> fidl::Result<()> {
136 encoder.debug_check_bounds::<Self>(offset);
137 encoder.write_num(self.into_primitive(), offset);
138 Ok(())
139 }
140 }
141
142 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
143 #[inline(always)]
144 fn new_empty() -> Self {
145 Self::Internal
146 }
147
148 #[inline]
149 unsafe fn decode(
150 &mut self,
151 decoder: &mut fidl::encoding::Decoder<'_, D>,
152 offset: usize,
153 _depth: fidl::encoding::Depth,
154 ) -> fidl::Result<()> {
155 decoder.debug_check_bounds::<Self>(offset);
156 let prim = decoder.read_num::<u32>(offset);
157
158 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
159 Ok(())
160 }
161 }
162
163 impl fidl::encoding::ValueTypeMarker for ForwardingEntry {
164 type Borrowed<'a> = &'a Self;
165 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
166 value
167 }
168 }
169
170 unsafe impl fidl::encoding::TypeMarker for ForwardingEntry {
171 type Owned = Self;
172
173 #[inline(always)]
174 fn inline_align(_context: fidl::encoding::Context) -> usize {
175 8
176 }
177
178 #[inline(always)]
179 fn inline_size(_context: fidl::encoding::Context) -> usize {
180 56
181 }
182 }
183
184 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ForwardingEntry, D>
185 for &ForwardingEntry
186 {
187 #[inline]
188 unsafe fn encode(
189 self,
190 encoder: &mut fidl::encoding::Encoder<'_, D>,
191 offset: usize,
192 _depth: fidl::encoding::Depth,
193 ) -> fidl::Result<()> {
194 encoder.debug_check_bounds::<ForwardingEntry>(offset);
195 fidl::encoding::Encode::<ForwardingEntry, D>::encode(
197 (
198 <fidl_fuchsia_net__common::Subnet as fidl::encoding::ValueTypeMarker>::borrow(&self.subnet),
199 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.device_id),
200 <fidl::encoding::OptionalUnion<fidl_fuchsia_net__common::IpAddress> as fidl::encoding::ValueTypeMarker>::borrow(&self.next_hop),
201 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.metric),
202 ),
203 encoder, offset, _depth
204 )
205 }
206 }
207 unsafe impl<
208 D: fidl::encoding::ResourceDialect,
209 T0: fidl::encoding::Encode<fidl_fuchsia_net__common::Subnet, D>,
210 T1: fidl::encoding::Encode<u64, D>,
211 T2: fidl::encoding::Encode<
212 fidl::encoding::OptionalUnion<fidl_fuchsia_net__common::IpAddress>,
213 D,
214 >,
215 T3: fidl::encoding::Encode<u32, D>,
216 > fidl::encoding::Encode<ForwardingEntry, D> for (T0, T1, T2, T3)
217 {
218 #[inline]
219 unsafe fn encode(
220 self,
221 encoder: &mut fidl::encoding::Encoder<'_, D>,
222 offset: usize,
223 depth: fidl::encoding::Depth,
224 ) -> fidl::Result<()> {
225 encoder.debug_check_bounds::<ForwardingEntry>(offset);
226 unsafe {
229 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(48);
230 (ptr as *mut u64).write_unaligned(0);
231 }
232 self.0.encode(encoder, offset + 0, depth)?;
234 self.1.encode(encoder, offset + 24, depth)?;
235 self.2.encode(encoder, offset + 32, depth)?;
236 self.3.encode(encoder, offset + 48, depth)?;
237 Ok(())
238 }
239 }
240
241 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ForwardingEntry {
242 #[inline(always)]
243 fn new_empty() -> Self {
244 Self {
245 subnet: fidl::new_empty!(fidl_fuchsia_net__common::Subnet, D),
246 device_id: fidl::new_empty!(u64, D),
247 next_hop: fidl::new_empty!(
248 fidl::encoding::OptionalUnion<fidl_fuchsia_net__common::IpAddress>,
249 D
250 ),
251 metric: fidl::new_empty!(u32, D),
252 }
253 }
254
255 #[inline]
256 unsafe fn decode(
257 &mut self,
258 decoder: &mut fidl::encoding::Decoder<'_, D>,
259 offset: usize,
260 _depth: fidl::encoding::Depth,
261 ) -> fidl::Result<()> {
262 decoder.debug_check_bounds::<Self>(offset);
263 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(48) };
265 let padval = unsafe { (ptr as *const u64).read_unaligned() };
266 let mask = 0xffffffff00000000u64;
267 let maskedval = padval & mask;
268 if maskedval != 0 {
269 return Err(fidl::Error::NonZeroPadding {
270 padding_start: offset + 48 + ((mask as u64).trailing_zeros() / 8) as usize,
271 });
272 }
273 fidl::decode!(
274 fidl_fuchsia_net__common::Subnet,
275 D,
276 &mut self.subnet,
277 decoder,
278 offset + 0,
279 _depth
280 )?;
281 fidl::decode!(u64, D, &mut self.device_id, decoder, offset + 24, _depth)?;
282 fidl::decode!(
283 fidl::encoding::OptionalUnion<fidl_fuchsia_net__common::IpAddress>,
284 D,
285 &mut self.next_hop,
286 decoder,
287 offset + 32,
288 _depth
289 )?;
290 fidl::decode!(u32, D, &mut self.metric, decoder, offset + 48, _depth)?;
291 Ok(())
292 }
293 }
294
295 impl fidl::encoding::ValueTypeMarker for LogSetLogPacketsRequest {
296 type Borrowed<'a> = &'a Self;
297 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
298 value
299 }
300 }
301
302 unsafe impl fidl::encoding::TypeMarker for LogSetLogPacketsRequest {
303 type Owned = Self;
304
305 #[inline(always)]
306 fn inline_align(_context: fidl::encoding::Context) -> usize {
307 1
308 }
309
310 #[inline(always)]
311 fn inline_size(_context: fidl::encoding::Context) -> usize {
312 1
313 }
314 }
315
316 unsafe impl<D: fidl::encoding::ResourceDialect>
317 fidl::encoding::Encode<LogSetLogPacketsRequest, D> for &LogSetLogPacketsRequest
318 {
319 #[inline]
320 unsafe fn encode(
321 self,
322 encoder: &mut fidl::encoding::Encoder<'_, D>,
323 offset: usize,
324 _depth: fidl::encoding::Depth,
325 ) -> fidl::Result<()> {
326 encoder.debug_check_bounds::<LogSetLogPacketsRequest>(offset);
327 fidl::encoding::Encode::<LogSetLogPacketsRequest, D>::encode(
329 (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enabled),),
330 encoder,
331 offset,
332 _depth,
333 )
334 }
335 }
336 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
337 fidl::encoding::Encode<LogSetLogPacketsRequest, D> for (T0,)
338 {
339 #[inline]
340 unsafe fn encode(
341 self,
342 encoder: &mut fidl::encoding::Encoder<'_, D>,
343 offset: usize,
344 depth: fidl::encoding::Depth,
345 ) -> fidl::Result<()> {
346 encoder.debug_check_bounds::<LogSetLogPacketsRequest>(offset);
347 self.0.encode(encoder, offset + 0, depth)?;
351 Ok(())
352 }
353 }
354
355 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
356 for LogSetLogPacketsRequest
357 {
358 #[inline(always)]
359 fn new_empty() -> Self {
360 Self { enabled: fidl::new_empty!(bool, D) }
361 }
362
363 #[inline]
364 unsafe fn decode(
365 &mut self,
366 decoder: &mut fidl::encoding::Decoder<'_, D>,
367 offset: usize,
368 _depth: fidl::encoding::Depth,
369 ) -> fidl::Result<()> {
370 decoder.debug_check_bounds::<Self>(offset);
371 fidl::decode!(bool, D, &mut self.enabled, decoder, offset + 0, _depth)?;
373 Ok(())
374 }
375 }
376
377 impl fidl::encoding::ValueTypeMarker for StackAddForwardingEntryRequest {
378 type Borrowed<'a> = &'a Self;
379 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
380 value
381 }
382 }
383
384 unsafe impl fidl::encoding::TypeMarker for StackAddForwardingEntryRequest {
385 type Owned = Self;
386
387 #[inline(always)]
388 fn inline_align(_context: fidl::encoding::Context) -> usize {
389 8
390 }
391
392 #[inline(always)]
393 fn inline_size(_context: fidl::encoding::Context) -> usize {
394 56
395 }
396 }
397
398 unsafe impl<D: fidl::encoding::ResourceDialect>
399 fidl::encoding::Encode<StackAddForwardingEntryRequest, D>
400 for &StackAddForwardingEntryRequest
401 {
402 #[inline]
403 unsafe fn encode(
404 self,
405 encoder: &mut fidl::encoding::Encoder<'_, D>,
406 offset: usize,
407 _depth: fidl::encoding::Depth,
408 ) -> fidl::Result<()> {
409 encoder.debug_check_bounds::<StackAddForwardingEntryRequest>(offset);
410 fidl::encoding::Encode::<StackAddForwardingEntryRequest, D>::encode(
412 (<ForwardingEntry as fidl::encoding::ValueTypeMarker>::borrow(&self.entry),),
413 encoder,
414 offset,
415 _depth,
416 )
417 }
418 }
419 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<ForwardingEntry, D>>
420 fidl::encoding::Encode<StackAddForwardingEntryRequest, D> for (T0,)
421 {
422 #[inline]
423 unsafe fn encode(
424 self,
425 encoder: &mut fidl::encoding::Encoder<'_, D>,
426 offset: usize,
427 depth: fidl::encoding::Depth,
428 ) -> fidl::Result<()> {
429 encoder.debug_check_bounds::<StackAddForwardingEntryRequest>(offset);
430 self.0.encode(encoder, offset + 0, depth)?;
434 Ok(())
435 }
436 }
437
438 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
439 for StackAddForwardingEntryRequest
440 {
441 #[inline(always)]
442 fn new_empty() -> Self {
443 Self { entry: fidl::new_empty!(ForwardingEntry, D) }
444 }
445
446 #[inline]
447 unsafe fn decode(
448 &mut self,
449 decoder: &mut fidl::encoding::Decoder<'_, D>,
450 offset: usize,
451 _depth: fidl::encoding::Depth,
452 ) -> fidl::Result<()> {
453 decoder.debug_check_bounds::<Self>(offset);
454 fidl::decode!(ForwardingEntry, D, &mut self.entry, decoder, offset + 0, _depth)?;
456 Ok(())
457 }
458 }
459
460 impl fidl::encoding::ValueTypeMarker for StackDelForwardingEntryRequest {
461 type Borrowed<'a> = &'a Self;
462 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
463 value
464 }
465 }
466
467 unsafe impl fidl::encoding::TypeMarker for StackDelForwardingEntryRequest {
468 type Owned = Self;
469
470 #[inline(always)]
471 fn inline_align(_context: fidl::encoding::Context) -> usize {
472 8
473 }
474
475 #[inline(always)]
476 fn inline_size(_context: fidl::encoding::Context) -> usize {
477 56
478 }
479 }
480
481 unsafe impl<D: fidl::encoding::ResourceDialect>
482 fidl::encoding::Encode<StackDelForwardingEntryRequest, D>
483 for &StackDelForwardingEntryRequest
484 {
485 #[inline]
486 unsafe fn encode(
487 self,
488 encoder: &mut fidl::encoding::Encoder<'_, D>,
489 offset: usize,
490 _depth: fidl::encoding::Depth,
491 ) -> fidl::Result<()> {
492 encoder.debug_check_bounds::<StackDelForwardingEntryRequest>(offset);
493 fidl::encoding::Encode::<StackDelForwardingEntryRequest, D>::encode(
495 (<ForwardingEntry as fidl::encoding::ValueTypeMarker>::borrow(&self.entry),),
496 encoder,
497 offset,
498 _depth,
499 )
500 }
501 }
502 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<ForwardingEntry, D>>
503 fidl::encoding::Encode<StackDelForwardingEntryRequest, D> for (T0,)
504 {
505 #[inline]
506 unsafe fn encode(
507 self,
508 encoder: &mut fidl::encoding::Encoder<'_, D>,
509 offset: usize,
510 depth: fidl::encoding::Depth,
511 ) -> fidl::Result<()> {
512 encoder.debug_check_bounds::<StackDelForwardingEntryRequest>(offset);
513 self.0.encode(encoder, offset + 0, depth)?;
517 Ok(())
518 }
519 }
520
521 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
522 for StackDelForwardingEntryRequest
523 {
524 #[inline(always)]
525 fn new_empty() -> Self {
526 Self { entry: fidl::new_empty!(ForwardingEntry, D) }
527 }
528
529 #[inline]
530 unsafe fn decode(
531 &mut self,
532 decoder: &mut fidl::encoding::Decoder<'_, D>,
533 offset: usize,
534 _depth: fidl::encoding::Depth,
535 ) -> fidl::Result<()> {
536 decoder.debug_check_bounds::<Self>(offset);
537 fidl::decode!(ForwardingEntry, D, &mut self.entry, decoder, offset + 0, _depth)?;
539 Ok(())
540 }
541 }
542}