fidl_fuchsia_hardware_inlineencryption__common/
fidl_fuchsia_hardware_inlineencryption__common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
12#[repr(C)]
13pub struct DeviceProgramKeyResponse {
14    pub slot: u8,
15}
16
17impl fidl::Persistable for DeviceProgramKeyResponse {}
18
19pub mod device_ordinals {
20    pub const PROGRAM_KEY: u64 = 0x30401dc60fc47cd0;
21    pub const DERIVE_RAW_SECRET: u64 = 0x605392dccdef79d4;
22}
23
24mod internal {
25    use super::*;
26
27    impl fidl::encoding::ValueTypeMarker for DeviceProgramKeyResponse {
28        type Borrowed<'a> = &'a Self;
29        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
30            value
31        }
32    }
33
34    unsafe impl fidl::encoding::TypeMarker for DeviceProgramKeyResponse {
35        type Owned = Self;
36
37        #[inline(always)]
38        fn inline_align(_context: fidl::encoding::Context) -> usize {
39            1
40        }
41
42        #[inline(always)]
43        fn inline_size(_context: fidl::encoding::Context) -> usize {
44            1
45        }
46        #[inline(always)]
47        fn encode_is_copy() -> bool {
48            true
49        }
50
51        #[inline(always)]
52        fn decode_is_copy() -> bool {
53            true
54        }
55    }
56
57    unsafe impl<D: fidl::encoding::ResourceDialect>
58        fidl::encoding::Encode<DeviceProgramKeyResponse, D> for &DeviceProgramKeyResponse
59    {
60        #[inline]
61        unsafe fn encode(
62            self,
63            encoder: &mut fidl::encoding::Encoder<'_, D>,
64            offset: usize,
65            _depth: fidl::encoding::Depth,
66        ) -> fidl::Result<()> {
67            encoder.debug_check_bounds::<DeviceProgramKeyResponse>(offset);
68            unsafe {
69                // Copy the object into the buffer.
70                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
71                (buf_ptr as *mut DeviceProgramKeyResponse)
72                    .write_unaligned((self as *const DeviceProgramKeyResponse).read());
73                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
74                // done second because the memcpy will write garbage to these bytes.
75            }
76            Ok(())
77        }
78    }
79    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
80        fidl::encoding::Encode<DeviceProgramKeyResponse, D> for (T0,)
81    {
82        #[inline]
83        unsafe fn encode(
84            self,
85            encoder: &mut fidl::encoding::Encoder<'_, D>,
86            offset: usize,
87            depth: fidl::encoding::Depth,
88        ) -> fidl::Result<()> {
89            encoder.debug_check_bounds::<DeviceProgramKeyResponse>(offset);
90            // Zero out padding regions. There's no need to apply masks
91            // because the unmasked parts will be overwritten by fields.
92            // Write the fields.
93            self.0.encode(encoder, offset + 0, depth)?;
94            Ok(())
95        }
96    }
97
98    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
99        for DeviceProgramKeyResponse
100    {
101        #[inline(always)]
102        fn new_empty() -> Self {
103            Self { slot: fidl::new_empty!(u8, D) }
104        }
105
106        #[inline]
107        unsafe fn decode(
108            &mut self,
109            decoder: &mut fidl::encoding::Decoder<'_, D>,
110            offset: usize,
111            _depth: fidl::encoding::Depth,
112        ) -> fidl::Result<()> {
113            decoder.debug_check_bounds::<Self>(offset);
114            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
115            // Verify that padding bytes are zero.
116            // Copy from the buffer into the object.
117            unsafe {
118                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
119            }
120            Ok(())
121        }
122    }
123}