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 fidl::endpoints::ControlHandle for PlayerControlHandle {
929    fn shutdown(&self) {
930        self.inner.shutdown()
931    }
932
933    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
934        self.inner.shutdown_with_epitaph(status)
935    }
936
937    fn is_closed(&self) -> bool {
938        self.inner.channel().is_closed()
939    }
940    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
941        self.inner.channel().on_closed()
942    }
943
944    #[cfg(target_os = "fuchsia")]
945    fn signal_peer(
946        &self,
947        clear_mask: zx::Signals,
948        set_mask: zx::Signals,
949    ) -> Result<(), zx_status::Status> {
950        use fidl::Peered;
951        self.inner.channel().signal_peer(clear_mask, set_mask)
952    }
953}
954
955impl PlayerControlHandle {}
956
957#[must_use = "FIDL methods require a response to be sent"]
958#[derive(Debug)]
959pub struct PlayerAddSoundFromFileResponder {
960    control_handle: std::mem::ManuallyDrop<PlayerControlHandle>,
961    tx_id: u32,
962}
963
964/// Set the the channel to be shutdown (see [`PlayerControlHandle::shutdown`])
965/// if the responder is dropped without sending a response, so that the client
966/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
967impl std::ops::Drop for PlayerAddSoundFromFileResponder {
968    fn drop(&mut self) {
969        self.control_handle.shutdown();
970        // Safety: drops once, never accessed again
971        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
972    }
973}
974
975impl fidl::endpoints::Responder for PlayerAddSoundFromFileResponder {
976    type ControlHandle = PlayerControlHandle;
977
978    fn control_handle(&self) -> &PlayerControlHandle {
979        &self.control_handle
980    }
981
982    fn drop_without_shutdown(mut self) {
983        // Safety: drops once, never accessed again due to mem::forget
984        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
985        // Prevent Drop from running (which would shut down the channel)
986        std::mem::forget(self);
987    }
988}
989
990impl PlayerAddSoundFromFileResponder {
991    /// Sends a response to the FIDL transaction.
992    ///
993    /// Sets the channel to shutdown if an error occurs.
994    pub fn send(self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
995        let _result = self.send_raw(result);
996        if _result.is_err() {
997            self.control_handle.shutdown();
998        }
999        self.drop_without_shutdown();
1000        _result
1001    }
1002
1003    /// Similar to "send" but does not shutdown the channel if an error occurs.
1004    pub fn send_no_shutdown_on_err(self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1005        let _result = self.send_raw(result);
1006        self.drop_without_shutdown();
1007        _result
1008    }
1009
1010    fn send_raw(&self, mut result: Result<i64, i32>) -> Result<(), fidl::Error> {
1011        self.control_handle
1012            .inner
1013            .send::<fidl::encoding::ResultType<PlayerAddSoundFromFileResponse, i32>>(
1014                result.map(|duration| (duration,)),
1015                self.tx_id,
1016                0x2fd248cffbd53f06,
1017                fidl::encoding::DynamicFlags::empty(),
1018            )
1019    }
1020}
1021
1022#[must_use = "FIDL methods require a response to be sent"]
1023#[derive(Debug)]
1024pub struct PlayerPlaySoundResponder {
1025    control_handle: std::mem::ManuallyDrop<PlayerControlHandle>,
1026    tx_id: u32,
1027}
1028
1029/// Set the the channel to be shutdown (see [`PlayerControlHandle::shutdown`])
1030/// if the responder is dropped without sending a response, so that the client
1031/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1032impl std::ops::Drop for PlayerPlaySoundResponder {
1033    fn drop(&mut self) {
1034        self.control_handle.shutdown();
1035        // Safety: drops once, never accessed again
1036        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1037    }
1038}
1039
1040impl fidl::endpoints::Responder for PlayerPlaySoundResponder {
1041    type ControlHandle = PlayerControlHandle;
1042
1043    fn control_handle(&self) -> &PlayerControlHandle {
1044        &self.control_handle
1045    }
1046
1047    fn drop_without_shutdown(mut self) {
1048        // Safety: drops once, never accessed again due to mem::forget
1049        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1050        // Prevent Drop from running (which would shut down the channel)
1051        std::mem::forget(self);
1052    }
1053}
1054
1055impl PlayerPlaySoundResponder {
1056    /// Sends a response to the FIDL transaction.
1057    ///
1058    /// Sets the channel to shutdown if an error occurs.
1059    pub fn send(self, mut result: Result<(), PlaySoundError>) -> Result<(), fidl::Error> {
1060        let _result = self.send_raw(result);
1061        if _result.is_err() {
1062            self.control_handle.shutdown();
1063        }
1064        self.drop_without_shutdown();
1065        _result
1066    }
1067
1068    /// Similar to "send" but does not shutdown the channel if an error occurs.
1069    pub fn send_no_shutdown_on_err(
1070        self,
1071        mut result: Result<(), PlaySoundError>,
1072    ) -> Result<(), fidl::Error> {
1073        let _result = self.send_raw(result);
1074        self.drop_without_shutdown();
1075        _result
1076    }
1077
1078    fn send_raw(&self, mut result: Result<(), PlaySoundError>) -> Result<(), fidl::Error> {
1079        self.control_handle.inner.send::<fidl::encoding::ResultType<
1080            fidl::encoding::EmptyStruct,
1081            PlaySoundError,
1082        >>(
1083            result,
1084            self.tx_id,
1085            0x76f7d6bd8d1725c1,
1086            fidl::encoding::DynamicFlags::empty(),
1087        )
1088    }
1089}
1090
1091#[must_use = "FIDL methods require a response to be sent"]
1092#[derive(Debug)]
1093pub struct PlayerPlaySound2Responder {
1094    control_handle: std::mem::ManuallyDrop<PlayerControlHandle>,
1095    tx_id: u32,
1096}
1097
1098/// Set the the channel to be shutdown (see [`PlayerControlHandle::shutdown`])
1099/// if the responder is dropped without sending a response, so that the client
1100/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1101impl std::ops::Drop for PlayerPlaySound2Responder {
1102    fn drop(&mut self) {
1103        self.control_handle.shutdown();
1104        // Safety: drops once, never accessed again
1105        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1106    }
1107}
1108
1109impl fidl::endpoints::Responder for PlayerPlaySound2Responder {
1110    type ControlHandle = PlayerControlHandle;
1111
1112    fn control_handle(&self) -> &PlayerControlHandle {
1113        &self.control_handle
1114    }
1115
1116    fn drop_without_shutdown(mut self) {
1117        // Safety: drops once, never accessed again due to mem::forget
1118        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1119        // Prevent Drop from running (which would shut down the channel)
1120        std::mem::forget(self);
1121    }
1122}
1123
1124impl PlayerPlaySound2Responder {
1125    /// Sends a response to the FIDL transaction.
1126    ///
1127    /// Sets the channel to shutdown if an error occurs.
1128    pub fn send(self, mut result: Result<(), PlaySoundError>) -> Result<(), fidl::Error> {
1129        let _result = self.send_raw(result);
1130        if _result.is_err() {
1131            self.control_handle.shutdown();
1132        }
1133        self.drop_without_shutdown();
1134        _result
1135    }
1136
1137    /// Similar to "send" but does not shutdown the channel if an error occurs.
1138    pub fn send_no_shutdown_on_err(
1139        self,
1140        mut result: Result<(), PlaySoundError>,
1141    ) -> Result<(), fidl::Error> {
1142        let _result = self.send_raw(result);
1143        self.drop_without_shutdown();
1144        _result
1145    }
1146
1147    fn send_raw(&self, mut result: Result<(), PlaySoundError>) -> Result<(), fidl::Error> {
1148        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1149            fidl::encoding::EmptyStruct,
1150            PlaySoundError,
1151        >>(
1152            fidl::encoding::FlexibleResult::new(result),
1153            self.tx_id,
1154            0x5e68b5f96613bc39,
1155            fidl::encoding::DynamicFlags::FLEXIBLE,
1156        )
1157    }
1158}
1159
1160mod internal {
1161    use super::*;
1162
1163    impl fidl::encoding::ResourceTypeMarker for PlayerAddSoundBufferRequest {
1164        type Borrowed<'a> = &'a mut Self;
1165        fn take_or_borrow<'a>(
1166            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1167        ) -> Self::Borrowed<'a> {
1168            value
1169        }
1170    }
1171
1172    unsafe impl fidl::encoding::TypeMarker for PlayerAddSoundBufferRequest {
1173        type Owned = Self;
1174
1175        #[inline(always)]
1176        fn inline_align(_context: fidl::encoding::Context) -> usize {
1177            8
1178        }
1179
1180        #[inline(always)]
1181        fn inline_size(_context: fidl::encoding::Context) -> usize {
1182            40
1183        }
1184    }
1185
1186    unsafe impl
1187        fidl::encoding::Encode<
1188            PlayerAddSoundBufferRequest,
1189            fidl::encoding::DefaultFuchsiaResourceDialect,
1190        > for &mut PlayerAddSoundBufferRequest
1191    {
1192        #[inline]
1193        unsafe fn encode(
1194            self,
1195            encoder: &mut fidl::encoding::Encoder<
1196                '_,
1197                fidl::encoding::DefaultFuchsiaResourceDialect,
1198            >,
1199            offset: usize,
1200            _depth: fidl::encoding::Depth,
1201        ) -> fidl::Result<()> {
1202            encoder.debug_check_bounds::<PlayerAddSoundBufferRequest>(offset);
1203            // Delegate to tuple encoding.
1204            fidl::encoding::Encode::<PlayerAddSoundBufferRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1205                (
1206                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
1207                    <fidl_fuchsia_mem::Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffer),
1208                    <fidl_fuchsia_media::AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
1209                ),
1210                encoder, offset, _depth
1211            )
1212        }
1213    }
1214    unsafe impl<
1215        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
1216        T1: fidl::encoding::Encode<
1217                fidl_fuchsia_mem::Buffer,
1218                fidl::encoding::DefaultFuchsiaResourceDialect,
1219            >,
1220        T2: fidl::encoding::Encode<
1221                fidl_fuchsia_media::AudioStreamType,
1222                fidl::encoding::DefaultFuchsiaResourceDialect,
1223            >,
1224    >
1225        fidl::encoding::Encode<
1226            PlayerAddSoundBufferRequest,
1227            fidl::encoding::DefaultFuchsiaResourceDialect,
1228        > for (T0, T1, T2)
1229    {
1230        #[inline]
1231        unsafe fn encode(
1232            self,
1233            encoder: &mut fidl::encoding::Encoder<
1234                '_,
1235                fidl::encoding::DefaultFuchsiaResourceDialect,
1236            >,
1237            offset: usize,
1238            depth: fidl::encoding::Depth,
1239        ) -> fidl::Result<()> {
1240            encoder.debug_check_bounds::<PlayerAddSoundBufferRequest>(offset);
1241            // Zero out padding regions. There's no need to apply masks
1242            // because the unmasked parts will be overwritten by fields.
1243            unsafe {
1244                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1245                (ptr as *mut u64).write_unaligned(0);
1246            }
1247            unsafe {
1248                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
1249                (ptr as *mut u64).write_unaligned(0);
1250            }
1251            // Write the fields.
1252            self.0.encode(encoder, offset + 0, depth)?;
1253            self.1.encode(encoder, offset + 8, depth)?;
1254            self.2.encode(encoder, offset + 24, depth)?;
1255            Ok(())
1256        }
1257    }
1258
1259    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1260        for PlayerAddSoundBufferRequest
1261    {
1262        #[inline(always)]
1263        fn new_empty() -> Self {
1264            Self {
1265                id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
1266                buffer: fidl::new_empty!(
1267                    fidl_fuchsia_mem::Buffer,
1268                    fidl::encoding::DefaultFuchsiaResourceDialect
1269                ),
1270                stream_type: fidl::new_empty!(
1271                    fidl_fuchsia_media::AudioStreamType,
1272                    fidl::encoding::DefaultFuchsiaResourceDialect
1273                ),
1274            }
1275        }
1276
1277        #[inline]
1278        unsafe fn decode(
1279            &mut self,
1280            decoder: &mut fidl::encoding::Decoder<
1281                '_,
1282                fidl::encoding::DefaultFuchsiaResourceDialect,
1283            >,
1284            offset: usize,
1285            _depth: fidl::encoding::Depth,
1286        ) -> fidl::Result<()> {
1287            decoder.debug_check_bounds::<Self>(offset);
1288            // Verify that padding bytes are zero.
1289            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1290            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1291            let mask = 0xffffffff00000000u64;
1292            let maskedval = padval & mask;
1293            if maskedval != 0 {
1294                return Err(fidl::Error::NonZeroPadding {
1295                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1296                });
1297            }
1298            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
1299            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1300            let mask = 0xffffffff00000000u64;
1301            let maskedval = padval & mask;
1302            if maskedval != 0 {
1303                return Err(fidl::Error::NonZeroPadding {
1304                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
1305                });
1306            }
1307            fidl::decode!(
1308                u32,
1309                fidl::encoding::DefaultFuchsiaResourceDialect,
1310                &mut self.id,
1311                decoder,
1312                offset + 0,
1313                _depth
1314            )?;
1315            fidl::decode!(
1316                fidl_fuchsia_mem::Buffer,
1317                fidl::encoding::DefaultFuchsiaResourceDialect,
1318                &mut self.buffer,
1319                decoder,
1320                offset + 8,
1321                _depth
1322            )?;
1323            fidl::decode!(
1324                fidl_fuchsia_media::AudioStreamType,
1325                fidl::encoding::DefaultFuchsiaResourceDialect,
1326                &mut self.stream_type,
1327                decoder,
1328                offset + 24,
1329                _depth
1330            )?;
1331            Ok(())
1332        }
1333    }
1334
1335    impl fidl::encoding::ResourceTypeMarker for PlayerAddSoundFromFileRequest {
1336        type Borrowed<'a> = &'a mut Self;
1337        fn take_or_borrow<'a>(
1338            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1339        ) -> Self::Borrowed<'a> {
1340            value
1341        }
1342    }
1343
1344    unsafe impl fidl::encoding::TypeMarker for PlayerAddSoundFromFileRequest {
1345        type Owned = Self;
1346
1347        #[inline(always)]
1348        fn inline_align(_context: fidl::encoding::Context) -> usize {
1349            4
1350        }
1351
1352        #[inline(always)]
1353        fn inline_size(_context: fidl::encoding::Context) -> usize {
1354            8
1355        }
1356    }
1357
1358    unsafe impl
1359        fidl::encoding::Encode<
1360            PlayerAddSoundFromFileRequest,
1361            fidl::encoding::DefaultFuchsiaResourceDialect,
1362        > for &mut PlayerAddSoundFromFileRequest
1363    {
1364        #[inline]
1365        unsafe fn encode(
1366            self,
1367            encoder: &mut fidl::encoding::Encoder<
1368                '_,
1369                fidl::encoding::DefaultFuchsiaResourceDialect,
1370            >,
1371            offset: usize,
1372            _depth: fidl::encoding::Depth,
1373        ) -> fidl::Result<()> {
1374            encoder.debug_check_bounds::<PlayerAddSoundFromFileRequest>(offset);
1375            // Delegate to tuple encoding.
1376            fidl::encoding::Encode::<
1377                PlayerAddSoundFromFileRequest,
1378                fidl::encoding::DefaultFuchsiaResourceDialect,
1379            >::encode(
1380                (
1381                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
1382                    <fidl::encoding::Endpoint<
1383                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
1384                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1385                        &mut self.file
1386                    ),
1387                ),
1388                encoder,
1389                offset,
1390                _depth,
1391            )
1392        }
1393    }
1394    unsafe impl<
1395        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
1396        T1: fidl::encoding::Encode<
1397                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
1398                fidl::encoding::DefaultFuchsiaResourceDialect,
1399            >,
1400    >
1401        fidl::encoding::Encode<
1402            PlayerAddSoundFromFileRequest,
1403            fidl::encoding::DefaultFuchsiaResourceDialect,
1404        > for (T0, T1)
1405    {
1406        #[inline]
1407        unsafe fn encode(
1408            self,
1409            encoder: &mut fidl::encoding::Encoder<
1410                '_,
1411                fidl::encoding::DefaultFuchsiaResourceDialect,
1412            >,
1413            offset: usize,
1414            depth: fidl::encoding::Depth,
1415        ) -> fidl::Result<()> {
1416            encoder.debug_check_bounds::<PlayerAddSoundFromFileRequest>(offset);
1417            // Zero out padding regions. There's no need to apply masks
1418            // because the unmasked parts will be overwritten by fields.
1419            // Write the fields.
1420            self.0.encode(encoder, offset + 0, depth)?;
1421            self.1.encode(encoder, offset + 4, depth)?;
1422            Ok(())
1423        }
1424    }
1425
1426    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1427        for PlayerAddSoundFromFileRequest
1428    {
1429        #[inline(always)]
1430        fn new_empty() -> Self {
1431            Self {
1432                id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
1433                file: fidl::new_empty!(
1434                    fidl::encoding::Endpoint<
1435                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
1436                    >,
1437                    fidl::encoding::DefaultFuchsiaResourceDialect
1438                ),
1439            }
1440        }
1441
1442        #[inline]
1443        unsafe fn decode(
1444            &mut self,
1445            decoder: &mut fidl::encoding::Decoder<
1446                '_,
1447                fidl::encoding::DefaultFuchsiaResourceDialect,
1448            >,
1449            offset: usize,
1450            _depth: fidl::encoding::Depth,
1451        ) -> fidl::Result<()> {
1452            decoder.debug_check_bounds::<Self>(offset);
1453            // Verify that padding bytes are zero.
1454            fidl::decode!(
1455                u32,
1456                fidl::encoding::DefaultFuchsiaResourceDialect,
1457                &mut self.id,
1458                decoder,
1459                offset + 0,
1460                _depth
1461            )?;
1462            fidl::decode!(
1463                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
1464                fidl::encoding::DefaultFuchsiaResourceDialect,
1465                &mut self.file,
1466                decoder,
1467                offset + 4,
1468                _depth
1469            )?;
1470            Ok(())
1471        }
1472    }
1473}