Skip to main content

fidl_fuchsia_firmware_crash__common/
fidl_fuchsia_firmware_crash__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
11pub const MAX_FIRMWARE_VERSION_LENGTH: u8 = 32;
12
13pub const MAX_REASON_LENGTH: u8 = 128;
14
15pub const MAX_SUBSYSTEM_NAME_LENGTH: u8 = 64;
16
17#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
18pub enum Error {
19    /// Returned if multiple outstanding calls to GetCrash.
20    AlreadyPending,
21    #[doc(hidden)]
22    __SourceBreaking { unknown_ordinal: u32 },
23}
24
25/// Pattern that matches an unknown `Error` member.
26#[macro_export]
27macro_rules! ErrorUnknown {
28    () => {
29        _
30    };
31}
32
33impl Error {
34    #[inline]
35    pub fn from_primitive(prim: u32) -> Option<Self> {
36        match prim {
37            2 => Some(Self::AlreadyPending),
38            _ => None,
39        }
40    }
41
42    #[inline]
43    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
44        match prim {
45            2 => Self::AlreadyPending,
46            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
47        }
48    }
49
50    #[inline]
51    pub fn unknown() -> Self {
52        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
53    }
54
55    #[inline]
56    pub const fn into_primitive(self) -> u32 {
57        match self {
58            Self::AlreadyPending => 2,
59            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
60        }
61    }
62
63    #[inline]
64    pub fn is_unknown(&self) -> bool {
65        match self {
66            Self::__SourceBreaking { unknown_ordinal: _ } => true,
67            _ => false,
68        }
69    }
70}
71
72pub mod reporter_ordinals {
73    pub const REPORT: u64 = 0x6283d741761d9fe5;
74}
75
76pub mod watcher_ordinals {
77    pub const GET_CRASH: u64 = 0x3958bce1352d0890;
78}
79
80mod internal {
81    use super::*;
82    unsafe impl fidl::encoding::TypeMarker for Error {
83        type Owned = Self;
84
85        #[inline(always)]
86        fn inline_align(_context: fidl::encoding::Context) -> usize {
87            std::mem::align_of::<u32>()
88        }
89
90        #[inline(always)]
91        fn inline_size(_context: fidl::encoding::Context) -> usize {
92            std::mem::size_of::<u32>()
93        }
94
95        #[inline(always)]
96        fn encode_is_copy() -> bool {
97            false
98        }
99
100        #[inline(always)]
101        fn decode_is_copy() -> bool {
102            false
103        }
104    }
105
106    impl fidl::encoding::ValueTypeMarker for Error {
107        type Borrowed<'a> = Self;
108        #[inline(always)]
109        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
110            *value
111        }
112    }
113
114    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
115        #[inline]
116        unsafe fn encode(
117            self,
118            encoder: &mut fidl::encoding::Encoder<'_, D>,
119            offset: usize,
120            _depth: fidl::encoding::Depth,
121        ) -> fidl::Result<()> {
122            encoder.debug_check_bounds::<Self>(offset);
123            encoder.write_num(self.into_primitive(), offset);
124            Ok(())
125        }
126    }
127
128    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
129        #[inline(always)]
130        fn new_empty() -> Self {
131            Self::unknown()
132        }
133
134        #[inline]
135        unsafe fn decode(
136            &mut self,
137            decoder: &mut fidl::encoding::Decoder<'_, D>,
138            offset: usize,
139            _depth: fidl::encoding::Depth,
140        ) -> fidl::Result<()> {
141            decoder.debug_check_bounds::<Self>(offset);
142            let prim = decoder.read_num::<u32>(offset);
143
144            *self = Self::from_primitive_allow_unknown(prim);
145            Ok(())
146        }
147    }
148}