fidl_fuchsia_power_manager_debug__common/
fidl_fuchsia_power_manager_debug__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/// Error variants that may be returned by the `Message` method.
12#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
13pub enum MessageError {
14    Generic,
15    InvalidNodeName,
16    UnsupportedCommand,
17    InvalidCommandArgs,
18    #[doc(hidden)]
19    __SourceBreaking {
20        unknown_ordinal: u32,
21    },
22}
23
24/// Pattern that matches an unknown `MessageError` member.
25#[macro_export]
26macro_rules! MessageErrorUnknown {
27    () => {
28        _
29    };
30}
31
32impl MessageError {
33    #[inline]
34    pub fn from_primitive(prim: u32) -> Option<Self> {
35        match prim {
36            0 => Some(Self::Generic),
37            1 => Some(Self::InvalidNodeName),
38            2 => Some(Self::UnsupportedCommand),
39            3 => Some(Self::InvalidCommandArgs),
40            _ => None,
41        }
42    }
43
44    #[inline]
45    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
46        match prim {
47            0 => Self::Generic,
48            1 => Self::InvalidNodeName,
49            2 => Self::UnsupportedCommand,
50            3 => Self::InvalidCommandArgs,
51            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
52        }
53    }
54
55    #[inline]
56    pub fn unknown() -> Self {
57        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
58    }
59
60    #[inline]
61    pub const fn into_primitive(self) -> u32 {
62        match self {
63            Self::Generic => 0,
64            Self::InvalidNodeName => 1,
65            Self::UnsupportedCommand => 2,
66            Self::InvalidCommandArgs => 3,
67            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
68        }
69    }
70
71    #[inline]
72    pub fn is_unknown(&self) -> bool {
73        match self {
74            Self::__SourceBreaking { unknown_ordinal: _ } => true,
75            _ => false,
76        }
77    }
78}
79
80#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
81pub struct DebugMessageRequest {
82    pub node_name: String,
83    pub command: String,
84    pub args: Vec<String>,
85}
86
87impl fidl::Persistable for DebugMessageRequest {}
88
89pub mod debug_ordinals {
90    pub const MESSAGE: u64 = 0x3a1d992128e015da;
91}
92
93mod internal {
94    use super::*;
95    unsafe impl fidl::encoding::TypeMarker for MessageError {
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            false
111        }
112
113        #[inline(always)]
114        fn decode_is_copy() -> bool {
115            false
116        }
117    }
118
119    impl fidl::encoding::ValueTypeMarker for MessageError {
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> for MessageError {
128        #[inline]
129        unsafe fn encode(
130            self,
131            encoder: &mut fidl::encoding::Encoder<'_, D>,
132            offset: usize,
133            _depth: fidl::encoding::Depth,
134        ) -> fidl::Result<()> {
135            encoder.debug_check_bounds::<Self>(offset);
136            encoder.write_num(self.into_primitive(), offset);
137            Ok(())
138        }
139    }
140
141    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MessageError {
142        #[inline(always)]
143        fn new_empty() -> Self {
144            Self::unknown()
145        }
146
147        #[inline]
148        unsafe fn decode(
149            &mut self,
150            decoder: &mut fidl::encoding::Decoder<'_, D>,
151            offset: usize,
152            _depth: fidl::encoding::Depth,
153        ) -> fidl::Result<()> {
154            decoder.debug_check_bounds::<Self>(offset);
155            let prim = decoder.read_num::<u32>(offset);
156
157            *self = Self::from_primitive_allow_unknown(prim);
158            Ok(())
159        }
160    }
161
162    impl fidl::encoding::ValueTypeMarker for DebugMessageRequest {
163        type Borrowed<'a> = &'a Self;
164        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
165            value
166        }
167    }
168
169    unsafe impl fidl::encoding::TypeMarker for DebugMessageRequest {
170        type Owned = Self;
171
172        #[inline(always)]
173        fn inline_align(_context: fidl::encoding::Context) -> usize {
174            8
175        }
176
177        #[inline(always)]
178        fn inline_size(_context: fidl::encoding::Context) -> usize {
179            48
180        }
181    }
182
183    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DebugMessageRequest, D>
184        for &DebugMessageRequest
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::<DebugMessageRequest>(offset);
194            // Delegate to tuple encoding.
195            fidl::encoding::Encode::<DebugMessageRequest, D>::encode(
196                (
197                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(&self.node_name),
198                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(&self.command),
199                    <fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow(&self.args),
200                ),
201                encoder, offset, _depth
202            )
203        }
204    }
205    unsafe impl<
206            D: fidl::encoding::ResourceDialect,
207            T0: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
208            T1: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
209            T2: fidl::encoding::Encode<
210                fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
211                D,
212            >,
213        > fidl::encoding::Encode<DebugMessageRequest, D> for (T0, T1, T2)
214    {
215        #[inline]
216        unsafe fn encode(
217            self,
218            encoder: &mut fidl::encoding::Encoder<'_, D>,
219            offset: usize,
220            depth: fidl::encoding::Depth,
221        ) -> fidl::Result<()> {
222            encoder.debug_check_bounds::<DebugMessageRequest>(offset);
223            // Zero out padding regions. There's no need to apply masks
224            // because the unmasked parts will be overwritten by fields.
225            // Write the fields.
226            self.0.encode(encoder, offset + 0, depth)?;
227            self.1.encode(encoder, offset + 16, depth)?;
228            self.2.encode(encoder, offset + 32, depth)?;
229            Ok(())
230        }
231    }
232
233    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DebugMessageRequest {
234        #[inline(always)]
235        fn new_empty() -> Self {
236            Self {
237                node_name: fidl::new_empty!(fidl::encoding::UnboundedString, D),
238                command: fidl::new_empty!(fidl::encoding::UnboundedString, D),
239                args: fidl::new_empty!(
240                    fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
241                    D
242                ),
243            }
244        }
245
246        #[inline]
247        unsafe fn decode(
248            &mut self,
249            decoder: &mut fidl::encoding::Decoder<'_, D>,
250            offset: usize,
251            _depth: fidl::encoding::Depth,
252        ) -> fidl::Result<()> {
253            decoder.debug_check_bounds::<Self>(offset);
254            // Verify that padding bytes are zero.
255            fidl::decode!(
256                fidl::encoding::UnboundedString,
257                D,
258                &mut self.node_name,
259                decoder,
260                offset + 0,
261                _depth
262            )?;
263            fidl::decode!(
264                fidl::encoding::UnboundedString,
265                D,
266                &mut self.command,
267                decoder,
268                offset + 16,
269                _depth
270            )?;
271            fidl::decode!(
272                fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
273                D,
274                &mut self.args,
275                decoder,
276                offset + 32,
277                _depth
278            )?;
279            Ok(())
280        }
281    }
282}