fidl_fuchsia_reloaddriver_test_common/
fidl_fuchsia_reloaddriver_test_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_FROM_LENGTH: u64 = 32;
12
13#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
14pub struct WaiterAckRequest {
15    pub from_node: String,
16    pub from_name: String,
17    pub status: i32,
18}
19
20impl fidl::Persistable for WaiterAckRequest {}
21
22mod internal {
23    use super::*;
24
25    impl fidl::encoding::ValueTypeMarker for WaiterAckRequest {
26        type Borrowed<'a> = &'a Self;
27        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
28            value
29        }
30    }
31
32    unsafe impl fidl::encoding::TypeMarker for WaiterAckRequest {
33        type Owned = Self;
34
35        #[inline(always)]
36        fn inline_align(_context: fidl::encoding::Context) -> usize {
37            8
38        }
39
40        #[inline(always)]
41        fn inline_size(_context: fidl::encoding::Context) -> usize {
42            40
43        }
44    }
45
46    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<WaiterAckRequest, D>
47        for &WaiterAckRequest
48    {
49        #[inline]
50        unsafe fn encode(
51            self,
52            encoder: &mut fidl::encoding::Encoder<'_, D>,
53            offset: usize,
54            _depth: fidl::encoding::Depth,
55        ) -> fidl::Result<()> {
56            encoder.debug_check_bounds::<WaiterAckRequest>(offset);
57            // Delegate to tuple encoding.
58            fidl::encoding::Encode::<WaiterAckRequest, D>::encode(
59                (
60                    <fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow(
61                        &self.from_node,
62                    ),
63                    <fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow(
64                        &self.from_name,
65                    ),
66                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
67                ),
68                encoder,
69                offset,
70                _depth,
71            )
72        }
73    }
74    unsafe impl<
75            D: fidl::encoding::ResourceDialect,
76            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<32>, D>,
77            T1: fidl::encoding::Encode<fidl::encoding::BoundedString<32>, D>,
78            T2: fidl::encoding::Encode<i32, D>,
79        > fidl::encoding::Encode<WaiterAckRequest, D> for (T0, T1, T2)
80    {
81        #[inline]
82        unsafe fn encode(
83            self,
84            encoder: &mut fidl::encoding::Encoder<'_, D>,
85            offset: usize,
86            depth: fidl::encoding::Depth,
87        ) -> fidl::Result<()> {
88            encoder.debug_check_bounds::<WaiterAckRequest>(offset);
89            // Zero out padding regions. There's no need to apply masks
90            // because the unmasked parts will be overwritten by fields.
91            unsafe {
92                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
93                (ptr as *mut u64).write_unaligned(0);
94            }
95            // Write the fields.
96            self.0.encode(encoder, offset + 0, depth)?;
97            self.1.encode(encoder, offset + 16, depth)?;
98            self.2.encode(encoder, offset + 32, depth)?;
99            Ok(())
100        }
101    }
102
103    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WaiterAckRequest {
104        #[inline(always)]
105        fn new_empty() -> Self {
106            Self {
107                from_node: fidl::new_empty!(fidl::encoding::BoundedString<32>, D),
108                from_name: fidl::new_empty!(fidl::encoding::BoundedString<32>, D),
109                status: fidl::new_empty!(i32, D),
110            }
111        }
112
113        #[inline]
114        unsafe fn decode(
115            &mut self,
116            decoder: &mut fidl::encoding::Decoder<'_, D>,
117            offset: usize,
118            _depth: fidl::encoding::Depth,
119        ) -> fidl::Result<()> {
120            decoder.debug_check_bounds::<Self>(offset);
121            // Verify that padding bytes are zero.
122            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
123            let padval = unsafe { (ptr as *const u64).read_unaligned() };
124            let mask = 0xffffffff00000000u64;
125            let maskedval = padval & mask;
126            if maskedval != 0 {
127                return Err(fidl::Error::NonZeroPadding {
128                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
129                });
130            }
131            fidl::decode!(
132                fidl::encoding::BoundedString<32>,
133                D,
134                &mut self.from_node,
135                decoder,
136                offset + 0,
137                _depth
138            )?;
139            fidl::decode!(
140                fidl::encoding::BoundedString<32>,
141                D,
142                &mut self.from_name,
143                decoder,
144                offset + 16,
145                _depth
146            )?;
147            fidl::decode!(i32, D, &mut self.status, decoder, offset + 32, _depth)?;
148            Ok(())
149        }
150    }
151}