fidl_fuchsia_tracing__common/
fidl_fuchsia_tracing__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 type CategoryDescription = String;
12
13/// aliases
14pub type CategoryName = String;
15
16pub type EnabledCategoryList = Vec<String>;
17
18pub type ProviderId = u32;
19
20pub type ProviderName = String;
21
22/// The maximum length of a category description.
23pub const MAX_CATEGORY_DESCRIPTION_LENGTH: u32 = 400;
24
25/// The maximum length of a category name.
26pub const MAX_CATEGORY_NAME_LENGTH: u32 = 100;
27
28/// The maximum number of categories supported.
29pub const MAX_NUM_ENABLED_CATEGORIES: u32 = 5000;
30
31/// The maximum number of categories supported.
32pub const MAX_NUM_KNOWN_CATEGORIES: u32 = 5000;
33
34/// The maximum length of a provider's name.
35pub const MAX_PROVIDER_NAME_LENGTH: u32 = 100;
36
37/// Choices for clearing/retaining trace buffer contents at Start.
38/// A brief summary of buffer contents:
39/// The trace buffer is divided into two main pieces: durable and non-durable.
40/// The durable portion contains things like the string and thread data for
41/// their respective references (trace_encoded_string_ref_t and
42/// trace_encoded_thread_ref_t). The non-durable portion contains the rest of
43/// the trace data like events); this is the portion that, for example, is
44/// discarded in circular buffering mode when the (non-durable) buffer fills.
45#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
46#[repr(u8)]
47pub enum BufferDisposition {
48    /// Clear the entire buffer, including durable buffer contents.
49    /// N.B. If this is done mid-session, then string and thread references
50    /// from prior to this point will become invalid - the underlying data
51    /// will be gone. To prevent this save buffer contents before clearing.
52    ///
53    /// This is typically used when buffer contents were saved after the
54    /// preceding Stop.
55    ClearEntire = 1,
56    /// Clear the non-durable portion of the buffer, retaining the durable
57    /// portion.
58    ///
59    /// This is typically used when buffer contents were not saved after the
60    /// preceding Stop and the current contents are to be discarded.
61    ClearNondurable = 2,
62    /// Retain buffer contents. New trace data is added where the previous
63    /// trace run left off.
64    ///
65    /// This is typically used when buffer contents were not saved after the
66    /// preceding Stop and the current contents are to be retained.
67    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/// The trace buffering mode.
88#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
89#[repr(u8)]
90pub enum BufferingMode {
91    /// In oneshot mode there is only one buffer that is not reused. When the
92    /// buffer fills the provider just keeps dropping records, keeping a count,
93    /// and then when tracing stops the header is updated to record final
94    /// state.
95    Oneshot = 1,
96    /// In circular mode, the buffer is continually written to until tracing
97    /// stops. When the buffer fills older records are discarded as needed.
98    Circular = 2,
99    /// In streaming mode, the buffer is effectively split into two pieces.
100    /// When one half of the buffer fills the provider notifies the trace
101    /// manager via the provided fifo, and then starts filling the other half
102    /// of the buffer. When the buffer is saved, the manager responds via the
103    /// provided fifo. If trace manager hasn't saved the buffer in time, and
104    /// the other buffer fills, then the provider is required to drop records
105    /// until space becomes available.
106    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/// The value returned by `GetKnownCategories`.
127#[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            // Delegate to tuple encoding.
305            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            // Zero out padding regions. There's no need to apply masks
335            // because the unmasked parts will be overwritten by fields.
336            // Write the fields.
337            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            // Verify that padding bytes are zero.
361            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}