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__common::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__common::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__common::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__common::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__common::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
430pub mod driver_ordinals {
431    pub const GET_SENSORS_LIST: u64 = 0x6a30da06929d426b;
432    pub const ACTIVATE_SENSOR: u64 = 0x6ff16c620f9f3c5b;
433    pub const DEACTIVATE_SENSOR: u64 = 0x64f003527d44ec55;
434    pub const CONFIGURE_SENSOR_RATE: u64 = 0x78a264bc9c645045;
435    pub const ON_SENSOR_EVENT: u64 = 0x2aaf0636bb3e1df9;
436}
437
438pub mod playback_ordinals {
439    pub const CONFIGURE_PLAYBACK: u64 = 0x64327bb27c3d8742;
440}
441
442mod internal {
443    use super::*;
444    unsafe impl fidl::encoding::TypeMarker for ActivateSensorError {
445        type Owned = Self;
446
447        #[inline(always)]
448        fn inline_align(_context: fidl::encoding::Context) -> usize {
449            std::mem::align_of::<u32>()
450        }
451
452        #[inline(always)]
453        fn inline_size(_context: fidl::encoding::Context) -> usize {
454            std::mem::size_of::<u32>()
455        }
456
457        #[inline(always)]
458        fn encode_is_copy() -> bool {
459            false
460        }
461
462        #[inline(always)]
463        fn decode_is_copy() -> bool {
464            false
465        }
466    }
467
468    impl fidl::encoding::ValueTypeMarker for ActivateSensorError {
469        type Borrowed<'a> = Self;
470        #[inline(always)]
471        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
472            *value
473        }
474    }
475
476    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
477        for ActivateSensorError
478    {
479        #[inline]
480        unsafe fn encode(
481            self,
482            encoder: &mut fidl::encoding::Encoder<'_, D>,
483            offset: usize,
484            _depth: fidl::encoding::Depth,
485        ) -> fidl::Result<()> {
486            encoder.debug_check_bounds::<Self>(offset);
487            encoder.write_num(self.into_primitive(), offset);
488            Ok(())
489        }
490    }
491
492    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ActivateSensorError {
493        #[inline(always)]
494        fn new_empty() -> Self {
495            Self::unknown()
496        }
497
498        #[inline]
499        unsafe fn decode(
500            &mut self,
501            decoder: &mut fidl::encoding::Decoder<'_, D>,
502            offset: usize,
503            _depth: fidl::encoding::Depth,
504        ) -> fidl::Result<()> {
505            decoder.debug_check_bounds::<Self>(offset);
506            let prim = decoder.read_num::<u32>(offset);
507
508            *self = Self::from_primitive_allow_unknown(prim);
509            Ok(())
510        }
511    }
512    unsafe impl fidl::encoding::TypeMarker for ConfigurePlaybackError {
513        type Owned = Self;
514
515        #[inline(always)]
516        fn inline_align(_context: fidl::encoding::Context) -> usize {
517            std::mem::align_of::<u32>()
518        }
519
520        #[inline(always)]
521        fn inline_size(_context: fidl::encoding::Context) -> usize {
522            std::mem::size_of::<u32>()
523        }
524
525        #[inline(always)]
526        fn encode_is_copy() -> bool {
527            false
528        }
529
530        #[inline(always)]
531        fn decode_is_copy() -> bool {
532            false
533        }
534    }
535
536    impl fidl::encoding::ValueTypeMarker for ConfigurePlaybackError {
537        type Borrowed<'a> = Self;
538        #[inline(always)]
539        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
540            *value
541        }
542    }
543
544    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
545        for ConfigurePlaybackError
546    {
547        #[inline]
548        unsafe fn encode(
549            self,
550            encoder: &mut fidl::encoding::Encoder<'_, D>,
551            offset: usize,
552            _depth: fidl::encoding::Depth,
553        ) -> fidl::Result<()> {
554            encoder.debug_check_bounds::<Self>(offset);
555            encoder.write_num(self.into_primitive(), offset);
556            Ok(())
557        }
558    }
559
560    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
561        for ConfigurePlaybackError
562    {
563        #[inline(always)]
564        fn new_empty() -> Self {
565            Self::unknown()
566        }
567
568        #[inline]
569        unsafe fn decode(
570            &mut self,
571            decoder: &mut fidl::encoding::Decoder<'_, D>,
572            offset: usize,
573            _depth: fidl::encoding::Depth,
574        ) -> fidl::Result<()> {
575            decoder.debug_check_bounds::<Self>(offset);
576            let prim = decoder.read_num::<u32>(offset);
577
578            *self = Self::from_primitive_allow_unknown(prim);
579            Ok(())
580        }
581    }
582    unsafe impl fidl::encoding::TypeMarker for ConfigureSensorRateError {
583        type Owned = Self;
584
585        #[inline(always)]
586        fn inline_align(_context: fidl::encoding::Context) -> usize {
587            std::mem::align_of::<u32>()
588        }
589
590        #[inline(always)]
591        fn inline_size(_context: fidl::encoding::Context) -> usize {
592            std::mem::size_of::<u32>()
593        }
594
595        #[inline(always)]
596        fn encode_is_copy() -> bool {
597            false
598        }
599
600        #[inline(always)]
601        fn decode_is_copy() -> bool {
602            false
603        }
604    }
605
606    impl fidl::encoding::ValueTypeMarker for ConfigureSensorRateError {
607        type Borrowed<'a> = Self;
608        #[inline(always)]
609        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
610            *value
611        }
612    }
613
614    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
615        for ConfigureSensorRateError
616    {
617        #[inline]
618        unsafe fn encode(
619            self,
620            encoder: &mut fidl::encoding::Encoder<'_, D>,
621            offset: usize,
622            _depth: fidl::encoding::Depth,
623        ) -> fidl::Result<()> {
624            encoder.debug_check_bounds::<Self>(offset);
625            encoder.write_num(self.into_primitive(), offset);
626            Ok(())
627        }
628    }
629
630    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
631        for ConfigureSensorRateError
632    {
633        #[inline(always)]
634        fn new_empty() -> Self {
635            Self::unknown()
636        }
637
638        #[inline]
639        unsafe fn decode(
640            &mut self,
641            decoder: &mut fidl::encoding::Decoder<'_, D>,
642            offset: usize,
643            _depth: fidl::encoding::Depth,
644        ) -> fidl::Result<()> {
645            decoder.debug_check_bounds::<Self>(offset);
646            let prim = decoder.read_num::<u32>(offset);
647
648            *self = Self::from_primitive_allow_unknown(prim);
649            Ok(())
650        }
651    }
652    unsafe impl fidl::encoding::TypeMarker for DeactivateSensorError {
653        type Owned = Self;
654
655        #[inline(always)]
656        fn inline_align(_context: fidl::encoding::Context) -> usize {
657            std::mem::align_of::<u32>()
658        }
659
660        #[inline(always)]
661        fn inline_size(_context: fidl::encoding::Context) -> usize {
662            std::mem::size_of::<u32>()
663        }
664
665        #[inline(always)]
666        fn encode_is_copy() -> bool {
667            false
668        }
669
670        #[inline(always)]
671        fn decode_is_copy() -> bool {
672            false
673        }
674    }
675
676    impl fidl::encoding::ValueTypeMarker for DeactivateSensorError {
677        type Borrowed<'a> = Self;
678        #[inline(always)]
679        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
680            *value
681        }
682    }
683
684    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
685        for DeactivateSensorError
686    {
687        #[inline]
688        unsafe fn encode(
689            self,
690            encoder: &mut fidl::encoding::Encoder<'_, D>,
691            offset: usize,
692            _depth: fidl::encoding::Depth,
693        ) -> fidl::Result<()> {
694            encoder.debug_check_bounds::<Self>(offset);
695            encoder.write_num(self.into_primitive(), offset);
696            Ok(())
697        }
698    }
699
700    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeactivateSensorError {
701        #[inline(always)]
702        fn new_empty() -> Self {
703            Self::unknown()
704        }
705
706        #[inline]
707        unsafe fn decode(
708            &mut self,
709            decoder: &mut fidl::encoding::Decoder<'_, D>,
710            offset: usize,
711            _depth: fidl::encoding::Depth,
712        ) -> fidl::Result<()> {
713            decoder.debug_check_bounds::<Self>(offset);
714            let prim = decoder.read_num::<u32>(offset);
715
716            *self = Self::from_primitive_allow_unknown(prim);
717            Ok(())
718        }
719    }
720
721    impl fidl::encoding::ValueTypeMarker for DriverActivateSensorRequest {
722        type Borrowed<'a> = &'a Self;
723        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
724            value
725        }
726    }
727
728    unsafe impl fidl::encoding::TypeMarker for DriverActivateSensorRequest {
729        type Owned = Self;
730
731        #[inline(always)]
732        fn inline_align(_context: fidl::encoding::Context) -> usize {
733            4
734        }
735
736        #[inline(always)]
737        fn inline_size(_context: fidl::encoding::Context) -> usize {
738            4
739        }
740        #[inline(always)]
741        fn encode_is_copy() -> bool {
742            true
743        }
744
745        #[inline(always)]
746        fn decode_is_copy() -> bool {
747            true
748        }
749    }
750
751    unsafe impl<D: fidl::encoding::ResourceDialect>
752        fidl::encoding::Encode<DriverActivateSensorRequest, D> for &DriverActivateSensorRequest
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::<DriverActivateSensorRequest>(offset);
762            unsafe {
763                // Copy the object into the buffer.
764                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
765                (buf_ptr as *mut DriverActivateSensorRequest)
766                    .write_unaligned((self as *const DriverActivateSensorRequest).read());
767                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
768                // done second because the memcpy will write garbage to these bytes.
769            }
770            Ok(())
771        }
772    }
773    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
774        fidl::encoding::Encode<DriverActivateSensorRequest, D> for (T0,)
775    {
776        #[inline]
777        unsafe fn encode(
778            self,
779            encoder: &mut fidl::encoding::Encoder<'_, D>,
780            offset: usize,
781            depth: fidl::encoding::Depth,
782        ) -> fidl::Result<()> {
783            encoder.debug_check_bounds::<DriverActivateSensorRequest>(offset);
784            // Zero out padding regions. There's no need to apply masks
785            // because the unmasked parts will be overwritten by fields.
786            // Write the fields.
787            self.0.encode(encoder, offset + 0, depth)?;
788            Ok(())
789        }
790    }
791
792    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
793        for DriverActivateSensorRequest
794    {
795        #[inline(always)]
796        fn new_empty() -> Self {
797            Self { sensor_id: fidl::new_empty!(i32, D) }
798        }
799
800        #[inline]
801        unsafe fn decode(
802            &mut self,
803            decoder: &mut fidl::encoding::Decoder<'_, D>,
804            offset: usize,
805            _depth: fidl::encoding::Depth,
806        ) -> fidl::Result<()> {
807            decoder.debug_check_bounds::<Self>(offset);
808            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
809            // Verify that padding bytes are zero.
810            // Copy from the buffer into the object.
811            unsafe {
812                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
813            }
814            Ok(())
815        }
816    }
817
818    impl fidl::encoding::ValueTypeMarker for DriverConfigureSensorRateRequest {
819        type Borrowed<'a> = &'a Self;
820        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
821            value
822        }
823    }
824
825    unsafe impl fidl::encoding::TypeMarker for DriverConfigureSensorRateRequest {
826        type Owned = Self;
827
828        #[inline(always)]
829        fn inline_align(_context: fidl::encoding::Context) -> usize {
830            8
831        }
832
833        #[inline(always)]
834        fn inline_size(_context: fidl::encoding::Context) -> usize {
835            24
836        }
837    }
838
839    unsafe impl<D: fidl::encoding::ResourceDialect>
840        fidl::encoding::Encode<DriverConfigureSensorRateRequest, D>
841        for &DriverConfigureSensorRateRequest
842    {
843        #[inline]
844        unsafe fn encode(
845            self,
846            encoder: &mut fidl::encoding::Encoder<'_, D>,
847            offset: usize,
848            _depth: fidl::encoding::Depth,
849        ) -> fidl::Result<()> {
850            encoder.debug_check_bounds::<DriverConfigureSensorRateRequest>(offset);
851            // Delegate to tuple encoding.
852            fidl::encoding::Encode::<DriverConfigureSensorRateRequest, D>::encode(
853                (
854                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.sensor_id),
855                    <fidl_fuchsia_sensors_types__common::SensorRateConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.sensor_rate_config),
856                ),
857                encoder, offset, _depth
858            )
859        }
860    }
861    unsafe impl<
862            D: fidl::encoding::ResourceDialect,
863            T0: fidl::encoding::Encode<i32, D>,
864            T1: fidl::encoding::Encode<fidl_fuchsia_sensors_types__common::SensorRateConfig, D>,
865        > fidl::encoding::Encode<DriverConfigureSensorRateRequest, D> for (T0, T1)
866    {
867        #[inline]
868        unsafe fn encode(
869            self,
870            encoder: &mut fidl::encoding::Encoder<'_, D>,
871            offset: usize,
872            depth: fidl::encoding::Depth,
873        ) -> fidl::Result<()> {
874            encoder.debug_check_bounds::<DriverConfigureSensorRateRequest>(offset);
875            // Zero out padding regions. There's no need to apply masks
876            // because the unmasked parts will be overwritten by fields.
877            unsafe {
878                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
879                (ptr as *mut u64).write_unaligned(0);
880            }
881            // Write the fields.
882            self.0.encode(encoder, offset + 0, depth)?;
883            self.1.encode(encoder, offset + 8, depth)?;
884            Ok(())
885        }
886    }
887
888    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
889        for DriverConfigureSensorRateRequest
890    {
891        #[inline(always)]
892        fn new_empty() -> Self {
893            Self {
894                sensor_id: fidl::new_empty!(i32, D),
895                sensor_rate_config: fidl::new_empty!(
896                    fidl_fuchsia_sensors_types__common::SensorRateConfig,
897                    D
898                ),
899            }
900        }
901
902        #[inline]
903        unsafe fn decode(
904            &mut self,
905            decoder: &mut fidl::encoding::Decoder<'_, D>,
906            offset: usize,
907            _depth: fidl::encoding::Depth,
908        ) -> fidl::Result<()> {
909            decoder.debug_check_bounds::<Self>(offset);
910            // Verify that padding bytes are zero.
911            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
912            let padval = unsafe { (ptr as *const u64).read_unaligned() };
913            let mask = 0xffffffff00000000u64;
914            let maskedval = padval & mask;
915            if maskedval != 0 {
916                return Err(fidl::Error::NonZeroPadding {
917                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
918                });
919            }
920            fidl::decode!(i32, D, &mut self.sensor_id, decoder, offset + 0, _depth)?;
921            fidl::decode!(
922                fidl_fuchsia_sensors_types__common::SensorRateConfig,
923                D,
924                &mut self.sensor_rate_config,
925                decoder,
926                offset + 8,
927                _depth
928            )?;
929            Ok(())
930        }
931    }
932
933    impl fidl::encoding::ValueTypeMarker for DriverDeactivateSensorRequest {
934        type Borrowed<'a> = &'a Self;
935        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
936            value
937        }
938    }
939
940    unsafe impl fidl::encoding::TypeMarker for DriverDeactivateSensorRequest {
941        type Owned = Self;
942
943        #[inline(always)]
944        fn inline_align(_context: fidl::encoding::Context) -> usize {
945            4
946        }
947
948        #[inline(always)]
949        fn inline_size(_context: fidl::encoding::Context) -> usize {
950            4
951        }
952        #[inline(always)]
953        fn encode_is_copy() -> bool {
954            true
955        }
956
957        #[inline(always)]
958        fn decode_is_copy() -> bool {
959            true
960        }
961    }
962
963    unsafe impl<D: fidl::encoding::ResourceDialect>
964        fidl::encoding::Encode<DriverDeactivateSensorRequest, D>
965        for &DriverDeactivateSensorRequest
966    {
967        #[inline]
968        unsafe fn encode(
969            self,
970            encoder: &mut fidl::encoding::Encoder<'_, D>,
971            offset: usize,
972            _depth: fidl::encoding::Depth,
973        ) -> fidl::Result<()> {
974            encoder.debug_check_bounds::<DriverDeactivateSensorRequest>(offset);
975            unsafe {
976                // Copy the object into the buffer.
977                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
978                (buf_ptr as *mut DriverDeactivateSensorRequest)
979                    .write_unaligned((self as *const DriverDeactivateSensorRequest).read());
980                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
981                // done second because the memcpy will write garbage to these bytes.
982            }
983            Ok(())
984        }
985    }
986    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
987        fidl::encoding::Encode<DriverDeactivateSensorRequest, D> for (T0,)
988    {
989        #[inline]
990        unsafe fn encode(
991            self,
992            encoder: &mut fidl::encoding::Encoder<'_, D>,
993            offset: usize,
994            depth: fidl::encoding::Depth,
995        ) -> fidl::Result<()> {
996            encoder.debug_check_bounds::<DriverDeactivateSensorRequest>(offset);
997            // Zero out padding regions. There's no need to apply masks
998            // because the unmasked parts will be overwritten by fields.
999            // Write the fields.
1000            self.0.encode(encoder, offset + 0, depth)?;
1001            Ok(())
1002        }
1003    }
1004
1005    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1006        for DriverDeactivateSensorRequest
1007    {
1008        #[inline(always)]
1009        fn new_empty() -> Self {
1010            Self { sensor_id: fidl::new_empty!(i32, D) }
1011        }
1012
1013        #[inline]
1014        unsafe fn decode(
1015            &mut self,
1016            decoder: &mut fidl::encoding::Decoder<'_, D>,
1017            offset: usize,
1018            _depth: fidl::encoding::Depth,
1019        ) -> fidl::Result<()> {
1020            decoder.debug_check_bounds::<Self>(offset);
1021            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1022            // Verify that padding bytes are zero.
1023            // Copy from the buffer into the object.
1024            unsafe {
1025                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1026            }
1027            Ok(())
1028        }
1029    }
1030
1031    impl fidl::encoding::ValueTypeMarker for DriverOnSensorEventRequest {
1032        type Borrowed<'a> = &'a Self;
1033        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1034            value
1035        }
1036    }
1037
1038    unsafe impl fidl::encoding::TypeMarker for DriverOnSensorEventRequest {
1039        type Owned = Self;
1040
1041        #[inline(always)]
1042        fn inline_align(_context: fidl::encoding::Context) -> usize {
1043            8
1044        }
1045
1046        #[inline(always)]
1047        fn inline_size(_context: fidl::encoding::Context) -> usize {
1048            40
1049        }
1050    }
1051
1052    unsafe impl<D: fidl::encoding::ResourceDialect>
1053        fidl::encoding::Encode<DriverOnSensorEventRequest, D> for &DriverOnSensorEventRequest
1054    {
1055        #[inline]
1056        unsafe fn encode(
1057            self,
1058            encoder: &mut fidl::encoding::Encoder<'_, D>,
1059            offset: usize,
1060            _depth: fidl::encoding::Depth,
1061        ) -> fidl::Result<()> {
1062            encoder.debug_check_bounds::<DriverOnSensorEventRequest>(offset);
1063            // Delegate to tuple encoding.
1064            fidl::encoding::Encode::<DriverOnSensorEventRequest, D>::encode(
1065                (
1066                    <fidl_fuchsia_sensors_types__common::SensorEvent as fidl::encoding::ValueTypeMarker>::borrow(&self.event),
1067                ),
1068                encoder, offset, _depth
1069            )
1070        }
1071    }
1072    unsafe impl<
1073            D: fidl::encoding::ResourceDialect,
1074            T0: fidl::encoding::Encode<fidl_fuchsia_sensors_types__common::SensorEvent, D>,
1075        > fidl::encoding::Encode<DriverOnSensorEventRequest, D> for (T0,)
1076    {
1077        #[inline]
1078        unsafe fn encode(
1079            self,
1080            encoder: &mut fidl::encoding::Encoder<'_, D>,
1081            offset: usize,
1082            depth: fidl::encoding::Depth,
1083        ) -> fidl::Result<()> {
1084            encoder.debug_check_bounds::<DriverOnSensorEventRequest>(offset);
1085            // Zero out padding regions. There's no need to apply masks
1086            // because the unmasked parts will be overwritten by fields.
1087            // Write the fields.
1088            self.0.encode(encoder, offset + 0, depth)?;
1089            Ok(())
1090        }
1091    }
1092
1093    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1094        for DriverOnSensorEventRequest
1095    {
1096        #[inline(always)]
1097        fn new_empty() -> Self {
1098            Self { event: fidl::new_empty!(fidl_fuchsia_sensors_types__common::SensorEvent, D) }
1099        }
1100
1101        #[inline]
1102        unsafe fn decode(
1103            &mut self,
1104            decoder: &mut fidl::encoding::Decoder<'_, D>,
1105            offset: usize,
1106            _depth: fidl::encoding::Depth,
1107        ) -> fidl::Result<()> {
1108            decoder.debug_check_bounds::<Self>(offset);
1109            // Verify that padding bytes are zero.
1110            fidl::decode!(
1111                fidl_fuchsia_sensors_types__common::SensorEvent,
1112                D,
1113                &mut self.event,
1114                decoder,
1115                offset + 0,
1116                _depth
1117            )?;
1118            Ok(())
1119        }
1120    }
1121
1122    impl fidl::encoding::ValueTypeMarker for DriverGetSensorsListResponse {
1123        type Borrowed<'a> = &'a Self;
1124        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1125            value
1126        }
1127    }
1128
1129    unsafe impl fidl::encoding::TypeMarker for DriverGetSensorsListResponse {
1130        type Owned = Self;
1131
1132        #[inline(always)]
1133        fn inline_align(_context: fidl::encoding::Context) -> usize {
1134            8
1135        }
1136
1137        #[inline(always)]
1138        fn inline_size(_context: fidl::encoding::Context) -> usize {
1139            16
1140        }
1141    }
1142
1143    unsafe impl<D: fidl::encoding::ResourceDialect>
1144        fidl::encoding::Encode<DriverGetSensorsListResponse, D> for &DriverGetSensorsListResponse
1145    {
1146        #[inline]
1147        unsafe fn encode(
1148            self,
1149            encoder: &mut fidl::encoding::Encoder<'_, D>,
1150            offset: usize,
1151            _depth: fidl::encoding::Depth,
1152        ) -> fidl::Result<()> {
1153            encoder.debug_check_bounds::<DriverGetSensorsListResponse>(offset);
1154            // Delegate to tuple encoding.
1155            fidl::encoding::Encode::<DriverGetSensorsListResponse, D>::encode(
1156                (
1157                    <fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types__common::SensorInfo> as fidl::encoding::ValueTypeMarker>::borrow(&self.sensor_list),
1158                ),
1159                encoder, offset, _depth
1160            )
1161        }
1162    }
1163    unsafe impl<
1164            D: fidl::encoding::ResourceDialect,
1165            T0: fidl::encoding::Encode<
1166                fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types__common::SensorInfo>,
1167                D,
1168            >,
1169        > fidl::encoding::Encode<DriverGetSensorsListResponse, D> for (T0,)
1170    {
1171        #[inline]
1172        unsafe fn encode(
1173            self,
1174            encoder: &mut fidl::encoding::Encoder<'_, D>,
1175            offset: usize,
1176            depth: fidl::encoding::Depth,
1177        ) -> fidl::Result<()> {
1178            encoder.debug_check_bounds::<DriverGetSensorsListResponse>(offset);
1179            // Zero out padding regions. There's no need to apply masks
1180            // because the unmasked parts will be overwritten by fields.
1181            // Write the fields.
1182            self.0.encode(encoder, offset + 0, depth)?;
1183            Ok(())
1184        }
1185    }
1186
1187    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1188        for DriverGetSensorsListResponse
1189    {
1190        #[inline(always)]
1191        fn new_empty() -> Self {
1192            Self {
1193                sensor_list: fidl::new_empty!(
1194                    fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types__common::SensorInfo>,
1195                    D
1196                ),
1197            }
1198        }
1199
1200        #[inline]
1201        unsafe fn decode(
1202            &mut self,
1203            decoder: &mut fidl::encoding::Decoder<'_, D>,
1204            offset: usize,
1205            _depth: fidl::encoding::Depth,
1206        ) -> fidl::Result<()> {
1207            decoder.debug_check_bounds::<Self>(offset);
1208            // Verify that padding bytes are zero.
1209            fidl::decode!(
1210                fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types__common::SensorInfo>,
1211                D,
1212                &mut self.sensor_list,
1213                decoder,
1214                offset + 0,
1215                _depth
1216            )?;
1217            Ok(())
1218        }
1219    }
1220
1221    impl fidl::encoding::ValueTypeMarker for PlaybackConfigurePlaybackRequest {
1222        type Borrowed<'a> = &'a Self;
1223        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1224            value
1225        }
1226    }
1227
1228    unsafe impl fidl::encoding::TypeMarker for PlaybackConfigurePlaybackRequest {
1229        type Owned = Self;
1230
1231        #[inline(always)]
1232        fn inline_align(_context: fidl::encoding::Context) -> usize {
1233            8
1234        }
1235
1236        #[inline(always)]
1237        fn inline_size(_context: fidl::encoding::Context) -> usize {
1238            16
1239        }
1240    }
1241
1242    unsafe impl<D: fidl::encoding::ResourceDialect>
1243        fidl::encoding::Encode<PlaybackConfigurePlaybackRequest, D>
1244        for &PlaybackConfigurePlaybackRequest
1245    {
1246        #[inline]
1247        unsafe fn encode(
1248            self,
1249            encoder: &mut fidl::encoding::Encoder<'_, D>,
1250            offset: usize,
1251            _depth: fidl::encoding::Depth,
1252        ) -> fidl::Result<()> {
1253            encoder.debug_check_bounds::<PlaybackConfigurePlaybackRequest>(offset);
1254            // Delegate to tuple encoding.
1255            fidl::encoding::Encode::<PlaybackConfigurePlaybackRequest, D>::encode(
1256                (<PlaybackSourceConfig as fidl::encoding::ValueTypeMarker>::borrow(
1257                    &self.source_config,
1258                ),),
1259                encoder,
1260                offset,
1261                _depth,
1262            )
1263        }
1264    }
1265    unsafe impl<
1266            D: fidl::encoding::ResourceDialect,
1267            T0: fidl::encoding::Encode<PlaybackSourceConfig, D>,
1268        > fidl::encoding::Encode<PlaybackConfigurePlaybackRequest, D> for (T0,)
1269    {
1270        #[inline]
1271        unsafe fn encode(
1272            self,
1273            encoder: &mut fidl::encoding::Encoder<'_, D>,
1274            offset: usize,
1275            depth: fidl::encoding::Depth,
1276        ) -> fidl::Result<()> {
1277            encoder.debug_check_bounds::<PlaybackConfigurePlaybackRequest>(offset);
1278            // Zero out padding regions. There's no need to apply masks
1279            // because the unmasked parts will be overwritten by fields.
1280            // Write the fields.
1281            self.0.encode(encoder, offset + 0, depth)?;
1282            Ok(())
1283        }
1284    }
1285
1286    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1287        for PlaybackConfigurePlaybackRequest
1288    {
1289        #[inline(always)]
1290        fn new_empty() -> Self {
1291            Self { source_config: fidl::new_empty!(PlaybackSourceConfig, D) }
1292        }
1293
1294        #[inline]
1295        unsafe fn decode(
1296            &mut self,
1297            decoder: &mut fidl::encoding::Decoder<'_, D>,
1298            offset: usize,
1299            _depth: fidl::encoding::Depth,
1300        ) -> fidl::Result<()> {
1301            decoder.debug_check_bounds::<Self>(offset);
1302            // Verify that padding bytes are zero.
1303            fidl::decode!(
1304                PlaybackSourceConfig,
1305                D,
1306                &mut self.source_config,
1307                decoder,
1308                offset + 0,
1309                _depth
1310            )?;
1311            Ok(())
1312        }
1313    }
1314
1315    impl FilePlaybackConfig {
1316        #[inline(always)]
1317        fn max_ordinal_present(&self) -> u64 {
1318            if let Some(_) = self.file_path {
1319                return 1;
1320            }
1321            0
1322        }
1323    }
1324
1325    impl fidl::encoding::ValueTypeMarker for FilePlaybackConfig {
1326        type Borrowed<'a> = &'a Self;
1327        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1328            value
1329        }
1330    }
1331
1332    unsafe impl fidl::encoding::TypeMarker for FilePlaybackConfig {
1333        type Owned = Self;
1334
1335        #[inline(always)]
1336        fn inline_align(_context: fidl::encoding::Context) -> usize {
1337            8
1338        }
1339
1340        #[inline(always)]
1341        fn inline_size(_context: fidl::encoding::Context) -> usize {
1342            16
1343        }
1344    }
1345
1346    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FilePlaybackConfig, D>
1347        for &FilePlaybackConfig
1348    {
1349        unsafe fn encode(
1350            self,
1351            encoder: &mut fidl::encoding::Encoder<'_, D>,
1352            offset: usize,
1353            mut depth: fidl::encoding::Depth,
1354        ) -> fidl::Result<()> {
1355            encoder.debug_check_bounds::<FilePlaybackConfig>(offset);
1356            // Vector header
1357            let max_ordinal: u64 = self.max_ordinal_present();
1358            encoder.write_num(max_ordinal, offset);
1359            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1360            // Calling encoder.out_of_line_offset(0) is not allowed.
1361            if max_ordinal == 0 {
1362                return Ok(());
1363            }
1364            depth.increment()?;
1365            let envelope_size = 8;
1366            let bytes_len = max_ordinal as usize * envelope_size;
1367            #[allow(unused_variables)]
1368            let offset = encoder.out_of_line_offset(bytes_len);
1369            let mut _prev_end_offset: usize = 0;
1370            if 1 > max_ordinal {
1371                return Ok(());
1372            }
1373
1374            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1375            // are envelope_size bytes.
1376            let cur_offset: usize = (1 - 1) * envelope_size;
1377
1378            // Zero reserved fields.
1379            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1380
1381            // Safety:
1382            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1383            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1384            //   envelope_size bytes, there is always sufficient room.
1385            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedString, D>(
1386                self.file_path.as_ref().map(
1387                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
1388                ),
1389                encoder,
1390                offset + cur_offset,
1391                depth,
1392            )?;
1393
1394            _prev_end_offset = cur_offset + envelope_size;
1395
1396            Ok(())
1397        }
1398    }
1399
1400    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FilePlaybackConfig {
1401        #[inline(always)]
1402        fn new_empty() -> Self {
1403            Self::default()
1404        }
1405
1406        unsafe fn decode(
1407            &mut self,
1408            decoder: &mut fidl::encoding::Decoder<'_, D>,
1409            offset: usize,
1410            mut depth: fidl::encoding::Depth,
1411        ) -> fidl::Result<()> {
1412            decoder.debug_check_bounds::<Self>(offset);
1413            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1414                None => return Err(fidl::Error::NotNullable),
1415                Some(len) => len,
1416            };
1417            // Calling decoder.out_of_line_offset(0) is not allowed.
1418            if len == 0 {
1419                return Ok(());
1420            };
1421            depth.increment()?;
1422            let envelope_size = 8;
1423            let bytes_len = len * envelope_size;
1424            let offset = decoder.out_of_line_offset(bytes_len)?;
1425            // Decode the envelope for each type.
1426            let mut _next_ordinal_to_read = 0;
1427            let mut next_offset = offset;
1428            let end_offset = offset + bytes_len;
1429            _next_ordinal_to_read += 1;
1430            if next_offset >= end_offset {
1431                return Ok(());
1432            }
1433
1434            // Decode unknown envelopes for gaps in ordinals.
1435            while _next_ordinal_to_read < 1 {
1436                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1437                _next_ordinal_to_read += 1;
1438                next_offset += envelope_size;
1439            }
1440
1441            let next_out_of_line = decoder.next_out_of_line();
1442            let handles_before = decoder.remaining_handles();
1443            if let Some((inlined, num_bytes, num_handles)) =
1444                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1445            {
1446                let member_inline_size =
1447                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
1448                        decoder.context,
1449                    );
1450                if inlined != (member_inline_size <= 4) {
1451                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1452                }
1453                let inner_offset;
1454                let mut inner_depth = depth.clone();
1455                if inlined {
1456                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1457                    inner_offset = next_offset;
1458                } else {
1459                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1460                    inner_depth.increment()?;
1461                }
1462                let val_ref = self
1463                    .file_path
1464                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::UnboundedString, D));
1465                fidl::decode!(
1466                    fidl::encoding::UnboundedString,
1467                    D,
1468                    val_ref,
1469                    decoder,
1470                    inner_offset,
1471                    inner_depth
1472                )?;
1473                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1474                {
1475                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1476                }
1477                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1478                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1479                }
1480            }
1481
1482            next_offset += envelope_size;
1483
1484            // Decode the remaining unknown envelopes.
1485            while next_offset < end_offset {
1486                _next_ordinal_to_read += 1;
1487                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1488                next_offset += envelope_size;
1489            }
1490
1491            Ok(())
1492        }
1493    }
1494
1495    impl FixedValuesPlaybackConfig {
1496        #[inline(always)]
1497        fn max_ordinal_present(&self) -> u64 {
1498            if let Some(_) = self.sensor_events {
1499                return 2;
1500            }
1501            if let Some(_) = self.sensor_list {
1502                return 1;
1503            }
1504            0
1505        }
1506    }
1507
1508    impl fidl::encoding::ValueTypeMarker for FixedValuesPlaybackConfig {
1509        type Borrowed<'a> = &'a Self;
1510        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1511            value
1512        }
1513    }
1514
1515    unsafe impl fidl::encoding::TypeMarker for FixedValuesPlaybackConfig {
1516        type Owned = Self;
1517
1518        #[inline(always)]
1519        fn inline_align(_context: fidl::encoding::Context) -> usize {
1520            8
1521        }
1522
1523        #[inline(always)]
1524        fn inline_size(_context: fidl::encoding::Context) -> usize {
1525            16
1526        }
1527    }
1528
1529    unsafe impl<D: fidl::encoding::ResourceDialect>
1530        fidl::encoding::Encode<FixedValuesPlaybackConfig, D> for &FixedValuesPlaybackConfig
1531    {
1532        unsafe fn encode(
1533            self,
1534            encoder: &mut fidl::encoding::Encoder<'_, D>,
1535            offset: usize,
1536            mut depth: fidl::encoding::Depth,
1537        ) -> fidl::Result<()> {
1538            encoder.debug_check_bounds::<FixedValuesPlaybackConfig>(offset);
1539            // Vector header
1540            let max_ordinal: u64 = self.max_ordinal_present();
1541            encoder.write_num(max_ordinal, offset);
1542            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1543            // Calling encoder.out_of_line_offset(0) is not allowed.
1544            if max_ordinal == 0 {
1545                return Ok(());
1546            }
1547            depth.increment()?;
1548            let envelope_size = 8;
1549            let bytes_len = max_ordinal as usize * envelope_size;
1550            #[allow(unused_variables)]
1551            let offset = encoder.out_of_line_offset(bytes_len);
1552            let mut _prev_end_offset: usize = 0;
1553            if 1 > max_ordinal {
1554                return Ok(());
1555            }
1556
1557            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1558            // are envelope_size bytes.
1559            let cur_offset: usize = (1 - 1) * envelope_size;
1560
1561            // Zero reserved fields.
1562            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1563
1564            // Safety:
1565            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1566            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1567            //   envelope_size bytes, there is always sufficient room.
1568            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types__common::SensorInfo>, D>(
1569            self.sensor_list.as_ref().map(<fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types__common::SensorInfo> as fidl::encoding::ValueTypeMarker>::borrow),
1570            encoder, offset + cur_offset, depth
1571        )?;
1572
1573            _prev_end_offset = cur_offset + envelope_size;
1574            if 2 > max_ordinal {
1575                return Ok(());
1576            }
1577
1578            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1579            // are envelope_size bytes.
1580            let cur_offset: usize = (2 - 1) * envelope_size;
1581
1582            // Zero reserved fields.
1583            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1584
1585            // Safety:
1586            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1587            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1588            //   envelope_size bytes, there is always sufficient room.
1589            fidl::encoding::encode_in_envelope_optional::<
1590                fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types__common::SensorEvent>,
1591                D,
1592            >(
1593                self.sensor_events.as_ref().map(
1594                    <fidl::encoding::UnboundedVector<
1595                        fidl_fuchsia_sensors_types__common::SensorEvent,
1596                    > as fidl::encoding::ValueTypeMarker>::borrow,
1597                ),
1598                encoder,
1599                offset + cur_offset,
1600                depth,
1601            )?;
1602
1603            _prev_end_offset = cur_offset + envelope_size;
1604
1605            Ok(())
1606        }
1607    }
1608
1609    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1610        for FixedValuesPlaybackConfig
1611    {
1612        #[inline(always)]
1613        fn new_empty() -> Self {
1614            Self::default()
1615        }
1616
1617        unsafe fn decode(
1618            &mut self,
1619            decoder: &mut fidl::encoding::Decoder<'_, D>,
1620            offset: usize,
1621            mut depth: fidl::encoding::Depth,
1622        ) -> fidl::Result<()> {
1623            decoder.debug_check_bounds::<Self>(offset);
1624            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1625                None => return Err(fidl::Error::NotNullable),
1626                Some(len) => len,
1627            };
1628            // Calling decoder.out_of_line_offset(0) is not allowed.
1629            if len == 0 {
1630                return Ok(());
1631            };
1632            depth.increment()?;
1633            let envelope_size = 8;
1634            let bytes_len = len * envelope_size;
1635            let offset = decoder.out_of_line_offset(bytes_len)?;
1636            // Decode the envelope for each type.
1637            let mut _next_ordinal_to_read = 0;
1638            let mut next_offset = offset;
1639            let end_offset = offset + bytes_len;
1640            _next_ordinal_to_read += 1;
1641            if next_offset >= end_offset {
1642                return Ok(());
1643            }
1644
1645            // Decode unknown envelopes for gaps in ordinals.
1646            while _next_ordinal_to_read < 1 {
1647                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1648                _next_ordinal_to_read += 1;
1649                next_offset += envelope_size;
1650            }
1651
1652            let next_out_of_line = decoder.next_out_of_line();
1653            let handles_before = decoder.remaining_handles();
1654            if let Some((inlined, num_bytes, num_handles)) =
1655                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1656            {
1657                let member_inline_size = <fidl::encoding::UnboundedVector<
1658                    fidl_fuchsia_sensors_types__common::SensorInfo,
1659                > as fidl::encoding::TypeMarker>::inline_size(
1660                    decoder.context
1661                );
1662                if inlined != (member_inline_size <= 4) {
1663                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1664                }
1665                let inner_offset;
1666                let mut inner_depth = depth.clone();
1667                if inlined {
1668                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1669                    inner_offset = next_offset;
1670                } else {
1671                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1672                    inner_depth.increment()?;
1673                }
1674                let val_ref = self.sensor_list.get_or_insert_with(|| {
1675                    fidl::new_empty!(
1676                        fidl::encoding::UnboundedVector<
1677                            fidl_fuchsia_sensors_types__common::SensorInfo,
1678                        >,
1679                        D
1680                    )
1681                });
1682                fidl::decode!(
1683                    fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types__common::SensorInfo>,
1684                    D,
1685                    val_ref,
1686                    decoder,
1687                    inner_offset,
1688                    inner_depth
1689                )?;
1690                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1691                {
1692                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1693                }
1694                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1695                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1696                }
1697            }
1698
1699            next_offset += envelope_size;
1700            _next_ordinal_to_read += 1;
1701            if next_offset >= end_offset {
1702                return Ok(());
1703            }
1704
1705            // Decode unknown envelopes for gaps in ordinals.
1706            while _next_ordinal_to_read < 2 {
1707                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1708                _next_ordinal_to_read += 1;
1709                next_offset += envelope_size;
1710            }
1711
1712            let next_out_of_line = decoder.next_out_of_line();
1713            let handles_before = decoder.remaining_handles();
1714            if let Some((inlined, num_bytes, num_handles)) =
1715                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1716            {
1717                let member_inline_size = <fidl::encoding::UnboundedVector<
1718                    fidl_fuchsia_sensors_types__common::SensorEvent,
1719                > as fidl::encoding::TypeMarker>::inline_size(
1720                    decoder.context
1721                );
1722                if inlined != (member_inline_size <= 4) {
1723                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1724                }
1725                let inner_offset;
1726                let mut inner_depth = depth.clone();
1727                if inlined {
1728                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1729                    inner_offset = next_offset;
1730                } else {
1731                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1732                    inner_depth.increment()?;
1733                }
1734                let val_ref = self.sensor_events.get_or_insert_with(|| {
1735                    fidl::new_empty!(
1736                        fidl::encoding::UnboundedVector<
1737                            fidl_fuchsia_sensors_types__common::SensorEvent,
1738                        >,
1739                        D
1740                    )
1741                });
1742                fidl::decode!(
1743                    fidl::encoding::UnboundedVector<
1744                        fidl_fuchsia_sensors_types__common::SensorEvent,
1745                    >,
1746                    D,
1747                    val_ref,
1748                    decoder,
1749                    inner_offset,
1750                    inner_depth
1751                )?;
1752                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1753                {
1754                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1755                }
1756                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1757                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1758                }
1759            }
1760
1761            next_offset += envelope_size;
1762
1763            // Decode the remaining unknown envelopes.
1764            while next_offset < end_offset {
1765                _next_ordinal_to_read += 1;
1766                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1767                next_offset += envelope_size;
1768            }
1769
1770            Ok(())
1771        }
1772    }
1773
1774    impl fidl::encoding::ValueTypeMarker for PlaybackSourceConfig {
1775        type Borrowed<'a> = &'a Self;
1776        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1777            value
1778        }
1779    }
1780
1781    unsafe impl fidl::encoding::TypeMarker for PlaybackSourceConfig {
1782        type Owned = Self;
1783
1784        #[inline(always)]
1785        fn inline_align(_context: fidl::encoding::Context) -> usize {
1786            8
1787        }
1788
1789        #[inline(always)]
1790        fn inline_size(_context: fidl::encoding::Context) -> usize {
1791            16
1792        }
1793    }
1794
1795    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PlaybackSourceConfig, D>
1796        for &PlaybackSourceConfig
1797    {
1798        #[inline]
1799        unsafe fn encode(
1800            self,
1801            encoder: &mut fidl::encoding::Encoder<'_, D>,
1802            offset: usize,
1803            _depth: fidl::encoding::Depth,
1804        ) -> fidl::Result<()> {
1805            encoder.debug_check_bounds::<PlaybackSourceConfig>(offset);
1806            encoder.write_num::<u64>(self.ordinal(), offset);
1807            match self {
1808                PlaybackSourceConfig::FixedValuesConfig(ref val) => {
1809                    fidl::encoding::encode_in_envelope::<FixedValuesPlaybackConfig, D>(
1810                        <FixedValuesPlaybackConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
1811                        encoder,
1812                        offset + 8,
1813                        _depth,
1814                    )
1815                }
1816                PlaybackSourceConfig::FilePlaybackConfig(ref val) => {
1817                    fidl::encoding::encode_in_envelope::<FilePlaybackConfig, D>(
1818                        <FilePlaybackConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
1819                        encoder,
1820                        offset + 8,
1821                        _depth,
1822                    )
1823                }
1824                PlaybackSourceConfig::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1825            }
1826        }
1827    }
1828
1829    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PlaybackSourceConfig {
1830        #[inline(always)]
1831        fn new_empty() -> Self {
1832            Self::__SourceBreaking { unknown_ordinal: 0 }
1833        }
1834
1835        #[inline]
1836        unsafe fn decode(
1837            &mut self,
1838            decoder: &mut fidl::encoding::Decoder<'_, D>,
1839            offset: usize,
1840            mut depth: fidl::encoding::Depth,
1841        ) -> fidl::Result<()> {
1842            decoder.debug_check_bounds::<Self>(offset);
1843            #[allow(unused_variables)]
1844            let next_out_of_line = decoder.next_out_of_line();
1845            let handles_before = decoder.remaining_handles();
1846            let (ordinal, inlined, num_bytes, num_handles) =
1847                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1848
1849            let member_inline_size = match ordinal {
1850                1 => <FixedValuesPlaybackConfig as fidl::encoding::TypeMarker>::inline_size(
1851                    decoder.context,
1852                ),
1853                2 => {
1854                    <FilePlaybackConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context)
1855                }
1856                0 => return Err(fidl::Error::UnknownUnionTag),
1857                _ => num_bytes as usize,
1858            };
1859
1860            if inlined != (member_inline_size <= 4) {
1861                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1862            }
1863            let _inner_offset;
1864            if inlined {
1865                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1866                _inner_offset = offset + 8;
1867            } else {
1868                depth.increment()?;
1869                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1870            }
1871            match ordinal {
1872                1 => {
1873                    #[allow(irrefutable_let_patterns)]
1874                    if let PlaybackSourceConfig::FixedValuesConfig(_) = self {
1875                        // Do nothing, read the value into the object
1876                    } else {
1877                        // Initialize `self` to the right variant
1878                        *self = PlaybackSourceConfig::FixedValuesConfig(fidl::new_empty!(
1879                            FixedValuesPlaybackConfig,
1880                            D
1881                        ));
1882                    }
1883                    #[allow(irrefutable_let_patterns)]
1884                    if let PlaybackSourceConfig::FixedValuesConfig(ref mut val) = self {
1885                        fidl::decode!(
1886                            FixedValuesPlaybackConfig,
1887                            D,
1888                            val,
1889                            decoder,
1890                            _inner_offset,
1891                            depth
1892                        )?;
1893                    } else {
1894                        unreachable!()
1895                    }
1896                }
1897                2 => {
1898                    #[allow(irrefutable_let_patterns)]
1899                    if let PlaybackSourceConfig::FilePlaybackConfig(_) = self {
1900                        // Do nothing, read the value into the object
1901                    } else {
1902                        // Initialize `self` to the right variant
1903                        *self = PlaybackSourceConfig::FilePlaybackConfig(fidl::new_empty!(
1904                            FilePlaybackConfig,
1905                            D
1906                        ));
1907                    }
1908                    #[allow(irrefutable_let_patterns)]
1909                    if let PlaybackSourceConfig::FilePlaybackConfig(ref mut val) = self {
1910                        fidl::decode!(FilePlaybackConfig, D, val, decoder, _inner_offset, depth)?;
1911                    } else {
1912                        unreachable!()
1913                    }
1914                }
1915                #[allow(deprecated)]
1916                ordinal => {
1917                    for _ in 0..num_handles {
1918                        decoder.drop_next_handle()?;
1919                    }
1920                    *self = PlaybackSourceConfig::__SourceBreaking { unknown_ordinal: ordinal };
1921                }
1922            }
1923            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1924                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1925            }
1926            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1927                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1928            }
1929            Ok(())
1930        }
1931    }
1932}