fidl_fuchsia_hardware_sensors_common/
fidl_fuchsia_hardware_sensors_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/// Errors that may be returned by Driver::ActivateSensor.
12#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
13pub enum ActivateSensorError {
14    /// The provided SensorId does not correspond to an actual sensor.
15    InvalidSensorId,
16    #[doc(hidden)]
17    __SourceBreaking { unknown_ordinal: u32 },
18}
19
20/// Pattern that matches an unknown `ActivateSensorError` member.
21#[macro_export]
22macro_rules! ActivateSensorErrorUnknown {
23    () => {
24        _
25    };
26}
27
28impl ActivateSensorError {
29    #[inline]
30    pub fn from_primitive(prim: u32) -> Option<Self> {
31        match prim {
32            1 => Some(Self::InvalidSensorId),
33            _ => None,
34        }
35    }
36
37    #[inline]
38    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
39        match prim {
40            1 => Self::InvalidSensorId,
41            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
42        }
43    }
44
45    #[inline]
46    pub fn unknown() -> Self {
47        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
48    }
49
50    #[inline]
51    pub const fn into_primitive(self) -> u32 {
52        match self {
53            Self::InvalidSensorId => 1,
54            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
55        }
56    }
57
58    #[inline]
59    pub fn is_unknown(&self) -> bool {
60        match self {
61            Self::__SourceBreaking { unknown_ordinal: _ } => true,
62            _ => false,
63        }
64    }
65}
66
67/// Errors that may be returned by ConfigurePlayback.
68#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
69pub enum ConfigurePlaybackError {
70    /// The type of the PlaybackSourceConfig union isn't recognized/supported.
71    InvalidConfigType,
72    /// Some part of the provided playback config is missing fields.
73    ConfigMissingFields,
74    /// A provided SensorInfo has a duplicate SensorId.
75    DuplicateSensorInfo,
76    /// No SensorEvents were given for a provided SensorInfo.
77    NoEventsForSensor,
78    /// A SensorEvent was seen with a SensorId for which no SensorInfo was
79    /// provided.
80    EventFromUnknownSensor,
81    /// A SensorEvent was seen with a SensorType that does not match the
82    /// corresponding SensorInfo.
83    EventSensorTypeMismatch,
84    /// A SensorEvent was seen with an EventPayload that doesn't match its
85    /// SensorType.
86    EventPayloadTypeMismatch,
87    /// The specified data file could not be opened.
88    FileOpenFailed,
89    /// The data in the specified file was not in the expected format.
90    ///
91    /// NOTE: Some file types may allow for situations where the file is not
92    /// fully read by the time configuration is complete. For example a call to
93    /// ConfigurePlayback may only result in a file's header being read and
94    /// parsed. Thus ConfigurePlayback not returning this error is not always a
95    /// guarantee that the whole file contains valid data.
96    FileParseError,
97    #[doc(hidden)]
98    __SourceBreaking { unknown_ordinal: u32 },
99}
100
101/// Pattern that matches an unknown `ConfigurePlaybackError` member.
102#[macro_export]
103macro_rules! ConfigurePlaybackErrorUnknown {
104    () => {
105        _
106    };
107}
108
109impl ConfigurePlaybackError {
110    #[inline]
111    pub fn from_primitive(prim: u32) -> Option<Self> {
112        match prim {
113            1 => Some(Self::InvalidConfigType),
114            2 => Some(Self::ConfigMissingFields),
115            3 => Some(Self::DuplicateSensorInfo),
116            4 => Some(Self::NoEventsForSensor),
117            5 => Some(Self::EventFromUnknownSensor),
118            6 => Some(Self::EventSensorTypeMismatch),
119            7 => Some(Self::EventPayloadTypeMismatch),
120            8 => Some(Self::FileOpenFailed),
121            9 => Some(Self::FileParseError),
122            _ => None,
123        }
124    }
125
126    #[inline]
127    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
128        match prim {
129            1 => Self::InvalidConfigType,
130            2 => Self::ConfigMissingFields,
131            3 => Self::DuplicateSensorInfo,
132            4 => Self::NoEventsForSensor,
133            5 => Self::EventFromUnknownSensor,
134            6 => Self::EventSensorTypeMismatch,
135            7 => Self::EventPayloadTypeMismatch,
136            8 => Self::FileOpenFailed,
137            9 => Self::FileParseError,
138            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
139        }
140    }
141
142    #[inline]
143    pub fn unknown() -> Self {
144        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
145    }
146
147    #[inline]
148    pub const fn into_primitive(self) -> u32 {
149        match self {
150            Self::InvalidConfigType => 1,
151            Self::ConfigMissingFields => 2,
152            Self::DuplicateSensorInfo => 3,
153            Self::NoEventsForSensor => 4,
154            Self::EventFromUnknownSensor => 5,
155            Self::EventSensorTypeMismatch => 6,
156            Self::EventPayloadTypeMismatch => 7,
157            Self::FileOpenFailed => 8,
158            Self::FileParseError => 9,
159            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
160        }
161    }
162
163    #[inline]
164    pub fn is_unknown(&self) -> bool {
165        match self {
166            Self::__SourceBreaking { unknown_ordinal: _ } => true,
167            _ => false,
168        }
169    }
170}
171
172/// Errors that may be returned by Driver::ConfigureSensorRate.
173#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
174pub enum ConfigureSensorRateError {
175    /// The provided sensor SensorId does not correspond to an actual sensor.
176    InvalidSensorId,
177    /// The rate configuration was missing fields or contained an unsupported
178    /// sample rate and/or maximum reporting latency.
179    InvalidConfig,
180    #[doc(hidden)]
181    __SourceBreaking { unknown_ordinal: u32 },
182}
183
184/// Pattern that matches an unknown `ConfigureSensorRateError` member.
185#[macro_export]
186macro_rules! ConfigureSensorRateErrorUnknown {
187    () => {
188        _
189    };
190}
191
192impl ConfigureSensorRateError {
193    #[inline]
194    pub fn from_primitive(prim: u32) -> Option<Self> {
195        match prim {
196            1 => Some(Self::InvalidSensorId),
197            2 => Some(Self::InvalidConfig),
198            _ => None,
199        }
200    }
201
202    #[inline]
203    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
204        match prim {
205            1 => Self::InvalidSensorId,
206            2 => Self::InvalidConfig,
207            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
208        }
209    }
210
211    #[inline]
212    pub fn unknown() -> Self {
213        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
214    }
215
216    #[inline]
217    pub const fn into_primitive(self) -> u32 {
218        match self {
219            Self::InvalidSensorId => 1,
220            Self::InvalidConfig => 2,
221            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
222        }
223    }
224
225    #[inline]
226    pub fn is_unknown(&self) -> bool {
227        match self {
228            Self::__SourceBreaking { unknown_ordinal: _ } => true,
229            _ => false,
230        }
231    }
232}
233
234/// Errors that may be returned by Driver::DeactivateSensor.
235#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
236pub enum DeactivateSensorError {
237    /// The provided SensorId does not correspond to an actual sensor.
238    InvalidSensorId,
239    #[doc(hidden)]
240    __SourceBreaking { unknown_ordinal: u32 },
241}
242
243/// Pattern that matches an unknown `DeactivateSensorError` member.
244#[macro_export]
245macro_rules! DeactivateSensorErrorUnknown {
246    () => {
247        _
248    };
249}
250
251impl DeactivateSensorError {
252    #[inline]
253    pub fn from_primitive(prim: u32) -> Option<Self> {
254        match prim {
255            1 => Some(Self::InvalidSensorId),
256            _ => None,
257        }
258    }
259
260    #[inline]
261    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
262        match prim {
263            1 => Self::InvalidSensorId,
264            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
265        }
266    }
267
268    #[inline]
269    pub fn unknown() -> Self {
270        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
271    }
272
273    #[inline]
274    pub const fn into_primitive(self) -> u32 {
275        match self {
276            Self::InvalidSensorId => 1,
277            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
278        }
279    }
280
281    #[inline]
282    pub fn is_unknown(&self) -> bool {
283        match self {
284            Self::__SourceBreaking { unknown_ordinal: _ } => true,
285            _ => false,
286        }
287    }
288}
289
290#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
291#[repr(C)]
292pub struct DriverActivateSensorRequest {
293    pub sensor_id: i32,
294}
295
296impl fidl::Persistable for DriverActivateSensorRequest {}
297
298#[derive(Clone, Debug, PartialEq)]
299pub struct DriverConfigureSensorRateRequest {
300    pub sensor_id: i32,
301    pub sensor_rate_config: fidl_fuchsia_sensors_types::SensorRateConfig,
302}
303
304impl fidl::Persistable for DriverConfigureSensorRateRequest {}
305
306#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
307#[repr(C)]
308pub struct DriverDeactivateSensorRequest {
309    pub sensor_id: i32,
310}
311
312impl fidl::Persistable for DriverDeactivateSensorRequest {}
313
314#[derive(Clone, Debug, PartialEq)]
315pub struct DriverOnSensorEventRequest {
316    pub event: fidl_fuchsia_sensors_types::SensorEvent,
317}
318
319impl fidl::Persistable for DriverOnSensorEventRequest {}
320
321#[derive(Clone, Debug, PartialEq)]
322pub struct DriverGetSensorsListResponse {
323    pub sensor_list: Vec<fidl_fuchsia_sensors_types::SensorInfo>,
324}
325
326impl fidl::Persistable for DriverGetSensorsListResponse {}
327
328#[derive(Clone, Debug, PartialEq)]
329pub struct PlaybackConfigurePlaybackRequest {
330    pub source_config: PlaybackSourceConfig,
331}
332
333impl fidl::Persistable for PlaybackConfigurePlaybackRequest {}
334
335/// A playback configuration which specifies a file from which to read sensor
336/// events.
337#[derive(Clone, Debug, Default, PartialEq)]
338pub struct FilePlaybackConfig {
339    /// The path of the data file to read.
340    pub file_path: Option<String>,
341    #[doc(hidden)]
342    pub __source_breaking: fidl::marker::SourceBreaking,
343}
344
345impl fidl::Persistable for FilePlaybackConfig {}
346
347/// A playback configuration which will emit events from the provided list.
348///
349/// The list of SensorEvents will be sorted into separate lists by SensorId and
350/// then played back according to each sensor's configured sample rate and max
351/// reporting latency. Thus the ordering of the entire list is only guaranteed
352/// to hold if all the SensorEvents are from the same sensor. Any timestamps or
353/// sequence numbers in the provided SensorEvents are ignored and overwritten.
354///
355/// There must be at least one event for every sensor in the sensor_list and
356/// there must not be any events for sensors that aren't in the sensor_list.
357#[derive(Clone, Debug, Default, PartialEq)]
358pub struct FixedValuesPlaybackConfig {
359    /// Sensors that will be advertised through the Driver protocol.
360    ///
361    /// Required.
362    pub sensor_list: Option<Vec<fidl_fuchsia_sensors_types::SensorInfo>>,
363    /// SensorsEvents which will be played back through the Driver protocol.
364    ///
365    /// Required.
366    pub sensor_events: Option<Vec<fidl_fuchsia_sensors_types::SensorEvent>>,
367    #[doc(hidden)]
368    pub __source_breaking: fidl::marker::SourceBreaking,
369}
370
371impl fidl::Persistable for FixedValuesPlaybackConfig {}
372
373/// Multiple types of playback are supported. Which type is used depends on
374/// which configuration is provided to Playback::ConfigurePlayback.
375#[derive(Clone, Debug)]
376pub enum PlaybackSourceConfig {
377    /// Configure for fixed values playback. See FixedValuesPlaybackConfig.
378    FixedValuesConfig(FixedValuesPlaybackConfig),
379    /// Configure to play back events from a data file. See FilePlaybackConfig.
380    FilePlaybackConfig(FilePlaybackConfig),
381    #[doc(hidden)]
382    __SourceBreaking { unknown_ordinal: u64 },
383}
384
385/// Pattern that matches an unknown `PlaybackSourceConfig` member.
386#[macro_export]
387macro_rules! PlaybackSourceConfigUnknown {
388    () => {
389        _
390    };
391}
392
393// Custom PartialEq so that unknown variants are not equal to themselves.
394impl PartialEq for PlaybackSourceConfig {
395    fn eq(&self, other: &Self) -> bool {
396        match (self, other) {
397            (Self::FixedValuesConfig(x), Self::FixedValuesConfig(y)) => *x == *y,
398            (Self::FilePlaybackConfig(x), Self::FilePlaybackConfig(y)) => *x == *y,
399            _ => false,
400        }
401    }
402}
403
404impl PlaybackSourceConfig {
405    #[inline]
406    pub fn ordinal(&self) -> u64 {
407        match *self {
408            Self::FixedValuesConfig(_) => 1,
409            Self::FilePlaybackConfig(_) => 2,
410            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
411        }
412    }
413
414    #[inline]
415    pub fn unknown_variant_for_testing() -> Self {
416        Self::__SourceBreaking { unknown_ordinal: 0 }
417    }
418
419    #[inline]
420    pub fn is_unknown(&self) -> bool {
421        match self {
422            Self::__SourceBreaking { .. } => true,
423            _ => false,
424        }
425    }
426}
427
428impl fidl::Persistable for PlaybackSourceConfig {}
429
430mod internal {
431    use super::*;
432    unsafe impl fidl::encoding::TypeMarker for ActivateSensorError {
433        type Owned = Self;
434
435        #[inline(always)]
436        fn inline_align(_context: fidl::encoding::Context) -> usize {
437            std::mem::align_of::<u32>()
438        }
439
440        #[inline(always)]
441        fn inline_size(_context: fidl::encoding::Context) -> usize {
442            std::mem::size_of::<u32>()
443        }
444
445        #[inline(always)]
446        fn encode_is_copy() -> bool {
447            false
448        }
449
450        #[inline(always)]
451        fn decode_is_copy() -> bool {
452            false
453        }
454    }
455
456    impl fidl::encoding::ValueTypeMarker for ActivateSensorError {
457        type Borrowed<'a> = Self;
458        #[inline(always)]
459        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
460            *value
461        }
462    }
463
464    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
465        for ActivateSensorError
466    {
467        #[inline]
468        unsafe fn encode(
469            self,
470            encoder: &mut fidl::encoding::Encoder<'_, D>,
471            offset: usize,
472            _depth: fidl::encoding::Depth,
473        ) -> fidl::Result<()> {
474            encoder.debug_check_bounds::<Self>(offset);
475            encoder.write_num(self.into_primitive(), offset);
476            Ok(())
477        }
478    }
479
480    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ActivateSensorError {
481        #[inline(always)]
482        fn new_empty() -> Self {
483            Self::unknown()
484        }
485
486        #[inline]
487        unsafe fn decode(
488            &mut self,
489            decoder: &mut fidl::encoding::Decoder<'_, D>,
490            offset: usize,
491            _depth: fidl::encoding::Depth,
492        ) -> fidl::Result<()> {
493            decoder.debug_check_bounds::<Self>(offset);
494            let prim = decoder.read_num::<u32>(offset);
495
496            *self = Self::from_primitive_allow_unknown(prim);
497            Ok(())
498        }
499    }
500    unsafe impl fidl::encoding::TypeMarker for ConfigurePlaybackError {
501        type Owned = Self;
502
503        #[inline(always)]
504        fn inline_align(_context: fidl::encoding::Context) -> usize {
505            std::mem::align_of::<u32>()
506        }
507
508        #[inline(always)]
509        fn inline_size(_context: fidl::encoding::Context) -> usize {
510            std::mem::size_of::<u32>()
511        }
512
513        #[inline(always)]
514        fn encode_is_copy() -> bool {
515            false
516        }
517
518        #[inline(always)]
519        fn decode_is_copy() -> bool {
520            false
521        }
522    }
523
524    impl fidl::encoding::ValueTypeMarker for ConfigurePlaybackError {
525        type Borrowed<'a> = Self;
526        #[inline(always)]
527        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
528            *value
529        }
530    }
531
532    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
533        for ConfigurePlaybackError
534    {
535        #[inline]
536        unsafe fn encode(
537            self,
538            encoder: &mut fidl::encoding::Encoder<'_, D>,
539            offset: usize,
540            _depth: fidl::encoding::Depth,
541        ) -> fidl::Result<()> {
542            encoder.debug_check_bounds::<Self>(offset);
543            encoder.write_num(self.into_primitive(), offset);
544            Ok(())
545        }
546    }
547
548    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
549        for ConfigurePlaybackError
550    {
551        #[inline(always)]
552        fn new_empty() -> Self {
553            Self::unknown()
554        }
555
556        #[inline]
557        unsafe fn decode(
558            &mut self,
559            decoder: &mut fidl::encoding::Decoder<'_, D>,
560            offset: usize,
561            _depth: fidl::encoding::Depth,
562        ) -> fidl::Result<()> {
563            decoder.debug_check_bounds::<Self>(offset);
564            let prim = decoder.read_num::<u32>(offset);
565
566            *self = Self::from_primitive_allow_unknown(prim);
567            Ok(())
568        }
569    }
570    unsafe impl fidl::encoding::TypeMarker for ConfigureSensorRateError {
571        type Owned = Self;
572
573        #[inline(always)]
574        fn inline_align(_context: fidl::encoding::Context) -> usize {
575            std::mem::align_of::<u32>()
576        }
577
578        #[inline(always)]
579        fn inline_size(_context: fidl::encoding::Context) -> usize {
580            std::mem::size_of::<u32>()
581        }
582
583        #[inline(always)]
584        fn encode_is_copy() -> bool {
585            false
586        }
587
588        #[inline(always)]
589        fn decode_is_copy() -> bool {
590            false
591        }
592    }
593
594    impl fidl::encoding::ValueTypeMarker for ConfigureSensorRateError {
595        type Borrowed<'a> = Self;
596        #[inline(always)]
597        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
598            *value
599        }
600    }
601
602    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
603        for ConfigureSensorRateError
604    {
605        #[inline]
606        unsafe fn encode(
607            self,
608            encoder: &mut fidl::encoding::Encoder<'_, D>,
609            offset: usize,
610            _depth: fidl::encoding::Depth,
611        ) -> fidl::Result<()> {
612            encoder.debug_check_bounds::<Self>(offset);
613            encoder.write_num(self.into_primitive(), offset);
614            Ok(())
615        }
616    }
617
618    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
619        for ConfigureSensorRateError
620    {
621        #[inline(always)]
622        fn new_empty() -> Self {
623            Self::unknown()
624        }
625
626        #[inline]
627        unsafe fn decode(
628            &mut self,
629            decoder: &mut fidl::encoding::Decoder<'_, D>,
630            offset: usize,
631            _depth: fidl::encoding::Depth,
632        ) -> fidl::Result<()> {
633            decoder.debug_check_bounds::<Self>(offset);
634            let prim = decoder.read_num::<u32>(offset);
635
636            *self = Self::from_primitive_allow_unknown(prim);
637            Ok(())
638        }
639    }
640    unsafe impl fidl::encoding::TypeMarker for DeactivateSensorError {
641        type Owned = Self;
642
643        #[inline(always)]
644        fn inline_align(_context: fidl::encoding::Context) -> usize {
645            std::mem::align_of::<u32>()
646        }
647
648        #[inline(always)]
649        fn inline_size(_context: fidl::encoding::Context) -> usize {
650            std::mem::size_of::<u32>()
651        }
652
653        #[inline(always)]
654        fn encode_is_copy() -> bool {
655            false
656        }
657
658        #[inline(always)]
659        fn decode_is_copy() -> bool {
660            false
661        }
662    }
663
664    impl fidl::encoding::ValueTypeMarker for DeactivateSensorError {
665        type Borrowed<'a> = Self;
666        #[inline(always)]
667        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
668            *value
669        }
670    }
671
672    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
673        for DeactivateSensorError
674    {
675        #[inline]
676        unsafe fn encode(
677            self,
678            encoder: &mut fidl::encoding::Encoder<'_, D>,
679            offset: usize,
680            _depth: fidl::encoding::Depth,
681        ) -> fidl::Result<()> {
682            encoder.debug_check_bounds::<Self>(offset);
683            encoder.write_num(self.into_primitive(), offset);
684            Ok(())
685        }
686    }
687
688    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeactivateSensorError {
689        #[inline(always)]
690        fn new_empty() -> Self {
691            Self::unknown()
692        }
693
694        #[inline]
695        unsafe fn decode(
696            &mut self,
697            decoder: &mut fidl::encoding::Decoder<'_, D>,
698            offset: usize,
699            _depth: fidl::encoding::Depth,
700        ) -> fidl::Result<()> {
701            decoder.debug_check_bounds::<Self>(offset);
702            let prim = decoder.read_num::<u32>(offset);
703
704            *self = Self::from_primitive_allow_unknown(prim);
705            Ok(())
706        }
707    }
708
709    impl fidl::encoding::ValueTypeMarker for DriverActivateSensorRequest {
710        type Borrowed<'a> = &'a Self;
711        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
712            value
713        }
714    }
715
716    unsafe impl fidl::encoding::TypeMarker for DriverActivateSensorRequest {
717        type Owned = Self;
718
719        #[inline(always)]
720        fn inline_align(_context: fidl::encoding::Context) -> usize {
721            4
722        }
723
724        #[inline(always)]
725        fn inline_size(_context: fidl::encoding::Context) -> usize {
726            4
727        }
728        #[inline(always)]
729        fn encode_is_copy() -> bool {
730            true
731        }
732
733        #[inline(always)]
734        fn decode_is_copy() -> bool {
735            true
736        }
737    }
738
739    unsafe impl<D: fidl::encoding::ResourceDialect>
740        fidl::encoding::Encode<DriverActivateSensorRequest, D> for &DriverActivateSensorRequest
741    {
742        #[inline]
743        unsafe fn encode(
744            self,
745            encoder: &mut fidl::encoding::Encoder<'_, D>,
746            offset: usize,
747            _depth: fidl::encoding::Depth,
748        ) -> fidl::Result<()> {
749            encoder.debug_check_bounds::<DriverActivateSensorRequest>(offset);
750            unsafe {
751                // Copy the object into the buffer.
752                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
753                (buf_ptr as *mut DriverActivateSensorRequest)
754                    .write_unaligned((self as *const DriverActivateSensorRequest).read());
755                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
756                // done second because the memcpy will write garbage to these bytes.
757            }
758            Ok(())
759        }
760    }
761    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
762        fidl::encoding::Encode<DriverActivateSensorRequest, D> for (T0,)
763    {
764        #[inline]
765        unsafe fn encode(
766            self,
767            encoder: &mut fidl::encoding::Encoder<'_, D>,
768            offset: usize,
769            depth: fidl::encoding::Depth,
770        ) -> fidl::Result<()> {
771            encoder.debug_check_bounds::<DriverActivateSensorRequest>(offset);
772            // Zero out padding regions. There's no need to apply masks
773            // because the unmasked parts will be overwritten by fields.
774            // Write the fields.
775            self.0.encode(encoder, offset + 0, depth)?;
776            Ok(())
777        }
778    }
779
780    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
781        for DriverActivateSensorRequest
782    {
783        #[inline(always)]
784        fn new_empty() -> Self {
785            Self { sensor_id: fidl::new_empty!(i32, D) }
786        }
787
788        #[inline]
789        unsafe fn decode(
790            &mut self,
791            decoder: &mut fidl::encoding::Decoder<'_, D>,
792            offset: usize,
793            _depth: fidl::encoding::Depth,
794        ) -> fidl::Result<()> {
795            decoder.debug_check_bounds::<Self>(offset);
796            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
797            // Verify that padding bytes are zero.
798            // Copy from the buffer into the object.
799            unsafe {
800                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
801            }
802            Ok(())
803        }
804    }
805
806    impl fidl::encoding::ValueTypeMarker for DriverConfigureSensorRateRequest {
807        type Borrowed<'a> = &'a Self;
808        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
809            value
810        }
811    }
812
813    unsafe impl fidl::encoding::TypeMarker for DriverConfigureSensorRateRequest {
814        type Owned = Self;
815
816        #[inline(always)]
817        fn inline_align(_context: fidl::encoding::Context) -> usize {
818            8
819        }
820
821        #[inline(always)]
822        fn inline_size(_context: fidl::encoding::Context) -> usize {
823            24
824        }
825    }
826
827    unsafe impl<D: fidl::encoding::ResourceDialect>
828        fidl::encoding::Encode<DriverConfigureSensorRateRequest, D>
829        for &DriverConfigureSensorRateRequest
830    {
831        #[inline]
832        unsafe fn encode(
833            self,
834            encoder: &mut fidl::encoding::Encoder<'_, D>,
835            offset: usize,
836            _depth: fidl::encoding::Depth,
837        ) -> fidl::Result<()> {
838            encoder.debug_check_bounds::<DriverConfigureSensorRateRequest>(offset);
839            // Delegate to tuple encoding.
840            fidl::encoding::Encode::<DriverConfigureSensorRateRequest, D>::encode(
841                (
842                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.sensor_id),
843                    <fidl_fuchsia_sensors_types::SensorRateConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.sensor_rate_config),
844                ),
845                encoder, offset, _depth
846            )
847        }
848    }
849    unsafe impl<
850            D: fidl::encoding::ResourceDialect,
851            T0: fidl::encoding::Encode<i32, D>,
852            T1: fidl::encoding::Encode<fidl_fuchsia_sensors_types::SensorRateConfig, D>,
853        > fidl::encoding::Encode<DriverConfigureSensorRateRequest, D> for (T0, T1)
854    {
855        #[inline]
856        unsafe fn encode(
857            self,
858            encoder: &mut fidl::encoding::Encoder<'_, D>,
859            offset: usize,
860            depth: fidl::encoding::Depth,
861        ) -> fidl::Result<()> {
862            encoder.debug_check_bounds::<DriverConfigureSensorRateRequest>(offset);
863            // Zero out padding regions. There's no need to apply masks
864            // because the unmasked parts will be overwritten by fields.
865            unsafe {
866                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
867                (ptr as *mut u64).write_unaligned(0);
868            }
869            // Write the fields.
870            self.0.encode(encoder, offset + 0, depth)?;
871            self.1.encode(encoder, offset + 8, depth)?;
872            Ok(())
873        }
874    }
875
876    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
877        for DriverConfigureSensorRateRequest
878    {
879        #[inline(always)]
880        fn new_empty() -> Self {
881            Self {
882                sensor_id: fidl::new_empty!(i32, D),
883                sensor_rate_config: fidl::new_empty!(
884                    fidl_fuchsia_sensors_types::SensorRateConfig,
885                    D
886                ),
887            }
888        }
889
890        #[inline]
891        unsafe fn decode(
892            &mut self,
893            decoder: &mut fidl::encoding::Decoder<'_, D>,
894            offset: usize,
895            _depth: fidl::encoding::Depth,
896        ) -> fidl::Result<()> {
897            decoder.debug_check_bounds::<Self>(offset);
898            // Verify that padding bytes are zero.
899            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
900            let padval = unsafe { (ptr as *const u64).read_unaligned() };
901            let mask = 0xffffffff00000000u64;
902            let maskedval = padval & mask;
903            if maskedval != 0 {
904                return Err(fidl::Error::NonZeroPadding {
905                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
906                });
907            }
908            fidl::decode!(i32, D, &mut self.sensor_id, decoder, offset + 0, _depth)?;
909            fidl::decode!(
910                fidl_fuchsia_sensors_types::SensorRateConfig,
911                D,
912                &mut self.sensor_rate_config,
913                decoder,
914                offset + 8,
915                _depth
916            )?;
917            Ok(())
918        }
919    }
920
921    impl fidl::encoding::ValueTypeMarker for DriverDeactivateSensorRequest {
922        type Borrowed<'a> = &'a Self;
923        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
924            value
925        }
926    }
927
928    unsafe impl fidl::encoding::TypeMarker for DriverDeactivateSensorRequest {
929        type Owned = Self;
930
931        #[inline(always)]
932        fn inline_align(_context: fidl::encoding::Context) -> usize {
933            4
934        }
935
936        #[inline(always)]
937        fn inline_size(_context: fidl::encoding::Context) -> usize {
938            4
939        }
940        #[inline(always)]
941        fn encode_is_copy() -> bool {
942            true
943        }
944
945        #[inline(always)]
946        fn decode_is_copy() -> bool {
947            true
948        }
949    }
950
951    unsafe impl<D: fidl::encoding::ResourceDialect>
952        fidl::encoding::Encode<DriverDeactivateSensorRequest, D>
953        for &DriverDeactivateSensorRequest
954    {
955        #[inline]
956        unsafe fn encode(
957            self,
958            encoder: &mut fidl::encoding::Encoder<'_, D>,
959            offset: usize,
960            _depth: fidl::encoding::Depth,
961        ) -> fidl::Result<()> {
962            encoder.debug_check_bounds::<DriverDeactivateSensorRequest>(offset);
963            unsafe {
964                // Copy the object into the buffer.
965                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
966                (buf_ptr as *mut DriverDeactivateSensorRequest)
967                    .write_unaligned((self as *const DriverDeactivateSensorRequest).read());
968                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
969                // done second because the memcpy will write garbage to these bytes.
970            }
971            Ok(())
972        }
973    }
974    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
975        fidl::encoding::Encode<DriverDeactivateSensorRequest, D> for (T0,)
976    {
977        #[inline]
978        unsafe fn encode(
979            self,
980            encoder: &mut fidl::encoding::Encoder<'_, D>,
981            offset: usize,
982            depth: fidl::encoding::Depth,
983        ) -> fidl::Result<()> {
984            encoder.debug_check_bounds::<DriverDeactivateSensorRequest>(offset);
985            // Zero out padding regions. There's no need to apply masks
986            // because the unmasked parts will be overwritten by fields.
987            // Write the fields.
988            self.0.encode(encoder, offset + 0, depth)?;
989            Ok(())
990        }
991    }
992
993    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
994        for DriverDeactivateSensorRequest
995    {
996        #[inline(always)]
997        fn new_empty() -> Self {
998            Self { sensor_id: fidl::new_empty!(i32, D) }
999        }
1000
1001        #[inline]
1002        unsafe fn decode(
1003            &mut self,
1004            decoder: &mut fidl::encoding::Decoder<'_, D>,
1005            offset: usize,
1006            _depth: fidl::encoding::Depth,
1007        ) -> fidl::Result<()> {
1008            decoder.debug_check_bounds::<Self>(offset);
1009            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1010            // Verify that padding bytes are zero.
1011            // Copy from the buffer into the object.
1012            unsafe {
1013                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1014            }
1015            Ok(())
1016        }
1017    }
1018
1019    impl fidl::encoding::ValueTypeMarker for DriverOnSensorEventRequest {
1020        type Borrowed<'a> = &'a Self;
1021        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1022            value
1023        }
1024    }
1025
1026    unsafe impl fidl::encoding::TypeMarker for DriverOnSensorEventRequest {
1027        type Owned = Self;
1028
1029        #[inline(always)]
1030        fn inline_align(_context: fidl::encoding::Context) -> usize {
1031            8
1032        }
1033
1034        #[inline(always)]
1035        fn inline_size(_context: fidl::encoding::Context) -> usize {
1036            40
1037        }
1038    }
1039
1040    unsafe impl<D: fidl::encoding::ResourceDialect>
1041        fidl::encoding::Encode<DriverOnSensorEventRequest, D> for &DriverOnSensorEventRequest
1042    {
1043        #[inline]
1044        unsafe fn encode(
1045            self,
1046            encoder: &mut fidl::encoding::Encoder<'_, D>,
1047            offset: usize,
1048            _depth: fidl::encoding::Depth,
1049        ) -> fidl::Result<()> {
1050            encoder.debug_check_bounds::<DriverOnSensorEventRequest>(offset);
1051            // Delegate to tuple encoding.
1052            fidl::encoding::Encode::<DriverOnSensorEventRequest, D>::encode(
1053                (
1054                    <fidl_fuchsia_sensors_types::SensorEvent as fidl::encoding::ValueTypeMarker>::borrow(&self.event),
1055                ),
1056                encoder, offset, _depth
1057            )
1058        }
1059    }
1060    unsafe impl<
1061            D: fidl::encoding::ResourceDialect,
1062            T0: fidl::encoding::Encode<fidl_fuchsia_sensors_types::SensorEvent, D>,
1063        > fidl::encoding::Encode<DriverOnSensorEventRequest, D> for (T0,)
1064    {
1065        #[inline]
1066        unsafe fn encode(
1067            self,
1068            encoder: &mut fidl::encoding::Encoder<'_, D>,
1069            offset: usize,
1070            depth: fidl::encoding::Depth,
1071        ) -> fidl::Result<()> {
1072            encoder.debug_check_bounds::<DriverOnSensorEventRequest>(offset);
1073            // Zero out padding regions. There's no need to apply masks
1074            // because the unmasked parts will be overwritten by fields.
1075            // Write the fields.
1076            self.0.encode(encoder, offset + 0, depth)?;
1077            Ok(())
1078        }
1079    }
1080
1081    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1082        for DriverOnSensorEventRequest
1083    {
1084        #[inline(always)]
1085        fn new_empty() -> Self {
1086            Self { event: fidl::new_empty!(fidl_fuchsia_sensors_types::SensorEvent, D) }
1087        }
1088
1089        #[inline]
1090        unsafe fn decode(
1091            &mut self,
1092            decoder: &mut fidl::encoding::Decoder<'_, D>,
1093            offset: usize,
1094            _depth: fidl::encoding::Depth,
1095        ) -> fidl::Result<()> {
1096            decoder.debug_check_bounds::<Self>(offset);
1097            // Verify that padding bytes are zero.
1098            fidl::decode!(
1099                fidl_fuchsia_sensors_types::SensorEvent,
1100                D,
1101                &mut self.event,
1102                decoder,
1103                offset + 0,
1104                _depth
1105            )?;
1106            Ok(())
1107        }
1108    }
1109
1110    impl fidl::encoding::ValueTypeMarker for DriverGetSensorsListResponse {
1111        type Borrowed<'a> = &'a Self;
1112        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1113            value
1114        }
1115    }
1116
1117    unsafe impl fidl::encoding::TypeMarker for DriverGetSensorsListResponse {
1118        type Owned = Self;
1119
1120        #[inline(always)]
1121        fn inline_align(_context: fidl::encoding::Context) -> usize {
1122            8
1123        }
1124
1125        #[inline(always)]
1126        fn inline_size(_context: fidl::encoding::Context) -> usize {
1127            16
1128        }
1129    }
1130
1131    unsafe impl<D: fidl::encoding::ResourceDialect>
1132        fidl::encoding::Encode<DriverGetSensorsListResponse, D> for &DriverGetSensorsListResponse
1133    {
1134        #[inline]
1135        unsafe fn encode(
1136            self,
1137            encoder: &mut fidl::encoding::Encoder<'_, D>,
1138            offset: usize,
1139            _depth: fidl::encoding::Depth,
1140        ) -> fidl::Result<()> {
1141            encoder.debug_check_bounds::<DriverGetSensorsListResponse>(offset);
1142            // Delegate to tuple encoding.
1143            fidl::encoding::Encode::<DriverGetSensorsListResponse, D>::encode(
1144                (
1145                    <fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorInfo> as fidl::encoding::ValueTypeMarker>::borrow(&self.sensor_list),
1146                ),
1147                encoder, offset, _depth
1148            )
1149        }
1150    }
1151    unsafe impl<
1152            D: fidl::encoding::ResourceDialect,
1153            T0: fidl::encoding::Encode<
1154                fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorInfo>,
1155                D,
1156            >,
1157        > fidl::encoding::Encode<DriverGetSensorsListResponse, D> for (T0,)
1158    {
1159        #[inline]
1160        unsafe fn encode(
1161            self,
1162            encoder: &mut fidl::encoding::Encoder<'_, D>,
1163            offset: usize,
1164            depth: fidl::encoding::Depth,
1165        ) -> fidl::Result<()> {
1166            encoder.debug_check_bounds::<DriverGetSensorsListResponse>(offset);
1167            // Zero out padding regions. There's no need to apply masks
1168            // because the unmasked parts will be overwritten by fields.
1169            // Write the fields.
1170            self.0.encode(encoder, offset + 0, depth)?;
1171            Ok(())
1172        }
1173    }
1174
1175    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1176        for DriverGetSensorsListResponse
1177    {
1178        #[inline(always)]
1179        fn new_empty() -> Self {
1180            Self {
1181                sensor_list: fidl::new_empty!(
1182                    fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorInfo>,
1183                    D
1184                ),
1185            }
1186        }
1187
1188        #[inline]
1189        unsafe fn decode(
1190            &mut self,
1191            decoder: &mut fidl::encoding::Decoder<'_, D>,
1192            offset: usize,
1193            _depth: fidl::encoding::Depth,
1194        ) -> fidl::Result<()> {
1195            decoder.debug_check_bounds::<Self>(offset);
1196            // Verify that padding bytes are zero.
1197            fidl::decode!(
1198                fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorInfo>,
1199                D,
1200                &mut self.sensor_list,
1201                decoder,
1202                offset + 0,
1203                _depth
1204            )?;
1205            Ok(())
1206        }
1207    }
1208
1209    impl fidl::encoding::ValueTypeMarker for PlaybackConfigurePlaybackRequest {
1210        type Borrowed<'a> = &'a Self;
1211        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1212            value
1213        }
1214    }
1215
1216    unsafe impl fidl::encoding::TypeMarker for PlaybackConfigurePlaybackRequest {
1217        type Owned = Self;
1218
1219        #[inline(always)]
1220        fn inline_align(_context: fidl::encoding::Context) -> usize {
1221            8
1222        }
1223
1224        #[inline(always)]
1225        fn inline_size(_context: fidl::encoding::Context) -> usize {
1226            16
1227        }
1228    }
1229
1230    unsafe impl<D: fidl::encoding::ResourceDialect>
1231        fidl::encoding::Encode<PlaybackConfigurePlaybackRequest, D>
1232        for &PlaybackConfigurePlaybackRequest
1233    {
1234        #[inline]
1235        unsafe fn encode(
1236            self,
1237            encoder: &mut fidl::encoding::Encoder<'_, D>,
1238            offset: usize,
1239            _depth: fidl::encoding::Depth,
1240        ) -> fidl::Result<()> {
1241            encoder.debug_check_bounds::<PlaybackConfigurePlaybackRequest>(offset);
1242            // Delegate to tuple encoding.
1243            fidl::encoding::Encode::<PlaybackConfigurePlaybackRequest, D>::encode(
1244                (<PlaybackSourceConfig as fidl::encoding::ValueTypeMarker>::borrow(
1245                    &self.source_config,
1246                ),),
1247                encoder,
1248                offset,
1249                _depth,
1250            )
1251        }
1252    }
1253    unsafe impl<
1254            D: fidl::encoding::ResourceDialect,
1255            T0: fidl::encoding::Encode<PlaybackSourceConfig, D>,
1256        > fidl::encoding::Encode<PlaybackConfigurePlaybackRequest, D> for (T0,)
1257    {
1258        #[inline]
1259        unsafe fn encode(
1260            self,
1261            encoder: &mut fidl::encoding::Encoder<'_, D>,
1262            offset: usize,
1263            depth: fidl::encoding::Depth,
1264        ) -> fidl::Result<()> {
1265            encoder.debug_check_bounds::<PlaybackConfigurePlaybackRequest>(offset);
1266            // Zero out padding regions. There's no need to apply masks
1267            // because the unmasked parts will be overwritten by fields.
1268            // Write the fields.
1269            self.0.encode(encoder, offset + 0, depth)?;
1270            Ok(())
1271        }
1272    }
1273
1274    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1275        for PlaybackConfigurePlaybackRequest
1276    {
1277        #[inline(always)]
1278        fn new_empty() -> Self {
1279            Self { source_config: fidl::new_empty!(PlaybackSourceConfig, D) }
1280        }
1281
1282        #[inline]
1283        unsafe fn decode(
1284            &mut self,
1285            decoder: &mut fidl::encoding::Decoder<'_, D>,
1286            offset: usize,
1287            _depth: fidl::encoding::Depth,
1288        ) -> fidl::Result<()> {
1289            decoder.debug_check_bounds::<Self>(offset);
1290            // Verify that padding bytes are zero.
1291            fidl::decode!(
1292                PlaybackSourceConfig,
1293                D,
1294                &mut self.source_config,
1295                decoder,
1296                offset + 0,
1297                _depth
1298            )?;
1299            Ok(())
1300        }
1301    }
1302
1303    impl FilePlaybackConfig {
1304        #[inline(always)]
1305        fn max_ordinal_present(&self) -> u64 {
1306            if let Some(_) = self.file_path {
1307                return 1;
1308            }
1309            0
1310        }
1311    }
1312
1313    impl fidl::encoding::ValueTypeMarker for FilePlaybackConfig {
1314        type Borrowed<'a> = &'a Self;
1315        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1316            value
1317        }
1318    }
1319
1320    unsafe impl fidl::encoding::TypeMarker for FilePlaybackConfig {
1321        type Owned = Self;
1322
1323        #[inline(always)]
1324        fn inline_align(_context: fidl::encoding::Context) -> usize {
1325            8
1326        }
1327
1328        #[inline(always)]
1329        fn inline_size(_context: fidl::encoding::Context) -> usize {
1330            16
1331        }
1332    }
1333
1334    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FilePlaybackConfig, D>
1335        for &FilePlaybackConfig
1336    {
1337        unsafe fn encode(
1338            self,
1339            encoder: &mut fidl::encoding::Encoder<'_, D>,
1340            offset: usize,
1341            mut depth: fidl::encoding::Depth,
1342        ) -> fidl::Result<()> {
1343            encoder.debug_check_bounds::<FilePlaybackConfig>(offset);
1344            // Vector header
1345            let max_ordinal: u64 = self.max_ordinal_present();
1346            encoder.write_num(max_ordinal, offset);
1347            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1348            // Calling encoder.out_of_line_offset(0) is not allowed.
1349            if max_ordinal == 0 {
1350                return Ok(());
1351            }
1352            depth.increment()?;
1353            let envelope_size = 8;
1354            let bytes_len = max_ordinal as usize * envelope_size;
1355            #[allow(unused_variables)]
1356            let offset = encoder.out_of_line_offset(bytes_len);
1357            let mut _prev_end_offset: usize = 0;
1358            if 1 > max_ordinal {
1359                return Ok(());
1360            }
1361
1362            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1363            // are envelope_size bytes.
1364            let cur_offset: usize = (1 - 1) * envelope_size;
1365
1366            // Zero reserved fields.
1367            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1368
1369            // Safety:
1370            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1371            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1372            //   envelope_size bytes, there is always sufficient room.
1373            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedString, D>(
1374                self.file_path.as_ref().map(
1375                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
1376                ),
1377                encoder,
1378                offset + cur_offset,
1379                depth,
1380            )?;
1381
1382            _prev_end_offset = cur_offset + envelope_size;
1383
1384            Ok(())
1385        }
1386    }
1387
1388    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FilePlaybackConfig {
1389        #[inline(always)]
1390        fn new_empty() -> Self {
1391            Self::default()
1392        }
1393
1394        unsafe fn decode(
1395            &mut self,
1396            decoder: &mut fidl::encoding::Decoder<'_, D>,
1397            offset: usize,
1398            mut depth: fidl::encoding::Depth,
1399        ) -> fidl::Result<()> {
1400            decoder.debug_check_bounds::<Self>(offset);
1401            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1402                None => return Err(fidl::Error::NotNullable),
1403                Some(len) => len,
1404            };
1405            // Calling decoder.out_of_line_offset(0) is not allowed.
1406            if len == 0 {
1407                return Ok(());
1408            };
1409            depth.increment()?;
1410            let envelope_size = 8;
1411            let bytes_len = len * envelope_size;
1412            let offset = decoder.out_of_line_offset(bytes_len)?;
1413            // Decode the envelope for each type.
1414            let mut _next_ordinal_to_read = 0;
1415            let mut next_offset = offset;
1416            let end_offset = offset + bytes_len;
1417            _next_ordinal_to_read += 1;
1418            if next_offset >= end_offset {
1419                return Ok(());
1420            }
1421
1422            // Decode unknown envelopes for gaps in ordinals.
1423            while _next_ordinal_to_read < 1 {
1424                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1425                _next_ordinal_to_read += 1;
1426                next_offset += envelope_size;
1427            }
1428
1429            let next_out_of_line = decoder.next_out_of_line();
1430            let handles_before = decoder.remaining_handles();
1431            if let Some((inlined, num_bytes, num_handles)) =
1432                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1433            {
1434                let member_inline_size =
1435                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
1436                        decoder.context,
1437                    );
1438                if inlined != (member_inline_size <= 4) {
1439                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1440                }
1441                let inner_offset;
1442                let mut inner_depth = depth.clone();
1443                if inlined {
1444                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1445                    inner_offset = next_offset;
1446                } else {
1447                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1448                    inner_depth.increment()?;
1449                }
1450                let val_ref = self
1451                    .file_path
1452                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::UnboundedString, D));
1453                fidl::decode!(
1454                    fidl::encoding::UnboundedString,
1455                    D,
1456                    val_ref,
1457                    decoder,
1458                    inner_offset,
1459                    inner_depth
1460                )?;
1461                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1462                {
1463                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1464                }
1465                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1466                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1467                }
1468            }
1469
1470            next_offset += envelope_size;
1471
1472            // Decode the remaining unknown envelopes.
1473            while next_offset < end_offset {
1474                _next_ordinal_to_read += 1;
1475                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1476                next_offset += envelope_size;
1477            }
1478
1479            Ok(())
1480        }
1481    }
1482
1483    impl FixedValuesPlaybackConfig {
1484        #[inline(always)]
1485        fn max_ordinal_present(&self) -> u64 {
1486            if let Some(_) = self.sensor_events {
1487                return 2;
1488            }
1489            if let Some(_) = self.sensor_list {
1490                return 1;
1491            }
1492            0
1493        }
1494    }
1495
1496    impl fidl::encoding::ValueTypeMarker for FixedValuesPlaybackConfig {
1497        type Borrowed<'a> = &'a Self;
1498        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1499            value
1500        }
1501    }
1502
1503    unsafe impl fidl::encoding::TypeMarker for FixedValuesPlaybackConfig {
1504        type Owned = Self;
1505
1506        #[inline(always)]
1507        fn inline_align(_context: fidl::encoding::Context) -> usize {
1508            8
1509        }
1510
1511        #[inline(always)]
1512        fn inline_size(_context: fidl::encoding::Context) -> usize {
1513            16
1514        }
1515    }
1516
1517    unsafe impl<D: fidl::encoding::ResourceDialect>
1518        fidl::encoding::Encode<FixedValuesPlaybackConfig, D> for &FixedValuesPlaybackConfig
1519    {
1520        unsafe fn encode(
1521            self,
1522            encoder: &mut fidl::encoding::Encoder<'_, D>,
1523            offset: usize,
1524            mut depth: fidl::encoding::Depth,
1525        ) -> fidl::Result<()> {
1526            encoder.debug_check_bounds::<FixedValuesPlaybackConfig>(offset);
1527            // Vector header
1528            let max_ordinal: u64 = self.max_ordinal_present();
1529            encoder.write_num(max_ordinal, offset);
1530            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1531            // Calling encoder.out_of_line_offset(0) is not allowed.
1532            if max_ordinal == 0 {
1533                return Ok(());
1534            }
1535            depth.increment()?;
1536            let envelope_size = 8;
1537            let bytes_len = max_ordinal as usize * envelope_size;
1538            #[allow(unused_variables)]
1539            let offset = encoder.out_of_line_offset(bytes_len);
1540            let mut _prev_end_offset: usize = 0;
1541            if 1 > max_ordinal {
1542                return Ok(());
1543            }
1544
1545            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1546            // are envelope_size bytes.
1547            let cur_offset: usize = (1 - 1) * envelope_size;
1548
1549            // Zero reserved fields.
1550            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1551
1552            // Safety:
1553            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1554            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1555            //   envelope_size bytes, there is always sufficient room.
1556            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorInfo>, D>(
1557            self.sensor_list.as_ref().map(<fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorInfo> as fidl::encoding::ValueTypeMarker>::borrow),
1558            encoder, offset + cur_offset, depth
1559        )?;
1560
1561            _prev_end_offset = cur_offset + envelope_size;
1562            if 2 > max_ordinal {
1563                return Ok(());
1564            }
1565
1566            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1567            // are envelope_size bytes.
1568            let cur_offset: usize = (2 - 1) * envelope_size;
1569
1570            // Zero reserved fields.
1571            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1572
1573            // Safety:
1574            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1575            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1576            //   envelope_size bytes, there is always sufficient room.
1577            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorEvent>, D>(
1578            self.sensor_events.as_ref().map(<fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorEvent> as fidl::encoding::ValueTypeMarker>::borrow),
1579            encoder, offset + cur_offset, depth
1580        )?;
1581
1582            _prev_end_offset = cur_offset + envelope_size;
1583
1584            Ok(())
1585        }
1586    }
1587
1588    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1589        for FixedValuesPlaybackConfig
1590    {
1591        #[inline(always)]
1592        fn new_empty() -> Self {
1593            Self::default()
1594        }
1595
1596        unsafe fn decode(
1597            &mut self,
1598            decoder: &mut fidl::encoding::Decoder<'_, D>,
1599            offset: usize,
1600            mut depth: fidl::encoding::Depth,
1601        ) -> fidl::Result<()> {
1602            decoder.debug_check_bounds::<Self>(offset);
1603            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1604                None => return Err(fidl::Error::NotNullable),
1605                Some(len) => len,
1606            };
1607            // Calling decoder.out_of_line_offset(0) is not allowed.
1608            if len == 0 {
1609                return Ok(());
1610            };
1611            depth.increment()?;
1612            let envelope_size = 8;
1613            let bytes_len = len * envelope_size;
1614            let offset = decoder.out_of_line_offset(bytes_len)?;
1615            // Decode the envelope for each type.
1616            let mut _next_ordinal_to_read = 0;
1617            let mut next_offset = offset;
1618            let end_offset = offset + bytes_len;
1619            _next_ordinal_to_read += 1;
1620            if next_offset >= end_offset {
1621                return Ok(());
1622            }
1623
1624            // Decode unknown envelopes for gaps in ordinals.
1625            while _next_ordinal_to_read < 1 {
1626                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1627                _next_ordinal_to_read += 1;
1628                next_offset += envelope_size;
1629            }
1630
1631            let next_out_of_line = decoder.next_out_of_line();
1632            let handles_before = decoder.remaining_handles();
1633            if let Some((inlined, num_bytes, num_handles)) =
1634                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1635            {
1636                let member_inline_size = <fidl::encoding::UnboundedVector<
1637                    fidl_fuchsia_sensors_types::SensorInfo,
1638                > as fidl::encoding::TypeMarker>::inline_size(
1639                    decoder.context
1640                );
1641                if inlined != (member_inline_size <= 4) {
1642                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1643                }
1644                let inner_offset;
1645                let mut inner_depth = depth.clone();
1646                if inlined {
1647                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1648                    inner_offset = next_offset;
1649                } else {
1650                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1651                    inner_depth.increment()?;
1652                }
1653                let val_ref = self.sensor_list.get_or_insert_with(|| {
1654                    fidl::new_empty!(
1655                        fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorInfo>,
1656                        D
1657                    )
1658                });
1659                fidl::decode!(
1660                    fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorInfo>,
1661                    D,
1662                    val_ref,
1663                    decoder,
1664                    inner_offset,
1665                    inner_depth
1666                )?;
1667                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1668                {
1669                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1670                }
1671                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1672                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1673                }
1674            }
1675
1676            next_offset += envelope_size;
1677            _next_ordinal_to_read += 1;
1678            if next_offset >= end_offset {
1679                return Ok(());
1680            }
1681
1682            // Decode unknown envelopes for gaps in ordinals.
1683            while _next_ordinal_to_read < 2 {
1684                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1685                _next_ordinal_to_read += 1;
1686                next_offset += envelope_size;
1687            }
1688
1689            let next_out_of_line = decoder.next_out_of_line();
1690            let handles_before = decoder.remaining_handles();
1691            if let Some((inlined, num_bytes, num_handles)) =
1692                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1693            {
1694                let member_inline_size = <fidl::encoding::UnboundedVector<
1695                    fidl_fuchsia_sensors_types::SensorEvent,
1696                > as fidl::encoding::TypeMarker>::inline_size(
1697                    decoder.context
1698                );
1699                if inlined != (member_inline_size <= 4) {
1700                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1701                }
1702                let inner_offset;
1703                let mut inner_depth = depth.clone();
1704                if inlined {
1705                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1706                    inner_offset = next_offset;
1707                } else {
1708                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1709                    inner_depth.increment()?;
1710                }
1711                let val_ref = self.sensor_events.get_or_insert_with(|| {
1712                    fidl::new_empty!(
1713                        fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorEvent>,
1714                        D
1715                    )
1716                });
1717                fidl::decode!(
1718                    fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorEvent>,
1719                    D,
1720                    val_ref,
1721                    decoder,
1722                    inner_offset,
1723                    inner_depth
1724                )?;
1725                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1726                {
1727                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1728                }
1729                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1730                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1731                }
1732            }
1733
1734            next_offset += envelope_size;
1735
1736            // Decode the remaining unknown envelopes.
1737            while next_offset < end_offset {
1738                _next_ordinal_to_read += 1;
1739                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1740                next_offset += envelope_size;
1741            }
1742
1743            Ok(())
1744        }
1745    }
1746
1747    impl fidl::encoding::ValueTypeMarker for PlaybackSourceConfig {
1748        type Borrowed<'a> = &'a Self;
1749        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1750            value
1751        }
1752    }
1753
1754    unsafe impl fidl::encoding::TypeMarker for PlaybackSourceConfig {
1755        type Owned = Self;
1756
1757        #[inline(always)]
1758        fn inline_align(_context: fidl::encoding::Context) -> usize {
1759            8
1760        }
1761
1762        #[inline(always)]
1763        fn inline_size(_context: fidl::encoding::Context) -> usize {
1764            16
1765        }
1766    }
1767
1768    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PlaybackSourceConfig, D>
1769        for &PlaybackSourceConfig
1770    {
1771        #[inline]
1772        unsafe fn encode(
1773            self,
1774            encoder: &mut fidl::encoding::Encoder<'_, D>,
1775            offset: usize,
1776            _depth: fidl::encoding::Depth,
1777        ) -> fidl::Result<()> {
1778            encoder.debug_check_bounds::<PlaybackSourceConfig>(offset);
1779            encoder.write_num::<u64>(self.ordinal(), offset);
1780            match self {
1781                PlaybackSourceConfig::FixedValuesConfig(ref val) => {
1782                    fidl::encoding::encode_in_envelope::<FixedValuesPlaybackConfig, D>(
1783                        <FixedValuesPlaybackConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
1784                        encoder,
1785                        offset + 8,
1786                        _depth,
1787                    )
1788                }
1789                PlaybackSourceConfig::FilePlaybackConfig(ref val) => {
1790                    fidl::encoding::encode_in_envelope::<FilePlaybackConfig, D>(
1791                        <FilePlaybackConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
1792                        encoder,
1793                        offset + 8,
1794                        _depth,
1795                    )
1796                }
1797                PlaybackSourceConfig::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1798            }
1799        }
1800    }
1801
1802    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PlaybackSourceConfig {
1803        #[inline(always)]
1804        fn new_empty() -> Self {
1805            Self::__SourceBreaking { unknown_ordinal: 0 }
1806        }
1807
1808        #[inline]
1809        unsafe fn decode(
1810            &mut self,
1811            decoder: &mut fidl::encoding::Decoder<'_, D>,
1812            offset: usize,
1813            mut depth: fidl::encoding::Depth,
1814        ) -> fidl::Result<()> {
1815            decoder.debug_check_bounds::<Self>(offset);
1816            #[allow(unused_variables)]
1817            let next_out_of_line = decoder.next_out_of_line();
1818            let handles_before = decoder.remaining_handles();
1819            let (ordinal, inlined, num_bytes, num_handles) =
1820                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1821
1822            let member_inline_size = match ordinal {
1823                1 => <FixedValuesPlaybackConfig as fidl::encoding::TypeMarker>::inline_size(
1824                    decoder.context,
1825                ),
1826                2 => {
1827                    <FilePlaybackConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context)
1828                }
1829                0 => return Err(fidl::Error::UnknownUnionTag),
1830                _ => num_bytes as usize,
1831            };
1832
1833            if inlined != (member_inline_size <= 4) {
1834                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1835            }
1836            let _inner_offset;
1837            if inlined {
1838                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1839                _inner_offset = offset + 8;
1840            } else {
1841                depth.increment()?;
1842                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1843            }
1844            match ordinal {
1845                1 => {
1846                    #[allow(irrefutable_let_patterns)]
1847                    if let PlaybackSourceConfig::FixedValuesConfig(_) = self {
1848                        // Do nothing, read the value into the object
1849                    } else {
1850                        // Initialize `self` to the right variant
1851                        *self = PlaybackSourceConfig::FixedValuesConfig(fidl::new_empty!(
1852                            FixedValuesPlaybackConfig,
1853                            D
1854                        ));
1855                    }
1856                    #[allow(irrefutable_let_patterns)]
1857                    if let PlaybackSourceConfig::FixedValuesConfig(ref mut val) = self {
1858                        fidl::decode!(
1859                            FixedValuesPlaybackConfig,
1860                            D,
1861                            val,
1862                            decoder,
1863                            _inner_offset,
1864                            depth
1865                        )?;
1866                    } else {
1867                        unreachable!()
1868                    }
1869                }
1870                2 => {
1871                    #[allow(irrefutable_let_patterns)]
1872                    if let PlaybackSourceConfig::FilePlaybackConfig(_) = self {
1873                        // Do nothing, read the value into the object
1874                    } else {
1875                        // Initialize `self` to the right variant
1876                        *self = PlaybackSourceConfig::FilePlaybackConfig(fidl::new_empty!(
1877                            FilePlaybackConfig,
1878                            D
1879                        ));
1880                    }
1881                    #[allow(irrefutable_let_patterns)]
1882                    if let PlaybackSourceConfig::FilePlaybackConfig(ref mut val) = self {
1883                        fidl::decode!(FilePlaybackConfig, D, val, decoder, _inner_offset, depth)?;
1884                    } else {
1885                        unreachable!()
1886                    }
1887                }
1888                #[allow(deprecated)]
1889                ordinal => {
1890                    for _ in 0..num_handles {
1891                        decoder.drop_next_handle()?;
1892                    }
1893                    *self = PlaybackSourceConfig::__SourceBreaking { unknown_ordinal: ordinal };
1894                }
1895            }
1896            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1897                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1898            }
1899            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1900                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1901            }
1902            Ok(())
1903        }
1904    }
1905}