fidl_fuchsia_hardware_ramdisk_common/
fidl_fuchsia_hardware_ramdisk_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/// Matches the value of ZBI_PARTITION_GUID_LEN.
12pub const GUID_LEN: u32 = 16;
13
14pub const MAX_NAME_LENGTH: u32 = 32;
15
16bitflags! {
17    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
18    pub struct RamdiskFlag: u32 {
19        /// Identifies if requests which are sent ot the ramdisk while it is
20        /// considered "asleep" should be processed when the ramdisk wakes
21        /// up. If this flag is not set, those requests are failed
22        /// immediately.
23        const RESUME_ON_WAKE = 1;
24        /// If set, blocks written after the last flush are filled with an
25        /// indeterminate value when waking after sleeping.
26        const DISCARD_NOT_FLUSHED_ON_WAKE = 2;
27        /// If set, blocks written after the last flush are filled at
28        /// random rather than all blocks.  This can be used to simulate
29        /// out-of-order writes.
30        const DISCARD_RANDOM = 4;
31    }
32}
33
34impl RamdiskFlag {
35    #[deprecated = "Strict bits should not use `has_unknown_bits`"]
36    #[inline(always)]
37    pub fn has_unknown_bits(&self) -> bool {
38        false
39    }
40
41    #[deprecated = "Strict bits should not use `get_unknown_bits`"]
42    #[inline(always)]
43    pub fn get_unknown_bits(&self) -> u32 {
44        0
45    }
46}
47
48#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
49#[repr(C)]
50pub struct BlockWriteCounts {
51    pub received: u64,
52    pub successful: u64,
53    pub failed: u64,
54}
55
56impl fidl::Persistable for BlockWriteCounts {}
57
58/// An array of bytes interpreted as a GUID. Wrapped in a struct to
59/// allow optional GUIDs.
60#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
61#[repr(C)]
62pub struct Guid {
63    pub value: [u8; 16],
64}
65
66impl fidl::Persistable for Guid {}
67
68#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
69pub struct RamdiskControllerCreateRequest {
70    pub block_size: u64,
71    pub block_count: u64,
72    pub type_guid: Option<Box<Guid>>,
73}
74
75impl fidl::Persistable for RamdiskControllerCreateRequest {}
76
77#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
78pub struct RamdiskControllerCreateFromVmoWithParamsResponse {
79    pub name: Option<String>,
80}
81
82impl fidl::Persistable for RamdiskControllerCreateFromVmoWithParamsResponse {}
83
84#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
85pub struct RamdiskControllerCreateFromVmoResponse {
86    pub name: Option<String>,
87}
88
89impl fidl::Persistable for RamdiskControllerCreateFromVmoResponse {}
90
91#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
92pub struct RamdiskControllerCreateResponse {
93    pub name: Option<String>,
94}
95
96impl fidl::Persistable for RamdiskControllerCreateResponse {}
97
98#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
99#[repr(C)]
100pub struct RamdiskGetBlockCountsResponse {
101    /// Counters for the number of write requests since the last call to either
102    /// "SleepAfter" or "Wake". All units are in individual blocks.
103    pub counts: BlockWriteCounts,
104}
105
106impl fidl::Persistable for RamdiskGetBlockCountsResponse {}
107
108#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
109pub struct RamdiskSetFlagsRequest {
110    pub flags: RamdiskFlag,
111}
112
113impl fidl::Persistable for RamdiskSetFlagsRequest {}
114
115#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
116#[repr(C)]
117pub struct RamdiskSleepAfterRequest {
118    pub count: u64,
119}
120
121impl fidl::Persistable for RamdiskSleepAfterRequest {}
122
123mod internal {
124    use super::*;
125    unsafe impl fidl::encoding::TypeMarker for RamdiskFlag {
126        type Owned = Self;
127
128        #[inline(always)]
129        fn inline_align(_context: fidl::encoding::Context) -> usize {
130            4
131        }
132
133        #[inline(always)]
134        fn inline_size(_context: fidl::encoding::Context) -> usize {
135            4
136        }
137    }
138
139    impl fidl::encoding::ValueTypeMarker for RamdiskFlag {
140        type Borrowed<'a> = Self;
141        #[inline(always)]
142        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
143            *value
144        }
145    }
146
147    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for RamdiskFlag {
148        #[inline]
149        unsafe fn encode(
150            self,
151            encoder: &mut fidl::encoding::Encoder<'_, D>,
152            offset: usize,
153            _depth: fidl::encoding::Depth,
154        ) -> fidl::Result<()> {
155            encoder.debug_check_bounds::<Self>(offset);
156            if self.bits() & Self::all().bits() != self.bits() {
157                return Err(fidl::Error::InvalidBitsValue);
158            }
159            encoder.write_num(self.bits(), offset);
160            Ok(())
161        }
162    }
163
164    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RamdiskFlag {
165        #[inline(always)]
166        fn new_empty() -> Self {
167            Self::empty()
168        }
169
170        #[inline]
171        unsafe fn decode(
172            &mut self,
173            decoder: &mut fidl::encoding::Decoder<'_, D>,
174            offset: usize,
175            _depth: fidl::encoding::Depth,
176        ) -> fidl::Result<()> {
177            decoder.debug_check_bounds::<Self>(offset);
178            let prim = decoder.read_num::<u32>(offset);
179            *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
180            Ok(())
181        }
182    }
183
184    impl fidl::encoding::ValueTypeMarker for BlockWriteCounts {
185        type Borrowed<'a> = &'a Self;
186        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
187            value
188        }
189    }
190
191    unsafe impl fidl::encoding::TypeMarker for BlockWriteCounts {
192        type Owned = Self;
193
194        #[inline(always)]
195        fn inline_align(_context: fidl::encoding::Context) -> usize {
196            8
197        }
198
199        #[inline(always)]
200        fn inline_size(_context: fidl::encoding::Context) -> usize {
201            24
202        }
203        #[inline(always)]
204        fn encode_is_copy() -> bool {
205            true
206        }
207
208        #[inline(always)]
209        fn decode_is_copy() -> bool {
210            true
211        }
212    }
213
214    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BlockWriteCounts, D>
215        for &BlockWriteCounts
216    {
217        #[inline]
218        unsafe fn encode(
219            self,
220            encoder: &mut fidl::encoding::Encoder<'_, D>,
221            offset: usize,
222            _depth: fidl::encoding::Depth,
223        ) -> fidl::Result<()> {
224            encoder.debug_check_bounds::<BlockWriteCounts>(offset);
225            unsafe {
226                // Copy the object into the buffer.
227                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
228                (buf_ptr as *mut BlockWriteCounts)
229                    .write_unaligned((self as *const BlockWriteCounts).read());
230                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
231                // done second because the memcpy will write garbage to these bytes.
232            }
233            Ok(())
234        }
235    }
236    unsafe impl<
237            D: fidl::encoding::ResourceDialect,
238            T0: fidl::encoding::Encode<u64, D>,
239            T1: fidl::encoding::Encode<u64, D>,
240            T2: fidl::encoding::Encode<u64, D>,
241        > fidl::encoding::Encode<BlockWriteCounts, D> for (T0, T1, T2)
242    {
243        #[inline]
244        unsafe fn encode(
245            self,
246            encoder: &mut fidl::encoding::Encoder<'_, D>,
247            offset: usize,
248            depth: fidl::encoding::Depth,
249        ) -> fidl::Result<()> {
250            encoder.debug_check_bounds::<BlockWriteCounts>(offset);
251            // Zero out padding regions. There's no need to apply masks
252            // because the unmasked parts will be overwritten by fields.
253            // Write the fields.
254            self.0.encode(encoder, offset + 0, depth)?;
255            self.1.encode(encoder, offset + 8, depth)?;
256            self.2.encode(encoder, offset + 16, depth)?;
257            Ok(())
258        }
259    }
260
261    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BlockWriteCounts {
262        #[inline(always)]
263        fn new_empty() -> Self {
264            Self {
265                received: fidl::new_empty!(u64, D),
266                successful: fidl::new_empty!(u64, D),
267                failed: fidl::new_empty!(u64, D),
268            }
269        }
270
271        #[inline]
272        unsafe fn decode(
273            &mut self,
274            decoder: &mut fidl::encoding::Decoder<'_, D>,
275            offset: usize,
276            _depth: fidl::encoding::Depth,
277        ) -> fidl::Result<()> {
278            decoder.debug_check_bounds::<Self>(offset);
279            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
280            // Verify that padding bytes are zero.
281            // Copy from the buffer into the object.
282            unsafe {
283                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 24);
284            }
285            Ok(())
286        }
287    }
288
289    impl fidl::encoding::ValueTypeMarker for Guid {
290        type Borrowed<'a> = &'a Self;
291        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
292            value
293        }
294    }
295
296    unsafe impl fidl::encoding::TypeMarker for Guid {
297        type Owned = Self;
298
299        #[inline(always)]
300        fn inline_align(_context: fidl::encoding::Context) -> usize {
301            1
302        }
303
304        #[inline(always)]
305        fn inline_size(_context: fidl::encoding::Context) -> usize {
306            16
307        }
308        #[inline(always)]
309        fn encode_is_copy() -> bool {
310            true
311        }
312
313        #[inline(always)]
314        fn decode_is_copy() -> bool {
315            true
316        }
317    }
318
319    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Guid, D> for &Guid {
320        #[inline]
321        unsafe fn encode(
322            self,
323            encoder: &mut fidl::encoding::Encoder<'_, D>,
324            offset: usize,
325            _depth: fidl::encoding::Depth,
326        ) -> fidl::Result<()> {
327            encoder.debug_check_bounds::<Guid>(offset);
328            unsafe {
329                // Copy the object into the buffer.
330                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
331                (buf_ptr as *mut Guid).write_unaligned((self as *const Guid).read());
332                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
333                // done second because the memcpy will write garbage to these bytes.
334            }
335            Ok(())
336        }
337    }
338    unsafe impl<
339            D: fidl::encoding::ResourceDialect,
340            T0: fidl::encoding::Encode<fidl::encoding::Array<u8, 16>, D>,
341        > fidl::encoding::Encode<Guid, D> for (T0,)
342    {
343        #[inline]
344        unsafe fn encode(
345            self,
346            encoder: &mut fidl::encoding::Encoder<'_, D>,
347            offset: usize,
348            depth: fidl::encoding::Depth,
349        ) -> fidl::Result<()> {
350            encoder.debug_check_bounds::<Guid>(offset);
351            // Zero out padding regions. There's no need to apply masks
352            // because the unmasked parts will be overwritten by fields.
353            // Write the fields.
354            self.0.encode(encoder, offset + 0, depth)?;
355            Ok(())
356        }
357    }
358
359    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Guid {
360        #[inline(always)]
361        fn new_empty() -> Self {
362            Self { value: fidl::new_empty!(fidl::encoding::Array<u8, 16>, D) }
363        }
364
365        #[inline]
366        unsafe fn decode(
367            &mut self,
368            decoder: &mut fidl::encoding::Decoder<'_, D>,
369            offset: usize,
370            _depth: fidl::encoding::Depth,
371        ) -> fidl::Result<()> {
372            decoder.debug_check_bounds::<Self>(offset);
373            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
374            // Verify that padding bytes are zero.
375            // Copy from the buffer into the object.
376            unsafe {
377                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
378            }
379            Ok(())
380        }
381    }
382
383    impl fidl::encoding::ValueTypeMarker for RamdiskControllerCreateRequest {
384        type Borrowed<'a> = &'a Self;
385        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
386            value
387        }
388    }
389
390    unsafe impl fidl::encoding::TypeMarker for RamdiskControllerCreateRequest {
391        type Owned = Self;
392
393        #[inline(always)]
394        fn inline_align(_context: fidl::encoding::Context) -> usize {
395            8
396        }
397
398        #[inline(always)]
399        fn inline_size(_context: fidl::encoding::Context) -> usize {
400            24
401        }
402    }
403
404    unsafe impl<D: fidl::encoding::ResourceDialect>
405        fidl::encoding::Encode<RamdiskControllerCreateRequest, D>
406        for &RamdiskControllerCreateRequest
407    {
408        #[inline]
409        unsafe fn encode(
410            self,
411            encoder: &mut fidl::encoding::Encoder<'_, D>,
412            offset: usize,
413            _depth: fidl::encoding::Depth,
414        ) -> fidl::Result<()> {
415            encoder.debug_check_bounds::<RamdiskControllerCreateRequest>(offset);
416            // Delegate to tuple encoding.
417            fidl::encoding::Encode::<RamdiskControllerCreateRequest, D>::encode(
418                (
419                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.block_size),
420                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.block_count),
421                    <fidl::encoding::Boxed<Guid> as fidl::encoding::ValueTypeMarker>::borrow(
422                        &self.type_guid,
423                    ),
424                ),
425                encoder,
426                offset,
427                _depth,
428            )
429        }
430    }
431    unsafe impl<
432            D: fidl::encoding::ResourceDialect,
433            T0: fidl::encoding::Encode<u64, D>,
434            T1: fidl::encoding::Encode<u64, D>,
435            T2: fidl::encoding::Encode<fidl::encoding::Boxed<Guid>, D>,
436        > fidl::encoding::Encode<RamdiskControllerCreateRequest, D> for (T0, T1, T2)
437    {
438        #[inline]
439        unsafe fn encode(
440            self,
441            encoder: &mut fidl::encoding::Encoder<'_, D>,
442            offset: usize,
443            depth: fidl::encoding::Depth,
444        ) -> fidl::Result<()> {
445            encoder.debug_check_bounds::<RamdiskControllerCreateRequest>(offset);
446            // Zero out padding regions. There's no need to apply masks
447            // because the unmasked parts will be overwritten by fields.
448            // Write the fields.
449            self.0.encode(encoder, offset + 0, depth)?;
450            self.1.encode(encoder, offset + 8, depth)?;
451            self.2.encode(encoder, offset + 16, depth)?;
452            Ok(())
453        }
454    }
455
456    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
457        for RamdiskControllerCreateRequest
458    {
459        #[inline(always)]
460        fn new_empty() -> Self {
461            Self {
462                block_size: fidl::new_empty!(u64, D),
463                block_count: fidl::new_empty!(u64, D),
464                type_guid: fidl::new_empty!(fidl::encoding::Boxed<Guid>, D),
465            }
466        }
467
468        #[inline]
469        unsafe fn decode(
470            &mut self,
471            decoder: &mut fidl::encoding::Decoder<'_, D>,
472            offset: usize,
473            _depth: fidl::encoding::Depth,
474        ) -> fidl::Result<()> {
475            decoder.debug_check_bounds::<Self>(offset);
476            // Verify that padding bytes are zero.
477            fidl::decode!(u64, D, &mut self.block_size, decoder, offset + 0, _depth)?;
478            fidl::decode!(u64, D, &mut self.block_count, decoder, offset + 8, _depth)?;
479            fidl::decode!(
480                fidl::encoding::Boxed<Guid>,
481                D,
482                &mut self.type_guid,
483                decoder,
484                offset + 16,
485                _depth
486            )?;
487            Ok(())
488        }
489    }
490
491    impl fidl::encoding::ValueTypeMarker for RamdiskControllerCreateFromVmoWithParamsResponse {
492        type Borrowed<'a> = &'a Self;
493        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
494            value
495        }
496    }
497
498    unsafe impl fidl::encoding::TypeMarker for RamdiskControllerCreateFromVmoWithParamsResponse {
499        type Owned = Self;
500
501        #[inline(always)]
502        fn inline_align(_context: fidl::encoding::Context) -> usize {
503            8
504        }
505
506        #[inline(always)]
507        fn inline_size(_context: fidl::encoding::Context) -> usize {
508            16
509        }
510    }
511
512    unsafe impl<D: fidl::encoding::ResourceDialect>
513        fidl::encoding::Encode<RamdiskControllerCreateFromVmoWithParamsResponse, D>
514        for &RamdiskControllerCreateFromVmoWithParamsResponse
515    {
516        #[inline]
517        unsafe fn encode(
518            self,
519            encoder: &mut fidl::encoding::Encoder<'_, D>,
520            offset: usize,
521            _depth: fidl::encoding::Depth,
522        ) -> fidl::Result<()> {
523            encoder.debug_check_bounds::<RamdiskControllerCreateFromVmoWithParamsResponse>(offset);
524            // Delegate to tuple encoding.
525            fidl::encoding::Encode::<RamdiskControllerCreateFromVmoWithParamsResponse, D>::encode(
526                (
527                    <fidl::encoding::Optional<fidl::encoding::BoundedString<32>> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
528                ),
529                encoder, offset, _depth
530            )
531        }
532    }
533    unsafe impl<
534            D: fidl::encoding::ResourceDialect,
535            T0: fidl::encoding::Encode<fidl::encoding::Optional<fidl::encoding::BoundedString<32>>, D>,
536        > fidl::encoding::Encode<RamdiskControllerCreateFromVmoWithParamsResponse, D> for (T0,)
537    {
538        #[inline]
539        unsafe fn encode(
540            self,
541            encoder: &mut fidl::encoding::Encoder<'_, D>,
542            offset: usize,
543            depth: fidl::encoding::Depth,
544        ) -> fidl::Result<()> {
545            encoder.debug_check_bounds::<RamdiskControllerCreateFromVmoWithParamsResponse>(offset);
546            // Zero out padding regions. There's no need to apply masks
547            // because the unmasked parts will be overwritten by fields.
548            // Write the fields.
549            self.0.encode(encoder, offset + 0, depth)?;
550            Ok(())
551        }
552    }
553
554    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
555        for RamdiskControllerCreateFromVmoWithParamsResponse
556    {
557        #[inline(always)]
558        fn new_empty() -> Self {
559            Self {
560                name: fidl::new_empty!(
561                    fidl::encoding::Optional<fidl::encoding::BoundedString<32>>,
562                    D
563                ),
564            }
565        }
566
567        #[inline]
568        unsafe fn decode(
569            &mut self,
570            decoder: &mut fidl::encoding::Decoder<'_, D>,
571            offset: usize,
572            _depth: fidl::encoding::Depth,
573        ) -> fidl::Result<()> {
574            decoder.debug_check_bounds::<Self>(offset);
575            // Verify that padding bytes are zero.
576            fidl::decode!(
577                fidl::encoding::Optional<fidl::encoding::BoundedString<32>>,
578                D,
579                &mut self.name,
580                decoder,
581                offset + 0,
582                _depth
583            )?;
584            Ok(())
585        }
586    }
587
588    impl fidl::encoding::ValueTypeMarker for RamdiskControllerCreateFromVmoResponse {
589        type Borrowed<'a> = &'a Self;
590        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
591            value
592        }
593    }
594
595    unsafe impl fidl::encoding::TypeMarker for RamdiskControllerCreateFromVmoResponse {
596        type Owned = Self;
597
598        #[inline(always)]
599        fn inline_align(_context: fidl::encoding::Context) -> usize {
600            8
601        }
602
603        #[inline(always)]
604        fn inline_size(_context: fidl::encoding::Context) -> usize {
605            16
606        }
607    }
608
609    unsafe impl<D: fidl::encoding::ResourceDialect>
610        fidl::encoding::Encode<RamdiskControllerCreateFromVmoResponse, D>
611        for &RamdiskControllerCreateFromVmoResponse
612    {
613        #[inline]
614        unsafe fn encode(
615            self,
616            encoder: &mut fidl::encoding::Encoder<'_, D>,
617            offset: usize,
618            _depth: fidl::encoding::Depth,
619        ) -> fidl::Result<()> {
620            encoder.debug_check_bounds::<RamdiskControllerCreateFromVmoResponse>(offset);
621            // Delegate to tuple encoding.
622            fidl::encoding::Encode::<RamdiskControllerCreateFromVmoResponse, D>::encode(
623                (
624                    <fidl::encoding::Optional<fidl::encoding::BoundedString<32>> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
625                ),
626                encoder, offset, _depth
627            )
628        }
629    }
630    unsafe impl<
631            D: fidl::encoding::ResourceDialect,
632            T0: fidl::encoding::Encode<fidl::encoding::Optional<fidl::encoding::BoundedString<32>>, D>,
633        > fidl::encoding::Encode<RamdiskControllerCreateFromVmoResponse, D> for (T0,)
634    {
635        #[inline]
636        unsafe fn encode(
637            self,
638            encoder: &mut fidl::encoding::Encoder<'_, D>,
639            offset: usize,
640            depth: fidl::encoding::Depth,
641        ) -> fidl::Result<()> {
642            encoder.debug_check_bounds::<RamdiskControllerCreateFromVmoResponse>(offset);
643            // Zero out padding regions. There's no need to apply masks
644            // because the unmasked parts will be overwritten by fields.
645            // Write the fields.
646            self.0.encode(encoder, offset + 0, depth)?;
647            Ok(())
648        }
649    }
650
651    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
652        for RamdiskControllerCreateFromVmoResponse
653    {
654        #[inline(always)]
655        fn new_empty() -> Self {
656            Self {
657                name: fidl::new_empty!(
658                    fidl::encoding::Optional<fidl::encoding::BoundedString<32>>,
659                    D
660                ),
661            }
662        }
663
664        #[inline]
665        unsafe fn decode(
666            &mut self,
667            decoder: &mut fidl::encoding::Decoder<'_, D>,
668            offset: usize,
669            _depth: fidl::encoding::Depth,
670        ) -> fidl::Result<()> {
671            decoder.debug_check_bounds::<Self>(offset);
672            // Verify that padding bytes are zero.
673            fidl::decode!(
674                fidl::encoding::Optional<fidl::encoding::BoundedString<32>>,
675                D,
676                &mut self.name,
677                decoder,
678                offset + 0,
679                _depth
680            )?;
681            Ok(())
682        }
683    }
684
685    impl fidl::encoding::ValueTypeMarker for RamdiskControllerCreateResponse {
686        type Borrowed<'a> = &'a Self;
687        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
688            value
689        }
690    }
691
692    unsafe impl fidl::encoding::TypeMarker for RamdiskControllerCreateResponse {
693        type Owned = Self;
694
695        #[inline(always)]
696        fn inline_align(_context: fidl::encoding::Context) -> usize {
697            8
698        }
699
700        #[inline(always)]
701        fn inline_size(_context: fidl::encoding::Context) -> usize {
702            16
703        }
704    }
705
706    unsafe impl<D: fidl::encoding::ResourceDialect>
707        fidl::encoding::Encode<RamdiskControllerCreateResponse, D>
708        for &RamdiskControllerCreateResponse
709    {
710        #[inline]
711        unsafe fn encode(
712            self,
713            encoder: &mut fidl::encoding::Encoder<'_, D>,
714            offset: usize,
715            _depth: fidl::encoding::Depth,
716        ) -> fidl::Result<()> {
717            encoder.debug_check_bounds::<RamdiskControllerCreateResponse>(offset);
718            // Delegate to tuple encoding.
719            fidl::encoding::Encode::<RamdiskControllerCreateResponse, D>::encode(
720                (
721                    <fidl::encoding::Optional<fidl::encoding::BoundedString<32>> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
722                ),
723                encoder, offset, _depth
724            )
725        }
726    }
727    unsafe impl<
728            D: fidl::encoding::ResourceDialect,
729            T0: fidl::encoding::Encode<fidl::encoding::Optional<fidl::encoding::BoundedString<32>>, D>,
730        > fidl::encoding::Encode<RamdiskControllerCreateResponse, D> for (T0,)
731    {
732        #[inline]
733        unsafe fn encode(
734            self,
735            encoder: &mut fidl::encoding::Encoder<'_, D>,
736            offset: usize,
737            depth: fidl::encoding::Depth,
738        ) -> fidl::Result<()> {
739            encoder.debug_check_bounds::<RamdiskControllerCreateResponse>(offset);
740            // Zero out padding regions. There's no need to apply masks
741            // because the unmasked parts will be overwritten by fields.
742            // Write the fields.
743            self.0.encode(encoder, offset + 0, depth)?;
744            Ok(())
745        }
746    }
747
748    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
749        for RamdiskControllerCreateResponse
750    {
751        #[inline(always)]
752        fn new_empty() -> Self {
753            Self {
754                name: fidl::new_empty!(
755                    fidl::encoding::Optional<fidl::encoding::BoundedString<32>>,
756                    D
757                ),
758            }
759        }
760
761        #[inline]
762        unsafe fn decode(
763            &mut self,
764            decoder: &mut fidl::encoding::Decoder<'_, D>,
765            offset: usize,
766            _depth: fidl::encoding::Depth,
767        ) -> fidl::Result<()> {
768            decoder.debug_check_bounds::<Self>(offset);
769            // Verify that padding bytes are zero.
770            fidl::decode!(
771                fidl::encoding::Optional<fidl::encoding::BoundedString<32>>,
772                D,
773                &mut self.name,
774                decoder,
775                offset + 0,
776                _depth
777            )?;
778            Ok(())
779        }
780    }
781
782    impl fidl::encoding::ValueTypeMarker for RamdiskGetBlockCountsResponse {
783        type Borrowed<'a> = &'a Self;
784        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
785            value
786        }
787    }
788
789    unsafe impl fidl::encoding::TypeMarker for RamdiskGetBlockCountsResponse {
790        type Owned = Self;
791
792        #[inline(always)]
793        fn inline_align(_context: fidl::encoding::Context) -> usize {
794            8
795        }
796
797        #[inline(always)]
798        fn inline_size(_context: fidl::encoding::Context) -> usize {
799            24
800        }
801        #[inline(always)]
802        fn encode_is_copy() -> bool {
803            true
804        }
805
806        #[inline(always)]
807        fn decode_is_copy() -> bool {
808            true
809        }
810    }
811
812    unsafe impl<D: fidl::encoding::ResourceDialect>
813        fidl::encoding::Encode<RamdiskGetBlockCountsResponse, D>
814        for &RamdiskGetBlockCountsResponse
815    {
816        #[inline]
817        unsafe fn encode(
818            self,
819            encoder: &mut fidl::encoding::Encoder<'_, D>,
820            offset: usize,
821            _depth: fidl::encoding::Depth,
822        ) -> fidl::Result<()> {
823            encoder.debug_check_bounds::<RamdiskGetBlockCountsResponse>(offset);
824            unsafe {
825                // Copy the object into the buffer.
826                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
827                (buf_ptr as *mut RamdiskGetBlockCountsResponse)
828                    .write_unaligned((self as *const RamdiskGetBlockCountsResponse).read());
829                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
830                // done second because the memcpy will write garbage to these bytes.
831            }
832            Ok(())
833        }
834    }
835    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<BlockWriteCounts, D>>
836        fidl::encoding::Encode<RamdiskGetBlockCountsResponse, D> for (T0,)
837    {
838        #[inline]
839        unsafe fn encode(
840            self,
841            encoder: &mut fidl::encoding::Encoder<'_, D>,
842            offset: usize,
843            depth: fidl::encoding::Depth,
844        ) -> fidl::Result<()> {
845            encoder.debug_check_bounds::<RamdiskGetBlockCountsResponse>(offset);
846            // Zero out padding regions. There's no need to apply masks
847            // because the unmasked parts will be overwritten by fields.
848            // Write the fields.
849            self.0.encode(encoder, offset + 0, depth)?;
850            Ok(())
851        }
852    }
853
854    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
855        for RamdiskGetBlockCountsResponse
856    {
857        #[inline(always)]
858        fn new_empty() -> Self {
859            Self { counts: fidl::new_empty!(BlockWriteCounts, D) }
860        }
861
862        #[inline]
863        unsafe fn decode(
864            &mut self,
865            decoder: &mut fidl::encoding::Decoder<'_, D>,
866            offset: usize,
867            _depth: fidl::encoding::Depth,
868        ) -> fidl::Result<()> {
869            decoder.debug_check_bounds::<Self>(offset);
870            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
871            // Verify that padding bytes are zero.
872            // Copy from the buffer into the object.
873            unsafe {
874                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 24);
875            }
876            Ok(())
877        }
878    }
879
880    impl fidl::encoding::ValueTypeMarker for RamdiskSetFlagsRequest {
881        type Borrowed<'a> = &'a Self;
882        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
883            value
884        }
885    }
886
887    unsafe impl fidl::encoding::TypeMarker for RamdiskSetFlagsRequest {
888        type Owned = Self;
889
890        #[inline(always)]
891        fn inline_align(_context: fidl::encoding::Context) -> usize {
892            4
893        }
894
895        #[inline(always)]
896        fn inline_size(_context: fidl::encoding::Context) -> usize {
897            4
898        }
899    }
900
901    unsafe impl<D: fidl::encoding::ResourceDialect>
902        fidl::encoding::Encode<RamdiskSetFlagsRequest, D> for &RamdiskSetFlagsRequest
903    {
904        #[inline]
905        unsafe fn encode(
906            self,
907            encoder: &mut fidl::encoding::Encoder<'_, D>,
908            offset: usize,
909            _depth: fidl::encoding::Depth,
910        ) -> fidl::Result<()> {
911            encoder.debug_check_bounds::<RamdiskSetFlagsRequest>(offset);
912            // Delegate to tuple encoding.
913            fidl::encoding::Encode::<RamdiskSetFlagsRequest, D>::encode(
914                (<RamdiskFlag as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),),
915                encoder,
916                offset,
917                _depth,
918            )
919        }
920    }
921    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<RamdiskFlag, D>>
922        fidl::encoding::Encode<RamdiskSetFlagsRequest, D> for (T0,)
923    {
924        #[inline]
925        unsafe fn encode(
926            self,
927            encoder: &mut fidl::encoding::Encoder<'_, D>,
928            offset: usize,
929            depth: fidl::encoding::Depth,
930        ) -> fidl::Result<()> {
931            encoder.debug_check_bounds::<RamdiskSetFlagsRequest>(offset);
932            // Zero out padding regions. There's no need to apply masks
933            // because the unmasked parts will be overwritten by fields.
934            // Write the fields.
935            self.0.encode(encoder, offset + 0, depth)?;
936            Ok(())
937        }
938    }
939
940    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
941        for RamdiskSetFlagsRequest
942    {
943        #[inline(always)]
944        fn new_empty() -> Self {
945            Self { flags: fidl::new_empty!(RamdiskFlag, D) }
946        }
947
948        #[inline]
949        unsafe fn decode(
950            &mut self,
951            decoder: &mut fidl::encoding::Decoder<'_, D>,
952            offset: usize,
953            _depth: fidl::encoding::Depth,
954        ) -> fidl::Result<()> {
955            decoder.debug_check_bounds::<Self>(offset);
956            // Verify that padding bytes are zero.
957            fidl::decode!(RamdiskFlag, D, &mut self.flags, decoder, offset + 0, _depth)?;
958            Ok(())
959        }
960    }
961
962    impl fidl::encoding::ValueTypeMarker for RamdiskSleepAfterRequest {
963        type Borrowed<'a> = &'a Self;
964        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
965            value
966        }
967    }
968
969    unsafe impl fidl::encoding::TypeMarker for RamdiskSleepAfterRequest {
970        type Owned = Self;
971
972        #[inline(always)]
973        fn inline_align(_context: fidl::encoding::Context) -> usize {
974            8
975        }
976
977        #[inline(always)]
978        fn inline_size(_context: fidl::encoding::Context) -> usize {
979            8
980        }
981        #[inline(always)]
982        fn encode_is_copy() -> bool {
983            true
984        }
985
986        #[inline(always)]
987        fn decode_is_copy() -> bool {
988            true
989        }
990    }
991
992    unsafe impl<D: fidl::encoding::ResourceDialect>
993        fidl::encoding::Encode<RamdiskSleepAfterRequest, D> for &RamdiskSleepAfterRequest
994    {
995        #[inline]
996        unsafe fn encode(
997            self,
998            encoder: &mut fidl::encoding::Encoder<'_, D>,
999            offset: usize,
1000            _depth: fidl::encoding::Depth,
1001        ) -> fidl::Result<()> {
1002            encoder.debug_check_bounds::<RamdiskSleepAfterRequest>(offset);
1003            unsafe {
1004                // Copy the object into the buffer.
1005                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1006                (buf_ptr as *mut RamdiskSleepAfterRequest)
1007                    .write_unaligned((self as *const RamdiskSleepAfterRequest).read());
1008                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1009                // done second because the memcpy will write garbage to these bytes.
1010            }
1011            Ok(())
1012        }
1013    }
1014    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
1015        fidl::encoding::Encode<RamdiskSleepAfterRequest, D> for (T0,)
1016    {
1017        #[inline]
1018        unsafe fn encode(
1019            self,
1020            encoder: &mut fidl::encoding::Encoder<'_, D>,
1021            offset: usize,
1022            depth: fidl::encoding::Depth,
1023        ) -> fidl::Result<()> {
1024            encoder.debug_check_bounds::<RamdiskSleepAfterRequest>(offset);
1025            // Zero out padding regions. There's no need to apply masks
1026            // because the unmasked parts will be overwritten by fields.
1027            // Write the fields.
1028            self.0.encode(encoder, offset + 0, depth)?;
1029            Ok(())
1030        }
1031    }
1032
1033    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1034        for RamdiskSleepAfterRequest
1035    {
1036        #[inline(always)]
1037        fn new_empty() -> Self {
1038            Self { count: fidl::new_empty!(u64, D) }
1039        }
1040
1041        #[inline]
1042        unsafe fn decode(
1043            &mut self,
1044            decoder: &mut fidl::encoding::Decoder<'_, D>,
1045            offset: usize,
1046            _depth: fidl::encoding::Depth,
1047        ) -> fidl::Result<()> {
1048            decoder.debug_check_bounds::<Self>(offset);
1049            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1050            // Verify that padding bytes are zero.
1051            // Copy from the buffer into the object.
1052            unsafe {
1053                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
1054            }
1055            Ok(())
1056        }
1057    }
1058}