fidl_fuchsia_test_audio__common/
fidl_fuchsia_test_audio__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
11pub const INJECTED_AUDIO_MAXIMUM_FILE_SIZE: u32 = 20971520;
16
17#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
19pub enum AudioTestError {
20 Fail,
26 #[doc(hidden)]
27 __SourceBreaking { unknown_ordinal: u32 },
28}
29
30#[macro_export]
32macro_rules! AudioTestErrorUnknown {
33 () => {
34 _
35 };
36}
37
38impl AudioTestError {
39 #[inline]
40 pub fn from_primitive(prim: u32) -> Option<Self> {
41 match prim {
42 1 => Some(Self::Fail),
43 _ => None,
44 }
45 }
46
47 #[inline]
48 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
49 match prim {
50 1 => Self::Fail,
51 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
52 }
53 }
54
55 #[inline]
56 pub fn unknown() -> Self {
57 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
58 }
59
60 #[inline]
61 pub const fn into_primitive(self) -> u32 {
62 match self {
63 Self::Fail => 1,
64 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
65 }
66 }
67
68 #[inline]
69 pub fn is_unknown(&self) -> bool {
70 match self {
71 Self::__SourceBreaking { unknown_ordinal: _ } => true,
72 _ => false,
73 }
74 }
75}
76
77#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
78#[repr(C)]
79pub struct InjectionGetInputAudioSizeRequest {
80 pub index: i32,
81}
82
83impl fidl::Persistable for InjectionGetInputAudioSizeRequest {}
84
85#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
86#[repr(C)]
87pub struct InjectionGetInputAudioSizeResponse {
88 pub byte_count: u64,
89}
90
91impl fidl::Persistable for InjectionGetInputAudioSizeResponse {}
92
93pub mod capture_ordinals {
94 pub const START_OUTPUT_CAPTURE: u64 = 0x3da5afb01b70be17;
95 pub const STOP_OUTPUT_CAPTURE: u64 = 0x4598c765e8859b6b;
96 pub const GET_OUTPUT_AUDIO: u64 = 0x23960702c8a96e54;
97}
98
99pub mod injection_ordinals {
100 pub const WRITE_INPUT_AUDIO: u64 = 0x2eaec6d4251a030d;
101 pub const GET_INPUT_AUDIO_SIZE: u64 = 0x57684145b51cf28;
102 pub const CLEAR_INPUT_AUDIO: u64 = 0x33259f902aace7b7;
103 pub const WAIT_UNTIL_INPUT_IS_DONE: u64 = 0x6cb5b4b48ffe7fc8;
104 pub const START_INPUT_INJECTION: u64 = 0x753a5415ad966b06;
105 pub const STOP_INPUT_INJECTION: u64 = 0x371fce6bb8d77fe;
106}
107
108mod internal {
109 use super::*;
110 unsafe impl fidl::encoding::TypeMarker for AudioTestError {
111 type Owned = Self;
112
113 #[inline(always)]
114 fn inline_align(_context: fidl::encoding::Context) -> usize {
115 std::mem::align_of::<u32>()
116 }
117
118 #[inline(always)]
119 fn inline_size(_context: fidl::encoding::Context) -> usize {
120 std::mem::size_of::<u32>()
121 }
122
123 #[inline(always)]
124 fn encode_is_copy() -> bool {
125 false
126 }
127
128 #[inline(always)]
129 fn decode_is_copy() -> bool {
130 false
131 }
132 }
133
134 impl fidl::encoding::ValueTypeMarker for AudioTestError {
135 type Borrowed<'a> = Self;
136 #[inline(always)]
137 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
138 *value
139 }
140 }
141
142 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for AudioTestError {
143 #[inline]
144 unsafe fn encode(
145 self,
146 encoder: &mut fidl::encoding::Encoder<'_, D>,
147 offset: usize,
148 _depth: fidl::encoding::Depth,
149 ) -> fidl::Result<()> {
150 encoder.debug_check_bounds::<Self>(offset);
151 encoder.write_num(self.into_primitive(), offset);
152 Ok(())
153 }
154 }
155
156 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for AudioTestError {
157 #[inline(always)]
158 fn new_empty() -> Self {
159 Self::unknown()
160 }
161
162 #[inline]
163 unsafe fn decode(
164 &mut self,
165 decoder: &mut fidl::encoding::Decoder<'_, D>,
166 offset: usize,
167 _depth: fidl::encoding::Depth,
168 ) -> fidl::Result<()> {
169 decoder.debug_check_bounds::<Self>(offset);
170 let prim = decoder.read_num::<u32>(offset);
171
172 *self = Self::from_primitive_allow_unknown(prim);
173 Ok(())
174 }
175 }
176
177 impl fidl::encoding::ValueTypeMarker for InjectionGetInputAudioSizeRequest {
178 type Borrowed<'a> = &'a Self;
179 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
180 value
181 }
182 }
183
184 unsafe impl fidl::encoding::TypeMarker for InjectionGetInputAudioSizeRequest {
185 type Owned = Self;
186
187 #[inline(always)]
188 fn inline_align(_context: fidl::encoding::Context) -> usize {
189 4
190 }
191
192 #[inline(always)]
193 fn inline_size(_context: fidl::encoding::Context) -> usize {
194 4
195 }
196 #[inline(always)]
197 fn encode_is_copy() -> bool {
198 true
199 }
200
201 #[inline(always)]
202 fn decode_is_copy() -> bool {
203 true
204 }
205 }
206
207 unsafe impl<D: fidl::encoding::ResourceDialect>
208 fidl::encoding::Encode<InjectionGetInputAudioSizeRequest, D>
209 for &InjectionGetInputAudioSizeRequest
210 {
211 #[inline]
212 unsafe fn encode(
213 self,
214 encoder: &mut fidl::encoding::Encoder<'_, D>,
215 offset: usize,
216 _depth: fidl::encoding::Depth,
217 ) -> fidl::Result<()> {
218 encoder.debug_check_bounds::<InjectionGetInputAudioSizeRequest>(offset);
219 unsafe {
220 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
222 (buf_ptr as *mut InjectionGetInputAudioSizeRequest)
223 .write_unaligned((self as *const InjectionGetInputAudioSizeRequest).read());
224 }
227 Ok(())
228 }
229 }
230 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
231 fidl::encoding::Encode<InjectionGetInputAudioSizeRequest, D> for (T0,)
232 {
233 #[inline]
234 unsafe fn encode(
235 self,
236 encoder: &mut fidl::encoding::Encoder<'_, D>,
237 offset: usize,
238 depth: fidl::encoding::Depth,
239 ) -> fidl::Result<()> {
240 encoder.debug_check_bounds::<InjectionGetInputAudioSizeRequest>(offset);
241 self.0.encode(encoder, offset + 0, depth)?;
245 Ok(())
246 }
247 }
248
249 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
250 for InjectionGetInputAudioSizeRequest
251 {
252 #[inline(always)]
253 fn new_empty() -> Self {
254 Self { index: fidl::new_empty!(i32, D) }
255 }
256
257 #[inline]
258 unsafe fn decode(
259 &mut self,
260 decoder: &mut fidl::encoding::Decoder<'_, D>,
261 offset: usize,
262 _depth: fidl::encoding::Depth,
263 ) -> fidl::Result<()> {
264 decoder.debug_check_bounds::<Self>(offset);
265 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
266 unsafe {
269 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
270 }
271 Ok(())
272 }
273 }
274
275 impl fidl::encoding::ValueTypeMarker for InjectionGetInputAudioSizeResponse {
276 type Borrowed<'a> = &'a Self;
277 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
278 value
279 }
280 }
281
282 unsafe impl fidl::encoding::TypeMarker for InjectionGetInputAudioSizeResponse {
283 type Owned = Self;
284
285 #[inline(always)]
286 fn inline_align(_context: fidl::encoding::Context) -> usize {
287 8
288 }
289
290 #[inline(always)]
291 fn inline_size(_context: fidl::encoding::Context) -> usize {
292 8
293 }
294 #[inline(always)]
295 fn encode_is_copy() -> bool {
296 true
297 }
298
299 #[inline(always)]
300 fn decode_is_copy() -> bool {
301 true
302 }
303 }
304
305 unsafe impl<D: fidl::encoding::ResourceDialect>
306 fidl::encoding::Encode<InjectionGetInputAudioSizeResponse, D>
307 for &InjectionGetInputAudioSizeResponse
308 {
309 #[inline]
310 unsafe fn encode(
311 self,
312 encoder: &mut fidl::encoding::Encoder<'_, D>,
313 offset: usize,
314 _depth: fidl::encoding::Depth,
315 ) -> fidl::Result<()> {
316 encoder.debug_check_bounds::<InjectionGetInputAudioSizeResponse>(offset);
317 unsafe {
318 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
320 (buf_ptr as *mut InjectionGetInputAudioSizeResponse)
321 .write_unaligned((self as *const InjectionGetInputAudioSizeResponse).read());
322 }
325 Ok(())
326 }
327 }
328 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
329 fidl::encoding::Encode<InjectionGetInputAudioSizeResponse, D> for (T0,)
330 {
331 #[inline]
332 unsafe fn encode(
333 self,
334 encoder: &mut fidl::encoding::Encoder<'_, D>,
335 offset: usize,
336 depth: fidl::encoding::Depth,
337 ) -> fidl::Result<()> {
338 encoder.debug_check_bounds::<InjectionGetInputAudioSizeResponse>(offset);
339 self.0.encode(encoder, offset + 0, depth)?;
343 Ok(())
344 }
345 }
346
347 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
348 for InjectionGetInputAudioSizeResponse
349 {
350 #[inline(always)]
351 fn new_empty() -> Self {
352 Self { byte_count: fidl::new_empty!(u64, D) }
353 }
354
355 #[inline]
356 unsafe fn decode(
357 &mut self,
358 decoder: &mut fidl::encoding::Decoder<'_, D>,
359 offset: usize,
360 _depth: fidl::encoding::Depth,
361 ) -> fidl::Result<()> {
362 decoder.debug_check_bounds::<Self>(offset);
363 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
364 unsafe {
367 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
368 }
369 Ok(())
370 }
371 }
372}