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