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