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