fidl_fuchsia_media_sounds__common/
fidl_fuchsia_media_sounds__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/// Error type for `Player.PlaySound`.
12#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
13#[repr(u32)]
14pub enum PlaySoundError {
15    /// The `id` passed to `PlaySound` is not recognized.
16    NoSuchSound = 1,
17    /// Underlying audio renderer failed.
18    RendererFailed = 2,
19    /// Playback of the sound was interrupted by a |StopPlayingSound| method call.
20    Stopped = 3,
21}
22
23impl PlaySoundError {
24    #[inline]
25    pub fn from_primitive(prim: u32) -> Option<Self> {
26        match prim {
27            1 => Some(Self::NoSuchSound),
28            2 => Some(Self::RendererFailed),
29            3 => Some(Self::Stopped),
30            _ => None,
31        }
32    }
33
34    #[inline]
35    pub const fn into_primitive(self) -> u32 {
36        self as u32
37    }
38}
39
40#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
41pub struct PlayerPlaySound2Request {
42    pub id: u32,
43    pub usage: fidl_fuchsia_media__common::AudioRenderUsage2,
44}
45
46impl fidl::Persistable for PlayerPlaySound2Request {}
47
48#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
49pub struct PlayerPlaySoundRequest {
50    pub id: u32,
51    pub usage: fidl_fuchsia_media__common::AudioRenderUsage,
52}
53
54impl fidl::Persistable for PlayerPlaySoundRequest {}
55
56#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
57#[repr(C)]
58pub struct PlayerRemoveSoundRequest {
59    pub id: u32,
60}
61
62impl fidl::Persistable for PlayerRemoveSoundRequest {}
63
64#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
65#[repr(C)]
66pub struct PlayerStopPlayingSoundRequest {
67    pub id: u32,
68}
69
70impl fidl::Persistable for PlayerStopPlayingSoundRequest {}
71
72#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
73#[repr(C)]
74pub struct PlayerAddSoundFromFileResponse {
75    pub duration: i64,
76}
77
78impl fidl::Persistable for PlayerAddSoundFromFileResponse {}
79
80pub mod player_ordinals {
81    pub const ADD_SOUND_FROM_FILE: u64 = 0x2fd248cffbd53f06;
82    pub const ADD_SOUND_BUFFER: u64 = 0x4eaa5c060d71da62;
83    pub const REMOVE_SOUND: u64 = 0x1a066f9fcf9ef0c2;
84    pub const PLAY_SOUND: u64 = 0x76f7d6bd8d1725c1;
85    pub const PLAY_SOUND2: u64 = 0x5e68b5f96613bc39;
86    pub const STOP_PLAYING_SOUND: u64 = 0x14487efba2de8152;
87}
88
89mod internal {
90    use super::*;
91    unsafe impl fidl::encoding::TypeMarker for PlaySoundError {
92        type Owned = Self;
93
94        #[inline(always)]
95        fn inline_align(_context: fidl::encoding::Context) -> usize {
96            std::mem::align_of::<u32>()
97        }
98
99        #[inline(always)]
100        fn inline_size(_context: fidl::encoding::Context) -> usize {
101            std::mem::size_of::<u32>()
102        }
103
104        #[inline(always)]
105        fn encode_is_copy() -> bool {
106            true
107        }
108
109        #[inline(always)]
110        fn decode_is_copy() -> bool {
111            false
112        }
113    }
114
115    impl fidl::encoding::ValueTypeMarker for PlaySoundError {
116        type Borrowed<'a> = Self;
117        #[inline(always)]
118        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
119            *value
120        }
121    }
122
123    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for PlaySoundError {
124        #[inline]
125        unsafe fn encode(
126            self,
127            encoder: &mut fidl::encoding::Encoder<'_, D>,
128            offset: usize,
129            _depth: fidl::encoding::Depth,
130        ) -> fidl::Result<()> {
131            encoder.debug_check_bounds::<Self>(offset);
132            encoder.write_num(self.into_primitive(), offset);
133            Ok(())
134        }
135    }
136
137    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PlaySoundError {
138        #[inline(always)]
139        fn new_empty() -> Self {
140            Self::NoSuchSound
141        }
142
143        #[inline]
144        unsafe fn decode(
145            &mut self,
146            decoder: &mut fidl::encoding::Decoder<'_, D>,
147            offset: usize,
148            _depth: fidl::encoding::Depth,
149        ) -> fidl::Result<()> {
150            decoder.debug_check_bounds::<Self>(offset);
151            let prim = decoder.read_num::<u32>(offset);
152
153            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
154            Ok(())
155        }
156    }
157
158    impl fidl::encoding::ValueTypeMarker for PlayerPlaySound2Request {
159        type Borrowed<'a> = &'a Self;
160        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
161            value
162        }
163    }
164
165    unsafe impl fidl::encoding::TypeMarker for PlayerPlaySound2Request {
166        type Owned = Self;
167
168        #[inline(always)]
169        fn inline_align(_context: fidl::encoding::Context) -> usize {
170            4
171        }
172
173        #[inline(always)]
174        fn inline_size(_context: fidl::encoding::Context) -> usize {
175            8
176        }
177    }
178
179    unsafe impl<D: fidl::encoding::ResourceDialect>
180        fidl::encoding::Encode<PlayerPlaySound2Request, D> for &PlayerPlaySound2Request
181    {
182        #[inline]
183        unsafe fn encode(
184            self,
185            encoder: &mut fidl::encoding::Encoder<'_, D>,
186            offset: usize,
187            _depth: fidl::encoding::Depth,
188        ) -> fidl::Result<()> {
189            encoder.debug_check_bounds::<PlayerPlaySound2Request>(offset);
190            // Delegate to tuple encoding.
191            fidl::encoding::Encode::<PlayerPlaySound2Request, D>::encode(
192                (
193                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
194                    <fidl_fuchsia_media__common::AudioRenderUsage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
195                ),
196                encoder, offset, _depth
197            )
198        }
199    }
200    unsafe impl<
201            D: fidl::encoding::ResourceDialect,
202            T0: fidl::encoding::Encode<u32, D>,
203            T1: fidl::encoding::Encode<fidl_fuchsia_media__common::AudioRenderUsage2, D>,
204        > fidl::encoding::Encode<PlayerPlaySound2Request, D> for (T0, T1)
205    {
206        #[inline]
207        unsafe fn encode(
208            self,
209            encoder: &mut fidl::encoding::Encoder<'_, D>,
210            offset: usize,
211            depth: fidl::encoding::Depth,
212        ) -> fidl::Result<()> {
213            encoder.debug_check_bounds::<PlayerPlaySound2Request>(offset);
214            // Zero out padding regions. There's no need to apply masks
215            // because the unmasked parts will be overwritten by fields.
216            // Write the fields.
217            self.0.encode(encoder, offset + 0, depth)?;
218            self.1.encode(encoder, offset + 4, depth)?;
219            Ok(())
220        }
221    }
222
223    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
224        for PlayerPlaySound2Request
225    {
226        #[inline(always)]
227        fn new_empty() -> Self {
228            Self {
229                id: fidl::new_empty!(u32, D),
230                usage: fidl::new_empty!(fidl_fuchsia_media__common::AudioRenderUsage2, D),
231            }
232        }
233
234        #[inline]
235        unsafe fn decode(
236            &mut self,
237            decoder: &mut fidl::encoding::Decoder<'_, D>,
238            offset: usize,
239            _depth: fidl::encoding::Depth,
240        ) -> fidl::Result<()> {
241            decoder.debug_check_bounds::<Self>(offset);
242            // Verify that padding bytes are zero.
243            fidl::decode!(u32, D, &mut self.id, decoder, offset + 0, _depth)?;
244            fidl::decode!(
245                fidl_fuchsia_media__common::AudioRenderUsage2,
246                D,
247                &mut self.usage,
248                decoder,
249                offset + 4,
250                _depth
251            )?;
252            Ok(())
253        }
254    }
255
256    impl fidl::encoding::ValueTypeMarker for PlayerPlaySoundRequest {
257        type Borrowed<'a> = &'a Self;
258        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
259            value
260        }
261    }
262
263    unsafe impl fidl::encoding::TypeMarker for PlayerPlaySoundRequest {
264        type Owned = Self;
265
266        #[inline(always)]
267        fn inline_align(_context: fidl::encoding::Context) -> usize {
268            4
269        }
270
271        #[inline(always)]
272        fn inline_size(_context: fidl::encoding::Context) -> usize {
273            8
274        }
275    }
276
277    unsafe impl<D: fidl::encoding::ResourceDialect>
278        fidl::encoding::Encode<PlayerPlaySoundRequest, D> for &PlayerPlaySoundRequest
279    {
280        #[inline]
281        unsafe fn encode(
282            self,
283            encoder: &mut fidl::encoding::Encoder<'_, D>,
284            offset: usize,
285            _depth: fidl::encoding::Depth,
286        ) -> fidl::Result<()> {
287            encoder.debug_check_bounds::<PlayerPlaySoundRequest>(offset);
288            // Delegate to tuple encoding.
289            fidl::encoding::Encode::<PlayerPlaySoundRequest, D>::encode(
290                (
291                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
292                    <fidl_fuchsia_media__common::AudioRenderUsage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
293                ),
294                encoder, offset, _depth
295            )
296        }
297    }
298    unsafe impl<
299            D: fidl::encoding::ResourceDialect,
300            T0: fidl::encoding::Encode<u32, D>,
301            T1: fidl::encoding::Encode<fidl_fuchsia_media__common::AudioRenderUsage, D>,
302        > fidl::encoding::Encode<PlayerPlaySoundRequest, D> for (T0, T1)
303    {
304        #[inline]
305        unsafe fn encode(
306            self,
307            encoder: &mut fidl::encoding::Encoder<'_, D>,
308            offset: usize,
309            depth: fidl::encoding::Depth,
310        ) -> fidl::Result<()> {
311            encoder.debug_check_bounds::<PlayerPlaySoundRequest>(offset);
312            // Zero out padding regions. There's no need to apply masks
313            // because the unmasked parts will be overwritten by fields.
314            // Write the fields.
315            self.0.encode(encoder, offset + 0, depth)?;
316            self.1.encode(encoder, offset + 4, depth)?;
317            Ok(())
318        }
319    }
320
321    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
322        for PlayerPlaySoundRequest
323    {
324        #[inline(always)]
325        fn new_empty() -> Self {
326            Self {
327                id: fidl::new_empty!(u32, D),
328                usage: fidl::new_empty!(fidl_fuchsia_media__common::AudioRenderUsage, D),
329            }
330        }
331
332        #[inline]
333        unsafe fn decode(
334            &mut self,
335            decoder: &mut fidl::encoding::Decoder<'_, D>,
336            offset: usize,
337            _depth: fidl::encoding::Depth,
338        ) -> fidl::Result<()> {
339            decoder.debug_check_bounds::<Self>(offset);
340            // Verify that padding bytes are zero.
341            fidl::decode!(u32, D, &mut self.id, decoder, offset + 0, _depth)?;
342            fidl::decode!(
343                fidl_fuchsia_media__common::AudioRenderUsage,
344                D,
345                &mut self.usage,
346                decoder,
347                offset + 4,
348                _depth
349            )?;
350            Ok(())
351        }
352    }
353
354    impl fidl::encoding::ValueTypeMarker for PlayerRemoveSoundRequest {
355        type Borrowed<'a> = &'a Self;
356        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
357            value
358        }
359    }
360
361    unsafe impl fidl::encoding::TypeMarker for PlayerRemoveSoundRequest {
362        type Owned = Self;
363
364        #[inline(always)]
365        fn inline_align(_context: fidl::encoding::Context) -> usize {
366            4
367        }
368
369        #[inline(always)]
370        fn inline_size(_context: fidl::encoding::Context) -> usize {
371            4
372        }
373        #[inline(always)]
374        fn encode_is_copy() -> bool {
375            true
376        }
377
378        #[inline(always)]
379        fn decode_is_copy() -> bool {
380            true
381        }
382    }
383
384    unsafe impl<D: fidl::encoding::ResourceDialect>
385        fidl::encoding::Encode<PlayerRemoveSoundRequest, D> for &PlayerRemoveSoundRequest
386    {
387        #[inline]
388        unsafe fn encode(
389            self,
390            encoder: &mut fidl::encoding::Encoder<'_, D>,
391            offset: usize,
392            _depth: fidl::encoding::Depth,
393        ) -> fidl::Result<()> {
394            encoder.debug_check_bounds::<PlayerRemoveSoundRequest>(offset);
395            unsafe {
396                // Copy the object into the buffer.
397                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
398                (buf_ptr as *mut PlayerRemoveSoundRequest)
399                    .write_unaligned((self as *const PlayerRemoveSoundRequest).read());
400                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
401                // done second because the memcpy will write garbage to these bytes.
402            }
403            Ok(())
404        }
405    }
406    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
407        fidl::encoding::Encode<PlayerRemoveSoundRequest, D> for (T0,)
408    {
409        #[inline]
410        unsafe fn encode(
411            self,
412            encoder: &mut fidl::encoding::Encoder<'_, D>,
413            offset: usize,
414            depth: fidl::encoding::Depth,
415        ) -> fidl::Result<()> {
416            encoder.debug_check_bounds::<PlayerRemoveSoundRequest>(offset);
417            // Zero out padding regions. There's no need to apply masks
418            // because the unmasked parts will be overwritten by fields.
419            // Write the fields.
420            self.0.encode(encoder, offset + 0, depth)?;
421            Ok(())
422        }
423    }
424
425    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
426        for PlayerRemoveSoundRequest
427    {
428        #[inline(always)]
429        fn new_empty() -> Self {
430            Self { id: fidl::new_empty!(u32, D) }
431        }
432
433        #[inline]
434        unsafe fn decode(
435            &mut self,
436            decoder: &mut fidl::encoding::Decoder<'_, D>,
437            offset: usize,
438            _depth: fidl::encoding::Depth,
439        ) -> fidl::Result<()> {
440            decoder.debug_check_bounds::<Self>(offset);
441            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
442            // Verify that padding bytes are zero.
443            // Copy from the buffer into the object.
444            unsafe {
445                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
446            }
447            Ok(())
448        }
449    }
450
451    impl fidl::encoding::ValueTypeMarker for PlayerStopPlayingSoundRequest {
452        type Borrowed<'a> = &'a Self;
453        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
454            value
455        }
456    }
457
458    unsafe impl fidl::encoding::TypeMarker for PlayerStopPlayingSoundRequest {
459        type Owned = Self;
460
461        #[inline(always)]
462        fn inline_align(_context: fidl::encoding::Context) -> usize {
463            4
464        }
465
466        #[inline(always)]
467        fn inline_size(_context: fidl::encoding::Context) -> usize {
468            4
469        }
470        #[inline(always)]
471        fn encode_is_copy() -> bool {
472            true
473        }
474
475        #[inline(always)]
476        fn decode_is_copy() -> bool {
477            true
478        }
479    }
480
481    unsafe impl<D: fidl::encoding::ResourceDialect>
482        fidl::encoding::Encode<PlayerStopPlayingSoundRequest, D>
483        for &PlayerStopPlayingSoundRequest
484    {
485        #[inline]
486        unsafe fn encode(
487            self,
488            encoder: &mut fidl::encoding::Encoder<'_, D>,
489            offset: usize,
490            _depth: fidl::encoding::Depth,
491        ) -> fidl::Result<()> {
492            encoder.debug_check_bounds::<PlayerStopPlayingSoundRequest>(offset);
493            unsafe {
494                // Copy the object into the buffer.
495                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
496                (buf_ptr as *mut PlayerStopPlayingSoundRequest)
497                    .write_unaligned((self as *const PlayerStopPlayingSoundRequest).read());
498                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
499                // done second because the memcpy will write garbage to these bytes.
500            }
501            Ok(())
502        }
503    }
504    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
505        fidl::encoding::Encode<PlayerStopPlayingSoundRequest, D> for (T0,)
506    {
507        #[inline]
508        unsafe fn encode(
509            self,
510            encoder: &mut fidl::encoding::Encoder<'_, D>,
511            offset: usize,
512            depth: fidl::encoding::Depth,
513        ) -> fidl::Result<()> {
514            encoder.debug_check_bounds::<PlayerStopPlayingSoundRequest>(offset);
515            // Zero out padding regions. There's no need to apply masks
516            // because the unmasked parts will be overwritten by fields.
517            // Write the fields.
518            self.0.encode(encoder, offset + 0, depth)?;
519            Ok(())
520        }
521    }
522
523    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
524        for PlayerStopPlayingSoundRequest
525    {
526        #[inline(always)]
527        fn new_empty() -> Self {
528            Self { id: fidl::new_empty!(u32, D) }
529        }
530
531        #[inline]
532        unsafe fn decode(
533            &mut self,
534            decoder: &mut fidl::encoding::Decoder<'_, D>,
535            offset: usize,
536            _depth: fidl::encoding::Depth,
537        ) -> fidl::Result<()> {
538            decoder.debug_check_bounds::<Self>(offset);
539            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
540            // Verify that padding bytes are zero.
541            // Copy from the buffer into the object.
542            unsafe {
543                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
544            }
545            Ok(())
546        }
547    }
548
549    impl fidl::encoding::ValueTypeMarker for PlayerAddSoundFromFileResponse {
550        type Borrowed<'a> = &'a Self;
551        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
552            value
553        }
554    }
555
556    unsafe impl fidl::encoding::TypeMarker for PlayerAddSoundFromFileResponse {
557        type Owned = Self;
558
559        #[inline(always)]
560        fn inline_align(_context: fidl::encoding::Context) -> usize {
561            8
562        }
563
564        #[inline(always)]
565        fn inline_size(_context: fidl::encoding::Context) -> usize {
566            8
567        }
568        #[inline(always)]
569        fn encode_is_copy() -> bool {
570            true
571        }
572
573        #[inline(always)]
574        fn decode_is_copy() -> bool {
575            true
576        }
577    }
578
579    unsafe impl<D: fidl::encoding::ResourceDialect>
580        fidl::encoding::Encode<PlayerAddSoundFromFileResponse, D>
581        for &PlayerAddSoundFromFileResponse
582    {
583        #[inline]
584        unsafe fn encode(
585            self,
586            encoder: &mut fidl::encoding::Encoder<'_, D>,
587            offset: usize,
588            _depth: fidl::encoding::Depth,
589        ) -> fidl::Result<()> {
590            encoder.debug_check_bounds::<PlayerAddSoundFromFileResponse>(offset);
591            unsafe {
592                // Copy the object into the buffer.
593                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
594                (buf_ptr as *mut PlayerAddSoundFromFileResponse)
595                    .write_unaligned((self as *const PlayerAddSoundFromFileResponse).read());
596                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
597                // done second because the memcpy will write garbage to these bytes.
598            }
599            Ok(())
600        }
601    }
602    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i64, D>>
603        fidl::encoding::Encode<PlayerAddSoundFromFileResponse, D> for (T0,)
604    {
605        #[inline]
606        unsafe fn encode(
607            self,
608            encoder: &mut fidl::encoding::Encoder<'_, D>,
609            offset: usize,
610            depth: fidl::encoding::Depth,
611        ) -> fidl::Result<()> {
612            encoder.debug_check_bounds::<PlayerAddSoundFromFileResponse>(offset);
613            // Zero out padding regions. There's no need to apply masks
614            // because the unmasked parts will be overwritten by fields.
615            // Write the fields.
616            self.0.encode(encoder, offset + 0, depth)?;
617            Ok(())
618        }
619    }
620
621    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
622        for PlayerAddSoundFromFileResponse
623    {
624        #[inline(always)]
625        fn new_empty() -> Self {
626            Self { duration: fidl::new_empty!(i64, D) }
627        }
628
629        #[inline]
630        unsafe fn decode(
631            &mut self,
632            decoder: &mut fidl::encoding::Decoder<'_, D>,
633            offset: usize,
634            _depth: fidl::encoding::Depth,
635        ) -> fidl::Result<()> {
636            decoder.debug_check_bounds::<Self>(offset);
637            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
638            // Verify that padding bytes are zero.
639            // Copy from the buffer into the object.
640            unsafe {
641                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
642            }
643            Ok(())
644        }
645    }
646}