fidl_fuchsia_diagnostics_persist__common/
fidl_fuchsia_diagnostics_persist__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_NAME_SIZE: u64 = 100;
12
13pub const MAX_TAGS: u64 = 100;
14
15#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
16#[repr(u32)]
17pub enum PersistResult {
18    Queued = 1,
19    TooBig = 2,
20    BadName = 3,
21    InternalError = 4,
22}
23
24impl PersistResult {
25    #[inline]
26    pub fn from_primitive(prim: u32) -> Option<Self> {
27        match prim {
28            1 => Some(Self::Queued),
29            2 => Some(Self::TooBig),
30            3 => Some(Self::BadName),
31            4 => Some(Self::InternalError),
32            _ => None,
33        }
34    }
35
36    #[inline]
37    pub const fn into_primitive(self) -> u32 {
38        self as u32
39    }
40}
41
42#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
43pub struct DataPersistencePersistRequest {
44    pub tag: String,
45}
46
47impl fidl::Persistable for DataPersistencePersistRequest {}
48
49#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
50pub struct DataPersistencePersistResponse {
51    pub result: PersistResult,
52}
53
54impl fidl::Persistable for DataPersistencePersistResponse {}
55
56#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
57pub struct DataPersistencePersistTagsRequest {
58    pub tags: Vec<String>,
59}
60
61impl fidl::Persistable for DataPersistencePersistTagsRequest {}
62
63#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
64pub struct DataPersistencePersistTagsResponse {
65    pub results: Vec<PersistResult>,
66}
67
68impl fidl::Persistable for DataPersistencePersistTagsResponse {}
69
70mod internal {
71    use super::*;
72    unsafe impl fidl::encoding::TypeMarker for PersistResult {
73        type Owned = Self;
74
75        #[inline(always)]
76        fn inline_align(_context: fidl::encoding::Context) -> usize {
77            std::mem::align_of::<u32>()
78        }
79
80        #[inline(always)]
81        fn inline_size(_context: fidl::encoding::Context) -> usize {
82            std::mem::size_of::<u32>()
83        }
84
85        #[inline(always)]
86        fn encode_is_copy() -> bool {
87            true
88        }
89
90        #[inline(always)]
91        fn decode_is_copy() -> bool {
92            false
93        }
94    }
95
96    impl fidl::encoding::ValueTypeMarker for PersistResult {
97        type Borrowed<'a> = Self;
98        #[inline(always)]
99        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
100            *value
101        }
102    }
103
104    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for PersistResult {
105        #[inline]
106        unsafe fn encode(
107            self,
108            encoder: &mut fidl::encoding::Encoder<'_, D>,
109            offset: usize,
110            _depth: fidl::encoding::Depth,
111        ) -> fidl::Result<()> {
112            encoder.debug_check_bounds::<Self>(offset);
113            encoder.write_num(self.into_primitive(), offset);
114            Ok(())
115        }
116    }
117
118    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PersistResult {
119        #[inline(always)]
120        fn new_empty() -> Self {
121            Self::Queued
122        }
123
124        #[inline]
125        unsafe fn decode(
126            &mut self,
127            decoder: &mut fidl::encoding::Decoder<'_, D>,
128            offset: usize,
129            _depth: fidl::encoding::Depth,
130        ) -> fidl::Result<()> {
131            decoder.debug_check_bounds::<Self>(offset);
132            let prim = decoder.read_num::<u32>(offset);
133
134            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
135            Ok(())
136        }
137    }
138
139    impl fidl::encoding::ValueTypeMarker for DataPersistencePersistRequest {
140        type Borrowed<'a> = &'a Self;
141        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
142            value
143        }
144    }
145
146    unsafe impl fidl::encoding::TypeMarker for DataPersistencePersistRequest {
147        type Owned = Self;
148
149        #[inline(always)]
150        fn inline_align(_context: fidl::encoding::Context) -> usize {
151            8
152        }
153
154        #[inline(always)]
155        fn inline_size(_context: fidl::encoding::Context) -> usize {
156            16
157        }
158    }
159
160    unsafe impl<D: fidl::encoding::ResourceDialect>
161        fidl::encoding::Encode<DataPersistencePersistRequest, D>
162        for &DataPersistencePersistRequest
163    {
164        #[inline]
165        unsafe fn encode(
166            self,
167            encoder: &mut fidl::encoding::Encoder<'_, D>,
168            offset: usize,
169            _depth: fidl::encoding::Depth,
170        ) -> fidl::Result<()> {
171            encoder.debug_check_bounds::<DataPersistencePersistRequest>(offset);
172            // Delegate to tuple encoding.
173            fidl::encoding::Encode::<DataPersistencePersistRequest, D>::encode(
174                (<fidl::encoding::BoundedString<100> as fidl::encoding::ValueTypeMarker>::borrow(
175                    &self.tag,
176                ),),
177                encoder,
178                offset,
179                _depth,
180            )
181        }
182    }
183    unsafe impl<
184            D: fidl::encoding::ResourceDialect,
185            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<100>, D>,
186        > fidl::encoding::Encode<DataPersistencePersistRequest, D> for (T0,)
187    {
188        #[inline]
189        unsafe fn encode(
190            self,
191            encoder: &mut fidl::encoding::Encoder<'_, D>,
192            offset: usize,
193            depth: fidl::encoding::Depth,
194        ) -> fidl::Result<()> {
195            encoder.debug_check_bounds::<DataPersistencePersistRequest>(offset);
196            // Zero out padding regions. There's no need to apply masks
197            // because the unmasked parts will be overwritten by fields.
198            // Write the fields.
199            self.0.encode(encoder, offset + 0, depth)?;
200            Ok(())
201        }
202    }
203
204    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
205        for DataPersistencePersistRequest
206    {
207        #[inline(always)]
208        fn new_empty() -> Self {
209            Self { tag: fidl::new_empty!(fidl::encoding::BoundedString<100>, D) }
210        }
211
212        #[inline]
213        unsafe fn decode(
214            &mut self,
215            decoder: &mut fidl::encoding::Decoder<'_, D>,
216            offset: usize,
217            _depth: fidl::encoding::Depth,
218        ) -> fidl::Result<()> {
219            decoder.debug_check_bounds::<Self>(offset);
220            // Verify that padding bytes are zero.
221            fidl::decode!(
222                fidl::encoding::BoundedString<100>,
223                D,
224                &mut self.tag,
225                decoder,
226                offset + 0,
227                _depth
228            )?;
229            Ok(())
230        }
231    }
232
233    impl fidl::encoding::ValueTypeMarker for DataPersistencePersistResponse {
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 DataPersistencePersistResponse {
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            4
251        }
252    }
253
254    unsafe impl<D: fidl::encoding::ResourceDialect>
255        fidl::encoding::Encode<DataPersistencePersistResponse, D>
256        for &DataPersistencePersistResponse
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::<DataPersistencePersistResponse>(offset);
266            // Delegate to tuple encoding.
267            fidl::encoding::Encode::<DataPersistencePersistResponse, D>::encode(
268                (<PersistResult as fidl::encoding::ValueTypeMarker>::borrow(&self.result),),
269                encoder,
270                offset,
271                _depth,
272            )
273        }
274    }
275    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<PersistResult, D>>
276        fidl::encoding::Encode<DataPersistencePersistResponse, D> for (T0,)
277    {
278        #[inline]
279        unsafe fn encode(
280            self,
281            encoder: &mut fidl::encoding::Encoder<'_, D>,
282            offset: usize,
283            depth: fidl::encoding::Depth,
284        ) -> fidl::Result<()> {
285            encoder.debug_check_bounds::<DataPersistencePersistResponse>(offset);
286            // Zero out padding regions. There's no need to apply masks
287            // because the unmasked parts will be overwritten by fields.
288            // Write the fields.
289            self.0.encode(encoder, offset + 0, depth)?;
290            Ok(())
291        }
292    }
293
294    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
295        for DataPersistencePersistResponse
296    {
297        #[inline(always)]
298        fn new_empty() -> Self {
299            Self { result: fidl::new_empty!(PersistResult, D) }
300        }
301
302        #[inline]
303        unsafe fn decode(
304            &mut self,
305            decoder: &mut fidl::encoding::Decoder<'_, D>,
306            offset: usize,
307            _depth: fidl::encoding::Depth,
308        ) -> fidl::Result<()> {
309            decoder.debug_check_bounds::<Self>(offset);
310            // Verify that padding bytes are zero.
311            fidl::decode!(PersistResult, D, &mut self.result, decoder, offset + 0, _depth)?;
312            Ok(())
313        }
314    }
315
316    impl fidl::encoding::ValueTypeMarker for DataPersistencePersistTagsRequest {
317        type Borrowed<'a> = &'a Self;
318        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
319            value
320        }
321    }
322
323    unsafe impl fidl::encoding::TypeMarker for DataPersistencePersistTagsRequest {
324        type Owned = Self;
325
326        #[inline(always)]
327        fn inline_align(_context: fidl::encoding::Context) -> usize {
328            8
329        }
330
331        #[inline(always)]
332        fn inline_size(_context: fidl::encoding::Context) -> usize {
333            16
334        }
335    }
336
337    unsafe impl<D: fidl::encoding::ResourceDialect>
338        fidl::encoding::Encode<DataPersistencePersistTagsRequest, D>
339        for &DataPersistencePersistTagsRequest
340    {
341        #[inline]
342        unsafe fn encode(
343            self,
344            encoder: &mut fidl::encoding::Encoder<'_, D>,
345            offset: usize,
346            _depth: fidl::encoding::Depth,
347        ) -> fidl::Result<()> {
348            encoder.debug_check_bounds::<DataPersistencePersistTagsRequest>(offset);
349            // Delegate to tuple encoding.
350            fidl::encoding::Encode::<DataPersistencePersistTagsRequest, D>::encode(
351                (
352                    <fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 100> as fidl::encoding::ValueTypeMarker>::borrow(&self.tags),
353                ),
354                encoder, offset, _depth
355            )
356        }
357    }
358    unsafe impl<
359            D: fidl::encoding::ResourceDialect,
360            T0: fidl::encoding::Encode<
361                fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 100>,
362                D,
363            >,
364        > fidl::encoding::Encode<DataPersistencePersistTagsRequest, D> for (T0,)
365    {
366        #[inline]
367        unsafe fn encode(
368            self,
369            encoder: &mut fidl::encoding::Encoder<'_, D>,
370            offset: usize,
371            depth: fidl::encoding::Depth,
372        ) -> fidl::Result<()> {
373            encoder.debug_check_bounds::<DataPersistencePersistTagsRequest>(offset);
374            // Zero out padding regions. There's no need to apply masks
375            // because the unmasked parts will be overwritten by fields.
376            // Write the fields.
377            self.0.encode(encoder, offset + 0, depth)?;
378            Ok(())
379        }
380    }
381
382    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
383        for DataPersistencePersistTagsRequest
384    {
385        #[inline(always)]
386        fn new_empty() -> Self {
387            Self {
388                tags: fidl::new_empty!(
389                    fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 100>,
390                    D
391                ),
392            }
393        }
394
395        #[inline]
396        unsafe fn decode(
397            &mut self,
398            decoder: &mut fidl::encoding::Decoder<'_, D>,
399            offset: usize,
400            _depth: fidl::encoding::Depth,
401        ) -> fidl::Result<()> {
402            decoder.debug_check_bounds::<Self>(offset);
403            // Verify that padding bytes are zero.
404            fidl::decode!(
405                fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 100>,
406                D,
407                &mut self.tags,
408                decoder,
409                offset + 0,
410                _depth
411            )?;
412            Ok(())
413        }
414    }
415
416    impl fidl::encoding::ValueTypeMarker for DataPersistencePersistTagsResponse {
417        type Borrowed<'a> = &'a Self;
418        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
419            value
420        }
421    }
422
423    unsafe impl fidl::encoding::TypeMarker for DataPersistencePersistTagsResponse {
424        type Owned = Self;
425
426        #[inline(always)]
427        fn inline_align(_context: fidl::encoding::Context) -> usize {
428            8
429        }
430
431        #[inline(always)]
432        fn inline_size(_context: fidl::encoding::Context) -> usize {
433            16
434        }
435    }
436
437    unsafe impl<D: fidl::encoding::ResourceDialect>
438        fidl::encoding::Encode<DataPersistencePersistTagsResponse, D>
439        for &DataPersistencePersistTagsResponse
440    {
441        #[inline]
442        unsafe fn encode(
443            self,
444            encoder: &mut fidl::encoding::Encoder<'_, D>,
445            offset: usize,
446            _depth: fidl::encoding::Depth,
447        ) -> fidl::Result<()> {
448            encoder.debug_check_bounds::<DataPersistencePersistTagsResponse>(offset);
449            // Delegate to tuple encoding.
450            fidl::encoding::Encode::<DataPersistencePersistTagsResponse, D>::encode(
451                (
452                    <fidl::encoding::Vector<PersistResult, 100> as fidl::encoding::ValueTypeMarker>::borrow(&self.results),
453                ),
454                encoder, offset, _depth
455            )
456        }
457    }
458    unsafe impl<
459            D: fidl::encoding::ResourceDialect,
460            T0: fidl::encoding::Encode<fidl::encoding::Vector<PersistResult, 100>, D>,
461        > fidl::encoding::Encode<DataPersistencePersistTagsResponse, D> for (T0,)
462    {
463        #[inline]
464        unsafe fn encode(
465            self,
466            encoder: &mut fidl::encoding::Encoder<'_, D>,
467            offset: usize,
468            depth: fidl::encoding::Depth,
469        ) -> fidl::Result<()> {
470            encoder.debug_check_bounds::<DataPersistencePersistTagsResponse>(offset);
471            // Zero out padding regions. There's no need to apply masks
472            // because the unmasked parts will be overwritten by fields.
473            // Write the fields.
474            self.0.encode(encoder, offset + 0, depth)?;
475            Ok(())
476        }
477    }
478
479    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
480        for DataPersistencePersistTagsResponse
481    {
482        #[inline(always)]
483        fn new_empty() -> Self {
484            Self { results: fidl::new_empty!(fidl::encoding::Vector<PersistResult, 100>, D) }
485        }
486
487        #[inline]
488        unsafe fn decode(
489            &mut self,
490            decoder: &mut fidl::encoding::Decoder<'_, D>,
491            offset: usize,
492            _depth: fidl::encoding::Depth,
493        ) -> fidl::Result<()> {
494            decoder.debug_check_bounds::<Self>(offset);
495            // Verify that padding bytes are zero.
496            fidl::decode!(fidl::encoding::Vector<PersistResult, 100>, D, &mut self.results, decoder, offset + 0, _depth)?;
497            Ok(())
498        }
499    }
500}