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
75pub mod controller_ordinals {
76    pub const CONNECT_TO_DEVICE_FIDL: u64 = 0x793c584be7211f0d;
77    pub const CONNECT_TO_CONTROLLER: u64 = 0x66774decb0c7a0d0;
78    pub const BIND: u64 = 0x3388f12801462769;
79    pub const REBIND: u64 = 0x384fb80cbc2782e2;
80    pub const UNBIND_CHILDREN: u64 = 0x31fae8d74db7a426;
81    pub const SCHEDULE_UNBIND: u64 = 0x6128ba9d76aff9c;
82    pub const GET_TOPOLOGICAL_PATH: u64 = 0x2689b37663e00788;
83}
84
85pub mod name_provider_ordinals {
86    pub const GET_DEVICE_NAME: u64 = 0x6030de8d2052b2ce;
87}
88
89mod internal {
90    use super::*;
91    unsafe impl fidl::encoding::TypeMarker for DeviceSignal {
92        type Owned = Self;
93
94        #[inline(always)]
95        fn inline_align(_context: fidl::encoding::Context) -> usize {
96            4
97        }
98
99        #[inline(always)]
100        fn inline_size(_context: fidl::encoding::Context) -> usize {
101            4
102        }
103    }
104
105    impl fidl::encoding::ValueTypeMarker for DeviceSignal {
106        type Borrowed<'a> = Self;
107        #[inline(always)]
108        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
109            *value
110        }
111    }
112
113    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for DeviceSignal {
114        #[inline]
115        unsafe fn encode(
116            self,
117            encoder: &mut fidl::encoding::Encoder<'_, D>,
118            offset: usize,
119            _depth: fidl::encoding::Depth,
120        ) -> fidl::Result<()> {
121            encoder.debug_check_bounds::<Self>(offset);
122            if self.bits() & Self::all().bits() != self.bits() {
123                return Err(fidl::Error::InvalidBitsValue);
124            }
125            encoder.write_num(self.bits(), offset);
126            Ok(())
127        }
128    }
129
130    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceSignal {
131        #[inline(always)]
132        fn new_empty() -> Self {
133            Self::empty()
134        }
135
136        #[inline]
137        unsafe fn decode(
138            &mut self,
139            decoder: &mut fidl::encoding::Decoder<'_, D>,
140            offset: usize,
141            _depth: fidl::encoding::Depth,
142        ) -> fidl::Result<()> {
143            decoder.debug_check_bounds::<Self>(offset);
144            let prim = decoder.read_num::<u32>(offset);
145            *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
146            Ok(())
147        }
148    }
149
150    impl fidl::encoding::ValueTypeMarker for ControllerBindRequest {
151        type Borrowed<'a> = &'a Self;
152        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
153            value
154        }
155    }
156
157    unsafe impl fidl::encoding::TypeMarker for ControllerBindRequest {
158        type Owned = Self;
159
160        #[inline(always)]
161        fn inline_align(_context: fidl::encoding::Context) -> usize {
162            8
163        }
164
165        #[inline(always)]
166        fn inline_size(_context: fidl::encoding::Context) -> usize {
167            16
168        }
169    }
170
171    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ControllerBindRequest, D>
172        for &ControllerBindRequest
173    {
174        #[inline]
175        unsafe fn encode(
176            self,
177            encoder: &mut fidl::encoding::Encoder<'_, D>,
178            offset: usize,
179            _depth: fidl::encoding::Depth,
180        ) -> fidl::Result<()> {
181            encoder.debug_check_bounds::<ControllerBindRequest>(offset);
182            // Delegate to tuple encoding.
183            fidl::encoding::Encode::<ControllerBindRequest, D>::encode(
184                (<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(
185                    &self.driver,
186                ),),
187                encoder,
188                offset,
189                _depth,
190            )
191        }
192    }
193    unsafe impl<
194            D: fidl::encoding::ResourceDialect,
195            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
196        > fidl::encoding::Encode<ControllerBindRequest, D> for (T0,)
197    {
198        #[inline]
199        unsafe fn encode(
200            self,
201            encoder: &mut fidl::encoding::Encoder<'_, D>,
202            offset: usize,
203            depth: fidl::encoding::Depth,
204        ) -> fidl::Result<()> {
205            encoder.debug_check_bounds::<ControllerBindRequest>(offset);
206            // Zero out padding regions. There's no need to apply masks
207            // because the unmasked parts will be overwritten by fields.
208            // Write the fields.
209            self.0.encode(encoder, offset + 0, depth)?;
210            Ok(())
211        }
212    }
213
214    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ControllerBindRequest {
215        #[inline(always)]
216        fn new_empty() -> Self {
217            Self { driver: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D) }
218        }
219
220        #[inline]
221        unsafe fn decode(
222            &mut self,
223            decoder: &mut fidl::encoding::Decoder<'_, D>,
224            offset: usize,
225            _depth: fidl::encoding::Depth,
226        ) -> fidl::Result<()> {
227            decoder.debug_check_bounds::<Self>(offset);
228            // Verify that padding bytes are zero.
229            fidl::decode!(
230                fidl::encoding::BoundedString<1024>,
231                D,
232                &mut self.driver,
233                decoder,
234                offset + 0,
235                _depth
236            )?;
237            Ok(())
238        }
239    }
240
241    impl fidl::encoding::ValueTypeMarker for ControllerRebindRequest {
242        type Borrowed<'a> = &'a Self;
243        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
244            value
245        }
246    }
247
248    unsafe impl fidl::encoding::TypeMarker for ControllerRebindRequest {
249        type Owned = Self;
250
251        #[inline(always)]
252        fn inline_align(_context: fidl::encoding::Context) -> usize {
253            8
254        }
255
256        #[inline(always)]
257        fn inline_size(_context: fidl::encoding::Context) -> usize {
258            16
259        }
260    }
261
262    unsafe impl<D: fidl::encoding::ResourceDialect>
263        fidl::encoding::Encode<ControllerRebindRequest, D> for &ControllerRebindRequest
264    {
265        #[inline]
266        unsafe fn encode(
267            self,
268            encoder: &mut fidl::encoding::Encoder<'_, D>,
269            offset: usize,
270            _depth: fidl::encoding::Depth,
271        ) -> fidl::Result<()> {
272            encoder.debug_check_bounds::<ControllerRebindRequest>(offset);
273            // Delegate to tuple encoding.
274            fidl::encoding::Encode::<ControllerRebindRequest, D>::encode(
275                (<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(
276                    &self.driver,
277                ),),
278                encoder,
279                offset,
280                _depth,
281            )
282        }
283    }
284    unsafe impl<
285            D: fidl::encoding::ResourceDialect,
286            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
287        > fidl::encoding::Encode<ControllerRebindRequest, D> for (T0,)
288    {
289        #[inline]
290        unsafe fn encode(
291            self,
292            encoder: &mut fidl::encoding::Encoder<'_, D>,
293            offset: usize,
294            depth: fidl::encoding::Depth,
295        ) -> fidl::Result<()> {
296            encoder.debug_check_bounds::<ControllerRebindRequest>(offset);
297            // Zero out padding regions. There's no need to apply masks
298            // because the unmasked parts will be overwritten by fields.
299            // Write the fields.
300            self.0.encode(encoder, offset + 0, depth)?;
301            Ok(())
302        }
303    }
304
305    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
306        for ControllerRebindRequest
307    {
308        #[inline(always)]
309        fn new_empty() -> Self {
310            Self { driver: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D) }
311        }
312
313        #[inline]
314        unsafe fn decode(
315            &mut self,
316            decoder: &mut fidl::encoding::Decoder<'_, D>,
317            offset: usize,
318            _depth: fidl::encoding::Depth,
319        ) -> fidl::Result<()> {
320            decoder.debug_check_bounds::<Self>(offset);
321            // Verify that padding bytes are zero.
322            fidl::decode!(
323                fidl::encoding::BoundedString<1024>,
324                D,
325                &mut self.driver,
326                decoder,
327                offset + 0,
328                _depth
329            )?;
330            Ok(())
331        }
332    }
333
334    impl fidl::encoding::ValueTypeMarker for ControllerGetTopologicalPathResponse {
335        type Borrowed<'a> = &'a Self;
336        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
337            value
338        }
339    }
340
341    unsafe impl fidl::encoding::TypeMarker for ControllerGetTopologicalPathResponse {
342        type Owned = Self;
343
344        #[inline(always)]
345        fn inline_align(_context: fidl::encoding::Context) -> usize {
346            8
347        }
348
349        #[inline(always)]
350        fn inline_size(_context: fidl::encoding::Context) -> usize {
351            16
352        }
353    }
354
355    unsafe impl<D: fidl::encoding::ResourceDialect>
356        fidl::encoding::Encode<ControllerGetTopologicalPathResponse, D>
357        for &ControllerGetTopologicalPathResponse
358    {
359        #[inline]
360        unsafe fn encode(
361            self,
362            encoder: &mut fidl::encoding::Encoder<'_, D>,
363            offset: usize,
364            _depth: fidl::encoding::Depth,
365        ) -> fidl::Result<()> {
366            encoder.debug_check_bounds::<ControllerGetTopologicalPathResponse>(offset);
367            // Delegate to tuple encoding.
368            fidl::encoding::Encode::<ControllerGetTopologicalPathResponse, D>::encode(
369                (<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(
370                    &self.path,
371                ),),
372                encoder,
373                offset,
374                _depth,
375            )
376        }
377    }
378    unsafe impl<
379            D: fidl::encoding::ResourceDialect,
380            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
381        > fidl::encoding::Encode<ControllerGetTopologicalPathResponse, D> for (T0,)
382    {
383        #[inline]
384        unsafe fn encode(
385            self,
386            encoder: &mut fidl::encoding::Encoder<'_, D>,
387            offset: usize,
388            depth: fidl::encoding::Depth,
389        ) -> fidl::Result<()> {
390            encoder.debug_check_bounds::<ControllerGetTopologicalPathResponse>(offset);
391            // Zero out padding regions. There's no need to apply masks
392            // because the unmasked parts will be overwritten by fields.
393            // Write the fields.
394            self.0.encode(encoder, offset + 0, depth)?;
395            Ok(())
396        }
397    }
398
399    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
400        for ControllerGetTopologicalPathResponse
401    {
402        #[inline(always)]
403        fn new_empty() -> Self {
404            Self { path: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D) }
405        }
406
407        #[inline]
408        unsafe fn decode(
409            &mut self,
410            decoder: &mut fidl::encoding::Decoder<'_, D>,
411            offset: usize,
412            _depth: fidl::encoding::Depth,
413        ) -> fidl::Result<()> {
414            decoder.debug_check_bounds::<Self>(offset);
415            // Verify that padding bytes are zero.
416            fidl::decode!(
417                fidl::encoding::BoundedString<1024>,
418                D,
419                &mut self.path,
420                decoder,
421                offset + 0,
422                _depth
423            )?;
424            Ok(())
425        }
426    }
427
428    impl fidl::encoding::ValueTypeMarker for NameProviderGetDeviceNameResponse {
429        type Borrowed<'a> = &'a Self;
430        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
431            value
432        }
433    }
434
435    unsafe impl fidl::encoding::TypeMarker for NameProviderGetDeviceNameResponse {
436        type Owned = Self;
437
438        #[inline(always)]
439        fn inline_align(_context: fidl::encoding::Context) -> usize {
440            8
441        }
442
443        #[inline(always)]
444        fn inline_size(_context: fidl::encoding::Context) -> usize {
445            16
446        }
447    }
448
449    unsafe impl<D: fidl::encoding::ResourceDialect>
450        fidl::encoding::Encode<NameProviderGetDeviceNameResponse, D>
451        for &NameProviderGetDeviceNameResponse
452    {
453        #[inline]
454        unsafe fn encode(
455            self,
456            encoder: &mut fidl::encoding::Encoder<'_, D>,
457            offset: usize,
458            _depth: fidl::encoding::Depth,
459        ) -> fidl::Result<()> {
460            encoder.debug_check_bounds::<NameProviderGetDeviceNameResponse>(offset);
461            // Delegate to tuple encoding.
462            fidl::encoding::Encode::<NameProviderGetDeviceNameResponse, D>::encode(
463                (<fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
464                    &self.name,
465                ),),
466                encoder,
467                offset,
468                _depth,
469            )
470        }
471    }
472    unsafe impl<
473            D: fidl::encoding::ResourceDialect,
474            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<255>, D>,
475        > fidl::encoding::Encode<NameProviderGetDeviceNameResponse, D> for (T0,)
476    {
477        #[inline]
478        unsafe fn encode(
479            self,
480            encoder: &mut fidl::encoding::Encoder<'_, D>,
481            offset: usize,
482            depth: fidl::encoding::Depth,
483        ) -> fidl::Result<()> {
484            encoder.debug_check_bounds::<NameProviderGetDeviceNameResponse>(offset);
485            // Zero out padding regions. There's no need to apply masks
486            // because the unmasked parts will be overwritten by fields.
487            // Write the fields.
488            self.0.encode(encoder, offset + 0, depth)?;
489            Ok(())
490        }
491    }
492
493    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
494        for NameProviderGetDeviceNameResponse
495    {
496        #[inline(always)]
497        fn new_empty() -> Self {
498            Self { name: fidl::new_empty!(fidl::encoding::BoundedString<255>, D) }
499        }
500
501        #[inline]
502        unsafe fn decode(
503            &mut self,
504            decoder: &mut fidl::encoding::Decoder<'_, D>,
505            offset: usize,
506            _depth: fidl::encoding::Depth,
507        ) -> fidl::Result<()> {
508            decoder.debug_check_bounds::<Self>(offset);
509            // Verify that padding bytes are zero.
510            fidl::decode!(
511                fidl::encoding::BoundedString<255>,
512                D,
513                &mut self.name,
514                decoder,
515                offset + 0,
516                _depth
517            )?;
518            Ok(())
519        }
520    }
521}