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