fidl_fuchsia_net_stackmigrationdeprecated_common/
fidl_fuchsia_net_stackmigrationdeprecated_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/// Known Network Stack versions.
12#[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    /// The value of the netstack version setting at boot time. This
52    /// reflects the currently running netstack.
53    pub current_boot: NetstackVersion,
54    /// The automated netstack version selected. If set and no `user`
55    /// version is set, it'll be applied on next boot. This reflects the
56    /// last applied configuration through
57    /// [`Control.SetAutomatedNetstackVersion`].
58    pub automated: Option<Box<VersionSetting>>,
59    /// The user netstack version selected. If set, it'll be applied on
60    /// next boot. The `user` version always takes predence over the
61    /// `automated` version. This reflects the last applied
62    /// configuration through [`Control.SetUserNetstackVersion`].
63    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/// A wrapper type around [`NetstackVersion`] providing optionality for
76/// [`Control`] methods.
77#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
78pub struct VersionSetting {
79    pub version: NetstackVersion,
80}
81
82impl fidl::Persistable for VersionSetting {}
83
84mod internal {
85    use super::*;
86    unsafe impl fidl::encoding::TypeMarker for NetstackVersion {
87        type Owned = Self;
88
89        #[inline(always)]
90        fn inline_align(_context: fidl::encoding::Context) -> usize {
91            std::mem::align_of::<u32>()
92        }
93
94        #[inline(always)]
95        fn inline_size(_context: fidl::encoding::Context) -> usize {
96            std::mem::size_of::<u32>()
97        }
98
99        #[inline(always)]
100        fn encode_is_copy() -> bool {
101            true
102        }
103
104        #[inline(always)]
105        fn decode_is_copy() -> bool {
106            false
107        }
108    }
109
110    impl fidl::encoding::ValueTypeMarker for NetstackVersion {
111        type Borrowed<'a> = Self;
112        #[inline(always)]
113        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
114            *value
115        }
116    }
117
118    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
119        for NetstackVersion
120    {
121        #[inline]
122        unsafe fn encode(
123            self,
124            encoder: &mut fidl::encoding::Encoder<'_, D>,
125            offset: usize,
126            _depth: fidl::encoding::Depth,
127        ) -> fidl::Result<()> {
128            encoder.debug_check_bounds::<Self>(offset);
129            encoder.write_num(self.into_primitive(), offset);
130            Ok(())
131        }
132    }
133
134    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for NetstackVersion {
135        #[inline(always)]
136        fn new_empty() -> Self {
137            Self::Netstack2
138        }
139
140        #[inline]
141        unsafe fn decode(
142            &mut self,
143            decoder: &mut fidl::encoding::Decoder<'_, D>,
144            offset: usize,
145            _depth: fidl::encoding::Depth,
146        ) -> fidl::Result<()> {
147            decoder.debug_check_bounds::<Self>(offset);
148            let prim = decoder.read_num::<u32>(offset);
149
150            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
151            Ok(())
152        }
153    }
154
155    impl fidl::encoding::ValueTypeMarker for ControlSetAutomatedNetstackVersionRequest {
156        type Borrowed<'a> = &'a Self;
157        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
158            value
159        }
160    }
161
162    unsafe impl fidl::encoding::TypeMarker for ControlSetAutomatedNetstackVersionRequest {
163        type Owned = Self;
164
165        #[inline(always)]
166        fn inline_align(_context: fidl::encoding::Context) -> usize {
167            8
168        }
169
170        #[inline(always)]
171        fn inline_size(_context: fidl::encoding::Context) -> usize {
172            8
173        }
174    }
175
176    unsafe impl<D: fidl::encoding::ResourceDialect>
177        fidl::encoding::Encode<ControlSetAutomatedNetstackVersionRequest, D>
178        for &ControlSetAutomatedNetstackVersionRequest
179    {
180        #[inline]
181        unsafe fn encode(
182            self,
183            encoder: &mut fidl::encoding::Encoder<'_, D>,
184            offset: usize,
185            _depth: fidl::encoding::Depth,
186        ) -> fidl::Result<()> {
187            encoder.debug_check_bounds::<ControlSetAutomatedNetstackVersionRequest>(offset);
188            // Delegate to tuple encoding.
189            fidl::encoding::Encode::<ControlSetAutomatedNetstackVersionRequest, D>::encode(
190                (
191                    <fidl::encoding::Boxed<VersionSetting> as fidl::encoding::ValueTypeMarker>::borrow(&self.version),
192                ),
193                encoder, offset, _depth
194            )
195        }
196    }
197    unsafe impl<
198            D: fidl::encoding::ResourceDialect,
199            T0: fidl::encoding::Encode<fidl::encoding::Boxed<VersionSetting>, D>,
200        > fidl::encoding::Encode<ControlSetAutomatedNetstackVersionRequest, D> for (T0,)
201    {
202        #[inline]
203        unsafe fn encode(
204            self,
205            encoder: &mut fidl::encoding::Encoder<'_, D>,
206            offset: usize,
207            depth: fidl::encoding::Depth,
208        ) -> fidl::Result<()> {
209            encoder.debug_check_bounds::<ControlSetAutomatedNetstackVersionRequest>(offset);
210            // Zero out padding regions. There's no need to apply masks
211            // because the unmasked parts will be overwritten by fields.
212            // Write the fields.
213            self.0.encode(encoder, offset + 0, depth)?;
214            Ok(())
215        }
216    }
217
218    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
219        for ControlSetAutomatedNetstackVersionRequest
220    {
221        #[inline(always)]
222        fn new_empty() -> Self {
223            Self { version: fidl::new_empty!(fidl::encoding::Boxed<VersionSetting>, D) }
224        }
225
226        #[inline]
227        unsafe fn decode(
228            &mut self,
229            decoder: &mut fidl::encoding::Decoder<'_, D>,
230            offset: usize,
231            _depth: fidl::encoding::Depth,
232        ) -> fidl::Result<()> {
233            decoder.debug_check_bounds::<Self>(offset);
234            // Verify that padding bytes are zero.
235            fidl::decode!(
236                fidl::encoding::Boxed<VersionSetting>,
237                D,
238                &mut self.version,
239                decoder,
240                offset + 0,
241                _depth
242            )?;
243            Ok(())
244        }
245    }
246
247    impl fidl::encoding::ValueTypeMarker for ControlSetUserNetstackVersionRequest {
248        type Borrowed<'a> = &'a Self;
249        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
250            value
251        }
252    }
253
254    unsafe impl fidl::encoding::TypeMarker for ControlSetUserNetstackVersionRequest {
255        type Owned = Self;
256
257        #[inline(always)]
258        fn inline_align(_context: fidl::encoding::Context) -> usize {
259            8
260        }
261
262        #[inline(always)]
263        fn inline_size(_context: fidl::encoding::Context) -> usize {
264            8
265        }
266    }
267
268    unsafe impl<D: fidl::encoding::ResourceDialect>
269        fidl::encoding::Encode<ControlSetUserNetstackVersionRequest, D>
270        for &ControlSetUserNetstackVersionRequest
271    {
272        #[inline]
273        unsafe fn encode(
274            self,
275            encoder: &mut fidl::encoding::Encoder<'_, D>,
276            offset: usize,
277            _depth: fidl::encoding::Depth,
278        ) -> fidl::Result<()> {
279            encoder.debug_check_bounds::<ControlSetUserNetstackVersionRequest>(offset);
280            // Delegate to tuple encoding.
281            fidl::encoding::Encode::<ControlSetUserNetstackVersionRequest, D>::encode(
282                (
283                    <fidl::encoding::Boxed<VersionSetting> as fidl::encoding::ValueTypeMarker>::borrow(&self.version),
284                ),
285                encoder, offset, _depth
286            )
287        }
288    }
289    unsafe impl<
290            D: fidl::encoding::ResourceDialect,
291            T0: fidl::encoding::Encode<fidl::encoding::Boxed<VersionSetting>, D>,
292        > fidl::encoding::Encode<ControlSetUserNetstackVersionRequest, D> for (T0,)
293    {
294        #[inline]
295        unsafe fn encode(
296            self,
297            encoder: &mut fidl::encoding::Encoder<'_, D>,
298            offset: usize,
299            depth: fidl::encoding::Depth,
300        ) -> fidl::Result<()> {
301            encoder.debug_check_bounds::<ControlSetUserNetstackVersionRequest>(offset);
302            // Zero out padding regions. There's no need to apply masks
303            // because the unmasked parts will be overwritten by fields.
304            // Write the fields.
305            self.0.encode(encoder, offset + 0, depth)?;
306            Ok(())
307        }
308    }
309
310    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
311        for ControlSetUserNetstackVersionRequest
312    {
313        #[inline(always)]
314        fn new_empty() -> Self {
315            Self { version: fidl::new_empty!(fidl::encoding::Boxed<VersionSetting>, D) }
316        }
317
318        #[inline]
319        unsafe fn decode(
320            &mut self,
321            decoder: &mut fidl::encoding::Decoder<'_, D>,
322            offset: usize,
323            _depth: fidl::encoding::Depth,
324        ) -> fidl::Result<()> {
325            decoder.debug_check_bounds::<Self>(offset);
326            // Verify that padding bytes are zero.
327            fidl::decode!(
328                fidl::encoding::Boxed<VersionSetting>,
329                D,
330                &mut self.version,
331                decoder,
332                offset + 0,
333                _depth
334            )?;
335            Ok(())
336        }
337    }
338
339    impl fidl::encoding::ValueTypeMarker for InEffectVersion {
340        type Borrowed<'a> = &'a Self;
341        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
342            value
343        }
344    }
345
346    unsafe impl fidl::encoding::TypeMarker for InEffectVersion {
347        type Owned = Self;
348
349        #[inline(always)]
350        fn inline_align(_context: fidl::encoding::Context) -> usize {
351            8
352        }
353
354        #[inline(always)]
355        fn inline_size(_context: fidl::encoding::Context) -> usize {
356            24
357        }
358    }
359
360    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<InEffectVersion, D>
361        for &InEffectVersion
362    {
363        #[inline]
364        unsafe fn encode(
365            self,
366            encoder: &mut fidl::encoding::Encoder<'_, D>,
367            offset: usize,
368            _depth: fidl::encoding::Depth,
369        ) -> fidl::Result<()> {
370            encoder.debug_check_bounds::<InEffectVersion>(offset);
371            // Delegate to tuple encoding.
372            fidl::encoding::Encode::<InEffectVersion, D>::encode(
373                (
374                    <NetstackVersion as fidl::encoding::ValueTypeMarker>::borrow(&self.current_boot),
375                    <fidl::encoding::Boxed<VersionSetting> as fidl::encoding::ValueTypeMarker>::borrow(&self.automated),
376                    <fidl::encoding::Boxed<VersionSetting> as fidl::encoding::ValueTypeMarker>::borrow(&self.user),
377                ),
378                encoder, offset, _depth
379            )
380        }
381    }
382    unsafe impl<
383            D: fidl::encoding::ResourceDialect,
384            T0: fidl::encoding::Encode<NetstackVersion, D>,
385            T1: fidl::encoding::Encode<fidl::encoding::Boxed<VersionSetting>, D>,
386            T2: fidl::encoding::Encode<fidl::encoding::Boxed<VersionSetting>, D>,
387        > fidl::encoding::Encode<InEffectVersion, D> for (T0, T1, T2)
388    {
389        #[inline]
390        unsafe fn encode(
391            self,
392            encoder: &mut fidl::encoding::Encoder<'_, D>,
393            offset: usize,
394            depth: fidl::encoding::Depth,
395        ) -> fidl::Result<()> {
396            encoder.debug_check_bounds::<InEffectVersion>(offset);
397            // Zero out padding regions. There's no need to apply masks
398            // because the unmasked parts will be overwritten by fields.
399            unsafe {
400                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
401                (ptr as *mut u64).write_unaligned(0);
402            }
403            // Write the fields.
404            self.0.encode(encoder, offset + 0, depth)?;
405            self.1.encode(encoder, offset + 8, depth)?;
406            self.2.encode(encoder, offset + 16, depth)?;
407            Ok(())
408        }
409    }
410
411    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InEffectVersion {
412        #[inline(always)]
413        fn new_empty() -> Self {
414            Self {
415                current_boot: fidl::new_empty!(NetstackVersion, D),
416                automated: fidl::new_empty!(fidl::encoding::Boxed<VersionSetting>, D),
417                user: fidl::new_empty!(fidl::encoding::Boxed<VersionSetting>, D),
418            }
419        }
420
421        #[inline]
422        unsafe fn decode(
423            &mut self,
424            decoder: &mut fidl::encoding::Decoder<'_, D>,
425            offset: usize,
426            _depth: fidl::encoding::Depth,
427        ) -> fidl::Result<()> {
428            decoder.debug_check_bounds::<Self>(offset);
429            // Verify that padding bytes are zero.
430            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
431            let padval = unsafe { (ptr as *const u64).read_unaligned() };
432            let mask = 0xffffffff00000000u64;
433            let maskedval = padval & mask;
434            if maskedval != 0 {
435                return Err(fidl::Error::NonZeroPadding {
436                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
437                });
438            }
439            fidl::decode!(NetstackVersion, D, &mut self.current_boot, decoder, offset + 0, _depth)?;
440            fidl::decode!(
441                fidl::encoding::Boxed<VersionSetting>,
442                D,
443                &mut self.automated,
444                decoder,
445                offset + 8,
446                _depth
447            )?;
448            fidl::decode!(
449                fidl::encoding::Boxed<VersionSetting>,
450                D,
451                &mut self.user,
452                decoder,
453                offset + 16,
454                _depth
455            )?;
456            Ok(())
457        }
458    }
459
460    impl fidl::encoding::ValueTypeMarker for StateGetNetstackVersionResponse {
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 StateGetNetstackVersionResponse {
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            24
478        }
479    }
480
481    unsafe impl<D: fidl::encoding::ResourceDialect>
482        fidl::encoding::Encode<StateGetNetstackVersionResponse, D>
483        for &StateGetNetstackVersionResponse
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::<StateGetNetstackVersionResponse>(offset);
493            // Delegate to tuple encoding.
494            fidl::encoding::Encode::<StateGetNetstackVersionResponse, D>::encode(
495                (<InEffectVersion as fidl::encoding::ValueTypeMarker>::borrow(
496                    &self.in_effect_version,
497                ),),
498                encoder,
499                offset,
500                _depth,
501            )
502        }
503    }
504    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<InEffectVersion, D>>
505        fidl::encoding::Encode<StateGetNetstackVersionResponse, D> for (T0,)
506    {
507        #[inline]
508        unsafe fn encode(
509            self,
510            encoder: &mut fidl::encoding::Encoder<'_, D>,
511            offset: usize,
512            depth: fidl::encoding::Depth,
513        ) -> fidl::Result<()> {
514            encoder.debug_check_bounds::<StateGetNetstackVersionResponse>(offset);
515            // Zero out padding regions. There's no need to apply masks
516            // because the unmasked parts will be overwritten by fields.
517            // Write the fields.
518            self.0.encode(encoder, offset + 0, depth)?;
519            Ok(())
520        }
521    }
522
523    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
524        for StateGetNetstackVersionResponse
525    {
526        #[inline(always)]
527        fn new_empty() -> Self {
528            Self { in_effect_version: fidl::new_empty!(InEffectVersion, D) }
529        }
530
531        #[inline]
532        unsafe fn decode(
533            &mut self,
534            decoder: &mut fidl::encoding::Decoder<'_, D>,
535            offset: usize,
536            _depth: fidl::encoding::Depth,
537        ) -> fidl::Result<()> {
538            decoder.debug_check_bounds::<Self>(offset);
539            // Verify that padding bytes are zero.
540            fidl::decode!(
541                InEffectVersion,
542                D,
543                &mut self.in_effect_version,
544                decoder,
545                offset + 0,
546                _depth
547            )?;
548            Ok(())
549        }
550    }
551
552    impl fidl::encoding::ValueTypeMarker for VersionSetting {
553        type Borrowed<'a> = &'a Self;
554        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
555            value
556        }
557    }
558
559    unsafe impl fidl::encoding::TypeMarker for VersionSetting {
560        type Owned = Self;
561
562        #[inline(always)]
563        fn inline_align(_context: fidl::encoding::Context) -> usize {
564            4
565        }
566
567        #[inline(always)]
568        fn inline_size(_context: fidl::encoding::Context) -> usize {
569            4
570        }
571    }
572
573    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<VersionSetting, D>
574        for &VersionSetting
575    {
576        #[inline]
577        unsafe fn encode(
578            self,
579            encoder: &mut fidl::encoding::Encoder<'_, D>,
580            offset: usize,
581            _depth: fidl::encoding::Depth,
582        ) -> fidl::Result<()> {
583            encoder.debug_check_bounds::<VersionSetting>(offset);
584            // Delegate to tuple encoding.
585            fidl::encoding::Encode::<VersionSetting, D>::encode(
586                (<NetstackVersion as fidl::encoding::ValueTypeMarker>::borrow(&self.version),),
587                encoder,
588                offset,
589                _depth,
590            )
591        }
592    }
593    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<NetstackVersion, D>>
594        fidl::encoding::Encode<VersionSetting, D> for (T0,)
595    {
596        #[inline]
597        unsafe fn encode(
598            self,
599            encoder: &mut fidl::encoding::Encoder<'_, D>,
600            offset: usize,
601            depth: fidl::encoding::Depth,
602        ) -> fidl::Result<()> {
603            encoder.debug_check_bounds::<VersionSetting>(offset);
604            // Zero out padding regions. There's no need to apply masks
605            // because the unmasked parts will be overwritten by fields.
606            // Write the fields.
607            self.0.encode(encoder, offset + 0, depth)?;
608            Ok(())
609        }
610    }
611
612    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for VersionSetting {
613        #[inline(always)]
614        fn new_empty() -> Self {
615            Self { version: fidl::new_empty!(NetstackVersion, D) }
616        }
617
618        #[inline]
619        unsafe fn decode(
620            &mut self,
621            decoder: &mut fidl::encoding::Decoder<'_, D>,
622            offset: usize,
623            _depth: fidl::encoding::Depth,
624        ) -> fidl::Result<()> {
625            decoder.debug_check_bounds::<Self>(offset);
626            // Verify that padding bytes are zero.
627            fidl::decode!(NetstackVersion, D, &mut self.version, decoder, offset + 0, _depth)?;
628            Ok(())
629        }
630    }
631}