Skip to main content

fidl_fuchsia_hardware_adb__common/
fidl_fuchsia_hardware_adb__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/// Max length of arguments passed in adb OPEN message.
12pub const MAX_ARGS_LENGTH: u64 = 1024;
13
14bitflags! {
15    /// ADB USB interface status flags.
16    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
17    pub struct StatusFlags: u32 {
18        const ONLINE = 1;
19    }
20}
21
22impl StatusFlags {
23    #[inline(always)]
24    pub fn from_bits_allow_unknown(bits: u32) -> Self {
25        Self::from_bits_retain(bits)
26    }
27
28    #[inline(always)]
29    pub fn has_unknown_bits(&self) -> bool {
30        self.get_unknown_bits() != 0
31    }
32
33    #[inline(always)]
34    pub fn get_unknown_bits(&self) -> u32 {
35        self.bits() & !Self::all().bits()
36    }
37}
38
39/// Represents the device's system type sent during the ADB connection handshake (A_CNXN).
40/// This identifies the mode the device is currently operating in to the ADB host.
41///
42/// The connection string in ADB, sent during the A_CNXN handshake, is structured as
43/// `<systemtype>:<serialno>:<banner>`.
44/// -  `<systemtype>`: Identifies the device's mode and corresponds to the values in `SystemType`.
45/// -  `<serialno>`: The device's serial number. This field is commonly empty.
46/// -  `<banner>`: Contains metadata about the device, such as properties like product name, model,
47///    and supported features (e.g., "ro.product.name=...", "features=...").
48#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
49pub enum SystemType {
50    /// The device is in normal boot.
51    Device,
52    /// The device is in recovery.
53    Recovery,
54    /// The device is in recovery sideload mode.
55    Sideload,
56    /// The device is in recovery rescue mode.
57    Rescue,
58    /// The device is in bootloader.
59    Bootloader,
60    #[doc(hidden)]
61    __SourceBreaking { unknown_ordinal: u32 },
62}
63
64/// Pattern that matches an unknown `SystemType` member.
65#[macro_export]
66macro_rules! SystemTypeUnknown {
67    () => {
68        _
69    };
70}
71
72impl SystemType {
73    #[inline]
74    pub fn from_primitive(prim: u32) -> Option<Self> {
75        match prim {
76            1 => Some(Self::Device),
77            2 => Some(Self::Recovery),
78            3 => Some(Self::Sideload),
79            4 => Some(Self::Rescue),
80            5 => Some(Self::Bootloader),
81            _ => None,
82        }
83    }
84
85    #[inline]
86    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
87        match prim {
88            1 => Self::Device,
89            2 => Self::Recovery,
90            3 => Self::Sideload,
91            4 => Self::Rescue,
92            5 => Self::Bootloader,
93            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
94        }
95    }
96
97    #[inline]
98    pub fn unknown() -> Self {
99        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
100    }
101
102    #[inline]
103    pub const fn into_primitive(self) -> u32 {
104        match self {
105            Self::Device => 1,
106            Self::Recovery => 2,
107            Self::Sideload => 3,
108            Self::Rescue => 4,
109            Self::Bootloader => 5,
110            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
111        }
112    }
113
114    #[inline]
115    pub fn is_unknown(&self) -> bool {
116        match self {
117            Self::__SourceBreaking { unknown_ordinal: _ } => true,
118            _ => false,
119        }
120    }
121}
122
123#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
124pub struct StateControllerSetSystemTypeRequest {
125    pub system_type: SystemType,
126}
127
128impl fidl::Persistable for StateControllerSetSystemTypeRequest {}
129
130#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
131pub struct UsbAdbImplOnStatusChangedRequest {
132    pub status: StatusFlags,
133}
134
135impl fidl::Persistable for UsbAdbImplOnStatusChangedRequest {}
136
137#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
138pub struct UsbAdbImplQueueTxRequest {
139    pub data: Vec<u8>,
140}
141
142impl fidl::Persistable for UsbAdbImplQueueTxRequest {}
143
144#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
145pub struct UsbAdbImplReceiveResponse {
146    pub data: Vec<u8>,
147}
148
149impl fidl::Persistable for UsbAdbImplReceiveResponse {}
150
151pub mod device_ordinals {
152    pub const START_ADB: u64 = 0x286c2e31de2159a5;
153    pub const STOP_ADB: u64 = 0x6d7d1816750fd3d0;
154}
155
156pub mod provider_ordinals {
157    pub const CONNECT_TO_SERVICE: u64 = 0x303e4a312d85292b;
158}
159
160pub mod state_controller_ordinals {
161    pub const SET_SYSTEM_TYPE: u64 = 0xa40a1100522d82e;
162}
163
164pub mod usb_adb_impl__ordinals {
165    pub const QUEUE_TX: u64 = 0x4c0af0efa9701dc9;
166    pub const RECEIVE: u64 = 0x68382fff953be5c4;
167    pub const ON_STATUS_CHANGED: u64 = 0x2f2926086c0a5b6e;
168}
169
170mod internal {
171    use super::*;
172    unsafe impl fidl::encoding::TypeMarker for StatusFlags {
173        type Owned = Self;
174
175        #[inline(always)]
176        fn inline_align(_context: fidl::encoding::Context) -> usize {
177            4
178        }
179
180        #[inline(always)]
181        fn inline_size(_context: fidl::encoding::Context) -> usize {
182            4
183        }
184    }
185
186    impl fidl::encoding::ValueTypeMarker for StatusFlags {
187        type Borrowed<'a> = Self;
188        #[inline(always)]
189        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
190            *value
191        }
192    }
193
194    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for StatusFlags {
195        #[inline]
196        unsafe fn encode(
197            self,
198            encoder: &mut fidl::encoding::Encoder<'_, D>,
199            offset: usize,
200            _depth: fidl::encoding::Depth,
201        ) -> fidl::Result<()> {
202            encoder.debug_check_bounds::<Self>(offset);
203            encoder.write_num(self.bits(), offset);
204            Ok(())
205        }
206    }
207
208    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StatusFlags {
209        #[inline(always)]
210        fn new_empty() -> Self {
211            Self::empty()
212        }
213
214        #[inline]
215        unsafe fn decode(
216            &mut self,
217            decoder: &mut fidl::encoding::Decoder<'_, D>,
218            offset: usize,
219            _depth: fidl::encoding::Depth,
220        ) -> fidl::Result<()> {
221            decoder.debug_check_bounds::<Self>(offset);
222            let prim = decoder.read_num::<u32>(offset);
223            *self = Self::from_bits_allow_unknown(prim);
224            Ok(())
225        }
226    }
227    unsafe impl fidl::encoding::TypeMarker for SystemType {
228        type Owned = Self;
229
230        #[inline(always)]
231        fn inline_align(_context: fidl::encoding::Context) -> usize {
232            std::mem::align_of::<u32>()
233        }
234
235        #[inline(always)]
236        fn inline_size(_context: fidl::encoding::Context) -> usize {
237            std::mem::size_of::<u32>()
238        }
239
240        #[inline(always)]
241        fn encode_is_copy() -> bool {
242            false
243        }
244
245        #[inline(always)]
246        fn decode_is_copy() -> bool {
247            false
248        }
249    }
250
251    impl fidl::encoding::ValueTypeMarker for SystemType {
252        type Borrowed<'a> = Self;
253        #[inline(always)]
254        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
255            *value
256        }
257    }
258
259    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for SystemType {
260        #[inline]
261        unsafe fn encode(
262            self,
263            encoder: &mut fidl::encoding::Encoder<'_, D>,
264            offset: usize,
265            _depth: fidl::encoding::Depth,
266        ) -> fidl::Result<()> {
267            encoder.debug_check_bounds::<Self>(offset);
268            encoder.write_num(self.into_primitive(), offset);
269            Ok(())
270        }
271    }
272
273    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SystemType {
274        #[inline(always)]
275        fn new_empty() -> Self {
276            Self::unknown()
277        }
278
279        #[inline]
280        unsafe fn decode(
281            &mut self,
282            decoder: &mut fidl::encoding::Decoder<'_, D>,
283            offset: usize,
284            _depth: fidl::encoding::Depth,
285        ) -> fidl::Result<()> {
286            decoder.debug_check_bounds::<Self>(offset);
287            let prim = decoder.read_num::<u32>(offset);
288
289            *self = Self::from_primitive_allow_unknown(prim);
290            Ok(())
291        }
292    }
293
294    impl fidl::encoding::ValueTypeMarker for StateControllerSetSystemTypeRequest {
295        type Borrowed<'a> = &'a Self;
296        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
297            value
298        }
299    }
300
301    unsafe impl fidl::encoding::TypeMarker for StateControllerSetSystemTypeRequest {
302        type Owned = Self;
303
304        #[inline(always)]
305        fn inline_align(_context: fidl::encoding::Context) -> usize {
306            4
307        }
308
309        #[inline(always)]
310        fn inline_size(_context: fidl::encoding::Context) -> usize {
311            4
312        }
313    }
314
315    unsafe impl<D: fidl::encoding::ResourceDialect>
316        fidl::encoding::Encode<StateControllerSetSystemTypeRequest, D>
317        for &StateControllerSetSystemTypeRequest
318    {
319        #[inline]
320        unsafe fn encode(
321            self,
322            encoder: &mut fidl::encoding::Encoder<'_, D>,
323            offset: usize,
324            _depth: fidl::encoding::Depth,
325        ) -> fidl::Result<()> {
326            encoder.debug_check_bounds::<StateControllerSetSystemTypeRequest>(offset);
327            // Delegate to tuple encoding.
328            fidl::encoding::Encode::<StateControllerSetSystemTypeRequest, D>::encode(
329                (<SystemType as fidl::encoding::ValueTypeMarker>::borrow(&self.system_type),),
330                encoder,
331                offset,
332                _depth,
333            )
334        }
335    }
336    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<SystemType, D>>
337        fidl::encoding::Encode<StateControllerSetSystemTypeRequest, D> for (T0,)
338    {
339        #[inline]
340        unsafe fn encode(
341            self,
342            encoder: &mut fidl::encoding::Encoder<'_, D>,
343            offset: usize,
344            depth: fidl::encoding::Depth,
345        ) -> fidl::Result<()> {
346            encoder.debug_check_bounds::<StateControllerSetSystemTypeRequest>(offset);
347            // Zero out padding regions. There's no need to apply masks
348            // because the unmasked parts will be overwritten by fields.
349            // Write the fields.
350            self.0.encode(encoder, offset + 0, depth)?;
351            Ok(())
352        }
353    }
354
355    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
356        for StateControllerSetSystemTypeRequest
357    {
358        #[inline(always)]
359        fn new_empty() -> Self {
360            Self { system_type: fidl::new_empty!(SystemType, D) }
361        }
362
363        #[inline]
364        unsafe fn decode(
365            &mut self,
366            decoder: &mut fidl::encoding::Decoder<'_, D>,
367            offset: usize,
368            _depth: fidl::encoding::Depth,
369        ) -> fidl::Result<()> {
370            decoder.debug_check_bounds::<Self>(offset);
371            // Verify that padding bytes are zero.
372            fidl::decode!(SystemType, D, &mut self.system_type, decoder, offset + 0, _depth)?;
373            Ok(())
374        }
375    }
376
377    impl fidl::encoding::ValueTypeMarker for UsbAdbImplOnStatusChangedRequest {
378        type Borrowed<'a> = &'a Self;
379        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
380            value
381        }
382    }
383
384    unsafe impl fidl::encoding::TypeMarker for UsbAdbImplOnStatusChangedRequest {
385        type Owned = Self;
386
387        #[inline(always)]
388        fn inline_align(_context: fidl::encoding::Context) -> usize {
389            4
390        }
391
392        #[inline(always)]
393        fn inline_size(_context: fidl::encoding::Context) -> usize {
394            4
395        }
396    }
397
398    unsafe impl<D: fidl::encoding::ResourceDialect>
399        fidl::encoding::Encode<UsbAdbImplOnStatusChangedRequest, D>
400        for &UsbAdbImplOnStatusChangedRequest
401    {
402        #[inline]
403        unsafe fn encode(
404            self,
405            encoder: &mut fidl::encoding::Encoder<'_, D>,
406            offset: usize,
407            _depth: fidl::encoding::Depth,
408        ) -> fidl::Result<()> {
409            encoder.debug_check_bounds::<UsbAdbImplOnStatusChangedRequest>(offset);
410            // Delegate to tuple encoding.
411            fidl::encoding::Encode::<UsbAdbImplOnStatusChangedRequest, D>::encode(
412                (<StatusFlags as fidl::encoding::ValueTypeMarker>::borrow(&self.status),),
413                encoder,
414                offset,
415                _depth,
416            )
417        }
418    }
419    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<StatusFlags, D>>
420        fidl::encoding::Encode<UsbAdbImplOnStatusChangedRequest, D> for (T0,)
421    {
422        #[inline]
423        unsafe fn encode(
424            self,
425            encoder: &mut fidl::encoding::Encoder<'_, D>,
426            offset: usize,
427            depth: fidl::encoding::Depth,
428        ) -> fidl::Result<()> {
429            encoder.debug_check_bounds::<UsbAdbImplOnStatusChangedRequest>(offset);
430            // Zero out padding regions. There's no need to apply masks
431            // because the unmasked parts will be overwritten by fields.
432            // Write the fields.
433            self.0.encode(encoder, offset + 0, depth)?;
434            Ok(())
435        }
436    }
437
438    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
439        for UsbAdbImplOnStatusChangedRequest
440    {
441        #[inline(always)]
442        fn new_empty() -> Self {
443            Self { status: fidl::new_empty!(StatusFlags, D) }
444        }
445
446        #[inline]
447        unsafe fn decode(
448            &mut self,
449            decoder: &mut fidl::encoding::Decoder<'_, D>,
450            offset: usize,
451            _depth: fidl::encoding::Depth,
452        ) -> fidl::Result<()> {
453            decoder.debug_check_bounds::<Self>(offset);
454            // Verify that padding bytes are zero.
455            fidl::decode!(StatusFlags, D, &mut self.status, decoder, offset + 0, _depth)?;
456            Ok(())
457        }
458    }
459
460    impl fidl::encoding::ValueTypeMarker for UsbAdbImplQueueTxRequest {
461        type Borrowed<'a> = &'a Self;
462        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
463            value
464        }
465    }
466
467    unsafe impl fidl::encoding::TypeMarker for UsbAdbImplQueueTxRequest {
468        type Owned = Self;
469
470        #[inline(always)]
471        fn inline_align(_context: fidl::encoding::Context) -> usize {
472            8
473        }
474
475        #[inline(always)]
476        fn inline_size(_context: fidl::encoding::Context) -> usize {
477            16
478        }
479    }
480
481    unsafe impl<D: fidl::encoding::ResourceDialect>
482        fidl::encoding::Encode<UsbAdbImplQueueTxRequest, D> for &UsbAdbImplQueueTxRequest
483    {
484        #[inline]
485        unsafe fn encode(
486            self,
487            encoder: &mut fidl::encoding::Encoder<'_, D>,
488            offset: usize,
489            _depth: fidl::encoding::Depth,
490        ) -> fidl::Result<()> {
491            encoder.debug_check_bounds::<UsbAdbImplQueueTxRequest>(offset);
492            // Delegate to tuple encoding.
493            fidl::encoding::Encode::<UsbAdbImplQueueTxRequest, D>::encode(
494                (<fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(
495                    &self.data,
496                ),),
497                encoder,
498                offset,
499                _depth,
500            )
501        }
502    }
503    unsafe impl<
504        D: fidl::encoding::ResourceDialect,
505        T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
506    > fidl::encoding::Encode<UsbAdbImplQueueTxRequest, D> for (T0,)
507    {
508        #[inline]
509        unsafe fn encode(
510            self,
511            encoder: &mut fidl::encoding::Encoder<'_, D>,
512            offset: usize,
513            depth: fidl::encoding::Depth,
514        ) -> fidl::Result<()> {
515            encoder.debug_check_bounds::<UsbAdbImplQueueTxRequest>(offset);
516            // Zero out padding regions. There's no need to apply masks
517            // because the unmasked parts will be overwritten by fields.
518            // Write the fields.
519            self.0.encode(encoder, offset + 0, depth)?;
520            Ok(())
521        }
522    }
523
524    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
525        for UsbAdbImplQueueTxRequest
526    {
527        #[inline(always)]
528        fn new_empty() -> Self {
529            Self { data: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D) }
530        }
531
532        #[inline]
533        unsafe fn decode(
534            &mut self,
535            decoder: &mut fidl::encoding::Decoder<'_, D>,
536            offset: usize,
537            _depth: fidl::encoding::Depth,
538        ) -> fidl::Result<()> {
539            decoder.debug_check_bounds::<Self>(offset);
540            // Verify that padding bytes are zero.
541            fidl::decode!(
542                fidl::encoding::UnboundedVector<u8>,
543                D,
544                &mut self.data,
545                decoder,
546                offset + 0,
547                _depth
548            )?;
549            Ok(())
550        }
551    }
552
553    impl fidl::encoding::ValueTypeMarker for UsbAdbImplReceiveResponse {
554        type Borrowed<'a> = &'a Self;
555        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
556            value
557        }
558    }
559
560    unsafe impl fidl::encoding::TypeMarker for UsbAdbImplReceiveResponse {
561        type Owned = Self;
562
563        #[inline(always)]
564        fn inline_align(_context: fidl::encoding::Context) -> usize {
565            8
566        }
567
568        #[inline(always)]
569        fn inline_size(_context: fidl::encoding::Context) -> usize {
570            16
571        }
572    }
573
574    unsafe impl<D: fidl::encoding::ResourceDialect>
575        fidl::encoding::Encode<UsbAdbImplReceiveResponse, D> for &UsbAdbImplReceiveResponse
576    {
577        #[inline]
578        unsafe fn encode(
579            self,
580            encoder: &mut fidl::encoding::Encoder<'_, D>,
581            offset: usize,
582            _depth: fidl::encoding::Depth,
583        ) -> fidl::Result<()> {
584            encoder.debug_check_bounds::<UsbAdbImplReceiveResponse>(offset);
585            // Delegate to tuple encoding.
586            fidl::encoding::Encode::<UsbAdbImplReceiveResponse, D>::encode(
587                (<fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(
588                    &self.data,
589                ),),
590                encoder,
591                offset,
592                _depth,
593            )
594        }
595    }
596    unsafe impl<
597        D: fidl::encoding::ResourceDialect,
598        T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
599    > fidl::encoding::Encode<UsbAdbImplReceiveResponse, D> for (T0,)
600    {
601        #[inline]
602        unsafe fn encode(
603            self,
604            encoder: &mut fidl::encoding::Encoder<'_, D>,
605            offset: usize,
606            depth: fidl::encoding::Depth,
607        ) -> fidl::Result<()> {
608            encoder.debug_check_bounds::<UsbAdbImplReceiveResponse>(offset);
609            // Zero out padding regions. There's no need to apply masks
610            // because the unmasked parts will be overwritten by fields.
611            // Write the fields.
612            self.0.encode(encoder, offset + 0, depth)?;
613            Ok(())
614        }
615    }
616
617    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
618        for UsbAdbImplReceiveResponse
619    {
620        #[inline(always)]
621        fn new_empty() -> Self {
622            Self { data: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D) }
623        }
624
625        #[inline]
626        unsafe fn decode(
627            &mut self,
628            decoder: &mut fidl::encoding::Decoder<'_, D>,
629            offset: usize,
630            _depth: fidl::encoding::Depth,
631        ) -> fidl::Result<()> {
632            decoder.debug_check_bounds::<Self>(offset);
633            // Verify that padding bytes are zero.
634            fidl::decode!(
635                fidl::encoding::UnboundedVector<u8>,
636                D,
637                &mut self.data,
638                decoder,
639                offset + 0,
640                _depth
641            )?;
642            Ok(())
643        }
644    }
645}