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#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
40pub struct UsbAdbImplOnStatusChangedRequest {
41    pub status: StatusFlags,
42}
43
44impl fidl::Persistable for UsbAdbImplOnStatusChangedRequest {}
45
46#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
47pub struct UsbAdbImplQueueTxRequest {
48    pub data: Vec<u8>,
49}
50
51impl fidl::Persistable for UsbAdbImplQueueTxRequest {}
52
53#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
54pub struct UsbAdbImplReceiveResponse {
55    pub data: Vec<u8>,
56}
57
58impl fidl::Persistable for UsbAdbImplReceiveResponse {}
59
60mod internal {
61    use super::*;
62    unsafe impl fidl::encoding::TypeMarker for StatusFlags {
63        type Owned = Self;
64
65        #[inline(always)]
66        fn inline_align(_context: fidl::encoding::Context) -> usize {
67            4
68        }
69
70        #[inline(always)]
71        fn inline_size(_context: fidl::encoding::Context) -> usize {
72            4
73        }
74    }
75
76    impl fidl::encoding::ValueTypeMarker for StatusFlags {
77        type Borrowed<'a> = Self;
78        #[inline(always)]
79        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
80            *value
81        }
82    }
83
84    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for StatusFlags {
85        #[inline]
86        unsafe fn encode(
87            self,
88            encoder: &mut fidl::encoding::Encoder<'_, D>,
89            offset: usize,
90            _depth: fidl::encoding::Depth,
91        ) -> fidl::Result<()> {
92            encoder.debug_check_bounds::<Self>(offset);
93            encoder.write_num(self.bits(), offset);
94            Ok(())
95        }
96    }
97
98    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StatusFlags {
99        #[inline(always)]
100        fn new_empty() -> Self {
101            Self::empty()
102        }
103
104        #[inline]
105        unsafe fn decode(
106            &mut self,
107            decoder: &mut fidl::encoding::Decoder<'_, D>,
108            offset: usize,
109            _depth: fidl::encoding::Depth,
110        ) -> fidl::Result<()> {
111            decoder.debug_check_bounds::<Self>(offset);
112            let prim = decoder.read_num::<u32>(offset);
113            *self = Self::from_bits_allow_unknown(prim);
114            Ok(())
115        }
116    }
117
118    impl fidl::encoding::ValueTypeMarker for UsbAdbImplOnStatusChangedRequest {
119        type Borrowed<'a> = &'a Self;
120        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
121            value
122        }
123    }
124
125    unsafe impl fidl::encoding::TypeMarker for UsbAdbImplOnStatusChangedRequest {
126        type Owned = Self;
127
128        #[inline(always)]
129        fn inline_align(_context: fidl::encoding::Context) -> usize {
130            4
131        }
132
133        #[inline(always)]
134        fn inline_size(_context: fidl::encoding::Context) -> usize {
135            4
136        }
137    }
138
139    unsafe impl<D: fidl::encoding::ResourceDialect>
140        fidl::encoding::Encode<UsbAdbImplOnStatusChangedRequest, D>
141        for &UsbAdbImplOnStatusChangedRequest
142    {
143        #[inline]
144        unsafe fn encode(
145            self,
146            encoder: &mut fidl::encoding::Encoder<'_, D>,
147            offset: usize,
148            _depth: fidl::encoding::Depth,
149        ) -> fidl::Result<()> {
150            encoder.debug_check_bounds::<UsbAdbImplOnStatusChangedRequest>(offset);
151            // Delegate to tuple encoding.
152            fidl::encoding::Encode::<UsbAdbImplOnStatusChangedRequest, D>::encode(
153                (<StatusFlags as fidl::encoding::ValueTypeMarker>::borrow(&self.status),),
154                encoder,
155                offset,
156                _depth,
157            )
158        }
159    }
160    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<StatusFlags, D>>
161        fidl::encoding::Encode<UsbAdbImplOnStatusChangedRequest, D> for (T0,)
162    {
163        #[inline]
164        unsafe fn encode(
165            self,
166            encoder: &mut fidl::encoding::Encoder<'_, D>,
167            offset: usize,
168            depth: fidl::encoding::Depth,
169        ) -> fidl::Result<()> {
170            encoder.debug_check_bounds::<UsbAdbImplOnStatusChangedRequest>(offset);
171            // Zero out padding regions. There's no need to apply masks
172            // because the unmasked parts will be overwritten by fields.
173            // Write the fields.
174            self.0.encode(encoder, offset + 0, depth)?;
175            Ok(())
176        }
177    }
178
179    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
180        for UsbAdbImplOnStatusChangedRequest
181    {
182        #[inline(always)]
183        fn new_empty() -> Self {
184            Self { status: fidl::new_empty!(StatusFlags, D) }
185        }
186
187        #[inline]
188        unsafe fn decode(
189            &mut self,
190            decoder: &mut fidl::encoding::Decoder<'_, D>,
191            offset: usize,
192            _depth: fidl::encoding::Depth,
193        ) -> fidl::Result<()> {
194            decoder.debug_check_bounds::<Self>(offset);
195            // Verify that padding bytes are zero.
196            fidl::decode!(StatusFlags, D, &mut self.status, decoder, offset + 0, _depth)?;
197            Ok(())
198        }
199    }
200
201    impl fidl::encoding::ValueTypeMarker for UsbAdbImplQueueTxRequest {
202        type Borrowed<'a> = &'a Self;
203        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
204            value
205        }
206    }
207
208    unsafe impl fidl::encoding::TypeMarker for UsbAdbImplQueueTxRequest {
209        type Owned = Self;
210
211        #[inline(always)]
212        fn inline_align(_context: fidl::encoding::Context) -> usize {
213            8
214        }
215
216        #[inline(always)]
217        fn inline_size(_context: fidl::encoding::Context) -> usize {
218            16
219        }
220    }
221
222    unsafe impl<D: fidl::encoding::ResourceDialect>
223        fidl::encoding::Encode<UsbAdbImplQueueTxRequest, D> for &UsbAdbImplQueueTxRequest
224    {
225        #[inline]
226        unsafe fn encode(
227            self,
228            encoder: &mut fidl::encoding::Encoder<'_, D>,
229            offset: usize,
230            _depth: fidl::encoding::Depth,
231        ) -> fidl::Result<()> {
232            encoder.debug_check_bounds::<UsbAdbImplQueueTxRequest>(offset);
233            // Delegate to tuple encoding.
234            fidl::encoding::Encode::<UsbAdbImplQueueTxRequest, D>::encode(
235                (<fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(
236                    &self.data,
237                ),),
238                encoder,
239                offset,
240                _depth,
241            )
242        }
243    }
244    unsafe impl<
245            D: fidl::encoding::ResourceDialect,
246            T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
247        > fidl::encoding::Encode<UsbAdbImplQueueTxRequest, D> for (T0,)
248    {
249        #[inline]
250        unsafe fn encode(
251            self,
252            encoder: &mut fidl::encoding::Encoder<'_, D>,
253            offset: usize,
254            depth: fidl::encoding::Depth,
255        ) -> fidl::Result<()> {
256            encoder.debug_check_bounds::<UsbAdbImplQueueTxRequest>(offset);
257            // Zero out padding regions. There's no need to apply masks
258            // because the unmasked parts will be overwritten by fields.
259            // Write the fields.
260            self.0.encode(encoder, offset + 0, depth)?;
261            Ok(())
262        }
263    }
264
265    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
266        for UsbAdbImplQueueTxRequest
267    {
268        #[inline(always)]
269        fn new_empty() -> Self {
270            Self { data: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D) }
271        }
272
273        #[inline]
274        unsafe fn decode(
275            &mut self,
276            decoder: &mut fidl::encoding::Decoder<'_, D>,
277            offset: usize,
278            _depth: fidl::encoding::Depth,
279        ) -> fidl::Result<()> {
280            decoder.debug_check_bounds::<Self>(offset);
281            // Verify that padding bytes are zero.
282            fidl::decode!(
283                fidl::encoding::UnboundedVector<u8>,
284                D,
285                &mut self.data,
286                decoder,
287                offset + 0,
288                _depth
289            )?;
290            Ok(())
291        }
292    }
293
294    impl fidl::encoding::ValueTypeMarker for UsbAdbImplReceiveResponse {
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 UsbAdbImplReceiveResponse {
302        type Owned = Self;
303
304        #[inline(always)]
305        fn inline_align(_context: fidl::encoding::Context) -> usize {
306            8
307        }
308
309        #[inline(always)]
310        fn inline_size(_context: fidl::encoding::Context) -> usize {
311            16
312        }
313    }
314
315    unsafe impl<D: fidl::encoding::ResourceDialect>
316        fidl::encoding::Encode<UsbAdbImplReceiveResponse, D> for &UsbAdbImplReceiveResponse
317    {
318        #[inline]
319        unsafe fn encode(
320            self,
321            encoder: &mut fidl::encoding::Encoder<'_, D>,
322            offset: usize,
323            _depth: fidl::encoding::Depth,
324        ) -> fidl::Result<()> {
325            encoder.debug_check_bounds::<UsbAdbImplReceiveResponse>(offset);
326            // Delegate to tuple encoding.
327            fidl::encoding::Encode::<UsbAdbImplReceiveResponse, D>::encode(
328                (<fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(
329                    &self.data,
330                ),),
331                encoder,
332                offset,
333                _depth,
334            )
335        }
336    }
337    unsafe impl<
338            D: fidl::encoding::ResourceDialect,
339            T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
340        > fidl::encoding::Encode<UsbAdbImplReceiveResponse, D> for (T0,)
341    {
342        #[inline]
343        unsafe fn encode(
344            self,
345            encoder: &mut fidl::encoding::Encoder<'_, D>,
346            offset: usize,
347            depth: fidl::encoding::Depth,
348        ) -> fidl::Result<()> {
349            encoder.debug_check_bounds::<UsbAdbImplReceiveResponse>(offset);
350            // Zero out padding regions. There's no need to apply masks
351            // because the unmasked parts will be overwritten by fields.
352            // Write the fields.
353            self.0.encode(encoder, offset + 0, depth)?;
354            Ok(())
355        }
356    }
357
358    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
359        for UsbAdbImplReceiveResponse
360    {
361        #[inline(always)]
362        fn new_empty() -> Self {
363            Self { data: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D) }
364        }
365
366        #[inline]
367        unsafe fn decode(
368            &mut self,
369            decoder: &mut fidl::encoding::Decoder<'_, D>,
370            offset: usize,
371            _depth: fidl::encoding::Depth,
372        ) -> fidl::Result<()> {
373            decoder.debug_check_bounds::<Self>(offset);
374            // Verify that padding bytes are zero.
375            fidl::decode!(
376                fidl::encoding::UnboundedVector<u8>,
377                D,
378                &mut self.data,
379                decoder,
380                offset + 0,
381                _depth
382            )?;
383            Ok(())
384        }
385    }
386}