fidl_fuchsia_device_fs__common/
fidl_fuchsia_device_fs__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/// This name is reserved for accessing the fuchsia.device/Controller protocol
12/// within /dev/. No devices can be created with this name.
13pub const DEVICE_CONTROLLER_NAME: &str = "device_controller";
14
15/// This name is reserved for accessing the device specific protocol
16/// within /dev/. No devices can be created with this name.
17pub const DEVICE_PROTOCOL_NAME: &str = "device_protocol";
18
19/// This name is reserved for accessing the fuchsia.device.fs/TopologicalPath protocol
20/// within /dev/. No devices can be created with this name.
21pub const DEVICE_TOPOLOGY_NAME: &str = "device_topology";
22
23/// Maximum length of a device path
24pub const MAX_DEVICE_PATH_LEN: u64 = 1024;
25
26/// Maximum length for a driver path
27pub const MAX_DRIVER_PATH_LEN: u64 = 1024;
28
29bitflags! {
30    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
31    pub struct ConnectionType: u8 {
32        /// Represents the fuchsia.io/Node protocol.
33        const NODE = 1;
34        /// Represents the fuchsia.device/Controller protocol.
35        const CONTROLLER = 2;
36        /// Represents the device specific FIDL.
37        const DEVICE = 4;
38    }
39}
40
41impl ConnectionType {
42    #[inline(always)]
43    pub fn from_bits_allow_unknown(bits: u8) -> Self {
44        Self::from_bits_retain(bits)
45    }
46
47    #[inline(always)]
48    pub fn has_unknown_bits(&self) -> bool {
49        self.get_unknown_bits() != 0
50    }
51
52    #[inline(always)]
53    pub fn get_unknown_bits(&self) -> u8 {
54        self.bits() & !Self::all().bits()
55    }
56}
57
58#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
59pub struct TopologicalPathGetTopologicalPathResponse {
60    pub path: String,
61}
62
63impl fidl::Persistable for TopologicalPathGetTopologicalPathResponse {}
64
65pub mod connector_ordinals {
66    pub const CONNECT: u64 = 0x2bfd50a6209194f9;
67}
68
69pub mod topological_path_ordinals {
70    pub const GET_TOPOLOGICAL_PATH: u64 = 0x56f6105571a973d8;
71}
72
73mod internal {
74    use super::*;
75    unsafe impl fidl::encoding::TypeMarker for ConnectionType {
76        type Owned = Self;
77
78        #[inline(always)]
79        fn inline_align(_context: fidl::encoding::Context) -> usize {
80            1
81        }
82
83        #[inline(always)]
84        fn inline_size(_context: fidl::encoding::Context) -> usize {
85            1
86        }
87    }
88
89    impl fidl::encoding::ValueTypeMarker for ConnectionType {
90        type Borrowed<'a> = Self;
91        #[inline(always)]
92        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
93            *value
94        }
95    }
96
97    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ConnectionType {
98        #[inline]
99        unsafe fn encode(
100            self,
101            encoder: &mut fidl::encoding::Encoder<'_, D>,
102            offset: usize,
103            _depth: fidl::encoding::Depth,
104        ) -> fidl::Result<()> {
105            encoder.debug_check_bounds::<Self>(offset);
106            encoder.write_num(self.bits(), offset);
107            Ok(())
108        }
109    }
110
111    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ConnectionType {
112        #[inline(always)]
113        fn new_empty() -> Self {
114            Self::empty()
115        }
116
117        #[inline]
118        unsafe fn decode(
119            &mut self,
120            decoder: &mut fidl::encoding::Decoder<'_, D>,
121            offset: usize,
122            _depth: fidl::encoding::Depth,
123        ) -> fidl::Result<()> {
124            decoder.debug_check_bounds::<Self>(offset);
125            let prim = decoder.read_num::<u8>(offset);
126            *self = Self::from_bits_allow_unknown(prim);
127            Ok(())
128        }
129    }
130
131    impl fidl::encoding::ValueTypeMarker for TopologicalPathGetTopologicalPathResponse {
132        type Borrowed<'a> = &'a Self;
133        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
134            value
135        }
136    }
137
138    unsafe impl fidl::encoding::TypeMarker for TopologicalPathGetTopologicalPathResponse {
139        type Owned = Self;
140
141        #[inline(always)]
142        fn inline_align(_context: fidl::encoding::Context) -> usize {
143            8
144        }
145
146        #[inline(always)]
147        fn inline_size(_context: fidl::encoding::Context) -> usize {
148            16
149        }
150    }
151
152    unsafe impl<D: fidl::encoding::ResourceDialect>
153        fidl::encoding::Encode<TopologicalPathGetTopologicalPathResponse, D>
154        for &TopologicalPathGetTopologicalPathResponse
155    {
156        #[inline]
157        unsafe fn encode(
158            self,
159            encoder: &mut fidl::encoding::Encoder<'_, D>,
160            offset: usize,
161            _depth: fidl::encoding::Depth,
162        ) -> fidl::Result<()> {
163            encoder.debug_check_bounds::<TopologicalPathGetTopologicalPathResponse>(offset);
164            // Delegate to tuple encoding.
165            fidl::encoding::Encode::<TopologicalPathGetTopologicalPathResponse, D>::encode(
166                (<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(
167                    &self.path,
168                ),),
169                encoder,
170                offset,
171                _depth,
172            )
173        }
174    }
175    unsafe impl<
176            D: fidl::encoding::ResourceDialect,
177            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
178        > fidl::encoding::Encode<TopologicalPathGetTopologicalPathResponse, D> for (T0,)
179    {
180        #[inline]
181        unsafe fn encode(
182            self,
183            encoder: &mut fidl::encoding::Encoder<'_, D>,
184            offset: usize,
185            depth: fidl::encoding::Depth,
186        ) -> fidl::Result<()> {
187            encoder.debug_check_bounds::<TopologicalPathGetTopologicalPathResponse>(offset);
188            // Zero out padding regions. There's no need to apply masks
189            // because the unmasked parts will be overwritten by fields.
190            // Write the fields.
191            self.0.encode(encoder, offset + 0, depth)?;
192            Ok(())
193        }
194    }
195
196    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
197        for TopologicalPathGetTopologicalPathResponse
198    {
199        #[inline(always)]
200        fn new_empty() -> Self {
201            Self { path: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D) }
202        }
203
204        #[inline]
205        unsafe fn decode(
206            &mut self,
207            decoder: &mut fidl::encoding::Decoder<'_, D>,
208            offset: usize,
209            _depth: fidl::encoding::Depth,
210        ) -> fidl::Result<()> {
211            decoder.debug_check_bounds::<Self>(offset);
212            // Verify that padding bytes are zero.
213            fidl::decode!(
214                fidl::encoding::BoundedString<1024>,
215                D,
216                &mut self.path,
217                decoder,
218                offset + 0,
219                _depth
220            )?;
221            Ok(())
222        }
223    }
224}