fidl_fuchsia_lowpan_spinel__common/
fidl_fuchsia_lowpan_spinel__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 MAX_FRAME_SIZE: u32 = 4096;
12
13#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
14#[repr(i32)]
15pub enum Error {
16    /// An unspecified error has occurred. This error type should be
17    /// avoided unless the use of a more specific error would be misleading.
18    ///
19    /// If this error is emitted, it is expected that a more descriptive error
20    /// will be present in the logs.
21    ///
22    /// Run-time Remediation: Close and re-open the device and attempt to use it.
23    /// If the error persists, indicate trouble to a higher level and stop.
24    Unspecified = 1,
25    /// `SendFrame()` was called with a frame that was larger than what
26    /// `GetMaxFrameSize()` indicated to be the maximum frame size.
27    ///
28    /// Note that `MAX_FRAME_SIZE` indicates the largest frame size supported
29    /// by this protocol, whereas `GetMaxFrameSize()` returns the largest
30    /// frame size supported by the Device.
31    ///
32    /// This error typically indicates a bug or logic-error in the use of the
33    /// `fuchsia.lowpan.spinel::Device` protocol.
34    ///
35    /// This error is only emitted via `->OnError()`.
36    OutboundFrameTooLarge = 2,
37    /// The remote device tried to send us a frame that was too large.
38    ///
39    /// This error typically indicates either frame corruption or a
40    /// misconfiguration of some sort.
41    ///
42    /// Run-time Remediation: The device should be reset and re-initialized.
43    ///
44    /// This error is only emitted via `->OnError()`.
45    InboundFrameTooLarge = 3,
46    /// Garbage-bytes/corruption detected on inbound frame.
47    ///
48    /// This error typically indicates that the connection between
49    /// the host and the Spinel device is unreliable. This may be caused
50    /// by hardware problems or implementation bugs.
51    ///
52    /// Run-time Remediation: The device should be reset (by sending a
53    /// spinel reset frame or by closing and re-opening) and then
54    /// re-initialized.
55    ///
56    /// This error is only emitted via `->OnError()`.
57    InboundFrameCorrupt = 4,
58    /// An I/O error has occurred.
59    ///
60    /// When this error is encountered, the device automatically closes.
61    ///
62    /// Run-time Remediation: Re-open the device and attempt to use it. If
63    /// the error persists, indicate trouble to a higher level (for example,
64    /// presenting a UI message indicating a malfunction) and stop.
65    IoError = 5,
66    /// This operation cannot be performed while the Spinel device is closed.
67    ///
68    /// This error typically indicates a bug or logic-error in the use of the
69    /// `fuchsia.lowpan.spinel::Device` protocol.
70    ///
71    /// This error is only emitted via `->OnError()`.
72    Closed = 6,
73}
74
75impl Error {
76    #[inline]
77    pub fn from_primitive(prim: i32) -> Option<Self> {
78        match prim {
79            1 => Some(Self::Unspecified),
80            2 => Some(Self::OutboundFrameTooLarge),
81            3 => Some(Self::InboundFrameTooLarge),
82            4 => Some(Self::InboundFrameCorrupt),
83            5 => Some(Self::IoError),
84            6 => Some(Self::Closed),
85            _ => None,
86        }
87    }
88
89    #[inline]
90    pub const fn into_primitive(self) -> i32 {
91        self as i32
92    }
93}
94
95#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
96#[repr(C)]
97pub struct DeviceGetMaxFrameSizeResponse {
98    pub size: u32,
99}
100
101impl fidl::Persistable for DeviceGetMaxFrameSizeResponse {}
102
103#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
104pub struct DeviceOnErrorRequest {
105    pub error: Error,
106    pub did_close: bool,
107}
108
109impl fidl::Persistable for DeviceOnErrorRequest {}
110
111#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
112#[repr(C)]
113pub struct DeviceOnReadyForSendFramesRequest {
114    pub number_of_frames: u32,
115}
116
117impl fidl::Persistable for DeviceOnReadyForSendFramesRequest {}
118
119#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
120pub struct DeviceOnReceiveFrameRequest {
121    pub data: Vec<u8>,
122}
123
124impl fidl::Persistable for DeviceOnReceiveFrameRequest {}
125
126#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
127#[repr(C)]
128pub struct DeviceReadyToReceiveFramesRequest {
129    pub number_of_frames: u32,
130}
131
132impl fidl::Persistable for DeviceReadyToReceiveFramesRequest {}
133
134#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
135pub struct DeviceSendFrameRequest {
136    pub data: Vec<u8>,
137}
138
139impl fidl::Persistable for DeviceSendFrameRequest {}
140
141pub mod device_ordinals {
142    pub const OPEN: u64 = 0x508cecb73a776ef7;
143    pub const CLOSE: u64 = 0x621a0f31b867781a;
144    pub const GET_MAX_FRAME_SIZE: u64 = 0x1d2d652e8b06d463;
145    pub const SEND_FRAME: u64 = 0x634f2957b35c5944;
146    pub const READY_TO_RECEIVE_FRAMES: u64 = 0x3147df23fdd53b87;
147    pub const ON_READY_FOR_SEND_FRAMES: u64 = 0x2b1d5b28c5811b53;
148    pub const ON_RECEIVE_FRAME: u64 = 0x61937a45670aabb0;
149    pub const ON_ERROR: u64 = 0x4d20e65a9d2625e1;
150}
151
152pub mod device_setup_ordinals {
153    pub const SET_CHANNEL: u64 = 0x7f8e02c174ef02a5;
154}
155
156mod internal {
157    use super::*;
158    unsafe impl fidl::encoding::TypeMarker for Error {
159        type Owned = Self;
160
161        #[inline(always)]
162        fn inline_align(_context: fidl::encoding::Context) -> usize {
163            std::mem::align_of::<i32>()
164        }
165
166        #[inline(always)]
167        fn inline_size(_context: fidl::encoding::Context) -> usize {
168            std::mem::size_of::<i32>()
169        }
170
171        #[inline(always)]
172        fn encode_is_copy() -> bool {
173            true
174        }
175
176        #[inline(always)]
177        fn decode_is_copy() -> bool {
178            false
179        }
180    }
181
182    impl fidl::encoding::ValueTypeMarker for Error {
183        type Borrowed<'a> = Self;
184        #[inline(always)]
185        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
186            *value
187        }
188    }
189
190    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
191        #[inline]
192        unsafe fn encode(
193            self,
194            encoder: &mut fidl::encoding::Encoder<'_, D>,
195            offset: usize,
196            _depth: fidl::encoding::Depth,
197        ) -> fidl::Result<()> {
198            encoder.debug_check_bounds::<Self>(offset);
199            encoder.write_num(self.into_primitive(), offset);
200            Ok(())
201        }
202    }
203
204    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
205        #[inline(always)]
206        fn new_empty() -> Self {
207            Self::Unspecified
208        }
209
210        #[inline]
211        unsafe fn decode(
212            &mut self,
213            decoder: &mut fidl::encoding::Decoder<'_, D>,
214            offset: usize,
215            _depth: fidl::encoding::Depth,
216        ) -> fidl::Result<()> {
217            decoder.debug_check_bounds::<Self>(offset);
218            let prim = decoder.read_num::<i32>(offset);
219
220            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
221            Ok(())
222        }
223    }
224
225    impl fidl::encoding::ValueTypeMarker for DeviceGetMaxFrameSizeResponse {
226        type Borrowed<'a> = &'a Self;
227        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
228            value
229        }
230    }
231
232    unsafe impl fidl::encoding::TypeMarker for DeviceGetMaxFrameSizeResponse {
233        type Owned = Self;
234
235        #[inline(always)]
236        fn inline_align(_context: fidl::encoding::Context) -> usize {
237            4
238        }
239
240        #[inline(always)]
241        fn inline_size(_context: fidl::encoding::Context) -> usize {
242            4
243        }
244        #[inline(always)]
245        fn encode_is_copy() -> bool {
246            true
247        }
248
249        #[inline(always)]
250        fn decode_is_copy() -> bool {
251            true
252        }
253    }
254
255    unsafe impl<D: fidl::encoding::ResourceDialect>
256        fidl::encoding::Encode<DeviceGetMaxFrameSizeResponse, D>
257        for &DeviceGetMaxFrameSizeResponse
258    {
259        #[inline]
260        unsafe fn encode(
261            self,
262            encoder: &mut fidl::encoding::Encoder<'_, D>,
263            offset: usize,
264            _depth: fidl::encoding::Depth,
265        ) -> fidl::Result<()> {
266            encoder.debug_check_bounds::<DeviceGetMaxFrameSizeResponse>(offset);
267            unsafe {
268                // Copy the object into the buffer.
269                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
270                (buf_ptr as *mut DeviceGetMaxFrameSizeResponse)
271                    .write_unaligned((self as *const DeviceGetMaxFrameSizeResponse).read());
272                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
273                // done second because the memcpy will write garbage to these bytes.
274            }
275            Ok(())
276        }
277    }
278    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
279        fidl::encoding::Encode<DeviceGetMaxFrameSizeResponse, D> for (T0,)
280    {
281        #[inline]
282        unsafe fn encode(
283            self,
284            encoder: &mut fidl::encoding::Encoder<'_, D>,
285            offset: usize,
286            depth: fidl::encoding::Depth,
287        ) -> fidl::Result<()> {
288            encoder.debug_check_bounds::<DeviceGetMaxFrameSizeResponse>(offset);
289            // Zero out padding regions. There's no need to apply masks
290            // because the unmasked parts will be overwritten by fields.
291            // Write the fields.
292            self.0.encode(encoder, offset + 0, depth)?;
293            Ok(())
294        }
295    }
296
297    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
298        for DeviceGetMaxFrameSizeResponse
299    {
300        #[inline(always)]
301        fn new_empty() -> Self {
302            Self { size: fidl::new_empty!(u32, D) }
303        }
304
305        #[inline]
306        unsafe fn decode(
307            &mut self,
308            decoder: &mut fidl::encoding::Decoder<'_, D>,
309            offset: usize,
310            _depth: fidl::encoding::Depth,
311        ) -> fidl::Result<()> {
312            decoder.debug_check_bounds::<Self>(offset);
313            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
314            // Verify that padding bytes are zero.
315            // Copy from the buffer into the object.
316            unsafe {
317                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
318            }
319            Ok(())
320        }
321    }
322
323    impl fidl::encoding::ValueTypeMarker for DeviceOnErrorRequest {
324        type Borrowed<'a> = &'a Self;
325        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
326            value
327        }
328    }
329
330    unsafe impl fidl::encoding::TypeMarker for DeviceOnErrorRequest {
331        type Owned = Self;
332
333        #[inline(always)]
334        fn inline_align(_context: fidl::encoding::Context) -> usize {
335            4
336        }
337
338        #[inline(always)]
339        fn inline_size(_context: fidl::encoding::Context) -> usize {
340            8
341        }
342    }
343
344    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceOnErrorRequest, D>
345        for &DeviceOnErrorRequest
346    {
347        #[inline]
348        unsafe fn encode(
349            self,
350            encoder: &mut fidl::encoding::Encoder<'_, D>,
351            offset: usize,
352            _depth: fidl::encoding::Depth,
353        ) -> fidl::Result<()> {
354            encoder.debug_check_bounds::<DeviceOnErrorRequest>(offset);
355            // Delegate to tuple encoding.
356            fidl::encoding::Encode::<DeviceOnErrorRequest, D>::encode(
357                (
358                    <Error as fidl::encoding::ValueTypeMarker>::borrow(&self.error),
359                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.did_close),
360                ),
361                encoder,
362                offset,
363                _depth,
364            )
365        }
366    }
367    unsafe impl<
368            D: fidl::encoding::ResourceDialect,
369            T0: fidl::encoding::Encode<Error, D>,
370            T1: fidl::encoding::Encode<bool, D>,
371        > fidl::encoding::Encode<DeviceOnErrorRequest, D> for (T0, T1)
372    {
373        #[inline]
374        unsafe fn encode(
375            self,
376            encoder: &mut fidl::encoding::Encoder<'_, D>,
377            offset: usize,
378            depth: fidl::encoding::Depth,
379        ) -> fidl::Result<()> {
380            encoder.debug_check_bounds::<DeviceOnErrorRequest>(offset);
381            // Zero out padding regions. There's no need to apply masks
382            // because the unmasked parts will be overwritten by fields.
383            unsafe {
384                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
385                (ptr as *mut u32).write_unaligned(0);
386            }
387            // Write the fields.
388            self.0.encode(encoder, offset + 0, depth)?;
389            self.1.encode(encoder, offset + 4, depth)?;
390            Ok(())
391        }
392    }
393
394    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceOnErrorRequest {
395        #[inline(always)]
396        fn new_empty() -> Self {
397            Self { error: fidl::new_empty!(Error, D), did_close: fidl::new_empty!(bool, D) }
398        }
399
400        #[inline]
401        unsafe fn decode(
402            &mut self,
403            decoder: &mut fidl::encoding::Decoder<'_, D>,
404            offset: usize,
405            _depth: fidl::encoding::Depth,
406        ) -> fidl::Result<()> {
407            decoder.debug_check_bounds::<Self>(offset);
408            // Verify that padding bytes are zero.
409            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
410            let padval = unsafe { (ptr as *const u32).read_unaligned() };
411            let mask = 0xffffff00u32;
412            let maskedval = padval & mask;
413            if maskedval != 0 {
414                return Err(fidl::Error::NonZeroPadding {
415                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
416                });
417            }
418            fidl::decode!(Error, D, &mut self.error, decoder, offset + 0, _depth)?;
419            fidl::decode!(bool, D, &mut self.did_close, decoder, offset + 4, _depth)?;
420            Ok(())
421        }
422    }
423
424    impl fidl::encoding::ValueTypeMarker for DeviceOnReadyForSendFramesRequest {
425        type Borrowed<'a> = &'a Self;
426        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
427            value
428        }
429    }
430
431    unsafe impl fidl::encoding::TypeMarker for DeviceOnReadyForSendFramesRequest {
432        type Owned = Self;
433
434        #[inline(always)]
435        fn inline_align(_context: fidl::encoding::Context) -> usize {
436            4
437        }
438
439        #[inline(always)]
440        fn inline_size(_context: fidl::encoding::Context) -> usize {
441            4
442        }
443        #[inline(always)]
444        fn encode_is_copy() -> bool {
445            true
446        }
447
448        #[inline(always)]
449        fn decode_is_copy() -> bool {
450            true
451        }
452    }
453
454    unsafe impl<D: fidl::encoding::ResourceDialect>
455        fidl::encoding::Encode<DeviceOnReadyForSendFramesRequest, D>
456        for &DeviceOnReadyForSendFramesRequest
457    {
458        #[inline]
459        unsafe fn encode(
460            self,
461            encoder: &mut fidl::encoding::Encoder<'_, D>,
462            offset: usize,
463            _depth: fidl::encoding::Depth,
464        ) -> fidl::Result<()> {
465            encoder.debug_check_bounds::<DeviceOnReadyForSendFramesRequest>(offset);
466            unsafe {
467                // Copy the object into the buffer.
468                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
469                (buf_ptr as *mut DeviceOnReadyForSendFramesRequest)
470                    .write_unaligned((self as *const DeviceOnReadyForSendFramesRequest).read());
471                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
472                // done second because the memcpy will write garbage to these bytes.
473            }
474            Ok(())
475        }
476    }
477    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
478        fidl::encoding::Encode<DeviceOnReadyForSendFramesRequest, D> for (T0,)
479    {
480        #[inline]
481        unsafe fn encode(
482            self,
483            encoder: &mut fidl::encoding::Encoder<'_, D>,
484            offset: usize,
485            depth: fidl::encoding::Depth,
486        ) -> fidl::Result<()> {
487            encoder.debug_check_bounds::<DeviceOnReadyForSendFramesRequest>(offset);
488            // Zero out padding regions. There's no need to apply masks
489            // because the unmasked parts will be overwritten by fields.
490            // Write the fields.
491            self.0.encode(encoder, offset + 0, depth)?;
492            Ok(())
493        }
494    }
495
496    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
497        for DeviceOnReadyForSendFramesRequest
498    {
499        #[inline(always)]
500        fn new_empty() -> Self {
501            Self { number_of_frames: fidl::new_empty!(u32, D) }
502        }
503
504        #[inline]
505        unsafe fn decode(
506            &mut self,
507            decoder: &mut fidl::encoding::Decoder<'_, D>,
508            offset: usize,
509            _depth: fidl::encoding::Depth,
510        ) -> fidl::Result<()> {
511            decoder.debug_check_bounds::<Self>(offset);
512            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
513            // Verify that padding bytes are zero.
514            // Copy from the buffer into the object.
515            unsafe {
516                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
517            }
518            Ok(())
519        }
520    }
521
522    impl fidl::encoding::ValueTypeMarker for DeviceOnReceiveFrameRequest {
523        type Borrowed<'a> = &'a Self;
524        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
525            value
526        }
527    }
528
529    unsafe impl fidl::encoding::TypeMarker for DeviceOnReceiveFrameRequest {
530        type Owned = Self;
531
532        #[inline(always)]
533        fn inline_align(_context: fidl::encoding::Context) -> usize {
534            8
535        }
536
537        #[inline(always)]
538        fn inline_size(_context: fidl::encoding::Context) -> usize {
539            16
540        }
541    }
542
543    unsafe impl<D: fidl::encoding::ResourceDialect>
544        fidl::encoding::Encode<DeviceOnReceiveFrameRequest, D> for &DeviceOnReceiveFrameRequest
545    {
546        #[inline]
547        unsafe fn encode(
548            self,
549            encoder: &mut fidl::encoding::Encoder<'_, D>,
550            offset: usize,
551            _depth: fidl::encoding::Depth,
552        ) -> fidl::Result<()> {
553            encoder.debug_check_bounds::<DeviceOnReceiveFrameRequest>(offset);
554            // Delegate to tuple encoding.
555            fidl::encoding::Encode::<DeviceOnReceiveFrameRequest, D>::encode(
556                (<fidl::encoding::Vector<u8, 4096> as fidl::encoding::ValueTypeMarker>::borrow(
557                    &self.data,
558                ),),
559                encoder,
560                offset,
561                _depth,
562            )
563        }
564    }
565    unsafe impl<
566            D: fidl::encoding::ResourceDialect,
567            T0: fidl::encoding::Encode<fidl::encoding::Vector<u8, 4096>, D>,
568        > fidl::encoding::Encode<DeviceOnReceiveFrameRequest, D> for (T0,)
569    {
570        #[inline]
571        unsafe fn encode(
572            self,
573            encoder: &mut fidl::encoding::Encoder<'_, D>,
574            offset: usize,
575            depth: fidl::encoding::Depth,
576        ) -> fidl::Result<()> {
577            encoder.debug_check_bounds::<DeviceOnReceiveFrameRequest>(offset);
578            // Zero out padding regions. There's no need to apply masks
579            // because the unmasked parts will be overwritten by fields.
580            // Write the fields.
581            self.0.encode(encoder, offset + 0, depth)?;
582            Ok(())
583        }
584    }
585
586    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
587        for DeviceOnReceiveFrameRequest
588    {
589        #[inline(always)]
590        fn new_empty() -> Self {
591            Self { data: fidl::new_empty!(fidl::encoding::Vector<u8, 4096>, D) }
592        }
593
594        #[inline]
595        unsafe fn decode(
596            &mut self,
597            decoder: &mut fidl::encoding::Decoder<'_, D>,
598            offset: usize,
599            _depth: fidl::encoding::Depth,
600        ) -> fidl::Result<()> {
601            decoder.debug_check_bounds::<Self>(offset);
602            // Verify that padding bytes are zero.
603            fidl::decode!(fidl::encoding::Vector<u8, 4096>, D, &mut self.data, decoder, offset + 0, _depth)?;
604            Ok(())
605        }
606    }
607
608    impl fidl::encoding::ValueTypeMarker for DeviceReadyToReceiveFramesRequest {
609        type Borrowed<'a> = &'a Self;
610        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
611            value
612        }
613    }
614
615    unsafe impl fidl::encoding::TypeMarker for DeviceReadyToReceiveFramesRequest {
616        type Owned = Self;
617
618        #[inline(always)]
619        fn inline_align(_context: fidl::encoding::Context) -> usize {
620            4
621        }
622
623        #[inline(always)]
624        fn inline_size(_context: fidl::encoding::Context) -> usize {
625            4
626        }
627        #[inline(always)]
628        fn encode_is_copy() -> bool {
629            true
630        }
631
632        #[inline(always)]
633        fn decode_is_copy() -> bool {
634            true
635        }
636    }
637
638    unsafe impl<D: fidl::encoding::ResourceDialect>
639        fidl::encoding::Encode<DeviceReadyToReceiveFramesRequest, D>
640        for &DeviceReadyToReceiveFramesRequest
641    {
642        #[inline]
643        unsafe fn encode(
644            self,
645            encoder: &mut fidl::encoding::Encoder<'_, D>,
646            offset: usize,
647            _depth: fidl::encoding::Depth,
648        ) -> fidl::Result<()> {
649            encoder.debug_check_bounds::<DeviceReadyToReceiveFramesRequest>(offset);
650            unsafe {
651                // Copy the object into the buffer.
652                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
653                (buf_ptr as *mut DeviceReadyToReceiveFramesRequest)
654                    .write_unaligned((self as *const DeviceReadyToReceiveFramesRequest).read());
655                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
656                // done second because the memcpy will write garbage to these bytes.
657            }
658            Ok(())
659        }
660    }
661    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
662        fidl::encoding::Encode<DeviceReadyToReceiveFramesRequest, D> for (T0,)
663    {
664        #[inline]
665        unsafe fn encode(
666            self,
667            encoder: &mut fidl::encoding::Encoder<'_, D>,
668            offset: usize,
669            depth: fidl::encoding::Depth,
670        ) -> fidl::Result<()> {
671            encoder.debug_check_bounds::<DeviceReadyToReceiveFramesRequest>(offset);
672            // Zero out padding regions. There's no need to apply masks
673            // because the unmasked parts will be overwritten by fields.
674            // Write the fields.
675            self.0.encode(encoder, offset + 0, depth)?;
676            Ok(())
677        }
678    }
679
680    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
681        for DeviceReadyToReceiveFramesRequest
682    {
683        #[inline(always)]
684        fn new_empty() -> Self {
685            Self { number_of_frames: fidl::new_empty!(u32, D) }
686        }
687
688        #[inline]
689        unsafe fn decode(
690            &mut self,
691            decoder: &mut fidl::encoding::Decoder<'_, D>,
692            offset: usize,
693            _depth: fidl::encoding::Depth,
694        ) -> fidl::Result<()> {
695            decoder.debug_check_bounds::<Self>(offset);
696            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
697            // Verify that padding bytes are zero.
698            // Copy from the buffer into the object.
699            unsafe {
700                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
701            }
702            Ok(())
703        }
704    }
705
706    impl fidl::encoding::ValueTypeMarker for DeviceSendFrameRequest {
707        type Borrowed<'a> = &'a Self;
708        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
709            value
710        }
711    }
712
713    unsafe impl fidl::encoding::TypeMarker for DeviceSendFrameRequest {
714        type Owned = Self;
715
716        #[inline(always)]
717        fn inline_align(_context: fidl::encoding::Context) -> usize {
718            8
719        }
720
721        #[inline(always)]
722        fn inline_size(_context: fidl::encoding::Context) -> usize {
723            16
724        }
725    }
726
727    unsafe impl<D: fidl::encoding::ResourceDialect>
728        fidl::encoding::Encode<DeviceSendFrameRequest, D> for &DeviceSendFrameRequest
729    {
730        #[inline]
731        unsafe fn encode(
732            self,
733            encoder: &mut fidl::encoding::Encoder<'_, D>,
734            offset: usize,
735            _depth: fidl::encoding::Depth,
736        ) -> fidl::Result<()> {
737            encoder.debug_check_bounds::<DeviceSendFrameRequest>(offset);
738            // Delegate to tuple encoding.
739            fidl::encoding::Encode::<DeviceSendFrameRequest, D>::encode(
740                (<fidl::encoding::Vector<u8, 4096> as fidl::encoding::ValueTypeMarker>::borrow(
741                    &self.data,
742                ),),
743                encoder,
744                offset,
745                _depth,
746            )
747        }
748    }
749    unsafe impl<
750            D: fidl::encoding::ResourceDialect,
751            T0: fidl::encoding::Encode<fidl::encoding::Vector<u8, 4096>, D>,
752        > fidl::encoding::Encode<DeviceSendFrameRequest, D> for (T0,)
753    {
754        #[inline]
755        unsafe fn encode(
756            self,
757            encoder: &mut fidl::encoding::Encoder<'_, D>,
758            offset: usize,
759            depth: fidl::encoding::Depth,
760        ) -> fidl::Result<()> {
761            encoder.debug_check_bounds::<DeviceSendFrameRequest>(offset);
762            // Zero out padding regions. There's no need to apply masks
763            // because the unmasked parts will be overwritten by fields.
764            // Write the fields.
765            self.0.encode(encoder, offset + 0, depth)?;
766            Ok(())
767        }
768    }
769
770    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
771        for DeviceSendFrameRequest
772    {
773        #[inline(always)]
774        fn new_empty() -> Self {
775            Self { data: fidl::new_empty!(fidl::encoding::Vector<u8, 4096>, D) }
776        }
777
778        #[inline]
779        unsafe fn decode(
780            &mut self,
781            decoder: &mut fidl::encoding::Decoder<'_, D>,
782            offset: usize,
783            _depth: fidl::encoding::Depth,
784        ) -> fidl::Result<()> {
785            decoder.debug_check_bounds::<Self>(offset);
786            // Verify that padding bytes are zero.
787            fidl::decode!(fidl::encoding::Vector<u8, 4096>, D, &mut self.data, decoder, offset + 0, _depth)?;
788            Ok(())
789        }
790    }
791}