fidl_fuchsia_memorypressure_common/
fidl_fuchsia_memorypressure_common.rs1#![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#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
13#[repr(u32)]
14pub enum Level {
15 Normal = 1,
24 Warning = 2,
36 Critical = 3,
47}
48
49impl Level {
50 #[inline]
51 pub fn from_primitive(prim: u32) -> Option<Self> {
52 match prim {
53 1 => Some(Self::Normal),
54 2 => Some(Self::Warning),
55 3 => Some(Self::Critical),
56 _ => None,
57 }
58 }
59
60 #[inline]
61 pub const fn into_primitive(self) -> u32 {
62 self as u32
63 }
64
65 #[deprecated = "Strict enums should not use `is_unknown`"]
66 #[inline]
67 pub fn is_unknown(&self) -> bool {
68 false
69 }
70}
71
72#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
73pub struct WatcherOnLevelChangedRequest {
74 pub level: Level,
75}
76
77impl fidl::Persistable for WatcherOnLevelChangedRequest {}
78
79mod internal {
80 use super::*;
81 unsafe impl fidl::encoding::TypeMarker for Level {
82 type Owned = Self;
83
84 #[inline(always)]
85 fn inline_align(_context: fidl::encoding::Context) -> usize {
86 std::mem::align_of::<u32>()
87 }
88
89 #[inline(always)]
90 fn inline_size(_context: fidl::encoding::Context) -> usize {
91 std::mem::size_of::<u32>()
92 }
93
94 #[inline(always)]
95 fn encode_is_copy() -> bool {
96 true
97 }
98
99 #[inline(always)]
100 fn decode_is_copy() -> bool {
101 false
102 }
103 }
104
105 impl fidl::encoding::ValueTypeMarker for Level {
106 type Borrowed<'a> = Self;
107 #[inline(always)]
108 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
109 *value
110 }
111 }
112
113 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Level {
114 #[inline]
115 unsafe fn encode(
116 self,
117 encoder: &mut fidl::encoding::Encoder<'_, D>,
118 offset: usize,
119 _depth: fidl::encoding::Depth,
120 ) -> fidl::Result<()> {
121 encoder.debug_check_bounds::<Self>(offset);
122 encoder.write_num(self.into_primitive(), offset);
123 Ok(())
124 }
125 }
126
127 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Level {
128 #[inline(always)]
129 fn new_empty() -> Self {
130 Self::Normal
131 }
132
133 #[inline]
134 unsafe fn decode(
135 &mut self,
136 decoder: &mut fidl::encoding::Decoder<'_, D>,
137 offset: usize,
138 _depth: fidl::encoding::Depth,
139 ) -> fidl::Result<()> {
140 decoder.debug_check_bounds::<Self>(offset);
141 let prim = decoder.read_num::<u32>(offset);
142
143 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
144 Ok(())
145 }
146 }
147
148 impl fidl::encoding::ValueTypeMarker for WatcherOnLevelChangedRequest {
149 type Borrowed<'a> = &'a Self;
150 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
151 value
152 }
153 }
154
155 unsafe impl fidl::encoding::TypeMarker for WatcherOnLevelChangedRequest {
156 type Owned = Self;
157
158 #[inline(always)]
159 fn inline_align(_context: fidl::encoding::Context) -> usize {
160 4
161 }
162
163 #[inline(always)]
164 fn inline_size(_context: fidl::encoding::Context) -> usize {
165 4
166 }
167 }
168
169 unsafe impl<D: fidl::encoding::ResourceDialect>
170 fidl::encoding::Encode<WatcherOnLevelChangedRequest, D> for &WatcherOnLevelChangedRequest
171 {
172 #[inline]
173 unsafe fn encode(
174 self,
175 encoder: &mut fidl::encoding::Encoder<'_, D>,
176 offset: usize,
177 _depth: fidl::encoding::Depth,
178 ) -> fidl::Result<()> {
179 encoder.debug_check_bounds::<WatcherOnLevelChangedRequest>(offset);
180 fidl::encoding::Encode::<WatcherOnLevelChangedRequest, D>::encode(
182 (<Level as fidl::encoding::ValueTypeMarker>::borrow(&self.level),),
183 encoder,
184 offset,
185 _depth,
186 )
187 }
188 }
189 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Level, D>>
190 fidl::encoding::Encode<WatcherOnLevelChangedRequest, D> for (T0,)
191 {
192 #[inline]
193 unsafe fn encode(
194 self,
195 encoder: &mut fidl::encoding::Encoder<'_, D>,
196 offset: usize,
197 depth: fidl::encoding::Depth,
198 ) -> fidl::Result<()> {
199 encoder.debug_check_bounds::<WatcherOnLevelChangedRequest>(offset);
200 self.0.encode(encoder, offset + 0, depth)?;
204 Ok(())
205 }
206 }
207
208 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
209 for WatcherOnLevelChangedRequest
210 {
211 #[inline(always)]
212 fn new_empty() -> Self {
213 Self { level: fidl::new_empty!(Level, D) }
214 }
215
216 #[inline]
217 unsafe fn decode(
218 &mut self,
219 decoder: &mut fidl::encoding::Decoder<'_, D>,
220 offset: usize,
221 _depth: fidl::encoding::Depth,
222 ) -> fidl::Result<()> {
223 decoder.debug_check_bounds::<Self>(offset);
224 fidl::decode!(Level, D, &mut self.level, decoder, offset + 0, _depth)?;
226 Ok(())
227 }
228 }
229}