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