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