fidl_fuchsia_media_sounds/
fidl_fuchsia_media_sounds.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::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13/// Error type for `Player.PlaySound`.
14#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
15#[repr(u32)]
16pub enum PlaySoundError {
17    /// The `id` passed to `PlaySound` is not recognized.
18    NoSuchSound = 1,
19    /// Underlying audio renderer failed.
20    RendererFailed = 2,
21    /// Playback of the sound was interrupted by a |StopPlayingSound| method call.
22    Stopped = 3,
23}
24
25impl PlaySoundError {
26    #[inline]
27    pub fn from_primitive(prim: u32) -> Option<Self> {
28        match prim {
29            1 => Some(Self::NoSuchSound),
30            2 => Some(Self::RendererFailed),
31            3 => Some(Self::Stopped),
32            _ => None,
33        }
34    }
35
36    #[inline]
37    pub const fn into_primitive(self) -> u32 {
38        self as u32
39    }
40
41    #[deprecated = "Strict enums should not use `is_unknown`"]
42    #[inline]
43    pub fn is_unknown(&self) -> bool {
44        false
45    }
46}
47
48#[derive(Debug, PartialEq)]
49pub struct PlayerAddSoundBufferRequest {
50    pub id: u32,
51    pub buffer: fidl_fuchsia_mem::Buffer,
52    pub stream_type: fidl_fuchsia_media::AudioStreamType,
53}
54
55impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
56    for PlayerAddSoundBufferRequest
57{
58}
59
60#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
61pub struct PlayerAddSoundFromFileRequest {
62    pub id: u32,
63    pub file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
64}
65
66impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
67    for PlayerAddSoundFromFileRequest
68{
69}
70
71#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
72pub struct PlayerPlaySound2Request {
73    pub id: u32,
74    pub usage: fidl_fuchsia_media::AudioRenderUsage2,
75}
76
77impl fidl::Persistable for PlayerPlaySound2Request {}
78
79#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
80pub struct PlayerPlaySoundRequest {
81    pub id: u32,
82    pub usage: fidl_fuchsia_media::AudioRenderUsage,
83}
84
85impl fidl::Persistable for PlayerPlaySoundRequest {}
86
87#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
88#[repr(C)]
89pub struct PlayerRemoveSoundRequest {
90    pub id: u32,
91}
92
93impl fidl::Persistable for PlayerRemoveSoundRequest {}
94
95#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
96#[repr(C)]
97pub struct PlayerStopPlayingSoundRequest {
98    pub id: u32,
99}
100
101impl fidl::Persistable for PlayerStopPlayingSoundRequest {}
102
103#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
104#[repr(C)]
105pub struct PlayerAddSoundFromFileResponse {
106    pub duration: i64,
107}
108
109impl fidl::Persistable for PlayerAddSoundFromFileResponse {}
110
111#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
112pub struct PlayerMarker;
113
114impl fidl::endpoints::ProtocolMarker for PlayerMarker {
115    type Proxy = PlayerProxy;
116    type RequestStream = PlayerRequestStream;
117    #[cfg(target_os = "fuchsia")]
118    type SynchronousProxy = PlayerSynchronousProxy;
119
120    const DEBUG_NAME: &'static str = "fuchsia.media.sounds.Player";
121}
122impl fidl::endpoints::DiscoverableProtocolMarker for PlayerMarker {}
123pub type PlayerAddSoundFromFileResult = Result<i64, i32>;
124pub type PlayerPlaySoundResult = Result<(), PlaySoundError>;
125pub type PlayerPlaySound2Result = Result<(), PlaySoundError>;
126
127pub trait PlayerProxyInterface: Send + Sync {
128    type AddSoundFromFileResponseFut: std::future::Future<Output = Result<PlayerAddSoundFromFileResult, fidl::Error>>
129        + Send;
130    fn r#add_sound_from_file(
131        &self,
132        id: u32,
133        file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
134    ) -> Self::AddSoundFromFileResponseFut;
135    fn r#add_sound_buffer(
136        &self,
137        id: u32,
138        buffer: fidl_fuchsia_mem::Buffer,
139        stream_type: &fidl_fuchsia_media::AudioStreamType,
140    ) -> Result<(), fidl::Error>;
141    fn r#remove_sound(&self, id: u32) -> Result<(), fidl::Error>;
142    type PlaySoundResponseFut: std::future::Future<Output = Result<PlayerPlaySoundResult, fidl::Error>>
143        + Send;
144    fn r#play_sound(
145        &self,
146        id: u32,
147        usage: fidl_fuchsia_media::AudioRenderUsage,
148    ) -> Self::PlaySoundResponseFut;
149    type PlaySound2ResponseFut: std::future::Future<Output = Result<PlayerPlaySound2Result, fidl::Error>>
150        + Send;
151    fn r#play_sound2(
152        &self,
153        id: u32,
154        usage: fidl_fuchsia_media::AudioRenderUsage2,
155    ) -> Self::PlaySound2ResponseFut;
156    fn r#stop_playing_sound(&self, id: u32) -> Result<(), fidl::Error>;
157}
158#[derive(Debug)]
159#[cfg(target_os = "fuchsia")]
160pub struct PlayerSynchronousProxy {
161    client: fidl::client::sync::Client,
162}
163
164#[cfg(target_os = "fuchsia")]
165impl fidl::endpoints::SynchronousProxy for PlayerSynchronousProxy {
166    type Proxy = PlayerProxy;
167    type Protocol = PlayerMarker;
168
169    fn from_channel(inner: fidl::Channel) -> Self {
170        Self::new(inner)
171    }
172
173    fn into_channel(self) -> fidl::Channel {
174        self.client.into_channel()
175    }
176
177    fn as_channel(&self) -> &fidl::Channel {
178        self.client.as_channel()
179    }
180}
181
182#[cfg(target_os = "fuchsia")]
183impl PlayerSynchronousProxy {
184    pub fn new(channel: fidl::Channel) -> Self {
185        let protocol_name = <PlayerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
186        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
187    }
188
189    pub fn into_channel(self) -> fidl::Channel {
190        self.client.into_channel()
191    }
192
193    /// Waits until an event arrives and returns it. It is safe for other
194    /// threads to make concurrent requests while waiting for an event.
195    pub fn wait_for_event(
196        &self,
197        deadline: zx::MonotonicInstant,
198    ) -> Result<PlayerEvent, fidl::Error> {
199        PlayerEvent::decode(self.client.wait_for_event(deadline)?)
200    }
201
202    /// Adds a sound to the collection maintained for the client, reading the sound from a file.
203    /// If `id` identifies an existing sound in the collection, the service will close the
204    /// connection. Returns the duration of the sound or an error status returned from an I/O
205    /// operation.
206    ///
207    /// Currently, only PCM WAV files and Ogg/Opus files are supported.
208    pub fn r#add_sound_from_file(
209        &self,
210        mut id: u32,
211        mut file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
212        ___deadline: zx::MonotonicInstant,
213    ) -> Result<PlayerAddSoundFromFileResult, fidl::Error> {
214        let _response = self.client.send_query::<
215            PlayerAddSoundFromFileRequest,
216            fidl::encoding::ResultType<PlayerAddSoundFromFileResponse, i32>,
217        >(
218            (id, file,),
219            0x2fd248cffbd53f06,
220            fidl::encoding::DynamicFlags::empty(),
221            ___deadline,
222        )?;
223        Ok(_response.map(|x| x.duration))
224    }
225
226    /// Adds a sound, in the form of a buffer containing raw PCM samples, to the collection
227    /// maintained for the client. The service will retain a handle to the buffer's VMO until the
228    /// sound is removed and is no longer playing or until the connection is closed.
229    ///
230    /// If `id` identifies an existing sound in the collection, the service will close the
231    /// connection.
232    pub fn r#add_sound_buffer(
233        &self,
234        mut id: u32,
235        mut buffer: fidl_fuchsia_mem::Buffer,
236        mut stream_type: &fidl_fuchsia_media::AudioStreamType,
237    ) -> Result<(), fidl::Error> {
238        self.client.send::<PlayerAddSoundBufferRequest>(
239            (id, &mut buffer, stream_type),
240            0x4eaa5c060d71da62,
241            fidl::encoding::DynamicFlags::empty(),
242        )
243    }
244
245    /// Removes a sound from the collection maintained for the client. A sound can be removed even
246    /// if a `PlaySound` method is pending for that sound.
247    ///
248    /// If `id` doesn't identify an existing sound in the collection, the service will do nothing.
249    /// This is tolerated so that clients don't have to wait for the response from
250    /// `AddSoundFromFile` before playing and removing the sound.
251    ///
252    /// Removing an unneeded sound frees the resources associated with that sound, principally
253    /// the VMO required to store the uncompressed sound.
254    pub fn r#remove_sound(&self, mut id: u32) -> Result<(), fidl::Error> {
255        self.client.send::<PlayerRemoveSoundRequest>(
256            (id,),
257            0x1a066f9fcf9ef0c2,
258            fidl::encoding::DynamicFlags::empty(),
259        )
260    }
261
262    /// Plays the existing sound identified by `id` using a renderer with usage `usage`. The
263    /// sound is played as soon as possible. The reply is sent when the sound is finished playing.
264    /// If `id` doesn't identify an existing sound in the collection, the method returns
265    /// `PlaySoundError.NO_SUCH_SOUND`. The most recent `PlaySound` call for a given valid id can
266    /// be stopped using `StopPlayingSound`, in which case, this method returns
267    /// `PlaySoundError.STOPPED`.
268    pub fn r#play_sound(
269        &self,
270        mut id: u32,
271        mut usage: fidl_fuchsia_media::AudioRenderUsage,
272        ___deadline: zx::MonotonicInstant,
273    ) -> Result<PlayerPlaySoundResult, fidl::Error> {
274        let _response = self.client.send_query::<
275            PlayerPlaySoundRequest,
276            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PlaySoundError>,
277        >(
278            (id, usage,),
279            0x76f7d6bd8d1725c1,
280            fidl::encoding::DynamicFlags::empty(),
281            ___deadline,
282        )?;
283        Ok(_response.map(|x| x))
284    }
285
286    pub fn r#play_sound2(
287        &self,
288        mut id: u32,
289        mut usage: fidl_fuchsia_media::AudioRenderUsage2,
290        ___deadline: zx::MonotonicInstant,
291    ) -> Result<PlayerPlaySound2Result, fidl::Error> {
292        let _response = self.client.send_query::<
293            PlayerPlaySound2Request,
294            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, PlaySoundError>,
295        >(
296            (id, usage,),
297            0x5e68b5f96613bc39,
298            fidl::encoding::DynamicFlags::FLEXIBLE,
299            ___deadline,
300        )?
301        .into_result::<PlayerMarker>("play_sound2")?;
302        Ok(_response.map(|x| x))
303    }
304
305    /// Stops playback of the sound identified by `id` invoked by the the most recent call to
306    /// `PlaySound` for that sound. If `id` doesn't identify an existing sound in the collection
307    /// or if the sound is not currently playing, this method does nothing. If more than one
308    /// `PlaySound` method is currently pending for that sound, only the most recent is stopped.
309    pub fn r#stop_playing_sound(&self, mut id: u32) -> Result<(), fidl::Error> {
310        self.client.send::<PlayerStopPlayingSoundRequest>(
311            (id,),
312            0x14487efba2de8152,
313            fidl::encoding::DynamicFlags::empty(),
314        )
315    }
316}
317
318#[derive(Debug, Clone)]
319pub struct PlayerProxy {
320    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
321}
322
323impl fidl::endpoints::Proxy for PlayerProxy {
324    type Protocol = PlayerMarker;
325
326    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
327        Self::new(inner)
328    }
329
330    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
331        self.client.into_channel().map_err(|client| Self { client })
332    }
333
334    fn as_channel(&self) -> &::fidl::AsyncChannel {
335        self.client.as_channel()
336    }
337}
338
339impl PlayerProxy {
340    /// Create a new Proxy for fuchsia.media.sounds/Player.
341    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
342        let protocol_name = <PlayerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
343        Self { client: fidl::client::Client::new(channel, protocol_name) }
344    }
345
346    /// Get a Stream of events from the remote end of the protocol.
347    ///
348    /// # Panics
349    ///
350    /// Panics if the event stream was already taken.
351    pub fn take_event_stream(&self) -> PlayerEventStream {
352        PlayerEventStream { event_receiver: self.client.take_event_receiver() }
353    }
354
355    /// Adds a sound to the collection maintained for the client, reading the sound from a file.
356    /// If `id` identifies an existing sound in the collection, the service will close the
357    /// connection. Returns the duration of the sound or an error status returned from an I/O
358    /// operation.
359    ///
360    /// Currently, only PCM WAV files and Ogg/Opus files are supported.
361    pub fn r#add_sound_from_file(
362        &self,
363        mut id: u32,
364        mut file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
365    ) -> fidl::client::QueryResponseFut<
366        PlayerAddSoundFromFileResult,
367        fidl::encoding::DefaultFuchsiaResourceDialect,
368    > {
369        PlayerProxyInterface::r#add_sound_from_file(self, id, file)
370    }
371
372    /// Adds a sound, in the form of a buffer containing raw PCM samples, to the collection
373    /// maintained for the client. The service will retain a handle to the buffer's VMO until the
374    /// sound is removed and is no longer playing or until the connection is closed.
375    ///
376    /// If `id` identifies an existing sound in the collection, the service will close the
377    /// connection.
378    pub fn r#add_sound_buffer(
379        &self,
380        mut id: u32,
381        mut buffer: fidl_fuchsia_mem::Buffer,
382        mut stream_type: &fidl_fuchsia_media::AudioStreamType,
383    ) -> Result<(), fidl::Error> {
384        PlayerProxyInterface::r#add_sound_buffer(self, id, buffer, stream_type)
385    }
386
387    /// Removes a sound from the collection maintained for the client. A sound can be removed even
388    /// if a `PlaySound` method is pending for that sound.
389    ///
390    /// If `id` doesn't identify an existing sound in the collection, the service will do nothing.
391    /// This is tolerated so that clients don't have to wait for the response from
392    /// `AddSoundFromFile` before playing and removing the sound.
393    ///
394    /// Removing an unneeded sound frees the resources associated with that sound, principally
395    /// the VMO required to store the uncompressed sound.
396    pub fn r#remove_sound(&self, mut id: u32) -> Result<(), fidl::Error> {
397        PlayerProxyInterface::r#remove_sound(self, id)
398    }
399
400    /// Plays the existing sound identified by `id` using a renderer with usage `usage`. The
401    /// sound is played as soon as possible. The reply is sent when the sound is finished playing.
402    /// If `id` doesn't identify an existing sound in the collection, the method returns
403    /// `PlaySoundError.NO_SUCH_SOUND`. The most recent `PlaySound` call for a given valid id can
404    /// be stopped using `StopPlayingSound`, in which case, this method returns
405    /// `PlaySoundError.STOPPED`.
406    pub fn r#play_sound(
407        &self,
408        mut id: u32,
409        mut usage: fidl_fuchsia_media::AudioRenderUsage,
410    ) -> fidl::client::QueryResponseFut<
411        PlayerPlaySoundResult,
412        fidl::encoding::DefaultFuchsiaResourceDialect,
413    > {
414        PlayerProxyInterface::r#play_sound(self, id, usage)
415    }
416
417    pub fn r#play_sound2(
418        &self,
419        mut id: u32,
420        mut usage: fidl_fuchsia_media::AudioRenderUsage2,
421    ) -> fidl::client::QueryResponseFut<
422        PlayerPlaySound2Result,
423        fidl::encoding::DefaultFuchsiaResourceDialect,
424    > {
425        PlayerProxyInterface::r#play_sound2(self, id, usage)
426    }
427
428    /// Stops playback of the sound identified by `id` invoked by the the most recent call to
429    /// `PlaySound` for that sound. If `id` doesn't identify an existing sound in the collection
430    /// or if the sound is not currently playing, this method does nothing. If more than one
431    /// `PlaySound` method is currently pending for that sound, only the most recent is stopped.
432    pub fn r#stop_playing_sound(&self, mut id: u32) -> Result<(), fidl::Error> {
433        PlayerProxyInterface::r#stop_playing_sound(self, id)
434    }
435}
436
437impl PlayerProxyInterface for PlayerProxy {
438    type AddSoundFromFileResponseFut = fidl::client::QueryResponseFut<
439        PlayerAddSoundFromFileResult,
440        fidl::encoding::DefaultFuchsiaResourceDialect,
441    >;
442    fn r#add_sound_from_file(
443        &self,
444        mut id: u32,
445        mut file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
446    ) -> Self::AddSoundFromFileResponseFut {
447        fn _decode(
448            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
449        ) -> Result<PlayerAddSoundFromFileResult, fidl::Error> {
450            let _response = fidl::client::decode_transaction_body::<
451                fidl::encoding::ResultType<PlayerAddSoundFromFileResponse, i32>,
452                fidl::encoding::DefaultFuchsiaResourceDialect,
453                0x2fd248cffbd53f06,
454            >(_buf?)?;
455            Ok(_response.map(|x| x.duration))
456        }
457        self.client
458            .send_query_and_decode::<PlayerAddSoundFromFileRequest, PlayerAddSoundFromFileResult>(
459                (id, file),
460                0x2fd248cffbd53f06,
461                fidl::encoding::DynamicFlags::empty(),
462                _decode,
463            )
464    }
465
466    fn r#add_sound_buffer(
467        &self,
468        mut id: u32,
469        mut buffer: fidl_fuchsia_mem::Buffer,
470        mut stream_type: &fidl_fuchsia_media::AudioStreamType,
471    ) -> Result<(), fidl::Error> {
472        self.client.send::<PlayerAddSoundBufferRequest>(
473            (id, &mut buffer, stream_type),
474            0x4eaa5c060d71da62,
475            fidl::encoding::DynamicFlags::empty(),
476        )
477    }
478
479    fn r#remove_sound(&self, mut id: u32) -> Result<(), fidl::Error> {
480        self.client.send::<PlayerRemoveSoundRequest>(
481            (id,),
482            0x1a066f9fcf9ef0c2,
483            fidl::encoding::DynamicFlags::empty(),
484        )
485    }
486
487    type PlaySoundResponseFut = fidl::client::QueryResponseFut<
488        PlayerPlaySoundResult,
489        fidl::encoding::DefaultFuchsiaResourceDialect,
490    >;
491    fn r#play_sound(
492        &self,
493        mut id: u32,
494        mut usage: fidl_fuchsia_media::AudioRenderUsage,
495    ) -> Self::PlaySoundResponseFut {
496        fn _decode(
497            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
498        ) -> Result<PlayerPlaySoundResult, fidl::Error> {
499            let _response = fidl::client::decode_transaction_body::<
500                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PlaySoundError>,
501                fidl::encoding::DefaultFuchsiaResourceDialect,
502                0x76f7d6bd8d1725c1,
503            >(_buf?)?;
504            Ok(_response.map(|x| x))
505        }
506        self.client.send_query_and_decode::<PlayerPlaySoundRequest, PlayerPlaySoundResult>(
507            (id, usage),
508            0x76f7d6bd8d1725c1,
509            fidl::encoding::DynamicFlags::empty(),
510            _decode,
511        )
512    }
513
514    type PlaySound2ResponseFut = fidl::client::QueryResponseFut<
515        PlayerPlaySound2Result,
516        fidl::encoding::DefaultFuchsiaResourceDialect,
517    >;
518    fn r#play_sound2(
519        &self,
520        mut id: u32,
521        mut usage: fidl_fuchsia_media::AudioRenderUsage2,
522    ) -> Self::PlaySound2ResponseFut {
523        fn _decode(
524            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
525        ) -> Result<PlayerPlaySound2Result, fidl::Error> {
526            let _response = fidl::client::decode_transaction_body::<
527                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, PlaySoundError>,
528                fidl::encoding::DefaultFuchsiaResourceDialect,
529                0x5e68b5f96613bc39,
530            >(_buf?)?
531            .into_result::<PlayerMarker>("play_sound2")?;
532            Ok(_response.map(|x| x))
533        }
534        self.client.send_query_and_decode::<PlayerPlaySound2Request, PlayerPlaySound2Result>(
535            (id, usage),
536            0x5e68b5f96613bc39,
537            fidl::encoding::DynamicFlags::FLEXIBLE,
538            _decode,
539        )
540    }
541
542    fn r#stop_playing_sound(&self, mut id: u32) -> Result<(), fidl::Error> {
543        self.client.send::<PlayerStopPlayingSoundRequest>(
544            (id,),
545            0x14487efba2de8152,
546            fidl::encoding::DynamicFlags::empty(),
547        )
548    }
549}
550
551pub struct PlayerEventStream {
552    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
553}
554
555impl std::marker::Unpin for PlayerEventStream {}
556
557impl futures::stream::FusedStream for PlayerEventStream {
558    fn is_terminated(&self) -> bool {
559        self.event_receiver.is_terminated()
560    }
561}
562
563impl futures::Stream for PlayerEventStream {
564    type Item = Result<PlayerEvent, fidl::Error>;
565
566    fn poll_next(
567        mut self: std::pin::Pin<&mut Self>,
568        cx: &mut std::task::Context<'_>,
569    ) -> std::task::Poll<Option<Self::Item>> {
570        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
571            &mut self.event_receiver,
572            cx
573        )?) {
574            Some(buf) => std::task::Poll::Ready(Some(PlayerEvent::decode(buf))),
575            None => std::task::Poll::Ready(None),
576        }
577    }
578}
579
580#[derive(Debug)]
581pub enum PlayerEvent {
582    #[non_exhaustive]
583    _UnknownEvent {
584        /// Ordinal of the event that was sent.
585        ordinal: u64,
586    },
587}
588
589impl PlayerEvent {
590    /// Decodes a message buffer as a [`PlayerEvent`].
591    fn decode(
592        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
593    ) -> Result<PlayerEvent, fidl::Error> {
594        let (bytes, _handles) = buf.split_mut();
595        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
596        debug_assert_eq!(tx_header.tx_id, 0);
597        match tx_header.ordinal {
598            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
599                Ok(PlayerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
600            }
601            _ => Err(fidl::Error::UnknownOrdinal {
602                ordinal: tx_header.ordinal,
603                protocol_name: <PlayerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
604            }),
605        }
606    }
607}
608
609/// A Stream of incoming requests for fuchsia.media.sounds/Player.
610pub struct PlayerRequestStream {
611    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
612    is_terminated: bool,
613}
614
615impl std::marker::Unpin for PlayerRequestStream {}
616
617impl futures::stream::FusedStream for PlayerRequestStream {
618    fn is_terminated(&self) -> bool {
619        self.is_terminated
620    }
621}
622
623impl fidl::endpoints::RequestStream for PlayerRequestStream {
624    type Protocol = PlayerMarker;
625    type ControlHandle = PlayerControlHandle;
626
627    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
628        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
629    }
630
631    fn control_handle(&self) -> Self::ControlHandle {
632        PlayerControlHandle { inner: self.inner.clone() }
633    }
634
635    fn into_inner(
636        self,
637    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
638    {
639        (self.inner, self.is_terminated)
640    }
641
642    fn from_inner(
643        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
644        is_terminated: bool,
645    ) -> Self {
646        Self { inner, is_terminated }
647    }
648}
649
650impl futures::Stream for PlayerRequestStream {
651    type Item = Result<PlayerRequest, fidl::Error>;
652
653    fn poll_next(
654        mut self: std::pin::Pin<&mut Self>,
655        cx: &mut std::task::Context<'_>,
656    ) -> std::task::Poll<Option<Self::Item>> {
657        let this = &mut *self;
658        if this.inner.check_shutdown(cx) {
659            this.is_terminated = true;
660            return std::task::Poll::Ready(None);
661        }
662        if this.is_terminated {
663            panic!("polled PlayerRequestStream after completion");
664        }
665        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
666            |bytes, handles| {
667                match this.inner.channel().read_etc(cx, bytes, handles) {
668                    std::task::Poll::Ready(Ok(())) => {}
669                    std::task::Poll::Pending => return std::task::Poll::Pending,
670                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
671                        this.is_terminated = true;
672                        return std::task::Poll::Ready(None);
673                    }
674                    std::task::Poll::Ready(Err(e)) => {
675                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
676                            e.into(),
677                        ))))
678                    }
679                }
680
681                // A message has been received from the channel
682                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
683
684                std::task::Poll::Ready(Some(match header.ordinal {
685                    0x2fd248cffbd53f06 => {
686                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
687                        let mut req = fidl::new_empty!(
688                            PlayerAddSoundFromFileRequest,
689                            fidl::encoding::DefaultFuchsiaResourceDialect
690                        );
691                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerAddSoundFromFileRequest>(&header, _body_bytes, handles, &mut req)?;
692                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
693                        Ok(PlayerRequest::AddSoundFromFile {
694                            id: req.id,
695                            file: req.file,
696
697                            responder: PlayerAddSoundFromFileResponder {
698                                control_handle: std::mem::ManuallyDrop::new(control_handle),
699                                tx_id: header.tx_id,
700                            },
701                        })
702                    }
703                    0x4eaa5c060d71da62 => {
704                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
705                        let mut req = fidl::new_empty!(
706                            PlayerAddSoundBufferRequest,
707                            fidl::encoding::DefaultFuchsiaResourceDialect
708                        );
709                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerAddSoundBufferRequest>(&header, _body_bytes, handles, &mut req)?;
710                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
711                        Ok(PlayerRequest::AddSoundBuffer {
712                            id: req.id,
713                            buffer: req.buffer,
714                            stream_type: req.stream_type,
715
716                            control_handle,
717                        })
718                    }
719                    0x1a066f9fcf9ef0c2 => {
720                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
721                        let mut req = fidl::new_empty!(
722                            PlayerRemoveSoundRequest,
723                            fidl::encoding::DefaultFuchsiaResourceDialect
724                        );
725                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerRemoveSoundRequest>(&header, _body_bytes, handles, &mut req)?;
726                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
727                        Ok(PlayerRequest::RemoveSound { id: req.id, control_handle })
728                    }
729                    0x76f7d6bd8d1725c1 => {
730                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
731                        let mut req = fidl::new_empty!(
732                            PlayerPlaySoundRequest,
733                            fidl::encoding::DefaultFuchsiaResourceDialect
734                        );
735                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerPlaySoundRequest>(&header, _body_bytes, handles, &mut req)?;
736                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
737                        Ok(PlayerRequest::PlaySound {
738                            id: req.id,
739                            usage: req.usage,
740
741                            responder: PlayerPlaySoundResponder {
742                                control_handle: std::mem::ManuallyDrop::new(control_handle),
743                                tx_id: header.tx_id,
744                            },
745                        })
746                    }
747                    0x5e68b5f96613bc39 => {
748                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
749                        let mut req = fidl::new_empty!(
750                            PlayerPlaySound2Request,
751                            fidl::encoding::DefaultFuchsiaResourceDialect
752                        );
753                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerPlaySound2Request>(&header, _body_bytes, handles, &mut req)?;
754                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
755                        Ok(PlayerRequest::PlaySound2 {
756                            id: req.id,
757                            usage: req.usage,
758
759                            responder: PlayerPlaySound2Responder {
760                                control_handle: std::mem::ManuallyDrop::new(control_handle),
761                                tx_id: header.tx_id,
762                            },
763                        })
764                    }
765                    0x14487efba2de8152 => {
766                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
767                        let mut req = fidl::new_empty!(
768                            PlayerStopPlayingSoundRequest,
769                            fidl::encoding::DefaultFuchsiaResourceDialect
770                        );
771                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerStopPlayingSoundRequest>(&header, _body_bytes, handles, &mut req)?;
772                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
773                        Ok(PlayerRequest::StopPlayingSound { id: req.id, control_handle })
774                    }
775                    _ if header.tx_id == 0
776                        && header
777                            .dynamic_flags()
778                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
779                    {
780                        Ok(PlayerRequest::_UnknownMethod {
781                            ordinal: header.ordinal,
782                            control_handle: PlayerControlHandle { inner: this.inner.clone() },
783                            method_type: fidl::MethodType::OneWay,
784                        })
785                    }
786                    _ if header
787                        .dynamic_flags()
788                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
789                    {
790                        this.inner.send_framework_err(
791                            fidl::encoding::FrameworkErr::UnknownMethod,
792                            header.tx_id,
793                            header.ordinal,
794                            header.dynamic_flags(),
795                            (bytes, handles),
796                        )?;
797                        Ok(PlayerRequest::_UnknownMethod {
798                            ordinal: header.ordinal,
799                            control_handle: PlayerControlHandle { inner: this.inner.clone() },
800                            method_type: fidl::MethodType::TwoWay,
801                        })
802                    }
803                    _ => Err(fidl::Error::UnknownOrdinal {
804                        ordinal: header.ordinal,
805                        protocol_name:
806                            <PlayerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
807                    }),
808                }))
809            },
810        )
811    }
812}
813
814/// Allows clients to play fire-and-forget sounds.
815#[derive(Debug)]
816pub enum PlayerRequest {
817    /// Adds a sound to the collection maintained for the client, reading the sound from a file.
818    /// If `id` identifies an existing sound in the collection, the service will close the
819    /// connection. Returns the duration of the sound or an error status returned from an I/O
820    /// operation.
821    ///
822    /// Currently, only PCM WAV files and Ogg/Opus files are supported.
823    AddSoundFromFile {
824        id: u32,
825        file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
826        responder: PlayerAddSoundFromFileResponder,
827    },
828    /// Adds a sound, in the form of a buffer containing raw PCM samples, to the collection
829    /// maintained for the client. The service will retain a handle to the buffer's VMO until the
830    /// sound is removed and is no longer playing or until the connection is closed.
831    ///
832    /// If `id` identifies an existing sound in the collection, the service will close the
833    /// connection.
834    AddSoundBuffer {
835        id: u32,
836        buffer: fidl_fuchsia_mem::Buffer,
837        stream_type: fidl_fuchsia_media::AudioStreamType,
838        control_handle: PlayerControlHandle,
839    },
840    /// Removes a sound from the collection maintained for the client. A sound can be removed even
841    /// if a `PlaySound` method is pending for that sound.
842    ///
843    /// If `id` doesn't identify an existing sound in the collection, the service will do nothing.
844    /// This is tolerated so that clients don't have to wait for the response from
845    /// `AddSoundFromFile` before playing and removing the sound.
846    ///
847    /// Removing an unneeded sound frees the resources associated with that sound, principally
848    /// the VMO required to store the uncompressed sound.
849    RemoveSound { id: u32, control_handle: PlayerControlHandle },
850    /// Plays the existing sound identified by `id` using a renderer with usage `usage`. The
851    /// sound is played as soon as possible. The reply is sent when the sound is finished playing.
852    /// If `id` doesn't identify an existing sound in the collection, the method returns
853    /// `PlaySoundError.NO_SUCH_SOUND`. The most recent `PlaySound` call for a given valid id can
854    /// be stopped using `StopPlayingSound`, in which case, this method returns
855    /// `PlaySoundError.STOPPED`.
856    PlaySound {
857        id: u32,
858        usage: fidl_fuchsia_media::AudioRenderUsage,
859        responder: PlayerPlaySoundResponder,
860    },
861    PlaySound2 {
862        id: u32,
863        usage: fidl_fuchsia_media::AudioRenderUsage2,
864        responder: PlayerPlaySound2Responder,
865    },
866    /// Stops playback of the sound identified by `id` invoked by the the most recent call to
867    /// `PlaySound` for that sound. If `id` doesn't identify an existing sound in the collection
868    /// or if the sound is not currently playing, this method does nothing. If more than one
869    /// `PlaySound` method is currently pending for that sound, only the most recent is stopped.
870    StopPlayingSound { id: u32, control_handle: PlayerControlHandle },
871    /// An interaction was received which does not match any known method.
872    #[non_exhaustive]
873    _UnknownMethod {
874        /// Ordinal of the method that was called.
875        ordinal: u64,
876        control_handle: PlayerControlHandle,
877        method_type: fidl::MethodType,
878    },
879}
880
881impl PlayerRequest {
882    #[allow(irrefutable_let_patterns)]
883    pub fn into_add_sound_from_file(
884        self,
885    ) -> Option<(
886        u32,
887        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
888        PlayerAddSoundFromFileResponder,
889    )> {
890        if let PlayerRequest::AddSoundFromFile { id, file, responder } = self {
891            Some((id, file, responder))
892        } else {
893            None
894        }
895    }
896
897    #[allow(irrefutable_let_patterns)]
898    pub fn into_add_sound_buffer(
899        self,
900    ) -> Option<(
901        u32,
902        fidl_fuchsia_mem::Buffer,
903        fidl_fuchsia_media::AudioStreamType,
904        PlayerControlHandle,
905    )> {
906        if let PlayerRequest::AddSoundBuffer { id, buffer, stream_type, control_handle } = self {
907            Some((id, buffer, stream_type, control_handle))
908        } else {
909            None
910        }
911    }
912
913    #[allow(irrefutable_let_patterns)]
914    pub fn into_remove_sound(self) -> Option<(u32, PlayerControlHandle)> {
915        if let PlayerRequest::RemoveSound { id, control_handle } = self {
916            Some((id, control_handle))
917        } else {
918            None
919        }
920    }
921
922    #[allow(irrefutable_let_patterns)]
923    pub fn into_play_sound(
924        self,
925    ) -> Option<(u32, fidl_fuchsia_media::AudioRenderUsage, PlayerPlaySoundResponder)> {
926        if let PlayerRequest::PlaySound { id, usage, responder } = self {
927            Some((id, usage, responder))
928        } else {
929            None
930        }
931    }
932
933    #[allow(irrefutable_let_patterns)]
934    pub fn into_play_sound2(
935        self,
936    ) -> Option<(u32, fidl_fuchsia_media::AudioRenderUsage2, PlayerPlaySound2Responder)> {
937        if let PlayerRequest::PlaySound2 { id, usage, responder } = self {
938            Some((id, usage, responder))
939        } else {
940            None
941        }
942    }
943
944    #[allow(irrefutable_let_patterns)]
945    pub fn into_stop_playing_sound(self) -> Option<(u32, PlayerControlHandle)> {
946        if let PlayerRequest::StopPlayingSound { id, control_handle } = self {
947            Some((id, control_handle))
948        } else {
949            None
950        }
951    }
952
953    /// Name of the method defined in FIDL
954    pub fn method_name(&self) -> &'static str {
955        match *self {
956            PlayerRequest::AddSoundFromFile { .. } => "add_sound_from_file",
957            PlayerRequest::AddSoundBuffer { .. } => "add_sound_buffer",
958            PlayerRequest::RemoveSound { .. } => "remove_sound",
959            PlayerRequest::PlaySound { .. } => "play_sound",
960            PlayerRequest::PlaySound2 { .. } => "play_sound2",
961            PlayerRequest::StopPlayingSound { .. } => "stop_playing_sound",
962            PlayerRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
963                "unknown one-way method"
964            }
965            PlayerRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
966                "unknown two-way method"
967            }
968        }
969    }
970}
971
972#[derive(Debug, Clone)]
973pub struct PlayerControlHandle {
974    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
975}
976
977impl fidl::endpoints::ControlHandle for PlayerControlHandle {
978    fn shutdown(&self) {
979        self.inner.shutdown()
980    }
981    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
982        self.inner.shutdown_with_epitaph(status)
983    }
984
985    fn is_closed(&self) -> bool {
986        self.inner.channel().is_closed()
987    }
988    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
989        self.inner.channel().on_closed()
990    }
991
992    #[cfg(target_os = "fuchsia")]
993    fn signal_peer(
994        &self,
995        clear_mask: zx::Signals,
996        set_mask: zx::Signals,
997    ) -> Result<(), zx_status::Status> {
998        use fidl::Peered;
999        self.inner.channel().signal_peer(clear_mask, set_mask)
1000    }
1001}
1002
1003impl PlayerControlHandle {}
1004
1005#[must_use = "FIDL methods require a response to be sent"]
1006#[derive(Debug)]
1007pub struct PlayerAddSoundFromFileResponder {
1008    control_handle: std::mem::ManuallyDrop<PlayerControlHandle>,
1009    tx_id: u32,
1010}
1011
1012/// Set the the channel to be shutdown (see [`PlayerControlHandle::shutdown`])
1013/// if the responder is dropped without sending a response, so that the client
1014/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1015impl std::ops::Drop for PlayerAddSoundFromFileResponder {
1016    fn drop(&mut self) {
1017        self.control_handle.shutdown();
1018        // Safety: drops once, never accessed again
1019        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1020    }
1021}
1022
1023impl fidl::endpoints::Responder for PlayerAddSoundFromFileResponder {
1024    type ControlHandle = PlayerControlHandle;
1025
1026    fn control_handle(&self) -> &PlayerControlHandle {
1027        &self.control_handle
1028    }
1029
1030    fn drop_without_shutdown(mut self) {
1031        // Safety: drops once, never accessed again due to mem::forget
1032        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1033        // Prevent Drop from running (which would shut down the channel)
1034        std::mem::forget(self);
1035    }
1036}
1037
1038impl PlayerAddSoundFromFileResponder {
1039    /// Sends a response to the FIDL transaction.
1040    ///
1041    /// Sets the channel to shutdown if an error occurs.
1042    pub fn send(self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1043        let _result = self.send_raw(result);
1044        if _result.is_err() {
1045            self.control_handle.shutdown();
1046        }
1047        self.drop_without_shutdown();
1048        _result
1049    }
1050
1051    /// Similar to "send" but does not shutdown the channel if an error occurs.
1052    pub fn send_no_shutdown_on_err(self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1053        let _result = self.send_raw(result);
1054        self.drop_without_shutdown();
1055        _result
1056    }
1057
1058    fn send_raw(&self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1059        self.control_handle
1060            .inner
1061            .send::<fidl::encoding::ResultType<PlayerAddSoundFromFileResponse, i32>>(
1062                result.map(|duration| (duration,)),
1063                self.tx_id,
1064                0x2fd248cffbd53f06,
1065                fidl::encoding::DynamicFlags::empty(),
1066            )
1067    }
1068}
1069
1070#[must_use = "FIDL methods require a response to be sent"]
1071#[derive(Debug)]
1072pub struct PlayerPlaySoundResponder {
1073    control_handle: std::mem::ManuallyDrop<PlayerControlHandle>,
1074    tx_id: u32,
1075}
1076
1077/// Set the the channel to be shutdown (see [`PlayerControlHandle::shutdown`])
1078/// if the responder is dropped without sending a response, so that the client
1079/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1080impl std::ops::Drop for PlayerPlaySoundResponder {
1081    fn drop(&mut self) {
1082        self.control_handle.shutdown();
1083        // Safety: drops once, never accessed again
1084        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1085    }
1086}
1087
1088impl fidl::endpoints::Responder for PlayerPlaySoundResponder {
1089    type ControlHandle = PlayerControlHandle;
1090
1091    fn control_handle(&self) -> &PlayerControlHandle {
1092        &self.control_handle
1093    }
1094
1095    fn drop_without_shutdown(mut self) {
1096        // Safety: drops once, never accessed again due to mem::forget
1097        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1098        // Prevent Drop from running (which would shut down the channel)
1099        std::mem::forget(self);
1100    }
1101}
1102
1103impl PlayerPlaySoundResponder {
1104    /// Sends a response to the FIDL transaction.
1105    ///
1106    /// Sets the channel to shutdown if an error occurs.
1107    pub fn send(self, mut result: Result<(), PlaySoundError>) -> Result<(), fidl::Error> {
1108        let _result = self.send_raw(result);
1109        if _result.is_err() {
1110            self.control_handle.shutdown();
1111        }
1112        self.drop_without_shutdown();
1113        _result
1114    }
1115
1116    /// Similar to "send" but does not shutdown the channel if an error occurs.
1117    pub fn send_no_shutdown_on_err(
1118        self,
1119        mut result: Result<(), PlaySoundError>,
1120    ) -> Result<(), fidl::Error> {
1121        let _result = self.send_raw(result);
1122        self.drop_without_shutdown();
1123        _result
1124    }
1125
1126    fn send_raw(&self, mut result: Result<(), PlaySoundError>) -> Result<(), fidl::Error> {
1127        self.control_handle.inner.send::<fidl::encoding::ResultType<
1128            fidl::encoding::EmptyStruct,
1129            PlaySoundError,
1130        >>(
1131            result,
1132            self.tx_id,
1133            0x76f7d6bd8d1725c1,
1134            fidl::encoding::DynamicFlags::empty(),
1135        )
1136    }
1137}
1138
1139#[must_use = "FIDL methods require a response to be sent"]
1140#[derive(Debug)]
1141pub struct PlayerPlaySound2Responder {
1142    control_handle: std::mem::ManuallyDrop<PlayerControlHandle>,
1143    tx_id: u32,
1144}
1145
1146/// Set the the channel to be shutdown (see [`PlayerControlHandle::shutdown`])
1147/// if the responder is dropped without sending a response, so that the client
1148/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1149impl std::ops::Drop for PlayerPlaySound2Responder {
1150    fn drop(&mut self) {
1151        self.control_handle.shutdown();
1152        // Safety: drops once, never accessed again
1153        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1154    }
1155}
1156
1157impl fidl::endpoints::Responder for PlayerPlaySound2Responder {
1158    type ControlHandle = PlayerControlHandle;
1159
1160    fn control_handle(&self) -> &PlayerControlHandle {
1161        &self.control_handle
1162    }
1163
1164    fn drop_without_shutdown(mut self) {
1165        // Safety: drops once, never accessed again due to mem::forget
1166        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1167        // Prevent Drop from running (which would shut down the channel)
1168        std::mem::forget(self);
1169    }
1170}
1171
1172impl PlayerPlaySound2Responder {
1173    /// Sends a response to the FIDL transaction.
1174    ///
1175    /// Sets the channel to shutdown if an error occurs.
1176    pub fn send(self, mut result: Result<(), PlaySoundError>) -> Result<(), fidl::Error> {
1177        let _result = self.send_raw(result);
1178        if _result.is_err() {
1179            self.control_handle.shutdown();
1180        }
1181        self.drop_without_shutdown();
1182        _result
1183    }
1184
1185    /// Similar to "send" but does not shutdown the channel if an error occurs.
1186    pub fn send_no_shutdown_on_err(
1187        self,
1188        mut result: Result<(), PlaySoundError>,
1189    ) -> Result<(), fidl::Error> {
1190        let _result = self.send_raw(result);
1191        self.drop_without_shutdown();
1192        _result
1193    }
1194
1195    fn send_raw(&self, mut result: Result<(), PlaySoundError>) -> Result<(), fidl::Error> {
1196        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1197            fidl::encoding::EmptyStruct,
1198            PlaySoundError,
1199        >>(
1200            fidl::encoding::FlexibleResult::new(result),
1201            self.tx_id,
1202            0x5e68b5f96613bc39,
1203            fidl::encoding::DynamicFlags::FLEXIBLE,
1204        )
1205    }
1206}
1207
1208mod internal {
1209    use super::*;
1210    unsafe impl fidl::encoding::TypeMarker for PlaySoundError {
1211        type Owned = Self;
1212
1213        #[inline(always)]
1214        fn inline_align(_context: fidl::encoding::Context) -> usize {
1215            std::mem::align_of::<u32>()
1216        }
1217
1218        #[inline(always)]
1219        fn inline_size(_context: fidl::encoding::Context) -> usize {
1220            std::mem::size_of::<u32>()
1221        }
1222
1223        #[inline(always)]
1224        fn encode_is_copy() -> bool {
1225            true
1226        }
1227
1228        #[inline(always)]
1229        fn decode_is_copy() -> bool {
1230            false
1231        }
1232    }
1233
1234    impl fidl::encoding::ValueTypeMarker for PlaySoundError {
1235        type Borrowed<'a> = Self;
1236        #[inline(always)]
1237        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1238            *value
1239        }
1240    }
1241
1242    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for PlaySoundError {
1243        #[inline]
1244        unsafe fn encode(
1245            self,
1246            encoder: &mut fidl::encoding::Encoder<'_, D>,
1247            offset: usize,
1248            _depth: fidl::encoding::Depth,
1249        ) -> fidl::Result<()> {
1250            encoder.debug_check_bounds::<Self>(offset);
1251            encoder.write_num(self.into_primitive(), offset);
1252            Ok(())
1253        }
1254    }
1255
1256    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PlaySoundError {
1257        #[inline(always)]
1258        fn new_empty() -> Self {
1259            Self::NoSuchSound
1260        }
1261
1262        #[inline]
1263        unsafe fn decode(
1264            &mut self,
1265            decoder: &mut fidl::encoding::Decoder<'_, D>,
1266            offset: usize,
1267            _depth: fidl::encoding::Depth,
1268        ) -> fidl::Result<()> {
1269            decoder.debug_check_bounds::<Self>(offset);
1270            let prim = decoder.read_num::<u32>(offset);
1271
1272            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1273            Ok(())
1274        }
1275    }
1276
1277    impl fidl::encoding::ResourceTypeMarker for PlayerAddSoundBufferRequest {
1278        type Borrowed<'a> = &'a mut Self;
1279        fn take_or_borrow<'a>(
1280            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1281        ) -> Self::Borrowed<'a> {
1282            value
1283        }
1284    }
1285
1286    unsafe impl fidl::encoding::TypeMarker for PlayerAddSoundBufferRequest {
1287        type Owned = Self;
1288
1289        #[inline(always)]
1290        fn inline_align(_context: fidl::encoding::Context) -> usize {
1291            8
1292        }
1293
1294        #[inline(always)]
1295        fn inline_size(_context: fidl::encoding::Context) -> usize {
1296            40
1297        }
1298    }
1299
1300    unsafe impl
1301        fidl::encoding::Encode<
1302            PlayerAddSoundBufferRequest,
1303            fidl::encoding::DefaultFuchsiaResourceDialect,
1304        > for &mut PlayerAddSoundBufferRequest
1305    {
1306        #[inline]
1307        unsafe fn encode(
1308            self,
1309            encoder: &mut fidl::encoding::Encoder<
1310                '_,
1311                fidl::encoding::DefaultFuchsiaResourceDialect,
1312            >,
1313            offset: usize,
1314            _depth: fidl::encoding::Depth,
1315        ) -> fidl::Result<()> {
1316            encoder.debug_check_bounds::<PlayerAddSoundBufferRequest>(offset);
1317            // Delegate to tuple encoding.
1318            fidl::encoding::Encode::<PlayerAddSoundBufferRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1319                (
1320                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
1321                    <fidl_fuchsia_mem::Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffer),
1322                    <fidl_fuchsia_media::AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
1323                ),
1324                encoder, offset, _depth
1325            )
1326        }
1327    }
1328    unsafe impl<
1329            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
1330            T1: fidl::encoding::Encode<
1331                fidl_fuchsia_mem::Buffer,
1332                fidl::encoding::DefaultFuchsiaResourceDialect,
1333            >,
1334            T2: fidl::encoding::Encode<
1335                fidl_fuchsia_media::AudioStreamType,
1336                fidl::encoding::DefaultFuchsiaResourceDialect,
1337            >,
1338        >
1339        fidl::encoding::Encode<
1340            PlayerAddSoundBufferRequest,
1341            fidl::encoding::DefaultFuchsiaResourceDialect,
1342        > for (T0, T1, T2)
1343    {
1344        #[inline]
1345        unsafe fn encode(
1346            self,
1347            encoder: &mut fidl::encoding::Encoder<
1348                '_,
1349                fidl::encoding::DefaultFuchsiaResourceDialect,
1350            >,
1351            offset: usize,
1352            depth: fidl::encoding::Depth,
1353        ) -> fidl::Result<()> {
1354            encoder.debug_check_bounds::<PlayerAddSoundBufferRequest>(offset);
1355            // Zero out padding regions. There's no need to apply masks
1356            // because the unmasked parts will be overwritten by fields.
1357            unsafe {
1358                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1359                (ptr as *mut u64).write_unaligned(0);
1360            }
1361            unsafe {
1362                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
1363                (ptr as *mut u64).write_unaligned(0);
1364            }
1365            // Write the fields.
1366            self.0.encode(encoder, offset + 0, depth)?;
1367            self.1.encode(encoder, offset + 8, depth)?;
1368            self.2.encode(encoder, offset + 24, depth)?;
1369            Ok(())
1370        }
1371    }
1372
1373    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1374        for PlayerAddSoundBufferRequest
1375    {
1376        #[inline(always)]
1377        fn new_empty() -> Self {
1378            Self {
1379                id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
1380                buffer: fidl::new_empty!(
1381                    fidl_fuchsia_mem::Buffer,
1382                    fidl::encoding::DefaultFuchsiaResourceDialect
1383                ),
1384                stream_type: fidl::new_empty!(
1385                    fidl_fuchsia_media::AudioStreamType,
1386                    fidl::encoding::DefaultFuchsiaResourceDialect
1387                ),
1388            }
1389        }
1390
1391        #[inline]
1392        unsafe fn decode(
1393            &mut self,
1394            decoder: &mut fidl::encoding::Decoder<
1395                '_,
1396                fidl::encoding::DefaultFuchsiaResourceDialect,
1397            >,
1398            offset: usize,
1399            _depth: fidl::encoding::Depth,
1400        ) -> fidl::Result<()> {
1401            decoder.debug_check_bounds::<Self>(offset);
1402            // Verify that padding bytes are zero.
1403            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1404            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1405            let mask = 0xffffffff00000000u64;
1406            let maskedval = padval & mask;
1407            if maskedval != 0 {
1408                return Err(fidl::Error::NonZeroPadding {
1409                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1410                });
1411            }
1412            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
1413            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1414            let mask = 0xffffffff00000000u64;
1415            let maskedval = padval & mask;
1416            if maskedval != 0 {
1417                return Err(fidl::Error::NonZeroPadding {
1418                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
1419                });
1420            }
1421            fidl::decode!(
1422                u32,
1423                fidl::encoding::DefaultFuchsiaResourceDialect,
1424                &mut self.id,
1425                decoder,
1426                offset + 0,
1427                _depth
1428            )?;
1429            fidl::decode!(
1430                fidl_fuchsia_mem::Buffer,
1431                fidl::encoding::DefaultFuchsiaResourceDialect,
1432                &mut self.buffer,
1433                decoder,
1434                offset + 8,
1435                _depth
1436            )?;
1437            fidl::decode!(
1438                fidl_fuchsia_media::AudioStreamType,
1439                fidl::encoding::DefaultFuchsiaResourceDialect,
1440                &mut self.stream_type,
1441                decoder,
1442                offset + 24,
1443                _depth
1444            )?;
1445            Ok(())
1446        }
1447    }
1448
1449    impl fidl::encoding::ResourceTypeMarker for PlayerAddSoundFromFileRequest {
1450        type Borrowed<'a> = &'a mut Self;
1451        fn take_or_borrow<'a>(
1452            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1453        ) -> Self::Borrowed<'a> {
1454            value
1455        }
1456    }
1457
1458    unsafe impl fidl::encoding::TypeMarker for PlayerAddSoundFromFileRequest {
1459        type Owned = Self;
1460
1461        #[inline(always)]
1462        fn inline_align(_context: fidl::encoding::Context) -> usize {
1463            4
1464        }
1465
1466        #[inline(always)]
1467        fn inline_size(_context: fidl::encoding::Context) -> usize {
1468            8
1469        }
1470    }
1471
1472    unsafe impl
1473        fidl::encoding::Encode<
1474            PlayerAddSoundFromFileRequest,
1475            fidl::encoding::DefaultFuchsiaResourceDialect,
1476        > for &mut PlayerAddSoundFromFileRequest
1477    {
1478        #[inline]
1479        unsafe fn encode(
1480            self,
1481            encoder: &mut fidl::encoding::Encoder<
1482                '_,
1483                fidl::encoding::DefaultFuchsiaResourceDialect,
1484            >,
1485            offset: usize,
1486            _depth: fidl::encoding::Depth,
1487        ) -> fidl::Result<()> {
1488            encoder.debug_check_bounds::<PlayerAddSoundFromFileRequest>(offset);
1489            // Delegate to tuple encoding.
1490            fidl::encoding::Encode::<
1491                PlayerAddSoundFromFileRequest,
1492                fidl::encoding::DefaultFuchsiaResourceDialect,
1493            >::encode(
1494                (
1495                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
1496                    <fidl::encoding::Endpoint<
1497                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
1498                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1499                        &mut self.file
1500                    ),
1501                ),
1502                encoder,
1503                offset,
1504                _depth,
1505            )
1506        }
1507    }
1508    unsafe impl<
1509            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
1510            T1: fidl::encoding::Encode<
1511                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
1512                fidl::encoding::DefaultFuchsiaResourceDialect,
1513            >,
1514        >
1515        fidl::encoding::Encode<
1516            PlayerAddSoundFromFileRequest,
1517            fidl::encoding::DefaultFuchsiaResourceDialect,
1518        > for (T0, T1)
1519    {
1520        #[inline]
1521        unsafe fn encode(
1522            self,
1523            encoder: &mut fidl::encoding::Encoder<
1524                '_,
1525                fidl::encoding::DefaultFuchsiaResourceDialect,
1526            >,
1527            offset: usize,
1528            depth: fidl::encoding::Depth,
1529        ) -> fidl::Result<()> {
1530            encoder.debug_check_bounds::<PlayerAddSoundFromFileRequest>(offset);
1531            // Zero out padding regions. There's no need to apply masks
1532            // because the unmasked parts will be overwritten by fields.
1533            // Write the fields.
1534            self.0.encode(encoder, offset + 0, depth)?;
1535            self.1.encode(encoder, offset + 4, depth)?;
1536            Ok(())
1537        }
1538    }
1539
1540    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1541        for PlayerAddSoundFromFileRequest
1542    {
1543        #[inline(always)]
1544        fn new_empty() -> Self {
1545            Self {
1546                id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
1547                file: fidl::new_empty!(
1548                    fidl::encoding::Endpoint<
1549                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
1550                    >,
1551                    fidl::encoding::DefaultFuchsiaResourceDialect
1552                ),
1553            }
1554        }
1555
1556        #[inline]
1557        unsafe fn decode(
1558            &mut self,
1559            decoder: &mut fidl::encoding::Decoder<
1560                '_,
1561                fidl::encoding::DefaultFuchsiaResourceDialect,
1562            >,
1563            offset: usize,
1564            _depth: fidl::encoding::Depth,
1565        ) -> fidl::Result<()> {
1566            decoder.debug_check_bounds::<Self>(offset);
1567            // Verify that padding bytes are zero.
1568            fidl::decode!(
1569                u32,
1570                fidl::encoding::DefaultFuchsiaResourceDialect,
1571                &mut self.id,
1572                decoder,
1573                offset + 0,
1574                _depth
1575            )?;
1576            fidl::decode!(
1577                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
1578                fidl::encoding::DefaultFuchsiaResourceDialect,
1579                &mut self.file,
1580                decoder,
1581                offset + 4,
1582                _depth
1583            )?;
1584            Ok(())
1585        }
1586    }
1587
1588    impl fidl::encoding::ValueTypeMarker for PlayerPlaySound2Request {
1589        type Borrowed<'a> = &'a Self;
1590        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1591            value
1592        }
1593    }
1594
1595    unsafe impl fidl::encoding::TypeMarker for PlayerPlaySound2Request {
1596        type Owned = Self;
1597
1598        #[inline(always)]
1599        fn inline_align(_context: fidl::encoding::Context) -> usize {
1600            4
1601        }
1602
1603        #[inline(always)]
1604        fn inline_size(_context: fidl::encoding::Context) -> usize {
1605            8
1606        }
1607    }
1608
1609    unsafe impl<D: fidl::encoding::ResourceDialect>
1610        fidl::encoding::Encode<PlayerPlaySound2Request, D> for &PlayerPlaySound2Request
1611    {
1612        #[inline]
1613        unsafe fn encode(
1614            self,
1615            encoder: &mut fidl::encoding::Encoder<'_, D>,
1616            offset: usize,
1617            _depth: fidl::encoding::Depth,
1618        ) -> fidl::Result<()> {
1619            encoder.debug_check_bounds::<PlayerPlaySound2Request>(offset);
1620            // Delegate to tuple encoding.
1621            fidl::encoding::Encode::<PlayerPlaySound2Request, D>::encode(
1622                (
1623                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
1624                    <fidl_fuchsia_media::AudioRenderUsage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
1625                ),
1626                encoder, offset, _depth
1627            )
1628        }
1629    }
1630    unsafe impl<
1631            D: fidl::encoding::ResourceDialect,
1632            T0: fidl::encoding::Encode<u32, D>,
1633            T1: fidl::encoding::Encode<fidl_fuchsia_media::AudioRenderUsage2, D>,
1634        > fidl::encoding::Encode<PlayerPlaySound2Request, D> for (T0, T1)
1635    {
1636        #[inline]
1637        unsafe fn encode(
1638            self,
1639            encoder: &mut fidl::encoding::Encoder<'_, D>,
1640            offset: usize,
1641            depth: fidl::encoding::Depth,
1642        ) -> fidl::Result<()> {
1643            encoder.debug_check_bounds::<PlayerPlaySound2Request>(offset);
1644            // Zero out padding regions. There's no need to apply masks
1645            // because the unmasked parts will be overwritten by fields.
1646            // Write the fields.
1647            self.0.encode(encoder, offset + 0, depth)?;
1648            self.1.encode(encoder, offset + 4, depth)?;
1649            Ok(())
1650        }
1651    }
1652
1653    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1654        for PlayerPlaySound2Request
1655    {
1656        #[inline(always)]
1657        fn new_empty() -> Self {
1658            Self {
1659                id: fidl::new_empty!(u32, D),
1660                usage: fidl::new_empty!(fidl_fuchsia_media::AudioRenderUsage2, D),
1661            }
1662        }
1663
1664        #[inline]
1665        unsafe fn decode(
1666            &mut self,
1667            decoder: &mut fidl::encoding::Decoder<'_, D>,
1668            offset: usize,
1669            _depth: fidl::encoding::Depth,
1670        ) -> fidl::Result<()> {
1671            decoder.debug_check_bounds::<Self>(offset);
1672            // Verify that padding bytes are zero.
1673            fidl::decode!(u32, D, &mut self.id, decoder, offset + 0, _depth)?;
1674            fidl::decode!(
1675                fidl_fuchsia_media::AudioRenderUsage2,
1676                D,
1677                &mut self.usage,
1678                decoder,
1679                offset + 4,
1680                _depth
1681            )?;
1682            Ok(())
1683        }
1684    }
1685
1686    impl fidl::encoding::ValueTypeMarker for PlayerPlaySoundRequest {
1687        type Borrowed<'a> = &'a Self;
1688        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1689            value
1690        }
1691    }
1692
1693    unsafe impl fidl::encoding::TypeMarker for PlayerPlaySoundRequest {
1694        type Owned = Self;
1695
1696        #[inline(always)]
1697        fn inline_align(_context: fidl::encoding::Context) -> usize {
1698            4
1699        }
1700
1701        #[inline(always)]
1702        fn inline_size(_context: fidl::encoding::Context) -> usize {
1703            8
1704        }
1705    }
1706
1707    unsafe impl<D: fidl::encoding::ResourceDialect>
1708        fidl::encoding::Encode<PlayerPlaySoundRequest, D> for &PlayerPlaySoundRequest
1709    {
1710        #[inline]
1711        unsafe fn encode(
1712            self,
1713            encoder: &mut fidl::encoding::Encoder<'_, D>,
1714            offset: usize,
1715            _depth: fidl::encoding::Depth,
1716        ) -> fidl::Result<()> {
1717            encoder.debug_check_bounds::<PlayerPlaySoundRequest>(offset);
1718            // Delegate to tuple encoding.
1719            fidl::encoding::Encode::<PlayerPlaySoundRequest, D>::encode(
1720                (
1721                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
1722                    <fidl_fuchsia_media::AudioRenderUsage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
1723                ),
1724                encoder, offset, _depth
1725            )
1726        }
1727    }
1728    unsafe impl<
1729            D: fidl::encoding::ResourceDialect,
1730            T0: fidl::encoding::Encode<u32, D>,
1731            T1: fidl::encoding::Encode<fidl_fuchsia_media::AudioRenderUsage, D>,
1732        > fidl::encoding::Encode<PlayerPlaySoundRequest, D> for (T0, T1)
1733    {
1734        #[inline]
1735        unsafe fn encode(
1736            self,
1737            encoder: &mut fidl::encoding::Encoder<'_, D>,
1738            offset: usize,
1739            depth: fidl::encoding::Depth,
1740        ) -> fidl::Result<()> {
1741            encoder.debug_check_bounds::<PlayerPlaySoundRequest>(offset);
1742            // Zero out padding regions. There's no need to apply masks
1743            // because the unmasked parts will be overwritten by fields.
1744            // Write the fields.
1745            self.0.encode(encoder, offset + 0, depth)?;
1746            self.1.encode(encoder, offset + 4, depth)?;
1747            Ok(())
1748        }
1749    }
1750
1751    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1752        for PlayerPlaySoundRequest
1753    {
1754        #[inline(always)]
1755        fn new_empty() -> Self {
1756            Self {
1757                id: fidl::new_empty!(u32, D),
1758                usage: fidl::new_empty!(fidl_fuchsia_media::AudioRenderUsage, D),
1759            }
1760        }
1761
1762        #[inline]
1763        unsafe fn decode(
1764            &mut self,
1765            decoder: &mut fidl::encoding::Decoder<'_, D>,
1766            offset: usize,
1767            _depth: fidl::encoding::Depth,
1768        ) -> fidl::Result<()> {
1769            decoder.debug_check_bounds::<Self>(offset);
1770            // Verify that padding bytes are zero.
1771            fidl::decode!(u32, D, &mut self.id, decoder, offset + 0, _depth)?;
1772            fidl::decode!(
1773                fidl_fuchsia_media::AudioRenderUsage,
1774                D,
1775                &mut self.usage,
1776                decoder,
1777                offset + 4,
1778                _depth
1779            )?;
1780            Ok(())
1781        }
1782    }
1783
1784    impl fidl::encoding::ValueTypeMarker for PlayerRemoveSoundRequest {
1785        type Borrowed<'a> = &'a Self;
1786        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1787            value
1788        }
1789    }
1790
1791    unsafe impl fidl::encoding::TypeMarker for PlayerRemoveSoundRequest {
1792        type Owned = Self;
1793
1794        #[inline(always)]
1795        fn inline_align(_context: fidl::encoding::Context) -> usize {
1796            4
1797        }
1798
1799        #[inline(always)]
1800        fn inline_size(_context: fidl::encoding::Context) -> usize {
1801            4
1802        }
1803        #[inline(always)]
1804        fn encode_is_copy() -> bool {
1805            true
1806        }
1807
1808        #[inline(always)]
1809        fn decode_is_copy() -> bool {
1810            true
1811        }
1812    }
1813
1814    unsafe impl<D: fidl::encoding::ResourceDialect>
1815        fidl::encoding::Encode<PlayerRemoveSoundRequest, D> for &PlayerRemoveSoundRequest
1816    {
1817        #[inline]
1818        unsafe fn encode(
1819            self,
1820            encoder: &mut fidl::encoding::Encoder<'_, D>,
1821            offset: usize,
1822            _depth: fidl::encoding::Depth,
1823        ) -> fidl::Result<()> {
1824            encoder.debug_check_bounds::<PlayerRemoveSoundRequest>(offset);
1825            unsafe {
1826                // Copy the object into the buffer.
1827                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1828                (buf_ptr as *mut PlayerRemoveSoundRequest)
1829                    .write_unaligned((self as *const PlayerRemoveSoundRequest).read());
1830                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1831                // done second because the memcpy will write garbage to these bytes.
1832            }
1833            Ok(())
1834        }
1835    }
1836    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
1837        fidl::encoding::Encode<PlayerRemoveSoundRequest, D> for (T0,)
1838    {
1839        #[inline]
1840        unsafe fn encode(
1841            self,
1842            encoder: &mut fidl::encoding::Encoder<'_, D>,
1843            offset: usize,
1844            depth: fidl::encoding::Depth,
1845        ) -> fidl::Result<()> {
1846            encoder.debug_check_bounds::<PlayerRemoveSoundRequest>(offset);
1847            // Zero out padding regions. There's no need to apply masks
1848            // because the unmasked parts will be overwritten by fields.
1849            // Write the fields.
1850            self.0.encode(encoder, offset + 0, depth)?;
1851            Ok(())
1852        }
1853    }
1854
1855    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1856        for PlayerRemoveSoundRequest
1857    {
1858        #[inline(always)]
1859        fn new_empty() -> Self {
1860            Self { id: fidl::new_empty!(u32, D) }
1861        }
1862
1863        #[inline]
1864        unsafe fn decode(
1865            &mut self,
1866            decoder: &mut fidl::encoding::Decoder<'_, D>,
1867            offset: usize,
1868            _depth: fidl::encoding::Depth,
1869        ) -> fidl::Result<()> {
1870            decoder.debug_check_bounds::<Self>(offset);
1871            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1872            // Verify that padding bytes are zero.
1873            // Copy from the buffer into the object.
1874            unsafe {
1875                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1876            }
1877            Ok(())
1878        }
1879    }
1880
1881    impl fidl::encoding::ValueTypeMarker for PlayerStopPlayingSoundRequest {
1882        type Borrowed<'a> = &'a Self;
1883        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1884            value
1885        }
1886    }
1887
1888    unsafe impl fidl::encoding::TypeMarker for PlayerStopPlayingSoundRequest {
1889        type Owned = Self;
1890
1891        #[inline(always)]
1892        fn inline_align(_context: fidl::encoding::Context) -> usize {
1893            4
1894        }
1895
1896        #[inline(always)]
1897        fn inline_size(_context: fidl::encoding::Context) -> usize {
1898            4
1899        }
1900        #[inline(always)]
1901        fn encode_is_copy() -> bool {
1902            true
1903        }
1904
1905        #[inline(always)]
1906        fn decode_is_copy() -> bool {
1907            true
1908        }
1909    }
1910
1911    unsafe impl<D: fidl::encoding::ResourceDialect>
1912        fidl::encoding::Encode<PlayerStopPlayingSoundRequest, D>
1913        for &PlayerStopPlayingSoundRequest
1914    {
1915        #[inline]
1916        unsafe fn encode(
1917            self,
1918            encoder: &mut fidl::encoding::Encoder<'_, D>,
1919            offset: usize,
1920            _depth: fidl::encoding::Depth,
1921        ) -> fidl::Result<()> {
1922            encoder.debug_check_bounds::<PlayerStopPlayingSoundRequest>(offset);
1923            unsafe {
1924                // Copy the object into the buffer.
1925                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1926                (buf_ptr as *mut PlayerStopPlayingSoundRequest)
1927                    .write_unaligned((self as *const PlayerStopPlayingSoundRequest).read());
1928                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1929                // done second because the memcpy will write garbage to these bytes.
1930            }
1931            Ok(())
1932        }
1933    }
1934    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
1935        fidl::encoding::Encode<PlayerStopPlayingSoundRequest, D> for (T0,)
1936    {
1937        #[inline]
1938        unsafe fn encode(
1939            self,
1940            encoder: &mut fidl::encoding::Encoder<'_, D>,
1941            offset: usize,
1942            depth: fidl::encoding::Depth,
1943        ) -> fidl::Result<()> {
1944            encoder.debug_check_bounds::<PlayerStopPlayingSoundRequest>(offset);
1945            // Zero out padding regions. There's no need to apply masks
1946            // because the unmasked parts will be overwritten by fields.
1947            // Write the fields.
1948            self.0.encode(encoder, offset + 0, depth)?;
1949            Ok(())
1950        }
1951    }
1952
1953    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1954        for PlayerStopPlayingSoundRequest
1955    {
1956        #[inline(always)]
1957        fn new_empty() -> Self {
1958            Self { id: fidl::new_empty!(u32, D) }
1959        }
1960
1961        #[inline]
1962        unsafe fn decode(
1963            &mut self,
1964            decoder: &mut fidl::encoding::Decoder<'_, D>,
1965            offset: usize,
1966            _depth: fidl::encoding::Depth,
1967        ) -> fidl::Result<()> {
1968            decoder.debug_check_bounds::<Self>(offset);
1969            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1970            // Verify that padding bytes are zero.
1971            // Copy from the buffer into the object.
1972            unsafe {
1973                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1974            }
1975            Ok(())
1976        }
1977    }
1978
1979    impl fidl::encoding::ValueTypeMarker for PlayerAddSoundFromFileResponse {
1980        type Borrowed<'a> = &'a Self;
1981        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1982            value
1983        }
1984    }
1985
1986    unsafe impl fidl::encoding::TypeMarker for PlayerAddSoundFromFileResponse {
1987        type Owned = Self;
1988
1989        #[inline(always)]
1990        fn inline_align(_context: fidl::encoding::Context) -> usize {
1991            8
1992        }
1993
1994        #[inline(always)]
1995        fn inline_size(_context: fidl::encoding::Context) -> usize {
1996            8
1997        }
1998        #[inline(always)]
1999        fn encode_is_copy() -> bool {
2000            true
2001        }
2002
2003        #[inline(always)]
2004        fn decode_is_copy() -> bool {
2005            true
2006        }
2007    }
2008
2009    unsafe impl<D: fidl::encoding::ResourceDialect>
2010        fidl::encoding::Encode<PlayerAddSoundFromFileResponse, D>
2011        for &PlayerAddSoundFromFileResponse
2012    {
2013        #[inline]
2014        unsafe fn encode(
2015            self,
2016            encoder: &mut fidl::encoding::Encoder<'_, D>,
2017            offset: usize,
2018            _depth: fidl::encoding::Depth,
2019        ) -> fidl::Result<()> {
2020            encoder.debug_check_bounds::<PlayerAddSoundFromFileResponse>(offset);
2021            unsafe {
2022                // Copy the object into the buffer.
2023                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
2024                (buf_ptr as *mut PlayerAddSoundFromFileResponse)
2025                    .write_unaligned((self as *const PlayerAddSoundFromFileResponse).read());
2026                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
2027                // done second because the memcpy will write garbage to these bytes.
2028            }
2029            Ok(())
2030        }
2031    }
2032    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i64, D>>
2033        fidl::encoding::Encode<PlayerAddSoundFromFileResponse, D> for (T0,)
2034    {
2035        #[inline]
2036        unsafe fn encode(
2037            self,
2038            encoder: &mut fidl::encoding::Encoder<'_, D>,
2039            offset: usize,
2040            depth: fidl::encoding::Depth,
2041        ) -> fidl::Result<()> {
2042            encoder.debug_check_bounds::<PlayerAddSoundFromFileResponse>(offset);
2043            // Zero out padding regions. There's no need to apply masks
2044            // because the unmasked parts will be overwritten by fields.
2045            // Write the fields.
2046            self.0.encode(encoder, offset + 0, depth)?;
2047            Ok(())
2048        }
2049    }
2050
2051    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2052        for PlayerAddSoundFromFileResponse
2053    {
2054        #[inline(always)]
2055        fn new_empty() -> Self {
2056            Self { duration: fidl::new_empty!(i64, D) }
2057        }
2058
2059        #[inline]
2060        unsafe fn decode(
2061            &mut self,
2062            decoder: &mut fidl::encoding::Decoder<'_, D>,
2063            offset: usize,
2064            _depth: fidl::encoding::Depth,
2065        ) -> fidl::Result<()> {
2066            decoder.debug_check_bounds::<Self>(offset);
2067            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
2068            // Verify that padding bytes are zero.
2069            // Copy from the buffer into the object.
2070            unsafe {
2071                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
2072            }
2073            Ok(())
2074        }
2075    }
2076}