Skip to main content

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 _};
10pub use fidl_fuchsia_media_sounds_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct PlayerAddSoundBufferRequest {
16    pub id: u32,
17    pub buffer: fidl_fuchsia_mem::Buffer,
18    pub stream_type: fidl_fuchsia_media::AudioStreamType,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
22    for PlayerAddSoundBufferRequest
23{
24}
25
26#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
27pub struct PlayerAddSoundFromFileRequest {
28    pub id: u32,
29    pub file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
33    for PlayerAddSoundFromFileRequest
34{
35}
36
37#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
38pub struct PlayerMarker;
39
40impl fidl::endpoints::ProtocolMarker for PlayerMarker {
41    type Proxy = PlayerProxy;
42    type RequestStream = PlayerRequestStream;
43    #[cfg(target_os = "fuchsia")]
44    type SynchronousProxy = PlayerSynchronousProxy;
45
46    const DEBUG_NAME: &'static str = "fuchsia.media.sounds.Player";
47}
48impl fidl::endpoints::DiscoverableProtocolMarker for PlayerMarker {}
49pub type PlayerAddSoundFromFileResult = Result<i64, i32>;
50pub type PlayerPlaySoundResult = Result<(), PlaySoundError>;
51pub type PlayerPlaySound2Result = Result<(), PlaySoundError>;
52
53pub trait PlayerProxyInterface: Send + Sync {
54    type AddSoundFromFileResponseFut: std::future::Future<Output = Result<PlayerAddSoundFromFileResult, fidl::Error>>
55        + Send;
56    fn r#add_sound_from_file(
57        &self,
58        id: u32,
59        file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
60    ) -> Self::AddSoundFromFileResponseFut;
61    fn r#add_sound_buffer(
62        &self,
63        id: u32,
64        buffer: fidl_fuchsia_mem::Buffer,
65        stream_type: &fidl_fuchsia_media::AudioStreamType,
66    ) -> Result<(), fidl::Error>;
67    fn r#remove_sound(&self, id: u32) -> Result<(), fidl::Error>;
68    type PlaySoundResponseFut: std::future::Future<Output = Result<PlayerPlaySoundResult, fidl::Error>>
69        + Send;
70    fn r#play_sound(
71        &self,
72        id: u32,
73        usage: fidl_fuchsia_media::AudioRenderUsage,
74    ) -> Self::PlaySoundResponseFut;
75    type PlaySound2ResponseFut: std::future::Future<Output = Result<PlayerPlaySound2Result, fidl::Error>>
76        + Send;
77    fn r#play_sound2(
78        &self,
79        id: u32,
80        usage: fidl_fuchsia_media::AudioRenderUsage2,
81    ) -> Self::PlaySound2ResponseFut;
82    fn r#stop_playing_sound(&self, id: u32) -> Result<(), fidl::Error>;
83}
84#[derive(Debug)]
85#[cfg(target_os = "fuchsia")]
86pub struct PlayerSynchronousProxy {
87    client: fidl::client::sync::Client,
88}
89
90#[cfg(target_os = "fuchsia")]
91impl fidl::endpoints::SynchronousProxy for PlayerSynchronousProxy {
92    type Proxy = PlayerProxy;
93    type Protocol = PlayerMarker;
94
95    fn from_channel(inner: fidl::Channel) -> Self {
96        Self::new(inner)
97    }
98
99    fn into_channel(self) -> fidl::Channel {
100        self.client.into_channel()
101    }
102
103    fn as_channel(&self) -> &fidl::Channel {
104        self.client.as_channel()
105    }
106}
107
108#[cfg(target_os = "fuchsia")]
109impl PlayerSynchronousProxy {
110    pub fn new(channel: fidl::Channel) -> Self {
111        Self { client: fidl::client::sync::Client::new(channel) }
112    }
113
114    pub fn into_channel(self) -> fidl::Channel {
115        self.client.into_channel()
116    }
117
118    /// Waits until an event arrives and returns it. It is safe for other
119    /// threads to make concurrent requests while waiting for an event.
120    pub fn wait_for_event(
121        &self,
122        deadline: zx::MonotonicInstant,
123    ) -> Result<PlayerEvent, fidl::Error> {
124        PlayerEvent::decode(self.client.wait_for_event::<PlayerMarker>(deadline)?)
125    }
126
127    /// Adds a sound to the collection maintained for the client, reading the sound from a file.
128    /// If `id` identifies an existing sound in the collection, the service will close the
129    /// connection. Returns the duration of the sound or an error status returned from an I/O
130    /// operation.
131    ///
132    /// Currently, only PCM WAV files and Ogg/Opus files are supported.
133    pub fn r#add_sound_from_file(
134        &self,
135        mut id: u32,
136        mut file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
137        ___deadline: zx::MonotonicInstant,
138    ) -> Result<PlayerAddSoundFromFileResult, fidl::Error> {
139        let _response = self.client.send_query::<
140            PlayerAddSoundFromFileRequest,
141            fidl::encoding::ResultType<PlayerAddSoundFromFileResponse, i32>,
142            PlayerMarker,
143        >(
144            (id, file,),
145            0x2fd248cffbd53f06,
146            fidl::encoding::DynamicFlags::empty(),
147            ___deadline,
148        )?;
149        Ok(_response.map(|x| x.duration))
150    }
151
152    /// Adds a sound, in the form of a buffer containing raw PCM samples, to the collection
153    /// maintained for the client. The service will retain a handle to the buffer's VMO until the
154    /// sound is removed and is no longer playing or until the connection is closed.
155    ///
156    /// If `id` identifies an existing sound in the collection, the service will close the
157    /// connection.
158    pub fn r#add_sound_buffer(
159        &self,
160        mut id: u32,
161        mut buffer: fidl_fuchsia_mem::Buffer,
162        mut stream_type: &fidl_fuchsia_media::AudioStreamType,
163    ) -> Result<(), fidl::Error> {
164        self.client.send::<PlayerAddSoundBufferRequest>(
165            (id, &mut buffer, stream_type),
166            0x4eaa5c060d71da62,
167            fidl::encoding::DynamicFlags::empty(),
168        )
169    }
170
171    /// Removes a sound from the collection maintained for the client. A sound can be removed even
172    /// if a `PlaySound` method is pending for that sound.
173    ///
174    /// If `id` doesn't identify an existing sound in the collection, the service will do nothing.
175    /// This is tolerated so that clients don't have to wait for the response from
176    /// `AddSoundFromFile` before playing and removing the sound.
177    ///
178    /// Removing an unneeded sound frees the resources associated with that sound, principally
179    /// the VMO required to store the uncompressed sound.
180    pub fn r#remove_sound(&self, mut id: u32) -> Result<(), fidl::Error> {
181        self.client.send::<PlayerRemoveSoundRequest>(
182            (id,),
183            0x1a066f9fcf9ef0c2,
184            fidl::encoding::DynamicFlags::empty(),
185        )
186    }
187
188    /// Plays the existing sound identified by `id` using a renderer with usage `usage`. The
189    /// sound is played as soon as possible. The reply is sent when the sound is finished playing.
190    /// If `id` doesn't identify an existing sound in the collection, the method returns
191    /// `PlaySoundError.NO_SUCH_SOUND`. The most recent `PlaySound` call for a given valid id can
192    /// be stopped using `StopPlayingSound`, in which case, this method returns
193    /// `PlaySoundError.STOPPED`.
194    pub fn r#play_sound(
195        &self,
196        mut id: u32,
197        mut usage: fidl_fuchsia_media::AudioRenderUsage,
198        ___deadline: zx::MonotonicInstant,
199    ) -> Result<PlayerPlaySoundResult, fidl::Error> {
200        let _response = self.client.send_query::<
201            PlayerPlaySoundRequest,
202            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PlaySoundError>,
203            PlayerMarker,
204        >(
205            (id, usage,),
206            0x76f7d6bd8d1725c1,
207            fidl::encoding::DynamicFlags::empty(),
208            ___deadline,
209        )?;
210        Ok(_response.map(|x| x))
211    }
212
213    pub fn r#play_sound2(
214        &self,
215        mut id: u32,
216        mut usage: fidl_fuchsia_media::AudioRenderUsage2,
217        ___deadline: zx::MonotonicInstant,
218    ) -> Result<PlayerPlaySound2Result, fidl::Error> {
219        let _response = self.client.send_query::<
220            PlayerPlaySound2Request,
221            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, PlaySoundError>,
222            PlayerMarker,
223        >(
224            (id, usage,),
225            0x5e68b5f96613bc39,
226            fidl::encoding::DynamicFlags::FLEXIBLE,
227            ___deadline,
228        )?
229        .into_result::<PlayerMarker>("play_sound2")?;
230        Ok(_response.map(|x| x))
231    }
232
233    /// Stops playback of the sound identified by `id` invoked by the the most recent call to
234    /// `PlaySound` for that sound. If `id` doesn't identify an existing sound in the collection
235    /// or if the sound is not currently playing, this method does nothing. If more than one
236    /// `PlaySound` method is currently pending for that sound, only the most recent is stopped.
237    pub fn r#stop_playing_sound(&self, mut id: u32) -> Result<(), fidl::Error> {
238        self.client.send::<PlayerStopPlayingSoundRequest>(
239            (id,),
240            0x14487efba2de8152,
241            fidl::encoding::DynamicFlags::empty(),
242        )
243    }
244}
245
246#[cfg(target_os = "fuchsia")]
247impl From<PlayerSynchronousProxy> for zx::NullableHandle {
248    fn from(value: PlayerSynchronousProxy) -> Self {
249        value.into_channel().into()
250    }
251}
252
253#[cfg(target_os = "fuchsia")]
254impl From<fidl::Channel> for PlayerSynchronousProxy {
255    fn from(value: fidl::Channel) -> Self {
256        Self::new(value)
257    }
258}
259
260#[cfg(target_os = "fuchsia")]
261impl fidl::endpoints::FromClient for PlayerSynchronousProxy {
262    type Protocol = PlayerMarker;
263
264    fn from_client(value: fidl::endpoints::ClientEnd<PlayerMarker>) -> Self {
265        Self::new(value.into_channel())
266    }
267}
268
269#[derive(Debug, Clone)]
270pub struct PlayerProxy {
271    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
272}
273
274impl fidl::endpoints::Proxy for PlayerProxy {
275    type Protocol = PlayerMarker;
276
277    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
278        Self::new(inner)
279    }
280
281    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
282        self.client.into_channel().map_err(|client| Self { client })
283    }
284
285    fn as_channel(&self) -> &::fidl::AsyncChannel {
286        self.client.as_channel()
287    }
288}
289
290impl PlayerProxy {
291    /// Create a new Proxy for fuchsia.media.sounds/Player.
292    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
293        let protocol_name = <PlayerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
294        Self { client: fidl::client::Client::new(channel, protocol_name) }
295    }
296
297    /// Get a Stream of events from the remote end of the protocol.
298    ///
299    /// # Panics
300    ///
301    /// Panics if the event stream was already taken.
302    pub fn take_event_stream(&self) -> PlayerEventStream {
303        PlayerEventStream { event_receiver: self.client.take_event_receiver() }
304    }
305
306    /// Adds a sound to the collection maintained for the client, reading the sound from a file.
307    /// If `id` identifies an existing sound in the collection, the service will close the
308    /// connection. Returns the duration of the sound or an error status returned from an I/O
309    /// operation.
310    ///
311    /// Currently, only PCM WAV files and Ogg/Opus files are supported.
312    pub fn r#add_sound_from_file(
313        &self,
314        mut id: u32,
315        mut file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
316    ) -> fidl::client::QueryResponseFut<
317        PlayerAddSoundFromFileResult,
318        fidl::encoding::DefaultFuchsiaResourceDialect,
319    > {
320        PlayerProxyInterface::r#add_sound_from_file(self, id, file)
321    }
322
323    /// Adds a sound, in the form of a buffer containing raw PCM samples, to the collection
324    /// maintained for the client. The service will retain a handle to the buffer's VMO until the
325    /// sound is removed and is no longer playing or until the connection is closed.
326    ///
327    /// If `id` identifies an existing sound in the collection, the service will close the
328    /// connection.
329    pub fn r#add_sound_buffer(
330        &self,
331        mut id: u32,
332        mut buffer: fidl_fuchsia_mem::Buffer,
333        mut stream_type: &fidl_fuchsia_media::AudioStreamType,
334    ) -> Result<(), fidl::Error> {
335        PlayerProxyInterface::r#add_sound_buffer(self, id, buffer, stream_type)
336    }
337
338    /// Removes a sound from the collection maintained for the client. A sound can be removed even
339    /// if a `PlaySound` method is pending for that sound.
340    ///
341    /// If `id` doesn't identify an existing sound in the collection, the service will do nothing.
342    /// This is tolerated so that clients don't have to wait for the response from
343    /// `AddSoundFromFile` before playing and removing the sound.
344    ///
345    /// Removing an unneeded sound frees the resources associated with that sound, principally
346    /// the VMO required to store the uncompressed sound.
347    pub fn r#remove_sound(&self, mut id: u32) -> Result<(), fidl::Error> {
348        PlayerProxyInterface::r#remove_sound(self, id)
349    }
350
351    /// Plays the existing sound identified by `id` using a renderer with usage `usage`. The
352    /// sound is played as soon as possible. The reply is sent when the sound is finished playing.
353    /// If `id` doesn't identify an existing sound in the collection, the method returns
354    /// `PlaySoundError.NO_SUCH_SOUND`. The most recent `PlaySound` call for a given valid id can
355    /// be stopped using `StopPlayingSound`, in which case, this method returns
356    /// `PlaySoundError.STOPPED`.
357    pub fn r#play_sound(
358        &self,
359        mut id: u32,
360        mut usage: fidl_fuchsia_media::AudioRenderUsage,
361    ) -> fidl::client::QueryResponseFut<
362        PlayerPlaySoundResult,
363        fidl::encoding::DefaultFuchsiaResourceDialect,
364    > {
365        PlayerProxyInterface::r#play_sound(self, id, usage)
366    }
367
368    pub fn r#play_sound2(
369        &self,
370        mut id: u32,
371        mut usage: fidl_fuchsia_media::AudioRenderUsage2,
372    ) -> fidl::client::QueryResponseFut<
373        PlayerPlaySound2Result,
374        fidl::encoding::DefaultFuchsiaResourceDialect,
375    > {
376        PlayerProxyInterface::r#play_sound2(self, id, usage)
377    }
378
379    /// Stops playback of the sound identified by `id` invoked by the the most recent call to
380    /// `PlaySound` for that sound. If `id` doesn't identify an existing sound in the collection
381    /// or if the sound is not currently playing, this method does nothing. If more than one
382    /// `PlaySound` method is currently pending for that sound, only the most recent is stopped.
383    pub fn r#stop_playing_sound(&self, mut id: u32) -> Result<(), fidl::Error> {
384        PlayerProxyInterface::r#stop_playing_sound(self, id)
385    }
386}
387
388impl PlayerProxyInterface for PlayerProxy {
389    type AddSoundFromFileResponseFut = fidl::client::QueryResponseFut<
390        PlayerAddSoundFromFileResult,
391        fidl::encoding::DefaultFuchsiaResourceDialect,
392    >;
393    fn r#add_sound_from_file(
394        &self,
395        mut id: u32,
396        mut file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
397    ) -> Self::AddSoundFromFileResponseFut {
398        fn _decode(
399            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
400        ) -> Result<PlayerAddSoundFromFileResult, fidl::Error> {
401            let _response = fidl::client::decode_transaction_body::<
402                fidl::encoding::ResultType<PlayerAddSoundFromFileResponse, i32>,
403                fidl::encoding::DefaultFuchsiaResourceDialect,
404                0x2fd248cffbd53f06,
405            >(_buf?)?;
406            Ok(_response.map(|x| x.duration))
407        }
408        self.client
409            .send_query_and_decode::<PlayerAddSoundFromFileRequest, PlayerAddSoundFromFileResult>(
410                (id, file),
411                0x2fd248cffbd53f06,
412                fidl::encoding::DynamicFlags::empty(),
413                _decode,
414            )
415    }
416
417    fn r#add_sound_buffer(
418        &self,
419        mut id: u32,
420        mut buffer: fidl_fuchsia_mem::Buffer,
421        mut stream_type: &fidl_fuchsia_media::AudioStreamType,
422    ) -> Result<(), fidl::Error> {
423        self.client.send::<PlayerAddSoundBufferRequest>(
424            (id, &mut buffer, stream_type),
425            0x4eaa5c060d71da62,
426            fidl::encoding::DynamicFlags::empty(),
427        )
428    }
429
430    fn r#remove_sound(&self, mut id: u32) -> Result<(), fidl::Error> {
431        self.client.send::<PlayerRemoveSoundRequest>(
432            (id,),
433            0x1a066f9fcf9ef0c2,
434            fidl::encoding::DynamicFlags::empty(),
435        )
436    }
437
438    type PlaySoundResponseFut = fidl::client::QueryResponseFut<
439        PlayerPlaySoundResult,
440        fidl::encoding::DefaultFuchsiaResourceDialect,
441    >;
442    fn r#play_sound(
443        &self,
444        mut id: u32,
445        mut usage: fidl_fuchsia_media::AudioRenderUsage,
446    ) -> Self::PlaySoundResponseFut {
447        fn _decode(
448            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
449        ) -> Result<PlayerPlaySoundResult, fidl::Error> {
450            let _response = fidl::client::decode_transaction_body::<
451                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PlaySoundError>,
452                fidl::encoding::DefaultFuchsiaResourceDialect,
453                0x76f7d6bd8d1725c1,
454            >(_buf?)?;
455            Ok(_response.map(|x| x))
456        }
457        self.client.send_query_and_decode::<PlayerPlaySoundRequest, PlayerPlaySoundResult>(
458            (id, usage),
459            0x76f7d6bd8d1725c1,
460            fidl::encoding::DynamicFlags::empty(),
461            _decode,
462        )
463    }
464
465    type PlaySound2ResponseFut = fidl::client::QueryResponseFut<
466        PlayerPlaySound2Result,
467        fidl::encoding::DefaultFuchsiaResourceDialect,
468    >;
469    fn r#play_sound2(
470        &self,
471        mut id: u32,
472        mut usage: fidl_fuchsia_media::AudioRenderUsage2,
473    ) -> Self::PlaySound2ResponseFut {
474        fn _decode(
475            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
476        ) -> Result<PlayerPlaySound2Result, fidl::Error> {
477            let _response = fidl::client::decode_transaction_body::<
478                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, PlaySoundError>,
479                fidl::encoding::DefaultFuchsiaResourceDialect,
480                0x5e68b5f96613bc39,
481            >(_buf?)?
482            .into_result::<PlayerMarker>("play_sound2")?;
483            Ok(_response.map(|x| x))
484        }
485        self.client.send_query_and_decode::<PlayerPlaySound2Request, PlayerPlaySound2Result>(
486            (id, usage),
487            0x5e68b5f96613bc39,
488            fidl::encoding::DynamicFlags::FLEXIBLE,
489            _decode,
490        )
491    }
492
493    fn r#stop_playing_sound(&self, mut id: u32) -> Result<(), fidl::Error> {
494        self.client.send::<PlayerStopPlayingSoundRequest>(
495            (id,),
496            0x14487efba2de8152,
497            fidl::encoding::DynamicFlags::empty(),
498        )
499    }
500}
501
502pub struct PlayerEventStream {
503    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
504}
505
506impl std::marker::Unpin for PlayerEventStream {}
507
508impl futures::stream::FusedStream for PlayerEventStream {
509    fn is_terminated(&self) -> bool {
510        self.event_receiver.is_terminated()
511    }
512}
513
514impl futures::Stream for PlayerEventStream {
515    type Item = Result<PlayerEvent, fidl::Error>;
516
517    fn poll_next(
518        mut self: std::pin::Pin<&mut Self>,
519        cx: &mut std::task::Context<'_>,
520    ) -> std::task::Poll<Option<Self::Item>> {
521        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
522            &mut self.event_receiver,
523            cx
524        )?) {
525            Some(buf) => std::task::Poll::Ready(Some(PlayerEvent::decode(buf))),
526            None => std::task::Poll::Ready(None),
527        }
528    }
529}
530
531#[derive(Debug)]
532pub enum PlayerEvent {
533    #[non_exhaustive]
534    _UnknownEvent {
535        /// Ordinal of the event that was sent.
536        ordinal: u64,
537    },
538}
539
540impl PlayerEvent {
541    /// Decodes a message buffer as a [`PlayerEvent`].
542    fn decode(
543        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
544    ) -> Result<PlayerEvent, fidl::Error> {
545        let (bytes, _handles) = buf.split_mut();
546        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
547        debug_assert_eq!(tx_header.tx_id, 0);
548        match tx_header.ordinal {
549            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
550                Ok(PlayerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
551            }
552            _ => Err(fidl::Error::UnknownOrdinal {
553                ordinal: tx_header.ordinal,
554                protocol_name: <PlayerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
555            }),
556        }
557    }
558}
559
560/// A Stream of incoming requests for fuchsia.media.sounds/Player.
561pub struct PlayerRequestStream {
562    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
563    is_terminated: bool,
564}
565
566impl std::marker::Unpin for PlayerRequestStream {}
567
568impl futures::stream::FusedStream for PlayerRequestStream {
569    fn is_terminated(&self) -> bool {
570        self.is_terminated
571    }
572}
573
574impl fidl::endpoints::RequestStream for PlayerRequestStream {
575    type Protocol = PlayerMarker;
576    type ControlHandle = PlayerControlHandle;
577
578    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
579        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
580    }
581
582    fn control_handle(&self) -> Self::ControlHandle {
583        PlayerControlHandle { inner: self.inner.clone() }
584    }
585
586    fn into_inner(
587        self,
588    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
589    {
590        (self.inner, self.is_terminated)
591    }
592
593    fn from_inner(
594        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
595        is_terminated: bool,
596    ) -> Self {
597        Self { inner, is_terminated }
598    }
599}
600
601impl futures::Stream for PlayerRequestStream {
602    type Item = Result<PlayerRequest, fidl::Error>;
603
604    fn poll_next(
605        mut self: std::pin::Pin<&mut Self>,
606        cx: &mut std::task::Context<'_>,
607    ) -> std::task::Poll<Option<Self::Item>> {
608        let this = &mut *self;
609        if this.inner.check_shutdown(cx) {
610            this.is_terminated = true;
611            return std::task::Poll::Ready(None);
612        }
613        if this.is_terminated {
614            panic!("polled PlayerRequestStream after completion");
615        }
616        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
617            |bytes, handles| {
618                match this.inner.channel().read_etc(cx, bytes, handles) {
619                    std::task::Poll::Ready(Ok(())) => {}
620                    std::task::Poll::Pending => return std::task::Poll::Pending,
621                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
622                        this.is_terminated = true;
623                        return std::task::Poll::Ready(None);
624                    }
625                    std::task::Poll::Ready(Err(e)) => {
626                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
627                            e.into(),
628                        ))));
629                    }
630                }
631
632                // A message has been received from the channel
633                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
634
635                std::task::Poll::Ready(Some(match header.ordinal {
636                    0x2fd248cffbd53f06 => {
637                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
638                        let mut req = fidl::new_empty!(
639                            PlayerAddSoundFromFileRequest,
640                            fidl::encoding::DefaultFuchsiaResourceDialect
641                        );
642                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerAddSoundFromFileRequest>(&header, _body_bytes, handles, &mut req)?;
643                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
644                        Ok(PlayerRequest::AddSoundFromFile {
645                            id: req.id,
646                            file: req.file,
647
648                            responder: PlayerAddSoundFromFileResponder {
649                                control_handle: std::mem::ManuallyDrop::new(control_handle),
650                                tx_id: header.tx_id,
651                            },
652                        })
653                    }
654                    0x4eaa5c060d71da62 => {
655                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
656                        let mut req = fidl::new_empty!(
657                            PlayerAddSoundBufferRequest,
658                            fidl::encoding::DefaultFuchsiaResourceDialect
659                        );
660                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerAddSoundBufferRequest>(&header, _body_bytes, handles, &mut req)?;
661                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
662                        Ok(PlayerRequest::AddSoundBuffer {
663                            id: req.id,
664                            buffer: req.buffer,
665                            stream_type: req.stream_type,
666
667                            control_handle,
668                        })
669                    }
670                    0x1a066f9fcf9ef0c2 => {
671                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
672                        let mut req = fidl::new_empty!(
673                            PlayerRemoveSoundRequest,
674                            fidl::encoding::DefaultFuchsiaResourceDialect
675                        );
676                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerRemoveSoundRequest>(&header, _body_bytes, handles, &mut req)?;
677                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
678                        Ok(PlayerRequest::RemoveSound { id: req.id, control_handle })
679                    }
680                    0x76f7d6bd8d1725c1 => {
681                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
682                        let mut req = fidl::new_empty!(
683                            PlayerPlaySoundRequest,
684                            fidl::encoding::DefaultFuchsiaResourceDialect
685                        );
686                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerPlaySoundRequest>(&header, _body_bytes, handles, &mut req)?;
687                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
688                        Ok(PlayerRequest::PlaySound {
689                            id: req.id,
690                            usage: req.usage,
691
692                            responder: PlayerPlaySoundResponder {
693                                control_handle: std::mem::ManuallyDrop::new(control_handle),
694                                tx_id: header.tx_id,
695                            },
696                        })
697                    }
698                    0x5e68b5f96613bc39 => {
699                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
700                        let mut req = fidl::new_empty!(
701                            PlayerPlaySound2Request,
702                            fidl::encoding::DefaultFuchsiaResourceDialect
703                        );
704                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerPlaySound2Request>(&header, _body_bytes, handles, &mut req)?;
705                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
706                        Ok(PlayerRequest::PlaySound2 {
707                            id: req.id,
708                            usage: req.usage,
709
710                            responder: PlayerPlaySound2Responder {
711                                control_handle: std::mem::ManuallyDrop::new(control_handle),
712                                tx_id: header.tx_id,
713                            },
714                        })
715                    }
716                    0x14487efba2de8152 => {
717                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
718                        let mut req = fidl::new_empty!(
719                            PlayerStopPlayingSoundRequest,
720                            fidl::encoding::DefaultFuchsiaResourceDialect
721                        );
722                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerStopPlayingSoundRequest>(&header, _body_bytes, handles, &mut req)?;
723                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
724                        Ok(PlayerRequest::StopPlayingSound { id: req.id, control_handle })
725                    }
726                    _ if header.tx_id == 0
727                        && header
728                            .dynamic_flags()
729                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
730                    {
731                        Ok(PlayerRequest::_UnknownMethod {
732                            ordinal: header.ordinal,
733                            control_handle: PlayerControlHandle { inner: this.inner.clone() },
734                            method_type: fidl::MethodType::OneWay,
735                        })
736                    }
737                    _ if header
738                        .dynamic_flags()
739                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
740                    {
741                        this.inner.send_framework_err(
742                            fidl::encoding::FrameworkErr::UnknownMethod,
743                            header.tx_id,
744                            header.ordinal,
745                            header.dynamic_flags(),
746                            (bytes, handles),
747                        )?;
748                        Ok(PlayerRequest::_UnknownMethod {
749                            ordinal: header.ordinal,
750                            control_handle: PlayerControlHandle { inner: this.inner.clone() },
751                            method_type: fidl::MethodType::TwoWay,
752                        })
753                    }
754                    _ => Err(fidl::Error::UnknownOrdinal {
755                        ordinal: header.ordinal,
756                        protocol_name:
757                            <PlayerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
758                    }),
759                }))
760            },
761        )
762    }
763}
764
765/// Allows clients to play fire-and-forget sounds.
766#[derive(Debug)]
767pub enum PlayerRequest {
768    /// Adds a sound to the collection maintained for the client, reading the sound from a file.
769    /// If `id` identifies an existing sound in the collection, the service will close the
770    /// connection. Returns the duration of the sound or an error status returned from an I/O
771    /// operation.
772    ///
773    /// Currently, only PCM WAV files and Ogg/Opus files are supported.
774    AddSoundFromFile {
775        id: u32,
776        file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
777        responder: PlayerAddSoundFromFileResponder,
778    },
779    /// Adds a sound, in the form of a buffer containing raw PCM samples, to the collection
780    /// maintained for the client. The service will retain a handle to the buffer's VMO until the
781    /// sound is removed and is no longer playing or until the connection is closed.
782    ///
783    /// If `id` identifies an existing sound in the collection, the service will close the
784    /// connection.
785    AddSoundBuffer {
786        id: u32,
787        buffer: fidl_fuchsia_mem::Buffer,
788        stream_type: fidl_fuchsia_media::AudioStreamType,
789        control_handle: PlayerControlHandle,
790    },
791    /// Removes a sound from the collection maintained for the client. A sound can be removed even
792    /// if a `PlaySound` method is pending for that sound.
793    ///
794    /// If `id` doesn't identify an existing sound in the collection, the service will do nothing.
795    /// This is tolerated so that clients don't have to wait for the response from
796    /// `AddSoundFromFile` before playing and removing the sound.
797    ///
798    /// Removing an unneeded sound frees the resources associated with that sound, principally
799    /// the VMO required to store the uncompressed sound.
800    RemoveSound { id: u32, control_handle: PlayerControlHandle },
801    /// Plays the existing sound identified by `id` using a renderer with usage `usage`. The
802    /// sound is played as soon as possible. The reply is sent when the sound is finished playing.
803    /// If `id` doesn't identify an existing sound in the collection, the method returns
804    /// `PlaySoundError.NO_SUCH_SOUND`. The most recent `PlaySound` call for a given valid id can
805    /// be stopped using `StopPlayingSound`, in which case, this method returns
806    /// `PlaySoundError.STOPPED`.
807    PlaySound {
808        id: u32,
809        usage: fidl_fuchsia_media::AudioRenderUsage,
810        responder: PlayerPlaySoundResponder,
811    },
812    PlaySound2 {
813        id: u32,
814        usage: fidl_fuchsia_media::AudioRenderUsage2,
815        responder: PlayerPlaySound2Responder,
816    },
817    /// Stops playback of the sound identified by `id` invoked by the the most recent call to
818    /// `PlaySound` for that sound. If `id` doesn't identify an existing sound in the collection
819    /// or if the sound is not currently playing, this method does nothing. If more than one
820    /// `PlaySound` method is currently pending for that sound, only the most recent is stopped.
821    StopPlayingSound { id: u32, control_handle: PlayerControlHandle },
822    /// An interaction was received which does not match any known method.
823    #[non_exhaustive]
824    _UnknownMethod {
825        /// Ordinal of the method that was called.
826        ordinal: u64,
827        control_handle: PlayerControlHandle,
828        method_type: fidl::MethodType,
829    },
830}
831
832impl PlayerRequest {
833    #[allow(irrefutable_let_patterns)]
834    pub fn into_add_sound_from_file(
835        self,
836    ) -> Option<(
837        u32,
838        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
839        PlayerAddSoundFromFileResponder,
840    )> {
841        if let PlayerRequest::AddSoundFromFile { id, file, responder } = self {
842            Some((id, file, responder))
843        } else {
844            None
845        }
846    }
847
848    #[allow(irrefutable_let_patterns)]
849    pub fn into_add_sound_buffer(
850        self,
851    ) -> Option<(
852        u32,
853        fidl_fuchsia_mem::Buffer,
854        fidl_fuchsia_media::AudioStreamType,
855        PlayerControlHandle,
856    )> {
857        if let PlayerRequest::AddSoundBuffer { id, buffer, stream_type, control_handle } = self {
858            Some((id, buffer, stream_type, control_handle))
859        } else {
860            None
861        }
862    }
863
864    #[allow(irrefutable_let_patterns)]
865    pub fn into_remove_sound(self) -> Option<(u32, PlayerControlHandle)> {
866        if let PlayerRequest::RemoveSound { id, control_handle } = self {
867            Some((id, control_handle))
868        } else {
869            None
870        }
871    }
872
873    #[allow(irrefutable_let_patterns)]
874    pub fn into_play_sound(
875        self,
876    ) -> Option<(u32, fidl_fuchsia_media::AudioRenderUsage, PlayerPlaySoundResponder)> {
877        if let PlayerRequest::PlaySound { id, usage, responder } = self {
878            Some((id, usage, responder))
879        } else {
880            None
881        }
882    }
883
884    #[allow(irrefutable_let_patterns)]
885    pub fn into_play_sound2(
886        self,
887    ) -> Option<(u32, fidl_fuchsia_media::AudioRenderUsage2, PlayerPlaySound2Responder)> {
888        if let PlayerRequest::PlaySound2 { id, usage, responder } = self {
889            Some((id, usage, responder))
890        } else {
891            None
892        }
893    }
894
895    #[allow(irrefutable_let_patterns)]
896    pub fn into_stop_playing_sound(self) -> Option<(u32, PlayerControlHandle)> {
897        if let PlayerRequest::StopPlayingSound { id, control_handle } = self {
898            Some((id, control_handle))
899        } else {
900            None
901        }
902    }
903
904    /// Name of the method defined in FIDL
905    pub fn method_name(&self) -> &'static str {
906        match *self {
907            PlayerRequest::AddSoundFromFile { .. } => "add_sound_from_file",
908            PlayerRequest::AddSoundBuffer { .. } => "add_sound_buffer",
909            PlayerRequest::RemoveSound { .. } => "remove_sound",
910            PlayerRequest::PlaySound { .. } => "play_sound",
911            PlayerRequest::PlaySound2 { .. } => "play_sound2",
912            PlayerRequest::StopPlayingSound { .. } => "stop_playing_sound",
913            PlayerRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
914                "unknown one-way method"
915            }
916            PlayerRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
917                "unknown two-way method"
918            }
919        }
920    }
921}
922
923#[derive(Debug, Clone)]
924pub struct PlayerControlHandle {
925    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
926}
927
928impl PlayerControlHandle {
929    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
930        self.inner.shutdown_with_epitaph(status.into())
931    }
932}
933
934impl fidl::endpoints::ControlHandle for PlayerControlHandle {
935    fn shutdown(&self) {
936        self.inner.shutdown()
937    }
938
939    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
940        self.inner.shutdown_with_epitaph(status)
941    }
942
943    fn is_closed(&self) -> bool {
944        self.inner.channel().is_closed()
945    }
946    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
947        self.inner.channel().on_closed()
948    }
949
950    #[cfg(target_os = "fuchsia")]
951    fn signal_peer(
952        &self,
953        clear_mask: zx::Signals,
954        set_mask: zx::Signals,
955    ) -> Result<(), zx_status::Status> {
956        use fidl::Peered;
957        self.inner.channel().signal_peer(clear_mask, set_mask)
958    }
959}
960
961impl PlayerControlHandle {}
962
963#[must_use = "FIDL methods require a response to be sent"]
964#[derive(Debug)]
965pub struct PlayerAddSoundFromFileResponder {
966    control_handle: std::mem::ManuallyDrop<PlayerControlHandle>,
967    tx_id: u32,
968}
969
970/// Set the the channel to be shutdown (see [`PlayerControlHandle::shutdown`])
971/// if the responder is dropped without sending a response, so that the client
972/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
973impl std::ops::Drop for PlayerAddSoundFromFileResponder {
974    fn drop(&mut self) {
975        self.control_handle.shutdown();
976        // Safety: drops once, never accessed again
977        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
978    }
979}
980
981impl fidl::endpoints::Responder for PlayerAddSoundFromFileResponder {
982    type ControlHandle = PlayerControlHandle;
983
984    fn control_handle(&self) -> &PlayerControlHandle {
985        &self.control_handle
986    }
987
988    fn drop_without_shutdown(mut self) {
989        // Safety: drops once, never accessed again due to mem::forget
990        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
991        // Prevent Drop from running (which would shut down the channel)
992        std::mem::forget(self);
993    }
994}
995
996impl PlayerAddSoundFromFileResponder {
997    /// Sends a response to the FIDL transaction.
998    ///
999    /// Sets the channel to shutdown if an error occurs.
1000    pub fn send(self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1001        let _result = self.send_raw(result);
1002        if _result.is_err() {
1003            self.control_handle.shutdown();
1004        }
1005        self.drop_without_shutdown();
1006        _result
1007    }
1008
1009    /// Similar to "send" but does not shutdown the channel if an error occurs.
1010    pub fn send_no_shutdown_on_err(self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1011        let _result = self.send_raw(result);
1012        self.drop_without_shutdown();
1013        _result
1014    }
1015
1016    fn send_raw(&self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1017        self.control_handle
1018            .inner
1019            .send::<fidl::encoding::ResultType<PlayerAddSoundFromFileResponse, i32>>(
1020                result.map(|duration| (duration,)),
1021                self.tx_id,
1022                0x2fd248cffbd53f06,
1023                fidl::encoding::DynamicFlags::empty(),
1024            )
1025    }
1026}
1027
1028#[must_use = "FIDL methods require a response to be sent"]
1029#[derive(Debug)]
1030pub struct PlayerPlaySoundResponder {
1031    control_handle: std::mem::ManuallyDrop<PlayerControlHandle>,
1032    tx_id: u32,
1033}
1034
1035/// Set the the channel to be shutdown (see [`PlayerControlHandle::shutdown`])
1036/// if the responder is dropped without sending a response, so that the client
1037/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1038impl std::ops::Drop for PlayerPlaySoundResponder {
1039    fn drop(&mut self) {
1040        self.control_handle.shutdown();
1041        // Safety: drops once, never accessed again
1042        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1043    }
1044}
1045
1046impl fidl::endpoints::Responder for PlayerPlaySoundResponder {
1047    type ControlHandle = PlayerControlHandle;
1048
1049    fn control_handle(&self) -> &PlayerControlHandle {
1050        &self.control_handle
1051    }
1052
1053    fn drop_without_shutdown(mut self) {
1054        // Safety: drops once, never accessed again due to mem::forget
1055        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1056        // Prevent Drop from running (which would shut down the channel)
1057        std::mem::forget(self);
1058    }
1059}
1060
1061impl PlayerPlaySoundResponder {
1062    /// Sends a response to the FIDL transaction.
1063    ///
1064    /// Sets the channel to shutdown if an error occurs.
1065    pub fn send(self, mut result: Result<(), PlaySoundError>) -> Result<(), fidl::Error> {
1066        let _result = self.send_raw(result);
1067        if _result.is_err() {
1068            self.control_handle.shutdown();
1069        }
1070        self.drop_without_shutdown();
1071        _result
1072    }
1073
1074    /// Similar to "send" but does not shutdown the channel if an error occurs.
1075    pub fn send_no_shutdown_on_err(
1076        self,
1077        mut result: Result<(), PlaySoundError>,
1078    ) -> Result<(), fidl::Error> {
1079        let _result = self.send_raw(result);
1080        self.drop_without_shutdown();
1081        _result
1082    }
1083
1084    fn send_raw(&self, mut result: Result<(), PlaySoundError>) -> Result<(), fidl::Error> {
1085        self.control_handle.inner.send::<fidl::encoding::ResultType<
1086            fidl::encoding::EmptyStruct,
1087            PlaySoundError,
1088        >>(
1089            result,
1090            self.tx_id,
1091            0x76f7d6bd8d1725c1,
1092            fidl::encoding::DynamicFlags::empty(),
1093        )
1094    }
1095}
1096
1097#[must_use = "FIDL methods require a response to be sent"]
1098#[derive(Debug)]
1099pub struct PlayerPlaySound2Responder {
1100    control_handle: std::mem::ManuallyDrop<PlayerControlHandle>,
1101    tx_id: u32,
1102}
1103
1104/// Set the the channel to be shutdown (see [`PlayerControlHandle::shutdown`])
1105/// if the responder is dropped without sending a response, so that the client
1106/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1107impl std::ops::Drop for PlayerPlaySound2Responder {
1108    fn drop(&mut self) {
1109        self.control_handle.shutdown();
1110        // Safety: drops once, never accessed again
1111        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1112    }
1113}
1114
1115impl fidl::endpoints::Responder for PlayerPlaySound2Responder {
1116    type ControlHandle = PlayerControlHandle;
1117
1118    fn control_handle(&self) -> &PlayerControlHandle {
1119        &self.control_handle
1120    }
1121
1122    fn drop_without_shutdown(mut self) {
1123        // Safety: drops once, never accessed again due to mem::forget
1124        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1125        // Prevent Drop from running (which would shut down the channel)
1126        std::mem::forget(self);
1127    }
1128}
1129
1130impl PlayerPlaySound2Responder {
1131    /// Sends a response to the FIDL transaction.
1132    ///
1133    /// Sets the channel to shutdown if an error occurs.
1134    pub fn send(self, mut result: Result<(), PlaySoundError>) -> Result<(), fidl::Error> {
1135        let _result = self.send_raw(result);
1136        if _result.is_err() {
1137            self.control_handle.shutdown();
1138        }
1139        self.drop_without_shutdown();
1140        _result
1141    }
1142
1143    /// Similar to "send" but does not shutdown the channel if an error occurs.
1144    pub fn send_no_shutdown_on_err(
1145        self,
1146        mut result: Result<(), PlaySoundError>,
1147    ) -> Result<(), fidl::Error> {
1148        let _result = self.send_raw(result);
1149        self.drop_without_shutdown();
1150        _result
1151    }
1152
1153    fn send_raw(&self, mut result: Result<(), PlaySoundError>) -> Result<(), fidl::Error> {
1154        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1155            fidl::encoding::EmptyStruct,
1156            PlaySoundError,
1157        >>(
1158            fidl::encoding::FlexibleResult::new(result),
1159            self.tx_id,
1160            0x5e68b5f96613bc39,
1161            fidl::encoding::DynamicFlags::FLEXIBLE,
1162        )
1163    }
1164}
1165
1166mod internal {
1167    use super::*;
1168
1169    impl fidl::encoding::ResourceTypeMarker for PlayerAddSoundBufferRequest {
1170        type Borrowed<'a> = &'a mut Self;
1171        fn take_or_borrow<'a>(
1172            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1173        ) -> Self::Borrowed<'a> {
1174            value
1175        }
1176    }
1177
1178    unsafe impl fidl::encoding::TypeMarker for PlayerAddSoundBufferRequest {
1179        type Owned = Self;
1180
1181        #[inline(always)]
1182        fn inline_align(_context: fidl::encoding::Context) -> usize {
1183            8
1184        }
1185
1186        #[inline(always)]
1187        fn inline_size(_context: fidl::encoding::Context) -> usize {
1188            40
1189        }
1190    }
1191
1192    unsafe impl
1193        fidl::encoding::Encode<
1194            PlayerAddSoundBufferRequest,
1195            fidl::encoding::DefaultFuchsiaResourceDialect,
1196        > for &mut PlayerAddSoundBufferRequest
1197    {
1198        #[inline]
1199        unsafe fn encode(
1200            self,
1201            encoder: &mut fidl::encoding::Encoder<
1202                '_,
1203                fidl::encoding::DefaultFuchsiaResourceDialect,
1204            >,
1205            offset: usize,
1206            _depth: fidl::encoding::Depth,
1207        ) -> fidl::Result<()> {
1208            encoder.debug_check_bounds::<PlayerAddSoundBufferRequest>(offset);
1209            // Delegate to tuple encoding.
1210            fidl::encoding::Encode::<PlayerAddSoundBufferRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1211                (
1212                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
1213                    <fidl_fuchsia_mem::Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffer),
1214                    <fidl_fuchsia_media::AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
1215                ),
1216                encoder, offset, _depth
1217            )
1218        }
1219    }
1220    unsafe impl<
1221        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
1222        T1: fidl::encoding::Encode<
1223                fidl_fuchsia_mem::Buffer,
1224                fidl::encoding::DefaultFuchsiaResourceDialect,
1225            >,
1226        T2: fidl::encoding::Encode<
1227                fidl_fuchsia_media::AudioStreamType,
1228                fidl::encoding::DefaultFuchsiaResourceDialect,
1229            >,
1230    >
1231        fidl::encoding::Encode<
1232            PlayerAddSoundBufferRequest,
1233            fidl::encoding::DefaultFuchsiaResourceDialect,
1234        > for (T0, T1, T2)
1235    {
1236        #[inline]
1237        unsafe fn encode(
1238            self,
1239            encoder: &mut fidl::encoding::Encoder<
1240                '_,
1241                fidl::encoding::DefaultFuchsiaResourceDialect,
1242            >,
1243            offset: usize,
1244            depth: fidl::encoding::Depth,
1245        ) -> fidl::Result<()> {
1246            encoder.debug_check_bounds::<PlayerAddSoundBufferRequest>(offset);
1247            // Zero out padding regions. There's no need to apply masks
1248            // because the unmasked parts will be overwritten by fields.
1249            unsafe {
1250                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1251                (ptr as *mut u64).write_unaligned(0);
1252            }
1253            unsafe {
1254                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
1255                (ptr as *mut u64).write_unaligned(0);
1256            }
1257            // Write the fields.
1258            self.0.encode(encoder, offset + 0, depth)?;
1259            self.1.encode(encoder, offset + 8, depth)?;
1260            self.2.encode(encoder, offset + 24, depth)?;
1261            Ok(())
1262        }
1263    }
1264
1265    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1266        for PlayerAddSoundBufferRequest
1267    {
1268        #[inline(always)]
1269        fn new_empty() -> Self {
1270            Self {
1271                id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
1272                buffer: fidl::new_empty!(
1273                    fidl_fuchsia_mem::Buffer,
1274                    fidl::encoding::DefaultFuchsiaResourceDialect
1275                ),
1276                stream_type: fidl::new_empty!(
1277                    fidl_fuchsia_media::AudioStreamType,
1278                    fidl::encoding::DefaultFuchsiaResourceDialect
1279                ),
1280            }
1281        }
1282
1283        #[inline]
1284        unsafe fn decode(
1285            &mut self,
1286            decoder: &mut fidl::encoding::Decoder<
1287                '_,
1288                fidl::encoding::DefaultFuchsiaResourceDialect,
1289            >,
1290            offset: usize,
1291            _depth: fidl::encoding::Depth,
1292        ) -> fidl::Result<()> {
1293            decoder.debug_check_bounds::<Self>(offset);
1294            // Verify that padding bytes are zero.
1295            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1296            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1297            let mask = 0xffffffff00000000u64;
1298            let maskedval = padval & mask;
1299            if maskedval != 0 {
1300                return Err(fidl::Error::NonZeroPadding {
1301                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1302                });
1303            }
1304            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
1305            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1306            let mask = 0xffffffff00000000u64;
1307            let maskedval = padval & mask;
1308            if maskedval != 0 {
1309                return Err(fidl::Error::NonZeroPadding {
1310                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
1311                });
1312            }
1313            fidl::decode!(
1314                u32,
1315                fidl::encoding::DefaultFuchsiaResourceDialect,
1316                &mut self.id,
1317                decoder,
1318                offset + 0,
1319                _depth
1320            )?;
1321            fidl::decode!(
1322                fidl_fuchsia_mem::Buffer,
1323                fidl::encoding::DefaultFuchsiaResourceDialect,
1324                &mut self.buffer,
1325                decoder,
1326                offset + 8,
1327                _depth
1328            )?;
1329            fidl::decode!(
1330                fidl_fuchsia_media::AudioStreamType,
1331                fidl::encoding::DefaultFuchsiaResourceDialect,
1332                &mut self.stream_type,
1333                decoder,
1334                offset + 24,
1335                _depth
1336            )?;
1337            Ok(())
1338        }
1339    }
1340
1341    impl fidl::encoding::ResourceTypeMarker for PlayerAddSoundFromFileRequest {
1342        type Borrowed<'a> = &'a mut Self;
1343        fn take_or_borrow<'a>(
1344            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1345        ) -> Self::Borrowed<'a> {
1346            value
1347        }
1348    }
1349
1350    unsafe impl fidl::encoding::TypeMarker for PlayerAddSoundFromFileRequest {
1351        type Owned = Self;
1352
1353        #[inline(always)]
1354        fn inline_align(_context: fidl::encoding::Context) -> usize {
1355            4
1356        }
1357
1358        #[inline(always)]
1359        fn inline_size(_context: fidl::encoding::Context) -> usize {
1360            8
1361        }
1362    }
1363
1364    unsafe impl
1365        fidl::encoding::Encode<
1366            PlayerAddSoundFromFileRequest,
1367            fidl::encoding::DefaultFuchsiaResourceDialect,
1368        > for &mut PlayerAddSoundFromFileRequest
1369    {
1370        #[inline]
1371        unsafe fn encode(
1372            self,
1373            encoder: &mut fidl::encoding::Encoder<
1374                '_,
1375                fidl::encoding::DefaultFuchsiaResourceDialect,
1376            >,
1377            offset: usize,
1378            _depth: fidl::encoding::Depth,
1379        ) -> fidl::Result<()> {
1380            encoder.debug_check_bounds::<PlayerAddSoundFromFileRequest>(offset);
1381            // Delegate to tuple encoding.
1382            fidl::encoding::Encode::<
1383                PlayerAddSoundFromFileRequest,
1384                fidl::encoding::DefaultFuchsiaResourceDialect,
1385            >::encode(
1386                (
1387                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
1388                    <fidl::encoding::Endpoint<
1389                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
1390                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1391                        &mut self.file
1392                    ),
1393                ),
1394                encoder,
1395                offset,
1396                _depth,
1397            )
1398        }
1399    }
1400    unsafe impl<
1401        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
1402        T1: fidl::encoding::Encode<
1403                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
1404                fidl::encoding::DefaultFuchsiaResourceDialect,
1405            >,
1406    >
1407        fidl::encoding::Encode<
1408            PlayerAddSoundFromFileRequest,
1409            fidl::encoding::DefaultFuchsiaResourceDialect,
1410        > for (T0, T1)
1411    {
1412        #[inline]
1413        unsafe fn encode(
1414            self,
1415            encoder: &mut fidl::encoding::Encoder<
1416                '_,
1417                fidl::encoding::DefaultFuchsiaResourceDialect,
1418            >,
1419            offset: usize,
1420            depth: fidl::encoding::Depth,
1421        ) -> fidl::Result<()> {
1422            encoder.debug_check_bounds::<PlayerAddSoundFromFileRequest>(offset);
1423            // Zero out padding regions. There's no need to apply masks
1424            // because the unmasked parts will be overwritten by fields.
1425            // Write the fields.
1426            self.0.encode(encoder, offset + 0, depth)?;
1427            self.1.encode(encoder, offset + 4, depth)?;
1428            Ok(())
1429        }
1430    }
1431
1432    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1433        for PlayerAddSoundFromFileRequest
1434    {
1435        #[inline(always)]
1436        fn new_empty() -> Self {
1437            Self {
1438                id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
1439                file: fidl::new_empty!(
1440                    fidl::encoding::Endpoint<
1441                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
1442                    >,
1443                    fidl::encoding::DefaultFuchsiaResourceDialect
1444                ),
1445            }
1446        }
1447
1448        #[inline]
1449        unsafe fn decode(
1450            &mut self,
1451            decoder: &mut fidl::encoding::Decoder<
1452                '_,
1453                fidl::encoding::DefaultFuchsiaResourceDialect,
1454            >,
1455            offset: usize,
1456            _depth: fidl::encoding::Depth,
1457        ) -> fidl::Result<()> {
1458            decoder.debug_check_bounds::<Self>(offset);
1459            // Verify that padding bytes are zero.
1460            fidl::decode!(
1461                u32,
1462                fidl::encoding::DefaultFuchsiaResourceDialect,
1463                &mut self.id,
1464                decoder,
1465                offset + 0,
1466                _depth
1467            )?;
1468            fidl::decode!(
1469                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
1470                fidl::encoding::DefaultFuchsiaResourceDialect,
1471                &mut self.file,
1472                decoder,
1473                offset + 4,
1474                _depth
1475            )?;
1476            Ok(())
1477        }
1478    }
1479}