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<fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>, D>,
210    > fidl::encoding::Encode<DebugMessageRequest, D> for (T0, T1, T2)
211    {
212        #[inline]
213        unsafe fn encode(
214            self,
215            encoder: &mut fidl::encoding::Encoder<'_, D>,
216            offset: usize,
217            depth: fidl::encoding::Depth,
218        ) -> fidl::Result<()> {
219            encoder.debug_check_bounds::<DebugMessageRequest>(offset);
220            // Zero out padding regions. There's no need to apply masks
221            // because the unmasked parts will be overwritten by fields.
222            // Write the fields.
223            self.0.encode(encoder, offset + 0, depth)?;
224            self.1.encode(encoder, offset + 16, depth)?;
225            self.2.encode(encoder, offset + 32, depth)?;
226            Ok(())
227        }
228    }
229
230    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DebugMessageRequest {
231        #[inline(always)]
232        fn new_empty() -> Self {
233            Self {
234                node_name: fidl::new_empty!(fidl::encoding::UnboundedString, D),
235                command: fidl::new_empty!(fidl::encoding::UnboundedString, D),
236                args: fidl::new_empty!(
237                    fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
238                    D
239                ),
240            }
241        }
242
243        #[inline]
244        unsafe fn decode(
245            &mut self,
246            decoder: &mut fidl::encoding::Decoder<'_, D>,
247            offset: usize,
248            _depth: fidl::encoding::Depth,
249        ) -> fidl::Result<()> {
250            decoder.debug_check_bounds::<Self>(offset);
251            // Verify that padding bytes are zero.
252            fidl::decode!(
253                fidl::encoding::UnboundedString,
254                D,
255                &mut self.node_name,
256                decoder,
257                offset + 0,
258                _depth
259            )?;
260            fidl::decode!(
261                fidl::encoding::UnboundedString,
262                D,
263                &mut self.command,
264                decoder,
265                offset + 16,
266                _depth
267            )?;
268            fidl::decode!(
269                fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
270                D,
271                &mut self.args,
272                decoder,
273                offset + 32,
274                _depth
275            )?;
276            Ok(())
277        }
278    }
279}