fidl_fuchsia_tracing__common/
fidl_fuchsia_tracing__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
11pub type CategoryDescription = String;
12
13pub type CategoryName = String;
15
16pub type EnabledCategoryList = Vec<String>;
17
18pub type ProviderId = u32;
19
20pub type ProviderName = String;
21
22pub const MAX_CATEGORY_DESCRIPTION_LENGTH: u32 = 400;
24
25pub const MAX_CATEGORY_NAME_LENGTH: u32 = 100;
27
28pub const MAX_NUM_ENABLED_CATEGORIES: u32 = 5000;
30
31pub const MAX_NUM_KNOWN_CATEGORIES: u32 = 5000;
33
34pub const MAX_PROVIDER_NAME_LENGTH: u32 = 100;
36
37#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
46#[repr(u8)]
47pub enum BufferDisposition {
48 ClearEntire = 1,
56 ClearNondurable = 2,
62 Retain = 3,
68}
69
70impl BufferDisposition {
71 #[inline]
72 pub fn from_primitive(prim: u8) -> Option<Self> {
73 match prim {
74 1 => Some(Self::ClearEntire),
75 2 => Some(Self::ClearNondurable),
76 3 => Some(Self::Retain),
77 _ => None,
78 }
79 }
80
81 #[inline]
82 pub const fn into_primitive(self) -> u8 {
83 self as u8
84 }
85}
86
87#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
89#[repr(u8)]
90pub enum BufferingMode {
91 Oneshot = 1,
96 Circular = 2,
99 Streaming = 3,
107}
108
109impl BufferingMode {
110 #[inline]
111 pub fn from_primitive(prim: u8) -> Option<Self> {
112 match prim {
113 1 => Some(Self::Oneshot),
114 2 => Some(Self::Circular),
115 3 => Some(Self::Streaming),
116 _ => None,
117 }
118 }
119
120 #[inline]
121 pub const fn into_primitive(self) -> u8 {
122 self as u8
123 }
124}
125
126#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
128pub struct KnownCategory {
129 pub name: String,
130 pub description: String,
131}
132
133impl fidl::Persistable for KnownCategory {}
134
135mod internal {
136 use super::*;
137 unsafe impl fidl::encoding::TypeMarker for BufferDisposition {
138 type Owned = Self;
139
140 #[inline(always)]
141 fn inline_align(_context: fidl::encoding::Context) -> usize {
142 std::mem::align_of::<u8>()
143 }
144
145 #[inline(always)]
146 fn inline_size(_context: fidl::encoding::Context) -> usize {
147 std::mem::size_of::<u8>()
148 }
149
150 #[inline(always)]
151 fn encode_is_copy() -> bool {
152 true
153 }
154
155 #[inline(always)]
156 fn decode_is_copy() -> bool {
157 false
158 }
159 }
160
161 impl fidl::encoding::ValueTypeMarker for BufferDisposition {
162 type Borrowed<'a> = Self;
163 #[inline(always)]
164 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
165 *value
166 }
167 }
168
169 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
170 for BufferDisposition
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::<Self>(offset);
180 encoder.write_num(self.into_primitive(), offset);
181 Ok(())
182 }
183 }
184
185 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BufferDisposition {
186 #[inline(always)]
187 fn new_empty() -> Self {
188 Self::ClearEntire
189 }
190
191 #[inline]
192 unsafe fn decode(
193 &mut self,
194 decoder: &mut fidl::encoding::Decoder<'_, D>,
195 offset: usize,
196 _depth: fidl::encoding::Depth,
197 ) -> fidl::Result<()> {
198 decoder.debug_check_bounds::<Self>(offset);
199 let prim = decoder.read_num::<u8>(offset);
200
201 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
202 Ok(())
203 }
204 }
205 unsafe impl fidl::encoding::TypeMarker for BufferingMode {
206 type Owned = Self;
207
208 #[inline(always)]
209 fn inline_align(_context: fidl::encoding::Context) -> usize {
210 std::mem::align_of::<u8>()
211 }
212
213 #[inline(always)]
214 fn inline_size(_context: fidl::encoding::Context) -> usize {
215 std::mem::size_of::<u8>()
216 }
217
218 #[inline(always)]
219 fn encode_is_copy() -> bool {
220 true
221 }
222
223 #[inline(always)]
224 fn decode_is_copy() -> bool {
225 false
226 }
227 }
228
229 impl fidl::encoding::ValueTypeMarker for BufferingMode {
230 type Borrowed<'a> = Self;
231 #[inline(always)]
232 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
233 *value
234 }
235 }
236
237 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for BufferingMode {
238 #[inline]
239 unsafe fn encode(
240 self,
241 encoder: &mut fidl::encoding::Encoder<'_, D>,
242 offset: usize,
243 _depth: fidl::encoding::Depth,
244 ) -> fidl::Result<()> {
245 encoder.debug_check_bounds::<Self>(offset);
246 encoder.write_num(self.into_primitive(), offset);
247 Ok(())
248 }
249 }
250
251 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BufferingMode {
252 #[inline(always)]
253 fn new_empty() -> Self {
254 Self::Oneshot
255 }
256
257 #[inline]
258 unsafe fn decode(
259 &mut self,
260 decoder: &mut fidl::encoding::Decoder<'_, D>,
261 offset: usize,
262 _depth: fidl::encoding::Depth,
263 ) -> fidl::Result<()> {
264 decoder.debug_check_bounds::<Self>(offset);
265 let prim = decoder.read_num::<u8>(offset);
266
267 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
268 Ok(())
269 }
270 }
271
272 impl fidl::encoding::ValueTypeMarker for KnownCategory {
273 type Borrowed<'a> = &'a Self;
274 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
275 value
276 }
277 }
278
279 unsafe impl fidl::encoding::TypeMarker for KnownCategory {
280 type Owned = Self;
281
282 #[inline(always)]
283 fn inline_align(_context: fidl::encoding::Context) -> usize {
284 8
285 }
286
287 #[inline(always)]
288 fn inline_size(_context: fidl::encoding::Context) -> usize {
289 32
290 }
291 }
292
293 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<KnownCategory, D>
294 for &KnownCategory
295 {
296 #[inline]
297 unsafe fn encode(
298 self,
299 encoder: &mut fidl::encoding::Encoder<'_, D>,
300 offset: usize,
301 _depth: fidl::encoding::Depth,
302 ) -> fidl::Result<()> {
303 encoder.debug_check_bounds::<KnownCategory>(offset);
304 fidl::encoding::Encode::<KnownCategory, D>::encode(
306 (
307 <fidl::encoding::BoundedString<100> as fidl::encoding::ValueTypeMarker>::borrow(
308 &self.name,
309 ),
310 <fidl::encoding::BoundedString<400> as fidl::encoding::ValueTypeMarker>::borrow(
311 &self.description,
312 ),
313 ),
314 encoder,
315 offset,
316 _depth,
317 )
318 }
319 }
320 unsafe impl<
321 D: fidl::encoding::ResourceDialect,
322 T0: fidl::encoding::Encode<fidl::encoding::BoundedString<100>, D>,
323 T1: fidl::encoding::Encode<fidl::encoding::BoundedString<400>, D>,
324 > fidl::encoding::Encode<KnownCategory, D> for (T0, T1)
325 {
326 #[inline]
327 unsafe fn encode(
328 self,
329 encoder: &mut fidl::encoding::Encoder<'_, D>,
330 offset: usize,
331 depth: fidl::encoding::Depth,
332 ) -> fidl::Result<()> {
333 encoder.debug_check_bounds::<KnownCategory>(offset);
334 self.0.encode(encoder, offset + 0, depth)?;
338 self.1.encode(encoder, offset + 16, depth)?;
339 Ok(())
340 }
341 }
342
343 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for KnownCategory {
344 #[inline(always)]
345 fn new_empty() -> Self {
346 Self {
347 name: fidl::new_empty!(fidl::encoding::BoundedString<100>, D),
348 description: fidl::new_empty!(fidl::encoding::BoundedString<400>, D),
349 }
350 }
351
352 #[inline]
353 unsafe fn decode(
354 &mut self,
355 decoder: &mut fidl::encoding::Decoder<'_, D>,
356 offset: usize,
357 _depth: fidl::encoding::Depth,
358 ) -> fidl::Result<()> {
359 decoder.debug_check_bounds::<Self>(offset);
360 fidl::decode!(
362 fidl::encoding::BoundedString<100>,
363 D,
364 &mut self.name,
365 decoder,
366 offset + 0,
367 _depth
368 )?;
369 fidl::decode!(
370 fidl::encoding::BoundedString<400>,
371 D,
372 &mut self.description,
373 decoder,
374 offset + 16,
375 _depth
376 )?;
377 Ok(())
378 }
379 }
380}