fidl_fuchsia_bluetooth_a2dp_common/
fidl_fuchsia_bluetooth_a2dp_common.rs1#![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#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
14#[repr(u32)]
15pub enum Role {
16 Source = 1,
18 Sink = 2,
20}
21
22impl Role {
23 #[inline]
24 pub fn from_primitive(prim: u32) -> Option<Self> {
25 match prim {
26 1 => Some(Self::Source),
27 2 => Some(Self::Sink),
28 _ => None,
29 }
30 }
31
32 #[inline]
33 pub const fn into_primitive(self) -> u32 {
34 self as u32
35 }
36
37 #[deprecated = "Strict enums should not use `is_unknown`"]
38 #[inline]
39 pub fn is_unknown(&self) -> bool {
40 false
41 }
42}
43
44#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
45pub struct AudioModeSetRoleRequest {
46 pub role: Role,
47}
48
49impl fidl::Persistable for AudioModeSetRoleRequest {}
50
51mod internal {
52 use super::*;
53 unsafe impl fidl::encoding::TypeMarker for Role {
54 type Owned = Self;
55
56 #[inline(always)]
57 fn inline_align(_context: fidl::encoding::Context) -> usize {
58 std::mem::align_of::<u32>()
59 }
60
61 #[inline(always)]
62 fn inline_size(_context: fidl::encoding::Context) -> usize {
63 std::mem::size_of::<u32>()
64 }
65
66 #[inline(always)]
67 fn encode_is_copy() -> bool {
68 true
69 }
70
71 #[inline(always)]
72 fn decode_is_copy() -> bool {
73 false
74 }
75 }
76
77 impl fidl::encoding::ValueTypeMarker for Role {
78 type Borrowed<'a> = Self;
79 #[inline(always)]
80 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
81 *value
82 }
83 }
84
85 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Role {
86 #[inline]
87 unsafe fn encode(
88 self,
89 encoder: &mut fidl::encoding::Encoder<'_, D>,
90 offset: usize,
91 _depth: fidl::encoding::Depth,
92 ) -> fidl::Result<()> {
93 encoder.debug_check_bounds::<Self>(offset);
94 encoder.write_num(self.into_primitive(), offset);
95 Ok(())
96 }
97 }
98
99 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Role {
100 #[inline(always)]
101 fn new_empty() -> Self {
102 Self::Source
103 }
104
105 #[inline]
106 unsafe fn decode(
107 &mut self,
108 decoder: &mut fidl::encoding::Decoder<'_, D>,
109 offset: usize,
110 _depth: fidl::encoding::Depth,
111 ) -> fidl::Result<()> {
112 decoder.debug_check_bounds::<Self>(offset);
113 let prim = decoder.read_num::<u32>(offset);
114
115 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
116 Ok(())
117 }
118 }
119
120 impl fidl::encoding::ValueTypeMarker for AudioModeSetRoleRequest {
121 type Borrowed<'a> = &'a Self;
122 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
123 value
124 }
125 }
126
127 unsafe impl fidl::encoding::TypeMarker for AudioModeSetRoleRequest {
128 type Owned = Self;
129
130 #[inline(always)]
131 fn inline_align(_context: fidl::encoding::Context) -> usize {
132 4
133 }
134
135 #[inline(always)]
136 fn inline_size(_context: fidl::encoding::Context) -> usize {
137 4
138 }
139 }
140
141 unsafe impl<D: fidl::encoding::ResourceDialect>
142 fidl::encoding::Encode<AudioModeSetRoleRequest, D> for &AudioModeSetRoleRequest
143 {
144 #[inline]
145 unsafe fn encode(
146 self,
147 encoder: &mut fidl::encoding::Encoder<'_, D>,
148 offset: usize,
149 _depth: fidl::encoding::Depth,
150 ) -> fidl::Result<()> {
151 encoder.debug_check_bounds::<AudioModeSetRoleRequest>(offset);
152 fidl::encoding::Encode::<AudioModeSetRoleRequest, D>::encode(
154 (<Role as fidl::encoding::ValueTypeMarker>::borrow(&self.role),),
155 encoder,
156 offset,
157 _depth,
158 )
159 }
160 }
161 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Role, D>>
162 fidl::encoding::Encode<AudioModeSetRoleRequest, D> for (T0,)
163 {
164 #[inline]
165 unsafe fn encode(
166 self,
167 encoder: &mut fidl::encoding::Encoder<'_, D>,
168 offset: usize,
169 depth: fidl::encoding::Depth,
170 ) -> fidl::Result<()> {
171 encoder.debug_check_bounds::<AudioModeSetRoleRequest>(offset);
172 self.0.encode(encoder, offset + 0, depth)?;
176 Ok(())
177 }
178 }
179
180 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
181 for AudioModeSetRoleRequest
182 {
183 #[inline(always)]
184 fn new_empty() -> Self {
185 Self { role: fidl::new_empty!(Role, D) }
186 }
187
188 #[inline]
189 unsafe fn decode(
190 &mut self,
191 decoder: &mut fidl::encoding::Decoder<'_, D>,
192 offset: usize,
193 _depth: fidl::encoding::Depth,
194 ) -> fidl::Result<()> {
195 decoder.debug_check_bounds::<Self>(offset);
196 fidl::decode!(Role, D, &mut self.role, decoder, offset + 0, _depth)?;
198 Ok(())
199 }
200 }
201}