fidl_fuchsia_tracing_provider__common/
fidl_fuchsia_tracing_provider__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#[derive(Clone, Debug, PartialEq)]
12pub struct ProviderGetKnownCategoriesResponse {
13    pub categories: Vec<fidl_fuchsia_tracing__common::KnownCategory>,
14}
15
16impl fidl::Persistable for ProviderGetKnownCategoriesResponse {}
17
18#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
19pub struct ProviderStartRequest {
20    pub options: StartOptions,
21}
22
23impl fidl::Persistable for ProviderStartRequest {}
24
25#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct RegistryRegisterProviderSynchronouslyResponse {
27    pub s: i32,
28    pub started: bool,
29}
30
31impl fidl::Persistable for RegistryRegisterProviderSynchronouslyResponse {}
32
33/// Additional options to control tracing at start.
34#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct StartOptions {
36    /// Whether and how to clear the buffer when starting data collection.
37    /// This allows, for example, multiple Start/Stop trace runs to be
38    /// collected in the same buffer.
39    pub buffer_disposition: fidl_fuchsia_tracing__common::BufferDisposition,
40    /// The trace categories to add to the initial set provided in
41    /// `ProviderConfig`.
42    pub additional_categories: Vec<String>,
43}
44
45impl fidl::Persistable for StartOptions {}
46
47pub mod provider_ordinals {
48    pub const INITIALIZE: u64 = 0x9e31667d7b180f7;
49    pub const START: u64 = 0x5bae2b60be66a815;
50    pub const STOP: u64 = 0x133df8ebb1897df0;
51    pub const TERMINATE: u64 = 0x6b5564032f2726b1;
52    pub const GET_KNOWN_CATEGORIES: u64 = 0x5f5b0ad77af3f886;
53}
54
55pub mod registry_ordinals {
56    pub const REGISTER_PROVIDER: u64 = 0x75bcae3dfa08479c;
57    pub const REGISTER_PROVIDER_SYNCHRONOUSLY: u64 = 0x4835ed419a808f16;
58}
59
60mod internal {
61    use super::*;
62
63    impl fidl::encoding::ValueTypeMarker for ProviderGetKnownCategoriesResponse {
64        type Borrowed<'a> = &'a Self;
65        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
66            value
67        }
68    }
69
70    unsafe impl fidl::encoding::TypeMarker for ProviderGetKnownCategoriesResponse {
71        type Owned = Self;
72
73        #[inline(always)]
74        fn inline_align(_context: fidl::encoding::Context) -> usize {
75            8
76        }
77
78        #[inline(always)]
79        fn inline_size(_context: fidl::encoding::Context) -> usize {
80            16
81        }
82    }
83
84    unsafe impl<D: fidl::encoding::ResourceDialect>
85        fidl::encoding::Encode<ProviderGetKnownCategoriesResponse, D>
86        for &ProviderGetKnownCategoriesResponse
87    {
88        #[inline]
89        unsafe fn encode(
90            self,
91            encoder: &mut fidl::encoding::Encoder<'_, D>,
92            offset: usize,
93            _depth: fidl::encoding::Depth,
94        ) -> fidl::Result<()> {
95            encoder.debug_check_bounds::<ProviderGetKnownCategoriesResponse>(offset);
96            // Delegate to tuple encoding.
97            fidl::encoding::Encode::<ProviderGetKnownCategoriesResponse, D>::encode(
98                (
99                    <fidl::encoding::Vector<fidl_fuchsia_tracing__common::KnownCategory, 5000> as fidl::encoding::ValueTypeMarker>::borrow(&self.categories),
100                ),
101                encoder, offset, _depth
102            )
103        }
104    }
105    unsafe impl<
106        D: fidl::encoding::ResourceDialect,
107        T0: fidl::encoding::Encode<
108                fidl::encoding::Vector<fidl_fuchsia_tracing__common::KnownCategory, 5000>,
109                D,
110            >,
111    > fidl::encoding::Encode<ProviderGetKnownCategoriesResponse, D> for (T0,)
112    {
113        #[inline]
114        unsafe fn encode(
115            self,
116            encoder: &mut fidl::encoding::Encoder<'_, D>,
117            offset: usize,
118            depth: fidl::encoding::Depth,
119        ) -> fidl::Result<()> {
120            encoder.debug_check_bounds::<ProviderGetKnownCategoriesResponse>(offset);
121            // Zero out padding regions. There's no need to apply masks
122            // because the unmasked parts will be overwritten by fields.
123            // Write the fields.
124            self.0.encode(encoder, offset + 0, depth)?;
125            Ok(())
126        }
127    }
128
129    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
130        for ProviderGetKnownCategoriesResponse
131    {
132        #[inline(always)]
133        fn new_empty() -> Self {
134            Self {
135                categories: fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_tracing__common::KnownCategory, 5000>, D),
136            }
137        }
138
139        #[inline]
140        unsafe fn decode(
141            &mut self,
142            decoder: &mut fidl::encoding::Decoder<'_, D>,
143            offset: usize,
144            _depth: fidl::encoding::Depth,
145        ) -> fidl::Result<()> {
146            decoder.debug_check_bounds::<Self>(offset);
147            // Verify that padding bytes are zero.
148            fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_tracing__common::KnownCategory, 5000>, D, &mut self.categories, decoder, offset + 0, _depth)?;
149            Ok(())
150        }
151    }
152
153    impl fidl::encoding::ValueTypeMarker for ProviderStartRequest {
154        type Borrowed<'a> = &'a Self;
155        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
156            value
157        }
158    }
159
160    unsafe impl fidl::encoding::TypeMarker for ProviderStartRequest {
161        type Owned = Self;
162
163        #[inline(always)]
164        fn inline_align(_context: fidl::encoding::Context) -> usize {
165            8
166        }
167
168        #[inline(always)]
169        fn inline_size(_context: fidl::encoding::Context) -> usize {
170            24
171        }
172    }
173
174    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ProviderStartRequest, D>
175        for &ProviderStartRequest
176    {
177        #[inline]
178        unsafe fn encode(
179            self,
180            encoder: &mut fidl::encoding::Encoder<'_, D>,
181            offset: usize,
182            _depth: fidl::encoding::Depth,
183        ) -> fidl::Result<()> {
184            encoder.debug_check_bounds::<ProviderStartRequest>(offset);
185            // Delegate to tuple encoding.
186            fidl::encoding::Encode::<ProviderStartRequest, D>::encode(
187                (<StartOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),),
188                encoder,
189                offset,
190                _depth,
191            )
192        }
193    }
194    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<StartOptions, D>>
195        fidl::encoding::Encode<ProviderStartRequest, D> for (T0,)
196    {
197        #[inline]
198        unsafe fn encode(
199            self,
200            encoder: &mut fidl::encoding::Encoder<'_, D>,
201            offset: usize,
202            depth: fidl::encoding::Depth,
203        ) -> fidl::Result<()> {
204            encoder.debug_check_bounds::<ProviderStartRequest>(offset);
205            // Zero out padding regions. There's no need to apply masks
206            // because the unmasked parts will be overwritten by fields.
207            // Write the fields.
208            self.0.encode(encoder, offset + 0, depth)?;
209            Ok(())
210        }
211    }
212
213    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ProviderStartRequest {
214        #[inline(always)]
215        fn new_empty() -> Self {
216            Self { options: fidl::new_empty!(StartOptions, D) }
217        }
218
219        #[inline]
220        unsafe fn decode(
221            &mut self,
222            decoder: &mut fidl::encoding::Decoder<'_, D>,
223            offset: usize,
224            _depth: fidl::encoding::Depth,
225        ) -> fidl::Result<()> {
226            decoder.debug_check_bounds::<Self>(offset);
227            // Verify that padding bytes are zero.
228            fidl::decode!(StartOptions, D, &mut self.options, decoder, offset + 0, _depth)?;
229            Ok(())
230        }
231    }
232
233    impl fidl::encoding::ValueTypeMarker for RegistryRegisterProviderSynchronouslyResponse {
234        type Borrowed<'a> = &'a Self;
235        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
236            value
237        }
238    }
239
240    unsafe impl fidl::encoding::TypeMarker for RegistryRegisterProviderSynchronouslyResponse {
241        type Owned = Self;
242
243        #[inline(always)]
244        fn inline_align(_context: fidl::encoding::Context) -> usize {
245            4
246        }
247
248        #[inline(always)]
249        fn inline_size(_context: fidl::encoding::Context) -> usize {
250            8
251        }
252    }
253
254    unsafe impl<D: fidl::encoding::ResourceDialect>
255        fidl::encoding::Encode<RegistryRegisterProviderSynchronouslyResponse, D>
256        for &RegistryRegisterProviderSynchronouslyResponse
257    {
258        #[inline]
259        unsafe fn encode(
260            self,
261            encoder: &mut fidl::encoding::Encoder<'_, D>,
262            offset: usize,
263            _depth: fidl::encoding::Depth,
264        ) -> fidl::Result<()> {
265            encoder.debug_check_bounds::<RegistryRegisterProviderSynchronouslyResponse>(offset);
266            // Delegate to tuple encoding.
267            fidl::encoding::Encode::<RegistryRegisterProviderSynchronouslyResponse, D>::encode(
268                (
269                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.s),
270                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.started),
271                ),
272                encoder,
273                offset,
274                _depth,
275            )
276        }
277    }
278    unsafe impl<
279        D: fidl::encoding::ResourceDialect,
280        T0: fidl::encoding::Encode<i32, D>,
281        T1: fidl::encoding::Encode<bool, D>,
282    > fidl::encoding::Encode<RegistryRegisterProviderSynchronouslyResponse, D> for (T0, T1)
283    {
284        #[inline]
285        unsafe fn encode(
286            self,
287            encoder: &mut fidl::encoding::Encoder<'_, D>,
288            offset: usize,
289            depth: fidl::encoding::Depth,
290        ) -> fidl::Result<()> {
291            encoder.debug_check_bounds::<RegistryRegisterProviderSynchronouslyResponse>(offset);
292            // Zero out padding regions. There's no need to apply masks
293            // because the unmasked parts will be overwritten by fields.
294            unsafe {
295                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
296                (ptr as *mut u32).write_unaligned(0);
297            }
298            // Write the fields.
299            self.0.encode(encoder, offset + 0, depth)?;
300            self.1.encode(encoder, offset + 4, depth)?;
301            Ok(())
302        }
303    }
304
305    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
306        for RegistryRegisterProviderSynchronouslyResponse
307    {
308        #[inline(always)]
309        fn new_empty() -> Self {
310            Self { s: fidl::new_empty!(i32, D), started: fidl::new_empty!(bool, D) }
311        }
312
313        #[inline]
314        unsafe fn decode(
315            &mut self,
316            decoder: &mut fidl::encoding::Decoder<'_, D>,
317            offset: usize,
318            _depth: fidl::encoding::Depth,
319        ) -> fidl::Result<()> {
320            decoder.debug_check_bounds::<Self>(offset);
321            // Verify that padding bytes are zero.
322            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
323            let padval = unsafe { (ptr as *const u32).read_unaligned() };
324            let mask = 0xffffff00u32;
325            let maskedval = padval & mask;
326            if maskedval != 0 {
327                return Err(fidl::Error::NonZeroPadding {
328                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
329                });
330            }
331            fidl::decode!(i32, D, &mut self.s, decoder, offset + 0, _depth)?;
332            fidl::decode!(bool, D, &mut self.started, decoder, offset + 4, _depth)?;
333            Ok(())
334        }
335    }
336
337    impl fidl::encoding::ValueTypeMarker for StartOptions {
338        type Borrowed<'a> = &'a Self;
339        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
340            value
341        }
342    }
343
344    unsafe impl fidl::encoding::TypeMarker for StartOptions {
345        type Owned = Self;
346
347        #[inline(always)]
348        fn inline_align(_context: fidl::encoding::Context) -> usize {
349            8
350        }
351
352        #[inline(always)]
353        fn inline_size(_context: fidl::encoding::Context) -> usize {
354            24
355        }
356    }
357
358    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<StartOptions, D>
359        for &StartOptions
360    {
361        #[inline]
362        unsafe fn encode(
363            self,
364            encoder: &mut fidl::encoding::Encoder<'_, D>,
365            offset: usize,
366            _depth: fidl::encoding::Depth,
367        ) -> fidl::Result<()> {
368            encoder.debug_check_bounds::<StartOptions>(offset);
369            // Delegate to tuple encoding.
370            fidl::encoding::Encode::<StartOptions, D>::encode(
371                (
372                    <fidl_fuchsia_tracing__common::BufferDisposition as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_disposition),
373                    <fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000> as fidl::encoding::ValueTypeMarker>::borrow(&self.additional_categories),
374                ),
375                encoder, offset, _depth
376            )
377        }
378    }
379    unsafe impl<
380        D: fidl::encoding::ResourceDialect,
381        T0: fidl::encoding::Encode<fidl_fuchsia_tracing__common::BufferDisposition, D>,
382        T1: fidl::encoding::Encode<fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000>, D>,
383    > fidl::encoding::Encode<StartOptions, D> for (T0, T1)
384    {
385        #[inline]
386        unsafe fn encode(
387            self,
388            encoder: &mut fidl::encoding::Encoder<'_, D>,
389            offset: usize,
390            depth: fidl::encoding::Depth,
391        ) -> fidl::Result<()> {
392            encoder.debug_check_bounds::<StartOptions>(offset);
393            // Zero out padding regions. There's no need to apply masks
394            // because the unmasked parts will be overwritten by fields.
395            unsafe {
396                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
397                (ptr as *mut u64).write_unaligned(0);
398            }
399            // Write the fields.
400            self.0.encode(encoder, offset + 0, depth)?;
401            self.1.encode(encoder, offset + 8, depth)?;
402            Ok(())
403        }
404    }
405
406    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StartOptions {
407        #[inline(always)]
408        fn new_empty() -> Self {
409            Self {
410                buffer_disposition: fidl::new_empty!(
411                    fidl_fuchsia_tracing__common::BufferDisposition,
412                    D
413                ),
414                additional_categories: fidl::new_empty!(
415                    fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000>,
416                    D
417                ),
418            }
419        }
420
421        #[inline]
422        unsafe fn decode(
423            &mut self,
424            decoder: &mut fidl::encoding::Decoder<'_, D>,
425            offset: usize,
426            _depth: fidl::encoding::Depth,
427        ) -> fidl::Result<()> {
428            decoder.debug_check_bounds::<Self>(offset);
429            // Verify that padding bytes are zero.
430            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
431            let padval = unsafe { (ptr as *const u64).read_unaligned() };
432            let mask = 0xffffffffffffff00u64;
433            let maskedval = padval & mask;
434            if maskedval != 0 {
435                return Err(fidl::Error::NonZeroPadding {
436                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
437                });
438            }
439            fidl::decode!(
440                fidl_fuchsia_tracing__common::BufferDisposition,
441                D,
442                &mut self.buffer_disposition,
443                decoder,
444                offset + 0,
445                _depth
446            )?;
447            fidl::decode!(
448                fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000>,
449                D,
450                &mut self.additional_categories,
451                decoder,
452                offset + 8,
453                _depth
454            )?;
455            Ok(())
456        }
457    }
458}