Skip to main content

fidl_next_common_fdf/
fidl_next_common_fdf.rs

1// DO NOT EDIT: This file is machine-generated by fidlgen
2#![warn(clippy::all)]
3#![allow(unused_parens, unused_variables, unused_mut, unused_imports, unreachable_code)]
4
5pub mod natural {
6
7    #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
8    #[repr(u32)]
9    pub enum ObjType {
10        Channel = 4,
11    }
12    impl ::core::convert::TryFrom<u32> for ObjType {
13        type Error = ::fidl_next::UnknownStrictEnumMemberError;
14        fn try_from(
15            value: u32,
16        ) -> ::core::result::Result<Self, ::fidl_next::UnknownStrictEnumMemberError> {
17            match value {
18                4 => Ok(Self::Channel),
19
20                _ => Err(::fidl_next::UnknownStrictEnumMemberError::new(value.into())),
21            }
22        }
23    }
24
25    unsafe impl<___E> ::fidl_next::Encode<crate::wire::ObjType, ___E> for ObjType
26    where
27        ___E: ?Sized,
28    {
29        #[inline]
30        fn encode(
31            self,
32            encoder: &mut ___E,
33            out: &mut ::core::mem::MaybeUninit<crate::wire::ObjType>,
34            _: (),
35        ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
36            ::fidl_next::Encode::encode(&self, encoder, out, ())
37        }
38    }
39
40    unsafe impl<'a, ___E> ::fidl_next::Encode<crate::wire::ObjType, ___E> for &'a ObjType
41    where
42        ___E: ?Sized,
43    {
44        #[inline]
45        fn encode(
46            self,
47            encoder: &mut ___E,
48            out: &mut ::core::mem::MaybeUninit<crate::wire::ObjType>,
49            _: (),
50        ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
51            ::fidl_next::munge!(let crate::wire::ObjType { value } = out);
52            let _ = value.write(::fidl_next::wire::Uint32::from(match *self {
53                ObjType::Channel => 4,
54            }));
55
56            Ok(())
57        }
58    }
59
60    impl ::core::convert::From<crate::wire::ObjType> for ObjType {
61        fn from(wire: crate::wire::ObjType) -> Self {
62            match u32::from(wire.value) {
63                4 => Self::Channel,
64
65                _ => unsafe { ::core::hint::unreachable_unchecked() },
66            }
67        }
68    }
69
70    impl ::fidl_next::FromWire<crate::wire::ObjType> for ObjType {
71        #[inline]
72        fn from_wire(wire: crate::wire::ObjType) -> Self {
73            Self::from(wire)
74        }
75    }
76
77    impl ::fidl_next::FromWireRef<crate::wire::ObjType> for ObjType {
78        #[inline]
79        fn from_wire_ref(wire: &crate::wire::ObjType) -> Self {
80            Self::from(*wire)
81        }
82    }
83}
84
85pub mod wire {
86
87    /// The wire type corresponding to [`ObjType`].
88    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
89    #[repr(transparent)]
90    pub struct ObjType {
91        pub(crate) value: ::fidl_next::wire::Uint32,
92    }
93
94    impl ::fidl_next::Constrained for ObjType {
95        type Constraint = ();
96
97        fn validate(
98            _: ::fidl_next::Slot<'_, Self>,
99            _: Self::Constraint,
100        ) -> Result<(), ::fidl_next::ValidationError> {
101            Ok(())
102        }
103    }
104
105    unsafe impl ::fidl_next::Wire for ObjType {
106        type Narrowed<'de> = Self;
107
108        #[inline]
109        fn zero_padding(_: &mut ::core::mem::MaybeUninit<Self>) {
110            // Wire enums have no padding
111        }
112    }
113
114    impl ObjType {
115        pub const CHANNEL: ObjType = ObjType { value: ::fidl_next::wire::Uint32(4) };
116    }
117
118    unsafe impl<___D> ::fidl_next::Decode<___D> for ObjType
119    where
120        ___D: ?Sized,
121    {
122        fn decode(
123            slot: ::fidl_next::Slot<'_, Self>,
124            _: &mut ___D,
125            _: (),
126        ) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
127            ::fidl_next::munge!(let Self { value } = slot);
128
129            match u32::from(*value) {
130                4 => (),
131                unknown => {
132                    return Err(::fidl_next::DecodeError::InvalidEnumOrdinal(unknown as i128));
133                }
134            }
135
136            Ok(())
137        }
138    }
139
140    impl ::core::convert::From<crate::natural::ObjType> for ObjType {
141        fn from(natural: crate::natural::ObjType) -> Self {
142            match natural {
143                crate::natural::ObjType::Channel => ObjType::CHANNEL,
144            }
145        }
146    }
147
148    impl ::fidl_next::IntoNatural for ObjType {
149        type Natural = crate::natural::ObjType;
150    }
151}
152
153pub mod wire_optional {}
154
155pub mod generic {}
156
157pub use self::natural::*;
158
159/// Compatibility shims which mimic some API surfaces of the current Rust bindings.
160pub mod compat {
161
162    impl ::fidl_next::CompatFrom<crate::ObjType> for ::fidl_fdf::ObjType {
163        fn compat_from(value: crate::ObjType) -> Self {
164            match value {
165                crate::ObjType::Channel => Self::Channel,
166            }
167        }
168    }
169
170    impl ::fidl_next::CompatFrom<::fidl_fdf::ObjType> for crate::ObjType {
171        fn compat_from(value: ::fidl_fdf::ObjType) -> Self {
172            match value {
173                ::fidl_fdf::ObjType::Channel => Self::Channel,
174            }
175        }
176    }
177}