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