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
11#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
13#[repr(u32)]
14pub enum NetstackVersion {
15 Netstack2 = 1,
16 Netstack3 = 2,
17}
18
19impl NetstackVersion {
20 #[inline]
21 pub fn from_primitive(prim: u32) -> Option<Self> {
22 match prim {
23 1 => Some(Self::Netstack2),
24 2 => Some(Self::Netstack3),
25 _ => None,
26 }
27 }
28
29 #[inline]
30 pub const fn into_primitive(self) -> u32 {
31 self as u32
32 }
33
34 #[deprecated = "Strict enums should not use `is_unknown`"]
35 #[inline]
36 pub fn is_unknown(&self) -> bool {
37 false
38 }
39}
40
41#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
42pub struct ControlSetAutomatedNetstackVersionRequest {
43 pub version: Option<Box<VersionSetting>>,
44}
45
46impl fidl::Persistable for ControlSetAutomatedNetstackVersionRequest {}
47
48#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
49pub struct ControlSetUserNetstackVersionRequest {
50 pub version: Option<Box<VersionSetting>>,
51}
52
53impl fidl::Persistable for ControlSetUserNetstackVersionRequest {}
54
55#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
56pub struct InEffectVersion {
57 pub current_boot: NetstackVersion,
60 pub automated: Option<Box<VersionSetting>>,
65 pub user: Option<Box<VersionSetting>>,
70}
71
72impl fidl::Persistable for InEffectVersion {}
73
74#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
75pub struct StateGetNetstackVersionResponse {
76 pub in_effect_version: InEffectVersion,
77}
78
79impl fidl::Persistable for StateGetNetstackVersionResponse {}
80
81#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
84pub struct VersionSetting {
85 pub version: NetstackVersion,
86}
87
88impl fidl::Persistable for VersionSetting {}
89
90mod internal {
91 use super::*;
92 unsafe impl fidl::encoding::TypeMarker for NetstackVersion {
93 type Owned = Self;
94
95 #[inline(always)]
96 fn inline_align(_context: fidl::encoding::Context) -> usize {
97 std::mem::align_of::<u32>()
98 }
99
100 #[inline(always)]
101 fn inline_size(_context: fidl::encoding::Context) -> usize {
102 std::mem::size_of::<u32>()
103 }
104
105 #[inline(always)]
106 fn encode_is_copy() -> bool {
107 true
108 }
109
110 #[inline(always)]
111 fn decode_is_copy() -> bool {
112 false
113 }
114 }
115
116 impl fidl::encoding::ValueTypeMarker for NetstackVersion {
117 type Borrowed<'a> = Self;
118 #[inline(always)]
119 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
120 *value
121 }
122 }
123
124 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
125 for NetstackVersion
126 {
127 #[inline]
128 unsafe fn encode(
129 self,
130 encoder: &mut fidl::encoding::Encoder<'_, D>,
131 offset: usize,
132 _depth: fidl::encoding::Depth,
133 ) -> fidl::Result<()> {
134 encoder.debug_check_bounds::<Self>(offset);
135 encoder.write_num(self.into_primitive(), offset);
136 Ok(())
137 }
138 }
139
140 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for NetstackVersion {
141 #[inline(always)]
142 fn new_empty() -> Self {
143 Self::Netstack2
144 }
145
146 #[inline]
147 unsafe fn decode(
148 &mut self,
149 decoder: &mut fidl::encoding::Decoder<'_, D>,
150 offset: usize,
151 _depth: fidl::encoding::Depth,
152 ) -> fidl::Result<()> {
153 decoder.debug_check_bounds::<Self>(offset);
154 let prim = decoder.read_num::<u32>(offset);
155
156 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
157 Ok(())
158 }
159 }
160
161 impl fidl::encoding::ValueTypeMarker for ControlSetAutomatedNetstackVersionRequest {
162 type Borrowed<'a> = &'a Self;
163 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
164 value
165 }
166 }
167
168 unsafe impl fidl::encoding::TypeMarker for ControlSetAutomatedNetstackVersionRequest {
169 type Owned = Self;
170
171 #[inline(always)]
172 fn inline_align(_context: fidl::encoding::Context) -> usize {
173 8
174 }
175
176 #[inline(always)]
177 fn inline_size(_context: fidl::encoding::Context) -> usize {
178 8
179 }
180 }
181
182 unsafe impl<D: fidl::encoding::ResourceDialect>
183 fidl::encoding::Encode<ControlSetAutomatedNetstackVersionRequest, D>
184 for &ControlSetAutomatedNetstackVersionRequest
185 {
186 #[inline]
187 unsafe fn encode(
188 self,
189 encoder: &mut fidl::encoding::Encoder<'_, D>,
190 offset: usize,
191 _depth: fidl::encoding::Depth,
192 ) -> fidl::Result<()> {
193 encoder.debug_check_bounds::<ControlSetAutomatedNetstackVersionRequest>(offset);
194 fidl::encoding::Encode::<ControlSetAutomatedNetstackVersionRequest, D>::encode(
196 (
197 <fidl::encoding::Boxed<VersionSetting> as fidl::encoding::ValueTypeMarker>::borrow(&self.version),
198 ),
199 encoder, offset, _depth
200 )
201 }
202 }
203 unsafe impl<
204 D: fidl::encoding::ResourceDialect,
205 T0: fidl::encoding::Encode<fidl::encoding::Boxed<VersionSetting>, D>,
206 > fidl::encoding::Encode<ControlSetAutomatedNetstackVersionRequest, D> for (T0,)
207 {
208 #[inline]
209 unsafe fn encode(
210 self,
211 encoder: &mut fidl::encoding::Encoder<'_, D>,
212 offset: usize,
213 depth: fidl::encoding::Depth,
214 ) -> fidl::Result<()> {
215 encoder.debug_check_bounds::<ControlSetAutomatedNetstackVersionRequest>(offset);
216 self.0.encode(encoder, offset + 0, depth)?;
220 Ok(())
221 }
222 }
223
224 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
225 for ControlSetAutomatedNetstackVersionRequest
226 {
227 #[inline(always)]
228 fn new_empty() -> Self {
229 Self { version: fidl::new_empty!(fidl::encoding::Boxed<VersionSetting>, D) }
230 }
231
232 #[inline]
233 unsafe fn decode(
234 &mut self,
235 decoder: &mut fidl::encoding::Decoder<'_, D>,
236 offset: usize,
237 _depth: fidl::encoding::Depth,
238 ) -> fidl::Result<()> {
239 decoder.debug_check_bounds::<Self>(offset);
240 fidl::decode!(
242 fidl::encoding::Boxed<VersionSetting>,
243 D,
244 &mut self.version,
245 decoder,
246 offset + 0,
247 _depth
248 )?;
249 Ok(())
250 }
251 }
252
253 impl fidl::encoding::ValueTypeMarker for ControlSetUserNetstackVersionRequest {
254 type Borrowed<'a> = &'a Self;
255 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
256 value
257 }
258 }
259
260 unsafe impl fidl::encoding::TypeMarker for ControlSetUserNetstackVersionRequest {
261 type Owned = Self;
262
263 #[inline(always)]
264 fn inline_align(_context: fidl::encoding::Context) -> usize {
265 8
266 }
267
268 #[inline(always)]
269 fn inline_size(_context: fidl::encoding::Context) -> usize {
270 8
271 }
272 }
273
274 unsafe impl<D: fidl::encoding::ResourceDialect>
275 fidl::encoding::Encode<ControlSetUserNetstackVersionRequest, D>
276 for &ControlSetUserNetstackVersionRequest
277 {
278 #[inline]
279 unsafe fn encode(
280 self,
281 encoder: &mut fidl::encoding::Encoder<'_, D>,
282 offset: usize,
283 _depth: fidl::encoding::Depth,
284 ) -> fidl::Result<()> {
285 encoder.debug_check_bounds::<ControlSetUserNetstackVersionRequest>(offset);
286 fidl::encoding::Encode::<ControlSetUserNetstackVersionRequest, D>::encode(
288 (
289 <fidl::encoding::Boxed<VersionSetting> as fidl::encoding::ValueTypeMarker>::borrow(&self.version),
290 ),
291 encoder, offset, _depth
292 )
293 }
294 }
295 unsafe impl<
296 D: fidl::encoding::ResourceDialect,
297 T0: fidl::encoding::Encode<fidl::encoding::Boxed<VersionSetting>, D>,
298 > fidl::encoding::Encode<ControlSetUserNetstackVersionRequest, D> for (T0,)
299 {
300 #[inline]
301 unsafe fn encode(
302 self,
303 encoder: &mut fidl::encoding::Encoder<'_, D>,
304 offset: usize,
305 depth: fidl::encoding::Depth,
306 ) -> fidl::Result<()> {
307 encoder.debug_check_bounds::<ControlSetUserNetstackVersionRequest>(offset);
308 self.0.encode(encoder, offset + 0, depth)?;
312 Ok(())
313 }
314 }
315
316 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
317 for ControlSetUserNetstackVersionRequest
318 {
319 #[inline(always)]
320 fn new_empty() -> Self {
321 Self { version: fidl::new_empty!(fidl::encoding::Boxed<VersionSetting>, D) }
322 }
323
324 #[inline]
325 unsafe fn decode(
326 &mut self,
327 decoder: &mut fidl::encoding::Decoder<'_, D>,
328 offset: usize,
329 _depth: fidl::encoding::Depth,
330 ) -> fidl::Result<()> {
331 decoder.debug_check_bounds::<Self>(offset);
332 fidl::decode!(
334 fidl::encoding::Boxed<VersionSetting>,
335 D,
336 &mut self.version,
337 decoder,
338 offset + 0,
339 _depth
340 )?;
341 Ok(())
342 }
343 }
344
345 impl fidl::encoding::ValueTypeMarker for InEffectVersion {
346 type Borrowed<'a> = &'a Self;
347 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
348 value
349 }
350 }
351
352 unsafe impl fidl::encoding::TypeMarker for InEffectVersion {
353 type Owned = Self;
354
355 #[inline(always)]
356 fn inline_align(_context: fidl::encoding::Context) -> usize {
357 8
358 }
359
360 #[inline(always)]
361 fn inline_size(_context: fidl::encoding::Context) -> usize {
362 24
363 }
364 }
365
366 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<InEffectVersion, D>
367 for &InEffectVersion
368 {
369 #[inline]
370 unsafe fn encode(
371 self,
372 encoder: &mut fidl::encoding::Encoder<'_, D>,
373 offset: usize,
374 _depth: fidl::encoding::Depth,
375 ) -> fidl::Result<()> {
376 encoder.debug_check_bounds::<InEffectVersion>(offset);
377 fidl::encoding::Encode::<InEffectVersion, D>::encode(
379 (
380 <NetstackVersion as fidl::encoding::ValueTypeMarker>::borrow(&self.current_boot),
381 <fidl::encoding::Boxed<VersionSetting> as fidl::encoding::ValueTypeMarker>::borrow(&self.automated),
382 <fidl::encoding::Boxed<VersionSetting> as fidl::encoding::ValueTypeMarker>::borrow(&self.user),
383 ),
384 encoder, offset, _depth
385 )
386 }
387 }
388 unsafe impl<
389 D: fidl::encoding::ResourceDialect,
390 T0: fidl::encoding::Encode<NetstackVersion, D>,
391 T1: fidl::encoding::Encode<fidl::encoding::Boxed<VersionSetting>, D>,
392 T2: fidl::encoding::Encode<fidl::encoding::Boxed<VersionSetting>, D>,
393 > fidl::encoding::Encode<InEffectVersion, D> for (T0, T1, T2)
394 {
395 #[inline]
396 unsafe fn encode(
397 self,
398 encoder: &mut fidl::encoding::Encoder<'_, D>,
399 offset: usize,
400 depth: fidl::encoding::Depth,
401 ) -> fidl::Result<()> {
402 encoder.debug_check_bounds::<InEffectVersion>(offset);
403 unsafe {
406 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
407 (ptr as *mut u64).write_unaligned(0);
408 }
409 self.0.encode(encoder, offset + 0, depth)?;
411 self.1.encode(encoder, offset + 8, depth)?;
412 self.2.encode(encoder, offset + 16, depth)?;
413 Ok(())
414 }
415 }
416
417 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InEffectVersion {
418 #[inline(always)]
419 fn new_empty() -> Self {
420 Self {
421 current_boot: fidl::new_empty!(NetstackVersion, D),
422 automated: fidl::new_empty!(fidl::encoding::Boxed<VersionSetting>, D),
423 user: fidl::new_empty!(fidl::encoding::Boxed<VersionSetting>, D),
424 }
425 }
426
427 #[inline]
428 unsafe fn decode(
429 &mut self,
430 decoder: &mut fidl::encoding::Decoder<'_, D>,
431 offset: usize,
432 _depth: fidl::encoding::Depth,
433 ) -> fidl::Result<()> {
434 decoder.debug_check_bounds::<Self>(offset);
435 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
437 let padval = unsafe { (ptr as *const u64).read_unaligned() };
438 let mask = 0xffffffff00000000u64;
439 let maskedval = padval & mask;
440 if maskedval != 0 {
441 return Err(fidl::Error::NonZeroPadding {
442 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
443 });
444 }
445 fidl::decode!(NetstackVersion, D, &mut self.current_boot, decoder, offset + 0, _depth)?;
446 fidl::decode!(
447 fidl::encoding::Boxed<VersionSetting>,
448 D,
449 &mut self.automated,
450 decoder,
451 offset + 8,
452 _depth
453 )?;
454 fidl::decode!(
455 fidl::encoding::Boxed<VersionSetting>,
456 D,
457 &mut self.user,
458 decoder,
459 offset + 16,
460 _depth
461 )?;
462 Ok(())
463 }
464 }
465
466 impl fidl::encoding::ValueTypeMarker for StateGetNetstackVersionResponse {
467 type Borrowed<'a> = &'a Self;
468 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
469 value
470 }
471 }
472
473 unsafe impl fidl::encoding::TypeMarker for StateGetNetstackVersionResponse {
474 type Owned = Self;
475
476 #[inline(always)]
477 fn inline_align(_context: fidl::encoding::Context) -> usize {
478 8
479 }
480
481 #[inline(always)]
482 fn inline_size(_context: fidl::encoding::Context) -> usize {
483 24
484 }
485 }
486
487 unsafe impl<D: fidl::encoding::ResourceDialect>
488 fidl::encoding::Encode<StateGetNetstackVersionResponse, D>
489 for &StateGetNetstackVersionResponse
490 {
491 #[inline]
492 unsafe fn encode(
493 self,
494 encoder: &mut fidl::encoding::Encoder<'_, D>,
495 offset: usize,
496 _depth: fidl::encoding::Depth,
497 ) -> fidl::Result<()> {
498 encoder.debug_check_bounds::<StateGetNetstackVersionResponse>(offset);
499 fidl::encoding::Encode::<StateGetNetstackVersionResponse, D>::encode(
501 (<InEffectVersion as fidl::encoding::ValueTypeMarker>::borrow(
502 &self.in_effect_version,
503 ),),
504 encoder,
505 offset,
506 _depth,
507 )
508 }
509 }
510 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<InEffectVersion, D>>
511 fidl::encoding::Encode<StateGetNetstackVersionResponse, D> for (T0,)
512 {
513 #[inline]
514 unsafe fn encode(
515 self,
516 encoder: &mut fidl::encoding::Encoder<'_, D>,
517 offset: usize,
518 depth: fidl::encoding::Depth,
519 ) -> fidl::Result<()> {
520 encoder.debug_check_bounds::<StateGetNetstackVersionResponse>(offset);
521 self.0.encode(encoder, offset + 0, depth)?;
525 Ok(())
526 }
527 }
528
529 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
530 for StateGetNetstackVersionResponse
531 {
532 #[inline(always)]
533 fn new_empty() -> Self {
534 Self { in_effect_version: fidl::new_empty!(InEffectVersion, D) }
535 }
536
537 #[inline]
538 unsafe fn decode(
539 &mut self,
540 decoder: &mut fidl::encoding::Decoder<'_, D>,
541 offset: usize,
542 _depth: fidl::encoding::Depth,
543 ) -> fidl::Result<()> {
544 decoder.debug_check_bounds::<Self>(offset);
545 fidl::decode!(
547 InEffectVersion,
548 D,
549 &mut self.in_effect_version,
550 decoder,
551 offset + 0,
552 _depth
553 )?;
554 Ok(())
555 }
556 }
557
558 impl fidl::encoding::ValueTypeMarker for VersionSetting {
559 type Borrowed<'a> = &'a Self;
560 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
561 value
562 }
563 }
564
565 unsafe impl fidl::encoding::TypeMarker for VersionSetting {
566 type Owned = Self;
567
568 #[inline(always)]
569 fn inline_align(_context: fidl::encoding::Context) -> usize {
570 4
571 }
572
573 #[inline(always)]
574 fn inline_size(_context: fidl::encoding::Context) -> usize {
575 4
576 }
577 }
578
579 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<VersionSetting, D>
580 for &VersionSetting
581 {
582 #[inline]
583 unsafe fn encode(
584 self,
585 encoder: &mut fidl::encoding::Encoder<'_, D>,
586 offset: usize,
587 _depth: fidl::encoding::Depth,
588 ) -> fidl::Result<()> {
589 encoder.debug_check_bounds::<VersionSetting>(offset);
590 fidl::encoding::Encode::<VersionSetting, D>::encode(
592 (<NetstackVersion as fidl::encoding::ValueTypeMarker>::borrow(&self.version),),
593 encoder,
594 offset,
595 _depth,
596 )
597 }
598 }
599 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<NetstackVersion, D>>
600 fidl::encoding::Encode<VersionSetting, D> for (T0,)
601 {
602 #[inline]
603 unsafe fn encode(
604 self,
605 encoder: &mut fidl::encoding::Encoder<'_, D>,
606 offset: usize,
607 depth: fidl::encoding::Depth,
608 ) -> fidl::Result<()> {
609 encoder.debug_check_bounds::<VersionSetting>(offset);
610 self.0.encode(encoder, offset + 0, depth)?;
614 Ok(())
615 }
616 }
617
618 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for VersionSetting {
619 #[inline(always)]
620 fn new_empty() -> Self {
621 Self { version: fidl::new_empty!(NetstackVersion, D) }
622 }
623
624 #[inline]
625 unsafe fn decode(
626 &mut self,
627 decoder: &mut fidl::encoding::Decoder<'_, D>,
628 offset: usize,
629 _depth: fidl::encoding::Depth,
630 ) -> fidl::Result<()> {
631 decoder.debug_check_bounds::<Self>(offset);
632 fidl::decode!(NetstackVersion, D, &mut self.version, decoder, offset + 0, _depth)?;
634 Ok(())
635 }
636 }
637}