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<
366                fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 100>,
367                D,
368            >,
369        > fidl::encoding::Encode<DataPersistencePersistTagsRequest, D> for (T0,)
370    {
371        #[inline]
372        unsafe fn encode(
373            self,
374            encoder: &mut fidl::encoding::Encoder<'_, D>,
375            offset: usize,
376            depth: fidl::encoding::Depth,
377        ) -> fidl::Result<()> {
378            encoder.debug_check_bounds::<DataPersistencePersistTagsRequest>(offset);
379            // Zero out padding regions. There's no need to apply masks
380            // because the unmasked parts will be overwritten by fields.
381            // Write the fields.
382            self.0.encode(encoder, offset + 0, depth)?;
383            Ok(())
384        }
385    }
386
387    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
388        for DataPersistencePersistTagsRequest
389    {
390        #[inline(always)]
391        fn new_empty() -> Self {
392            Self {
393                tags: fidl::new_empty!(
394                    fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 100>,
395                    D
396                ),
397            }
398        }
399
400        #[inline]
401        unsafe fn decode(
402            &mut self,
403            decoder: &mut fidl::encoding::Decoder<'_, D>,
404            offset: usize,
405            _depth: fidl::encoding::Depth,
406        ) -> fidl::Result<()> {
407            decoder.debug_check_bounds::<Self>(offset);
408            // Verify that padding bytes are zero.
409            fidl::decode!(
410                fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 100>,
411                D,
412                &mut self.tags,
413                decoder,
414                offset + 0,
415                _depth
416            )?;
417            Ok(())
418        }
419    }
420
421    impl fidl::encoding::ValueTypeMarker for DataPersistencePersistTagsResponse {
422        type Borrowed<'a> = &'a Self;
423        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
424            value
425        }
426    }
427
428    unsafe impl fidl::encoding::TypeMarker for DataPersistencePersistTagsResponse {
429        type Owned = Self;
430
431        #[inline(always)]
432        fn inline_align(_context: fidl::encoding::Context) -> usize {
433            8
434        }
435
436        #[inline(always)]
437        fn inline_size(_context: fidl::encoding::Context) -> usize {
438            16
439        }
440    }
441
442    unsafe impl<D: fidl::encoding::ResourceDialect>
443        fidl::encoding::Encode<DataPersistencePersistTagsResponse, D>
444        for &DataPersistencePersistTagsResponse
445    {
446        #[inline]
447        unsafe fn encode(
448            self,
449            encoder: &mut fidl::encoding::Encoder<'_, D>,
450            offset: usize,
451            _depth: fidl::encoding::Depth,
452        ) -> fidl::Result<()> {
453            encoder.debug_check_bounds::<DataPersistencePersistTagsResponse>(offset);
454            // Delegate to tuple encoding.
455            fidl::encoding::Encode::<DataPersistencePersistTagsResponse, D>::encode(
456                (
457                    <fidl::encoding::Vector<PersistResult, 100> as fidl::encoding::ValueTypeMarker>::borrow(&self.results),
458                ),
459                encoder, offset, _depth
460            )
461        }
462    }
463    unsafe impl<
464            D: fidl::encoding::ResourceDialect,
465            T0: fidl::encoding::Encode<fidl::encoding::Vector<PersistResult, 100>, D>,
466        > fidl::encoding::Encode<DataPersistencePersistTagsResponse, D> for (T0,)
467    {
468        #[inline]
469        unsafe fn encode(
470            self,
471            encoder: &mut fidl::encoding::Encoder<'_, D>,
472            offset: usize,
473            depth: fidl::encoding::Depth,
474        ) -> fidl::Result<()> {
475            encoder.debug_check_bounds::<DataPersistencePersistTagsResponse>(offset);
476            // Zero out padding regions. There's no need to apply masks
477            // because the unmasked parts will be overwritten by fields.
478            // Write the fields.
479            self.0.encode(encoder, offset + 0, depth)?;
480            Ok(())
481        }
482    }
483
484    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
485        for DataPersistencePersistTagsResponse
486    {
487        #[inline(always)]
488        fn new_empty() -> Self {
489            Self { results: fidl::new_empty!(fidl::encoding::Vector<PersistResult, 100>, D) }
490        }
491
492        #[inline]
493        unsafe fn decode(
494            &mut self,
495            decoder: &mut fidl::encoding::Decoder<'_, D>,
496            offset: usize,
497            _depth: fidl::encoding::Depth,
498        ) -> fidl::Result<()> {
499            decoder.debug_check_bounds::<Self>(offset);
500            // Verify that padding bytes are zero.
501            fidl::decode!(fidl::encoding::Vector<PersistResult, 100>, D, &mut self.results, decoder, offset + 0, _depth)?;
502            Ok(())
503        }
504    }
505}