fidl_fuchsia_input_interaction__common/
fidl_fuchsia_input_interaction__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/// State is an enumeration of the activity states the system may be in.
12#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
13pub enum State {
14    Invalid,
15    /// IDLE implies that the system is not currently being used by a user.
16    /// In other words, the system is not ACTIVE.
17    Idle,
18    /// ACTIVE implies that a user has recently or is currently using the
19    /// system.
20    ///
21    /// Activity can be signalled by discrete input interactions (cursor,
22    /// keyboard, touchscreen, mouse, or media buttons).
23    ///
24    /// The specific meaning of "recently" is an implementation
25    /// detail of the Activity Service, but a typical value is 15 minutes.
26    Active,
27    #[doc(hidden)]
28    __SourceBreaking {
29        unknown_ordinal: u32,
30    },
31}
32
33/// Pattern that matches an unknown `State` member.
34#[macro_export]
35macro_rules! StateUnknown {
36    () => {
37        _
38    };
39}
40
41impl State {
42    #[inline]
43    pub fn from_primitive(prim: u32) -> Option<Self> {
44        match prim {
45            0 => Some(Self::Invalid),
46            1 => Some(Self::Idle),
47            2 => Some(Self::Active),
48            _ => None,
49        }
50    }
51
52    #[inline]
53    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
54        match prim {
55            0 => Self::Invalid,
56            1 => Self::Idle,
57            2 => Self::Active,
58            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
59        }
60    }
61
62    #[inline]
63    pub fn unknown() -> Self {
64        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
65    }
66
67    #[inline]
68    pub const fn into_primitive(self) -> u32 {
69        match self {
70            Self::Invalid => 0,
71            Self::Idle => 1,
72            Self::Active => 2,
73            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
74        }
75    }
76
77    #[inline]
78    pub fn is_unknown(&self) -> bool {
79        match self {
80            Self::__SourceBreaking { unknown_ordinal: _ } => true,
81            _ => false,
82        }
83    }
84}
85
86pub mod notifier_ordinals {
87    pub const WATCH_STATE: u64 = 0xf379d6bc002e8ee;
88}
89
90mod internal {
91    use super::*;
92    unsafe impl fidl::encoding::TypeMarker for State {
93        type Owned = Self;
94
95        #[inline(always)]
96        fn inline_align(_context: fidl::encoding::Context) -> usize {
97            std::mem::align_of::<u32>()
98        }
99
100        #[inline(always)]
101        fn inline_size(_context: fidl::encoding::Context) -> usize {
102            std::mem::size_of::<u32>()
103        }
104
105        #[inline(always)]
106        fn encode_is_copy() -> bool {
107            false
108        }
109
110        #[inline(always)]
111        fn decode_is_copy() -> bool {
112            false
113        }
114    }
115
116    impl fidl::encoding::ValueTypeMarker for State {
117        type Borrowed<'a> = Self;
118        #[inline(always)]
119        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
120            *value
121        }
122    }
123
124    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for State {
125        #[inline]
126        unsafe fn encode(
127            self,
128            encoder: &mut fidl::encoding::Encoder<'_, D>,
129            offset: usize,
130            _depth: fidl::encoding::Depth,
131        ) -> fidl::Result<()> {
132            encoder.debug_check_bounds::<Self>(offset);
133            encoder.write_num(self.into_primitive(), offset);
134            Ok(())
135        }
136    }
137
138    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for State {
139        #[inline(always)]
140        fn new_empty() -> Self {
141            Self::unknown()
142        }
143
144        #[inline]
145        unsafe fn decode(
146            &mut self,
147            decoder: &mut fidl::encoding::Decoder<'_, D>,
148            offset: usize,
149            _depth: fidl::encoding::Depth,
150        ) -> fidl::Result<()> {
151            decoder.debug_check_bounds::<Self>(offset);
152            let prim = decoder.read_num::<u32>(offset);
153
154            *self = Self::from_primitive_allow_unknown(prim);
155            Ok(())
156        }
157    }
158}