Skip to main content

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
24pub mod driver_device_ordinals {
25    pub const PROGRAM_KEY: u64 = 0x30401dc60fc47cd0;
26    pub const DERIVE_RAW_SECRET: u64 = 0x605392dccdef79d4;
27}
28
29mod internal {
30    use super::*;
31
32    impl fidl::encoding::ValueTypeMarker for DeviceProgramKeyResponse {
33        type Borrowed<'a> = &'a Self;
34        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
35            value
36        }
37    }
38
39    unsafe impl fidl::encoding::TypeMarker for DeviceProgramKeyResponse {
40        type Owned = Self;
41
42        #[inline(always)]
43        fn inline_align(_context: fidl::encoding::Context) -> usize {
44            1
45        }
46
47        #[inline(always)]
48        fn inline_size(_context: fidl::encoding::Context) -> usize {
49            1
50        }
51        #[inline(always)]
52        fn encode_is_copy() -> bool {
53            true
54        }
55
56        #[inline(always)]
57        fn decode_is_copy() -> bool {
58            true
59        }
60    }
61
62    unsafe impl<D: fidl::encoding::ResourceDialect>
63        fidl::encoding::Encode<DeviceProgramKeyResponse, D> for &DeviceProgramKeyResponse
64    {
65        #[inline]
66        unsafe fn encode(
67            self,
68            encoder: &mut fidl::encoding::Encoder<'_, D>,
69            offset: usize,
70            _depth: fidl::encoding::Depth,
71        ) -> fidl::Result<()> {
72            encoder.debug_check_bounds::<DeviceProgramKeyResponse>(offset);
73            unsafe {
74                // Copy the object into the buffer.
75                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
76                (buf_ptr as *mut DeviceProgramKeyResponse)
77                    .write_unaligned((self as *const DeviceProgramKeyResponse).read());
78                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
79                // done second because the memcpy will write garbage to these bytes.
80            }
81            Ok(())
82        }
83    }
84    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
85        fidl::encoding::Encode<DeviceProgramKeyResponse, D> for (T0,)
86    {
87        #[inline]
88        unsafe fn encode(
89            self,
90            encoder: &mut fidl::encoding::Encoder<'_, D>,
91            offset: usize,
92            depth: fidl::encoding::Depth,
93        ) -> fidl::Result<()> {
94            encoder.debug_check_bounds::<DeviceProgramKeyResponse>(offset);
95            // Zero out padding regions. There's no need to apply masks
96            // because the unmasked parts will be overwritten by fields.
97            // Write the fields.
98            self.0.encode(encoder, offset + 0, depth)?;
99            Ok(())
100        }
101    }
102
103    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
104        for DeviceProgramKeyResponse
105    {
106        #[inline(always)]
107        fn new_empty() -> Self {
108            Self { slot: fidl::new_empty!(u8, D) }
109        }
110
111        #[inline]
112        unsafe fn decode(
113            &mut self,
114            decoder: &mut fidl::encoding::Decoder<'_, D>,
115            offset: usize,
116            _depth: fidl::encoding::Depth,
117        ) -> fidl::Result<()> {
118            decoder.debug_check_bounds::<Self>(offset);
119            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
120            // Verify that padding bytes are zero.
121            // Copy from the buffer into the object.
122            unsafe {
123                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
124            }
125            Ok(())
126        }
127    }
128}