Skip to main content

fidl_fuchsia_storage_mapping_common/
fidl_fuchsia_storage_mapping_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 MappingSessionCloseRequest {
14    pub key: u64,
15}
16
17impl fidl::Persistable for MappingSessionCloseRequest {}
18
19#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
20pub struct MappingSessionOpenRequest {
21    /// Session-unique numeric handle allocated by the client. The filesystem associates
22    /// the node's disk extents with this key when communicating with the block driver.
23    pub key: u64,
24    /// Content identifier for the node (e.g. 32-byte blob Merkle root hash) used by the
25    /// filesystem to look up its extents on disk.
26    pub identifier: Vec<u8>,
27}
28
29impl fidl::Persistable for MappingSessionOpenRequest {}
30
31#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
32#[repr(C)]
33pub struct MappingSessionOpenResponse {
34    pub size: u64,
35}
36
37impl fidl::Persistable for MappingSessionOpenResponse {}
38
39pub mod mapping_provider_ordinals {
40    pub const OPEN_SESSION: u64 = 0x392ee248d504919a;
41}
42
43pub mod mapping_session_ordinals {
44    pub const OPEN: u64 = 0x1b3f5b2b1e68472b;
45    pub const CLOSE: u64 = 0x34708ae0c1044d20;
46}
47
48mod internal {
49    use super::*;
50
51    impl fidl::encoding::ValueTypeMarker for MappingSessionCloseRequest {
52        type Borrowed<'a> = &'a Self;
53        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
54            value
55        }
56    }
57
58    unsafe impl fidl::encoding::TypeMarker for MappingSessionCloseRequest {
59        type Owned = Self;
60
61        #[inline(always)]
62        fn inline_align(_context: fidl::encoding::Context) -> usize {
63            8
64        }
65
66        #[inline(always)]
67        fn inline_size(_context: fidl::encoding::Context) -> usize {
68            8
69        }
70        #[inline(always)]
71        fn encode_is_copy() -> bool {
72            true
73        }
74
75        #[inline(always)]
76        fn decode_is_copy() -> bool {
77            true
78        }
79    }
80
81    unsafe impl<D: fidl::encoding::ResourceDialect>
82        fidl::encoding::Encode<MappingSessionCloseRequest, D> for &MappingSessionCloseRequest
83    {
84        #[inline]
85        unsafe fn encode(
86            self,
87            encoder: &mut fidl::encoding::Encoder<'_, D>,
88            offset: usize,
89            _depth: fidl::encoding::Depth,
90        ) -> fidl::Result<()> {
91            encoder.debug_check_bounds::<MappingSessionCloseRequest>(offset);
92            unsafe {
93                // Copy the object into the buffer.
94                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
95                (buf_ptr as *mut MappingSessionCloseRequest)
96                    .write_unaligned((self as *const MappingSessionCloseRequest).read());
97                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
98                // done second because the memcpy will write garbage to these bytes.
99            }
100            Ok(())
101        }
102    }
103    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
104        fidl::encoding::Encode<MappingSessionCloseRequest, D> for (T0,)
105    {
106        #[inline]
107        unsafe fn encode(
108            self,
109            encoder: &mut fidl::encoding::Encoder<'_, D>,
110            offset: usize,
111            depth: fidl::encoding::Depth,
112        ) -> fidl::Result<()> {
113            encoder.debug_check_bounds::<MappingSessionCloseRequest>(offset);
114            // Zero out padding regions. There's no need to apply masks
115            // because the unmasked parts will be overwritten by fields.
116            // Write the fields.
117            self.0.encode(encoder, offset + 0, depth)?;
118            Ok(())
119        }
120    }
121
122    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
123        for MappingSessionCloseRequest
124    {
125        #[inline(always)]
126        fn new_empty() -> Self {
127            Self { key: fidl::new_empty!(u64, D) }
128        }
129
130        #[inline]
131        unsafe fn decode(
132            &mut self,
133            decoder: &mut fidl::encoding::Decoder<'_, D>,
134            offset: usize,
135            _depth: fidl::encoding::Depth,
136        ) -> fidl::Result<()> {
137            decoder.debug_check_bounds::<Self>(offset);
138            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
139            // Verify that padding bytes are zero.
140            // Copy from the buffer into the object.
141            unsafe {
142                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
143            }
144            Ok(())
145        }
146    }
147
148    impl fidl::encoding::ValueTypeMarker for MappingSessionOpenRequest {
149        type Borrowed<'a> = &'a Self;
150        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
151            value
152        }
153    }
154
155    unsafe impl fidl::encoding::TypeMarker for MappingSessionOpenRequest {
156        type Owned = Self;
157
158        #[inline(always)]
159        fn inline_align(_context: fidl::encoding::Context) -> usize {
160            8
161        }
162
163        #[inline(always)]
164        fn inline_size(_context: fidl::encoding::Context) -> usize {
165            24
166        }
167    }
168
169    unsafe impl<D: fidl::encoding::ResourceDialect>
170        fidl::encoding::Encode<MappingSessionOpenRequest, D> for &MappingSessionOpenRequest
171    {
172        #[inline]
173        unsafe fn encode(
174            self,
175            encoder: &mut fidl::encoding::Encoder<'_, D>,
176            offset: usize,
177            _depth: fidl::encoding::Depth,
178        ) -> fidl::Result<()> {
179            encoder.debug_check_bounds::<MappingSessionOpenRequest>(offset);
180            // Delegate to tuple encoding.
181            fidl::encoding::Encode::<MappingSessionOpenRequest, D>::encode(
182                (
183                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.key),
184                    <fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(&self.identifier),
185                ),
186                encoder, offset, _depth
187            )
188        }
189    }
190    unsafe impl<
191        D: fidl::encoding::ResourceDialect,
192        T0: fidl::encoding::Encode<u64, D>,
193        T1: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
194    > fidl::encoding::Encode<MappingSessionOpenRequest, D> for (T0, T1)
195    {
196        #[inline]
197        unsafe fn encode(
198            self,
199            encoder: &mut fidl::encoding::Encoder<'_, D>,
200            offset: usize,
201            depth: fidl::encoding::Depth,
202        ) -> fidl::Result<()> {
203            encoder.debug_check_bounds::<MappingSessionOpenRequest>(offset);
204            // Zero out padding regions. There's no need to apply masks
205            // because the unmasked parts will be overwritten by fields.
206            // Write the fields.
207            self.0.encode(encoder, offset + 0, depth)?;
208            self.1.encode(encoder, offset + 8, depth)?;
209            Ok(())
210        }
211    }
212
213    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
214        for MappingSessionOpenRequest
215    {
216        #[inline(always)]
217        fn new_empty() -> Self {
218            Self {
219                key: fidl::new_empty!(u64, D),
220                identifier: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D),
221            }
222        }
223
224        #[inline]
225        unsafe fn decode(
226            &mut self,
227            decoder: &mut fidl::encoding::Decoder<'_, D>,
228            offset: usize,
229            _depth: fidl::encoding::Depth,
230        ) -> fidl::Result<()> {
231            decoder.debug_check_bounds::<Self>(offset);
232            // Verify that padding bytes are zero.
233            fidl::decode!(u64, D, &mut self.key, decoder, offset + 0, _depth)?;
234            fidl::decode!(
235                fidl::encoding::UnboundedVector<u8>,
236                D,
237                &mut self.identifier,
238                decoder,
239                offset + 8,
240                _depth
241            )?;
242            Ok(())
243        }
244    }
245
246    impl fidl::encoding::ValueTypeMarker for MappingSessionOpenResponse {
247        type Borrowed<'a> = &'a Self;
248        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
249            value
250        }
251    }
252
253    unsafe impl fidl::encoding::TypeMarker for MappingSessionOpenResponse {
254        type Owned = Self;
255
256        #[inline(always)]
257        fn inline_align(_context: fidl::encoding::Context) -> usize {
258            8
259        }
260
261        #[inline(always)]
262        fn inline_size(_context: fidl::encoding::Context) -> usize {
263            8
264        }
265        #[inline(always)]
266        fn encode_is_copy() -> bool {
267            true
268        }
269
270        #[inline(always)]
271        fn decode_is_copy() -> bool {
272            true
273        }
274    }
275
276    unsafe impl<D: fidl::encoding::ResourceDialect>
277        fidl::encoding::Encode<MappingSessionOpenResponse, D> for &MappingSessionOpenResponse
278    {
279        #[inline]
280        unsafe fn encode(
281            self,
282            encoder: &mut fidl::encoding::Encoder<'_, D>,
283            offset: usize,
284            _depth: fidl::encoding::Depth,
285        ) -> fidl::Result<()> {
286            encoder.debug_check_bounds::<MappingSessionOpenResponse>(offset);
287            unsafe {
288                // Copy the object into the buffer.
289                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
290                (buf_ptr as *mut MappingSessionOpenResponse)
291                    .write_unaligned((self as *const MappingSessionOpenResponse).read());
292                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
293                // done second because the memcpy will write garbage to these bytes.
294            }
295            Ok(())
296        }
297    }
298    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
299        fidl::encoding::Encode<MappingSessionOpenResponse, D> for (T0,)
300    {
301        #[inline]
302        unsafe fn encode(
303            self,
304            encoder: &mut fidl::encoding::Encoder<'_, D>,
305            offset: usize,
306            depth: fidl::encoding::Depth,
307        ) -> fidl::Result<()> {
308            encoder.debug_check_bounds::<MappingSessionOpenResponse>(offset);
309            // Zero out padding regions. There's no need to apply masks
310            // because the unmasked parts will be overwritten by fields.
311            // Write the fields.
312            self.0.encode(encoder, offset + 0, depth)?;
313            Ok(())
314        }
315    }
316
317    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
318        for MappingSessionOpenResponse
319    {
320        #[inline(always)]
321        fn new_empty() -> Self {
322            Self { size: fidl::new_empty!(u64, D) }
323        }
324
325        #[inline]
326        unsafe fn decode(
327            &mut self,
328            decoder: &mut fidl::encoding::Decoder<'_, D>,
329            offset: usize,
330            _depth: fidl::encoding::Depth,
331        ) -> fidl::Result<()> {
332            decoder.debug_check_bounds::<Self>(offset);
333            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
334            // Verify that padding bytes are zero.
335            // Copy from the buffer into the object.
336            unsafe {
337                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
338            }
339            Ok(())
340        }
341    }
342}