fidl_fuchsia_device_common/
fidl_fuchsia_device_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 DEFAULT_DEVICE_NAME: &str = "fuchsia";
12
13/// Maximum length of a device name (without a null byte), based on
14/// HOST_NAME_MAX as defined by <limits.h>.
15pub const DEVICE_NAME_MAX: u32 = 255;
16
17/// Maxmium length for a device name
18pub const MAX_DEVICE_NAME_LEN: u64 = 32;
19
20/// Maximum length of a device path
21pub const MAX_DEVICE_PATH_LEN: u64 = 1024;
22
23/// Maxmium length for a driver name
24pub const MAX_DRIVER_NAME_LEN: u64 = 32;
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 DeviceSignal: u32 {
32        /// Indicates the device is ready for reading.
33        const READABLE = 16777216;
34        /// Indicates an out-of-band state transition has occurred.
35        const OOB = 33554432;
36        /// Indicates the device is ready for writing.
37        const WRITABLE = 67108864;
38        /// Indicates the device has encountered an error state.
39        const ERROR = 134217728;
40        /// Indicates the device has hung up on the current connection.
41        const HANGUP = 268435456;
42    }
43}
44
45impl DeviceSignal {}
46
47#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
48pub struct ControllerBindRequest {
49    pub driver: String,
50}
51
52impl fidl::Persistable for ControllerBindRequest {}
53
54#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
55pub struct ControllerRebindRequest {
56    pub driver: String,
57}
58
59impl fidl::Persistable for ControllerRebindRequest {}
60
61#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
62pub struct ControllerGetTopologicalPathResponse {
63    pub path: String,
64}
65
66impl fidl::Persistable for ControllerGetTopologicalPathResponse {}
67
68#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
69pub struct NameProviderGetDeviceNameResponse {
70    pub name: String,
71}
72
73impl fidl::Persistable for NameProviderGetDeviceNameResponse {}
74
75mod internal {
76    use super::*;
77    unsafe impl fidl::encoding::TypeMarker for DeviceSignal {
78        type Owned = Self;
79
80        #[inline(always)]
81        fn inline_align(_context: fidl::encoding::Context) -> usize {
82            4
83        }
84
85        #[inline(always)]
86        fn inline_size(_context: fidl::encoding::Context) -> usize {
87            4
88        }
89    }
90
91    impl fidl::encoding::ValueTypeMarker for DeviceSignal {
92        type Borrowed<'a> = Self;
93        #[inline(always)]
94        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
95            *value
96        }
97    }
98
99    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for DeviceSignal {
100        #[inline]
101        unsafe fn encode(
102            self,
103            encoder: &mut fidl::encoding::Encoder<'_, D>,
104            offset: usize,
105            _depth: fidl::encoding::Depth,
106        ) -> fidl::Result<()> {
107            encoder.debug_check_bounds::<Self>(offset);
108            if self.bits() & Self::all().bits() != self.bits() {
109                return Err(fidl::Error::InvalidBitsValue);
110            }
111            encoder.write_num(self.bits(), offset);
112            Ok(())
113        }
114    }
115
116    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceSignal {
117        #[inline(always)]
118        fn new_empty() -> Self {
119            Self::empty()
120        }
121
122        #[inline]
123        unsafe fn decode(
124            &mut self,
125            decoder: &mut fidl::encoding::Decoder<'_, D>,
126            offset: usize,
127            _depth: fidl::encoding::Depth,
128        ) -> fidl::Result<()> {
129            decoder.debug_check_bounds::<Self>(offset);
130            let prim = decoder.read_num::<u32>(offset);
131            *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
132            Ok(())
133        }
134    }
135
136    impl fidl::encoding::ValueTypeMarker for ControllerBindRequest {
137        type Borrowed<'a> = &'a Self;
138        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
139            value
140        }
141    }
142
143    unsafe impl fidl::encoding::TypeMarker for ControllerBindRequest {
144        type Owned = Self;
145
146        #[inline(always)]
147        fn inline_align(_context: fidl::encoding::Context) -> usize {
148            8
149        }
150
151        #[inline(always)]
152        fn inline_size(_context: fidl::encoding::Context) -> usize {
153            16
154        }
155    }
156
157    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ControllerBindRequest, D>
158        for &ControllerBindRequest
159    {
160        #[inline]
161        unsafe fn encode(
162            self,
163            encoder: &mut fidl::encoding::Encoder<'_, D>,
164            offset: usize,
165            _depth: fidl::encoding::Depth,
166        ) -> fidl::Result<()> {
167            encoder.debug_check_bounds::<ControllerBindRequest>(offset);
168            // Delegate to tuple encoding.
169            fidl::encoding::Encode::<ControllerBindRequest, D>::encode(
170                (<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(
171                    &self.driver,
172                ),),
173                encoder,
174                offset,
175                _depth,
176            )
177        }
178    }
179    unsafe impl<
180            D: fidl::encoding::ResourceDialect,
181            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
182        > fidl::encoding::Encode<ControllerBindRequest, D> for (T0,)
183    {
184        #[inline]
185        unsafe fn encode(
186            self,
187            encoder: &mut fidl::encoding::Encoder<'_, D>,
188            offset: usize,
189            depth: fidl::encoding::Depth,
190        ) -> fidl::Result<()> {
191            encoder.debug_check_bounds::<ControllerBindRequest>(offset);
192            // Zero out padding regions. There's no need to apply masks
193            // because the unmasked parts will be overwritten by fields.
194            // Write the fields.
195            self.0.encode(encoder, offset + 0, depth)?;
196            Ok(())
197        }
198    }
199
200    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ControllerBindRequest {
201        #[inline(always)]
202        fn new_empty() -> Self {
203            Self { driver: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D) }
204        }
205
206        #[inline]
207        unsafe fn decode(
208            &mut self,
209            decoder: &mut fidl::encoding::Decoder<'_, D>,
210            offset: usize,
211            _depth: fidl::encoding::Depth,
212        ) -> fidl::Result<()> {
213            decoder.debug_check_bounds::<Self>(offset);
214            // Verify that padding bytes are zero.
215            fidl::decode!(
216                fidl::encoding::BoundedString<1024>,
217                D,
218                &mut self.driver,
219                decoder,
220                offset + 0,
221                _depth
222            )?;
223            Ok(())
224        }
225    }
226
227    impl fidl::encoding::ValueTypeMarker for ControllerRebindRequest {
228        type Borrowed<'a> = &'a Self;
229        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
230            value
231        }
232    }
233
234    unsafe impl fidl::encoding::TypeMarker for ControllerRebindRequest {
235        type Owned = Self;
236
237        #[inline(always)]
238        fn inline_align(_context: fidl::encoding::Context) -> usize {
239            8
240        }
241
242        #[inline(always)]
243        fn inline_size(_context: fidl::encoding::Context) -> usize {
244            16
245        }
246    }
247
248    unsafe impl<D: fidl::encoding::ResourceDialect>
249        fidl::encoding::Encode<ControllerRebindRequest, D> for &ControllerRebindRequest
250    {
251        #[inline]
252        unsafe fn encode(
253            self,
254            encoder: &mut fidl::encoding::Encoder<'_, D>,
255            offset: usize,
256            _depth: fidl::encoding::Depth,
257        ) -> fidl::Result<()> {
258            encoder.debug_check_bounds::<ControllerRebindRequest>(offset);
259            // Delegate to tuple encoding.
260            fidl::encoding::Encode::<ControllerRebindRequest, D>::encode(
261                (<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(
262                    &self.driver,
263                ),),
264                encoder,
265                offset,
266                _depth,
267            )
268        }
269    }
270    unsafe impl<
271            D: fidl::encoding::ResourceDialect,
272            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
273        > fidl::encoding::Encode<ControllerRebindRequest, D> for (T0,)
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::<ControllerRebindRequest>(offset);
283            // Zero out padding regions. There's no need to apply masks
284            // because the unmasked parts will be overwritten by fields.
285            // Write the fields.
286            self.0.encode(encoder, offset + 0, depth)?;
287            Ok(())
288        }
289    }
290
291    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
292        for ControllerRebindRequest
293    {
294        #[inline(always)]
295        fn new_empty() -> Self {
296            Self { driver: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D) }
297        }
298
299        #[inline]
300        unsafe fn decode(
301            &mut self,
302            decoder: &mut fidl::encoding::Decoder<'_, D>,
303            offset: usize,
304            _depth: fidl::encoding::Depth,
305        ) -> fidl::Result<()> {
306            decoder.debug_check_bounds::<Self>(offset);
307            // Verify that padding bytes are zero.
308            fidl::decode!(
309                fidl::encoding::BoundedString<1024>,
310                D,
311                &mut self.driver,
312                decoder,
313                offset + 0,
314                _depth
315            )?;
316            Ok(())
317        }
318    }
319
320    impl fidl::encoding::ValueTypeMarker for ControllerGetTopologicalPathResponse {
321        type Borrowed<'a> = &'a Self;
322        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
323            value
324        }
325    }
326
327    unsafe impl fidl::encoding::TypeMarker for ControllerGetTopologicalPathResponse {
328        type Owned = Self;
329
330        #[inline(always)]
331        fn inline_align(_context: fidl::encoding::Context) -> usize {
332            8
333        }
334
335        #[inline(always)]
336        fn inline_size(_context: fidl::encoding::Context) -> usize {
337            16
338        }
339    }
340
341    unsafe impl<D: fidl::encoding::ResourceDialect>
342        fidl::encoding::Encode<ControllerGetTopologicalPathResponse, D>
343        for &ControllerGetTopologicalPathResponse
344    {
345        #[inline]
346        unsafe fn encode(
347            self,
348            encoder: &mut fidl::encoding::Encoder<'_, D>,
349            offset: usize,
350            _depth: fidl::encoding::Depth,
351        ) -> fidl::Result<()> {
352            encoder.debug_check_bounds::<ControllerGetTopologicalPathResponse>(offset);
353            // Delegate to tuple encoding.
354            fidl::encoding::Encode::<ControllerGetTopologicalPathResponse, D>::encode(
355                (<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(
356                    &self.path,
357                ),),
358                encoder,
359                offset,
360                _depth,
361            )
362        }
363    }
364    unsafe impl<
365            D: fidl::encoding::ResourceDialect,
366            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
367        > fidl::encoding::Encode<ControllerGetTopologicalPathResponse, D> for (T0,)
368    {
369        #[inline]
370        unsafe fn encode(
371            self,
372            encoder: &mut fidl::encoding::Encoder<'_, D>,
373            offset: usize,
374            depth: fidl::encoding::Depth,
375        ) -> fidl::Result<()> {
376            encoder.debug_check_bounds::<ControllerGetTopologicalPathResponse>(offset);
377            // Zero out padding regions. There's no need to apply masks
378            // because the unmasked parts will be overwritten by fields.
379            // Write the fields.
380            self.0.encode(encoder, offset + 0, depth)?;
381            Ok(())
382        }
383    }
384
385    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
386        for ControllerGetTopologicalPathResponse
387    {
388        #[inline(always)]
389        fn new_empty() -> Self {
390            Self { path: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D) }
391        }
392
393        #[inline]
394        unsafe fn decode(
395            &mut self,
396            decoder: &mut fidl::encoding::Decoder<'_, D>,
397            offset: usize,
398            _depth: fidl::encoding::Depth,
399        ) -> fidl::Result<()> {
400            decoder.debug_check_bounds::<Self>(offset);
401            // Verify that padding bytes are zero.
402            fidl::decode!(
403                fidl::encoding::BoundedString<1024>,
404                D,
405                &mut self.path,
406                decoder,
407                offset + 0,
408                _depth
409            )?;
410            Ok(())
411        }
412    }
413
414    impl fidl::encoding::ValueTypeMarker for NameProviderGetDeviceNameResponse {
415        type Borrowed<'a> = &'a Self;
416        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
417            value
418        }
419    }
420
421    unsafe impl fidl::encoding::TypeMarker for NameProviderGetDeviceNameResponse {
422        type Owned = Self;
423
424        #[inline(always)]
425        fn inline_align(_context: fidl::encoding::Context) -> usize {
426            8
427        }
428
429        #[inline(always)]
430        fn inline_size(_context: fidl::encoding::Context) -> usize {
431            16
432        }
433    }
434
435    unsafe impl<D: fidl::encoding::ResourceDialect>
436        fidl::encoding::Encode<NameProviderGetDeviceNameResponse, D>
437        for &NameProviderGetDeviceNameResponse
438    {
439        #[inline]
440        unsafe fn encode(
441            self,
442            encoder: &mut fidl::encoding::Encoder<'_, D>,
443            offset: usize,
444            _depth: fidl::encoding::Depth,
445        ) -> fidl::Result<()> {
446            encoder.debug_check_bounds::<NameProviderGetDeviceNameResponse>(offset);
447            // Delegate to tuple encoding.
448            fidl::encoding::Encode::<NameProviderGetDeviceNameResponse, D>::encode(
449                (<fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
450                    &self.name,
451                ),),
452                encoder,
453                offset,
454                _depth,
455            )
456        }
457    }
458    unsafe impl<
459            D: fidl::encoding::ResourceDialect,
460            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<255>, D>,
461        > fidl::encoding::Encode<NameProviderGetDeviceNameResponse, D> for (T0,)
462    {
463        #[inline]
464        unsafe fn encode(
465            self,
466            encoder: &mut fidl::encoding::Encoder<'_, D>,
467            offset: usize,
468            depth: fidl::encoding::Depth,
469        ) -> fidl::Result<()> {
470            encoder.debug_check_bounds::<NameProviderGetDeviceNameResponse>(offset);
471            // Zero out padding regions. There's no need to apply masks
472            // because the unmasked parts will be overwritten by fields.
473            // Write the fields.
474            self.0.encode(encoder, offset + 0, depth)?;
475            Ok(())
476        }
477    }
478
479    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
480        for NameProviderGetDeviceNameResponse
481    {
482        #[inline(always)]
483        fn new_empty() -> Self {
484            Self { name: fidl::new_empty!(fidl::encoding::BoundedString<255>, D) }
485        }
486
487        #[inline]
488        unsafe fn decode(
489            &mut self,
490            decoder: &mut fidl::encoding::Decoder<'_, D>,
491            offset: usize,
492            _depth: fidl::encoding::Depth,
493        ) -> fidl::Result<()> {
494            decoder.debug_check_bounds::<Self>(offset);
495            // Verify that padding bytes are zero.
496            fidl::decode!(
497                fidl::encoding::BoundedString<255>,
498                D,
499                &mut self.name,
500                decoder,
501                offset + 0,
502                _depth
503            )?;
504            Ok(())
505        }
506    }
507}