fidl_fuchsia_media_sessions2/
fidl_fuchsia_media_sessions2.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_sessions2_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ActiveSessionWatchActiveSessionResponse {
16    pub session: Option<fidl::endpoints::ClientEnd<SessionControlMarker>>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for ActiveSessionWatchActiveSessionResponse
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct DiscoveryConnectToSessionRequest {
26    pub session_id: u64,
27    pub session_control_request: fidl::endpoints::ServerEnd<SessionControlMarker>,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for DiscoveryConnectToSessionRequest
32{
33}
34
35#[derive(Debug, PartialEq)]
36pub struct DiscoveryWatchSessionsRequest {
37    pub watch_options: WatchOptions,
38    pub session_watcher: fidl::endpoints::ClientEnd<SessionsWatcherMarker>,
39}
40
41impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
42    for DiscoveryWatchSessionsRequest
43{
44}
45
46#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
47pub struct ObserverDiscoveryConnectToSessionRequest {
48    pub session_id: u64,
49    pub session_request: fidl::endpoints::ServerEnd<SessionObserverMarker>,
50}
51
52impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
53    for ObserverDiscoveryConnectToSessionRequest
54{
55}
56
57#[derive(Debug, PartialEq)]
58pub struct ObserverDiscoveryWatchSessionsRequest {
59    pub watch_options: WatchOptions,
60    pub sessions_watcher: fidl::endpoints::ClientEnd<SessionsWatcherMarker>,
61}
62
63impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
64    for ObserverDiscoveryWatchSessionsRequest
65{
66}
67
68#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
69pub struct PlayerControlBindVolumeControlRequest {
70    pub volume_control_request:
71        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
72}
73
74impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
75    for PlayerControlBindVolumeControlRequest
76{
77}
78
79#[derive(Debug, PartialEq)]
80pub struct PublisherPublishRequest {
81    pub player: fidl::endpoints::ClientEnd<PlayerMarker>,
82    pub registration: PlayerRegistration,
83}
84
85impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PublisherPublishRequest {}
86
87#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
88pub struct SessionControlBindVolumeControlRequest {
89    pub volume_control_request:
90        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
91}
92
93impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
94    for SessionControlBindVolumeControlRequest
95{
96}
97
98#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
99pub struct ActiveSessionMarker;
100
101impl fidl::endpoints::ProtocolMarker for ActiveSessionMarker {
102    type Proxy = ActiveSessionProxy;
103    type RequestStream = ActiveSessionRequestStream;
104    #[cfg(target_os = "fuchsia")]
105    type SynchronousProxy = ActiveSessionSynchronousProxy;
106
107    const DEBUG_NAME: &'static str = "fuchsia.media.sessions2.ActiveSession";
108}
109impl fidl::endpoints::DiscoverableProtocolMarker for ActiveSessionMarker {}
110
111pub trait ActiveSessionProxyInterface: Send + Sync {
112    type WatchActiveSessionResponseFut: std::future::Future<
113            Output = Result<Option<fidl::endpoints::ClientEnd<SessionControlMarker>>, fidl::Error>,
114        > + Send;
115    fn r#watch_active_session(&self) -> Self::WatchActiveSessionResponseFut;
116}
117#[derive(Debug)]
118#[cfg(target_os = "fuchsia")]
119pub struct ActiveSessionSynchronousProxy {
120    client: fidl::client::sync::Client,
121}
122
123#[cfg(target_os = "fuchsia")]
124impl fidl::endpoints::SynchronousProxy for ActiveSessionSynchronousProxy {
125    type Proxy = ActiveSessionProxy;
126    type Protocol = ActiveSessionMarker;
127
128    fn from_channel(inner: fidl::Channel) -> Self {
129        Self::new(inner)
130    }
131
132    fn into_channel(self) -> fidl::Channel {
133        self.client.into_channel()
134    }
135
136    fn as_channel(&self) -> &fidl::Channel {
137        self.client.as_channel()
138    }
139}
140
141#[cfg(target_os = "fuchsia")]
142impl ActiveSessionSynchronousProxy {
143    pub fn new(channel: fidl::Channel) -> Self {
144        let protocol_name = <ActiveSessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
145        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
146    }
147
148    pub fn into_channel(self) -> fidl::Channel {
149        self.client.into_channel()
150    }
151
152    /// Waits until an event arrives and returns it. It is safe for other
153    /// threads to make concurrent requests while waiting for an event.
154    pub fn wait_for_event(
155        &self,
156        deadline: zx::MonotonicInstant,
157    ) -> Result<ActiveSessionEvent, fidl::Error> {
158        ActiveSessionEvent::decode(self.client.wait_for_event(deadline)?)
159    }
160
161    /// Watches the active session. The first request will be answered immediately
162    /// with the current active session. Always leave a request hanging to receive
163    /// a reply when the active session changes.
164    pub fn r#watch_active_session(
165        &self,
166        ___deadline: zx::MonotonicInstant,
167    ) -> Result<Option<fidl::endpoints::ClientEnd<SessionControlMarker>>, fidl::Error> {
168        let _response = self
169            .client
170            .send_query::<fidl::encoding::EmptyPayload, ActiveSessionWatchActiveSessionResponse>(
171                (),
172                0xc072168d525fff8,
173                fidl::encoding::DynamicFlags::empty(),
174                ___deadline,
175            )?;
176        Ok(_response.session)
177    }
178}
179
180#[cfg(target_os = "fuchsia")]
181impl From<ActiveSessionSynchronousProxy> for zx::Handle {
182    fn from(value: ActiveSessionSynchronousProxy) -> Self {
183        value.into_channel().into()
184    }
185}
186
187#[cfg(target_os = "fuchsia")]
188impl From<fidl::Channel> for ActiveSessionSynchronousProxy {
189    fn from(value: fidl::Channel) -> Self {
190        Self::new(value)
191    }
192}
193
194#[derive(Debug, Clone)]
195pub struct ActiveSessionProxy {
196    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
197}
198
199impl fidl::endpoints::Proxy for ActiveSessionProxy {
200    type Protocol = ActiveSessionMarker;
201
202    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
203        Self::new(inner)
204    }
205
206    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
207        self.client.into_channel().map_err(|client| Self { client })
208    }
209
210    fn as_channel(&self) -> &::fidl::AsyncChannel {
211        self.client.as_channel()
212    }
213}
214
215impl ActiveSessionProxy {
216    /// Create a new Proxy for fuchsia.media.sessions2/ActiveSession.
217    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
218        let protocol_name = <ActiveSessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
219        Self { client: fidl::client::Client::new(channel, protocol_name) }
220    }
221
222    /// Get a Stream of events from the remote end of the protocol.
223    ///
224    /// # Panics
225    ///
226    /// Panics if the event stream was already taken.
227    pub fn take_event_stream(&self) -> ActiveSessionEventStream {
228        ActiveSessionEventStream { event_receiver: self.client.take_event_receiver() }
229    }
230
231    /// Watches the active session. The first request will be answered immediately
232    /// with the current active session. Always leave a request hanging to receive
233    /// a reply when the active session changes.
234    pub fn r#watch_active_session(
235        &self,
236    ) -> fidl::client::QueryResponseFut<
237        Option<fidl::endpoints::ClientEnd<SessionControlMarker>>,
238        fidl::encoding::DefaultFuchsiaResourceDialect,
239    > {
240        ActiveSessionProxyInterface::r#watch_active_session(self)
241    }
242}
243
244impl ActiveSessionProxyInterface for ActiveSessionProxy {
245    type WatchActiveSessionResponseFut = fidl::client::QueryResponseFut<
246        Option<fidl::endpoints::ClientEnd<SessionControlMarker>>,
247        fidl::encoding::DefaultFuchsiaResourceDialect,
248    >;
249    fn r#watch_active_session(&self) -> Self::WatchActiveSessionResponseFut {
250        fn _decode(
251            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
252        ) -> Result<Option<fidl::endpoints::ClientEnd<SessionControlMarker>>, fidl::Error> {
253            let _response = fidl::client::decode_transaction_body::<
254                ActiveSessionWatchActiveSessionResponse,
255                fidl::encoding::DefaultFuchsiaResourceDialect,
256                0xc072168d525fff8,
257            >(_buf?)?;
258            Ok(_response.session)
259        }
260        self.client.send_query_and_decode::<
261            fidl::encoding::EmptyPayload,
262            Option<fidl::endpoints::ClientEnd<SessionControlMarker>>,
263        >(
264            (),
265            0xc072168d525fff8,
266            fidl::encoding::DynamicFlags::empty(),
267            _decode,
268        )
269    }
270}
271
272pub struct ActiveSessionEventStream {
273    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
274}
275
276impl std::marker::Unpin for ActiveSessionEventStream {}
277
278impl futures::stream::FusedStream for ActiveSessionEventStream {
279    fn is_terminated(&self) -> bool {
280        self.event_receiver.is_terminated()
281    }
282}
283
284impl futures::Stream for ActiveSessionEventStream {
285    type Item = Result<ActiveSessionEvent, fidl::Error>;
286
287    fn poll_next(
288        mut self: std::pin::Pin<&mut Self>,
289        cx: &mut std::task::Context<'_>,
290    ) -> std::task::Poll<Option<Self::Item>> {
291        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
292            &mut self.event_receiver,
293            cx
294        )?) {
295            Some(buf) => std::task::Poll::Ready(Some(ActiveSessionEvent::decode(buf))),
296            None => std::task::Poll::Ready(None),
297        }
298    }
299}
300
301#[derive(Debug)]
302pub enum ActiveSessionEvent {}
303
304impl ActiveSessionEvent {
305    /// Decodes a message buffer as a [`ActiveSessionEvent`].
306    fn decode(
307        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
308    ) -> Result<ActiveSessionEvent, fidl::Error> {
309        let (bytes, _handles) = buf.split_mut();
310        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
311        debug_assert_eq!(tx_header.tx_id, 0);
312        match tx_header.ordinal {
313            _ => Err(fidl::Error::UnknownOrdinal {
314                ordinal: tx_header.ordinal,
315                protocol_name: <ActiveSessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
316            }),
317        }
318    }
319}
320
321/// A Stream of incoming requests for fuchsia.media.sessions2/ActiveSession.
322pub struct ActiveSessionRequestStream {
323    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
324    is_terminated: bool,
325}
326
327impl std::marker::Unpin for ActiveSessionRequestStream {}
328
329impl futures::stream::FusedStream for ActiveSessionRequestStream {
330    fn is_terminated(&self) -> bool {
331        self.is_terminated
332    }
333}
334
335impl fidl::endpoints::RequestStream for ActiveSessionRequestStream {
336    type Protocol = ActiveSessionMarker;
337    type ControlHandle = ActiveSessionControlHandle;
338
339    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
340        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
341    }
342
343    fn control_handle(&self) -> Self::ControlHandle {
344        ActiveSessionControlHandle { inner: self.inner.clone() }
345    }
346
347    fn into_inner(
348        self,
349    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
350    {
351        (self.inner, self.is_terminated)
352    }
353
354    fn from_inner(
355        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
356        is_terminated: bool,
357    ) -> Self {
358        Self { inner, is_terminated }
359    }
360}
361
362impl futures::Stream for ActiveSessionRequestStream {
363    type Item = Result<ActiveSessionRequest, fidl::Error>;
364
365    fn poll_next(
366        mut self: std::pin::Pin<&mut Self>,
367        cx: &mut std::task::Context<'_>,
368    ) -> std::task::Poll<Option<Self::Item>> {
369        let this = &mut *self;
370        if this.inner.check_shutdown(cx) {
371            this.is_terminated = true;
372            return std::task::Poll::Ready(None);
373        }
374        if this.is_terminated {
375            panic!("polled ActiveSessionRequestStream after completion");
376        }
377        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
378            |bytes, handles| {
379                match this.inner.channel().read_etc(cx, bytes, handles) {
380                    std::task::Poll::Ready(Ok(())) => {}
381                    std::task::Poll::Pending => return std::task::Poll::Pending,
382                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
383                        this.is_terminated = true;
384                        return std::task::Poll::Ready(None);
385                    }
386                    std::task::Poll::Ready(Err(e)) => {
387                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
388                            e.into(),
389                        ))))
390                    }
391                }
392
393                // A message has been received from the channel
394                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
395
396                std::task::Poll::Ready(Some(match header.ordinal {
397                    0xc072168d525fff8 => {
398                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
399                        let mut req = fidl::new_empty!(
400                            fidl::encoding::EmptyPayload,
401                            fidl::encoding::DefaultFuchsiaResourceDialect
402                        );
403                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
404                        let control_handle =
405                            ActiveSessionControlHandle { inner: this.inner.clone() };
406                        Ok(ActiveSessionRequest::WatchActiveSession {
407                            responder: ActiveSessionWatchActiveSessionResponder {
408                                control_handle: std::mem::ManuallyDrop::new(control_handle),
409                                tx_id: header.tx_id,
410                            },
411                        })
412                    }
413                    _ => Err(fidl::Error::UnknownOrdinal {
414                        ordinal: header.ordinal,
415                        protocol_name:
416                            <ActiveSessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
417                    }),
418                }))
419            },
420        )
421    }
422}
423
424/// A protocol for watching the current active media session on the device.
425///
426/// The currently active media session is the most recent existing media session
427/// to announce a "Playing" state on the local device, even if it is now paused.
428#[derive(Debug)]
429pub enum ActiveSessionRequest {
430    /// Watches the active session. The first request will be answered immediately
431    /// with the current active session. Always leave a request hanging to receive
432    /// a reply when the active session changes.
433    WatchActiveSession { responder: ActiveSessionWatchActiveSessionResponder },
434}
435
436impl ActiveSessionRequest {
437    #[allow(irrefutable_let_patterns)]
438    pub fn into_watch_active_session(self) -> Option<(ActiveSessionWatchActiveSessionResponder)> {
439        if let ActiveSessionRequest::WatchActiveSession { responder } = self {
440            Some((responder))
441        } else {
442            None
443        }
444    }
445
446    /// Name of the method defined in FIDL
447    pub fn method_name(&self) -> &'static str {
448        match *self {
449            ActiveSessionRequest::WatchActiveSession { .. } => "watch_active_session",
450        }
451    }
452}
453
454#[derive(Debug, Clone)]
455pub struct ActiveSessionControlHandle {
456    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
457}
458
459impl fidl::endpoints::ControlHandle for ActiveSessionControlHandle {
460    fn shutdown(&self) {
461        self.inner.shutdown()
462    }
463    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
464        self.inner.shutdown_with_epitaph(status)
465    }
466
467    fn is_closed(&self) -> bool {
468        self.inner.channel().is_closed()
469    }
470    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
471        self.inner.channel().on_closed()
472    }
473
474    #[cfg(target_os = "fuchsia")]
475    fn signal_peer(
476        &self,
477        clear_mask: zx::Signals,
478        set_mask: zx::Signals,
479    ) -> Result<(), zx_status::Status> {
480        use fidl::Peered;
481        self.inner.channel().signal_peer(clear_mask, set_mask)
482    }
483}
484
485impl ActiveSessionControlHandle {}
486
487#[must_use = "FIDL methods require a response to be sent"]
488#[derive(Debug)]
489pub struct ActiveSessionWatchActiveSessionResponder {
490    control_handle: std::mem::ManuallyDrop<ActiveSessionControlHandle>,
491    tx_id: u32,
492}
493
494/// Set the the channel to be shutdown (see [`ActiveSessionControlHandle::shutdown`])
495/// if the responder is dropped without sending a response, so that the client
496/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
497impl std::ops::Drop for ActiveSessionWatchActiveSessionResponder {
498    fn drop(&mut self) {
499        self.control_handle.shutdown();
500        // Safety: drops once, never accessed again
501        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
502    }
503}
504
505impl fidl::endpoints::Responder for ActiveSessionWatchActiveSessionResponder {
506    type ControlHandle = ActiveSessionControlHandle;
507
508    fn control_handle(&self) -> &ActiveSessionControlHandle {
509        &self.control_handle
510    }
511
512    fn drop_without_shutdown(mut self) {
513        // Safety: drops once, never accessed again due to mem::forget
514        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
515        // Prevent Drop from running (which would shut down the channel)
516        std::mem::forget(self);
517    }
518}
519
520impl ActiveSessionWatchActiveSessionResponder {
521    /// Sends a response to the FIDL transaction.
522    ///
523    /// Sets the channel to shutdown if an error occurs.
524    pub fn send(
525        self,
526        mut session: Option<fidl::endpoints::ClientEnd<SessionControlMarker>>,
527    ) -> Result<(), fidl::Error> {
528        let _result = self.send_raw(session);
529        if _result.is_err() {
530            self.control_handle.shutdown();
531        }
532        self.drop_without_shutdown();
533        _result
534    }
535
536    /// Similar to "send" but does not shutdown the channel if an error occurs.
537    pub fn send_no_shutdown_on_err(
538        self,
539        mut session: Option<fidl::endpoints::ClientEnd<SessionControlMarker>>,
540    ) -> Result<(), fidl::Error> {
541        let _result = self.send_raw(session);
542        self.drop_without_shutdown();
543        _result
544    }
545
546    fn send_raw(
547        &self,
548        mut session: Option<fidl::endpoints::ClientEnd<SessionControlMarker>>,
549    ) -> Result<(), fidl::Error> {
550        self.control_handle.inner.send::<ActiveSessionWatchActiveSessionResponse>(
551            (session,),
552            self.tx_id,
553            0xc072168d525fff8,
554            fidl::encoding::DynamicFlags::empty(),
555        )
556    }
557}
558
559#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
560pub struct DiscoveryMarker;
561
562impl fidl::endpoints::ProtocolMarker for DiscoveryMarker {
563    type Proxy = DiscoveryProxy;
564    type RequestStream = DiscoveryRequestStream;
565    #[cfg(target_os = "fuchsia")]
566    type SynchronousProxy = DiscoverySynchronousProxy;
567
568    const DEBUG_NAME: &'static str = "fuchsia.media.sessions2.Discovery";
569}
570impl fidl::endpoints::DiscoverableProtocolMarker for DiscoveryMarker {}
571
572pub trait DiscoveryProxyInterface: Send + Sync {
573    fn r#watch_sessions(
574        &self,
575        watch_options: &WatchOptions,
576        session_watcher: fidl::endpoints::ClientEnd<SessionsWatcherMarker>,
577    ) -> Result<(), fidl::Error>;
578    fn r#connect_to_session(
579        &self,
580        session_id: u64,
581        session_control_request: fidl::endpoints::ServerEnd<SessionControlMarker>,
582    ) -> Result<(), fidl::Error>;
583}
584#[derive(Debug)]
585#[cfg(target_os = "fuchsia")]
586pub struct DiscoverySynchronousProxy {
587    client: fidl::client::sync::Client,
588}
589
590#[cfg(target_os = "fuchsia")]
591impl fidl::endpoints::SynchronousProxy for DiscoverySynchronousProxy {
592    type Proxy = DiscoveryProxy;
593    type Protocol = DiscoveryMarker;
594
595    fn from_channel(inner: fidl::Channel) -> Self {
596        Self::new(inner)
597    }
598
599    fn into_channel(self) -> fidl::Channel {
600        self.client.into_channel()
601    }
602
603    fn as_channel(&self) -> &fidl::Channel {
604        self.client.as_channel()
605    }
606}
607
608#[cfg(target_os = "fuchsia")]
609impl DiscoverySynchronousProxy {
610    pub fn new(channel: fidl::Channel) -> Self {
611        let protocol_name = <DiscoveryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
612        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
613    }
614
615    pub fn into_channel(self) -> fidl::Channel {
616        self.client.into_channel()
617    }
618
619    /// Waits until an event arrives and returns it. It is safe for other
620    /// threads to make concurrent requests while waiting for an event.
621    pub fn wait_for_event(
622        &self,
623        deadline: zx::MonotonicInstant,
624    ) -> Result<DiscoveryEvent, fidl::Error> {
625        DiscoveryEvent::decode(self.client.wait_for_event(deadline)?)
626    }
627
628    /// Connects a session watcher configured with the given options.
629    pub fn r#watch_sessions(
630        &self,
631        mut watch_options: &WatchOptions,
632        mut session_watcher: fidl::endpoints::ClientEnd<SessionsWatcherMarker>,
633    ) -> Result<(), fidl::Error> {
634        self.client.send::<DiscoveryWatchSessionsRequest>(
635            (watch_options, session_watcher),
636            0x4231b30d98dcd2fe,
637            fidl::encoding::DynamicFlags::empty(),
638        )
639    }
640
641    /// Connects to a `SessionControl` for `session_id` if present. Drops the
642    /// given channel otherwise.
643    pub fn r#connect_to_session(
644        &self,
645        mut session_id: u64,
646        mut session_control_request: fidl::endpoints::ServerEnd<SessionControlMarker>,
647    ) -> Result<(), fidl::Error> {
648        self.client.send::<DiscoveryConnectToSessionRequest>(
649            (session_id, session_control_request),
650            0x37da54e09f63ca3d,
651            fidl::encoding::DynamicFlags::empty(),
652        )
653    }
654}
655
656#[cfg(target_os = "fuchsia")]
657impl From<DiscoverySynchronousProxy> for zx::Handle {
658    fn from(value: DiscoverySynchronousProxy) -> Self {
659        value.into_channel().into()
660    }
661}
662
663#[cfg(target_os = "fuchsia")]
664impl From<fidl::Channel> for DiscoverySynchronousProxy {
665    fn from(value: fidl::Channel) -> Self {
666        Self::new(value)
667    }
668}
669
670#[derive(Debug, Clone)]
671pub struct DiscoveryProxy {
672    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
673}
674
675impl fidl::endpoints::Proxy for DiscoveryProxy {
676    type Protocol = DiscoveryMarker;
677
678    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
679        Self::new(inner)
680    }
681
682    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
683        self.client.into_channel().map_err(|client| Self { client })
684    }
685
686    fn as_channel(&self) -> &::fidl::AsyncChannel {
687        self.client.as_channel()
688    }
689}
690
691impl DiscoveryProxy {
692    /// Create a new Proxy for fuchsia.media.sessions2/Discovery.
693    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
694        let protocol_name = <DiscoveryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
695        Self { client: fidl::client::Client::new(channel, protocol_name) }
696    }
697
698    /// Get a Stream of events from the remote end of the protocol.
699    ///
700    /// # Panics
701    ///
702    /// Panics if the event stream was already taken.
703    pub fn take_event_stream(&self) -> DiscoveryEventStream {
704        DiscoveryEventStream { event_receiver: self.client.take_event_receiver() }
705    }
706
707    /// Connects a session watcher configured with the given options.
708    pub fn r#watch_sessions(
709        &self,
710        mut watch_options: &WatchOptions,
711        mut session_watcher: fidl::endpoints::ClientEnd<SessionsWatcherMarker>,
712    ) -> Result<(), fidl::Error> {
713        DiscoveryProxyInterface::r#watch_sessions(self, watch_options, session_watcher)
714    }
715
716    /// Connects to a `SessionControl` for `session_id` if present. Drops the
717    /// given channel otherwise.
718    pub fn r#connect_to_session(
719        &self,
720        mut session_id: u64,
721        mut session_control_request: fidl::endpoints::ServerEnd<SessionControlMarker>,
722    ) -> Result<(), fidl::Error> {
723        DiscoveryProxyInterface::r#connect_to_session(self, session_id, session_control_request)
724    }
725}
726
727impl DiscoveryProxyInterface for DiscoveryProxy {
728    fn r#watch_sessions(
729        &self,
730        mut watch_options: &WatchOptions,
731        mut session_watcher: fidl::endpoints::ClientEnd<SessionsWatcherMarker>,
732    ) -> Result<(), fidl::Error> {
733        self.client.send::<DiscoveryWatchSessionsRequest>(
734            (watch_options, session_watcher),
735            0x4231b30d98dcd2fe,
736            fidl::encoding::DynamicFlags::empty(),
737        )
738    }
739
740    fn r#connect_to_session(
741        &self,
742        mut session_id: u64,
743        mut session_control_request: fidl::endpoints::ServerEnd<SessionControlMarker>,
744    ) -> Result<(), fidl::Error> {
745        self.client.send::<DiscoveryConnectToSessionRequest>(
746            (session_id, session_control_request),
747            0x37da54e09f63ca3d,
748            fidl::encoding::DynamicFlags::empty(),
749        )
750    }
751}
752
753pub struct DiscoveryEventStream {
754    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
755}
756
757impl std::marker::Unpin for DiscoveryEventStream {}
758
759impl futures::stream::FusedStream for DiscoveryEventStream {
760    fn is_terminated(&self) -> bool {
761        self.event_receiver.is_terminated()
762    }
763}
764
765impl futures::Stream for DiscoveryEventStream {
766    type Item = Result<DiscoveryEvent, fidl::Error>;
767
768    fn poll_next(
769        mut self: std::pin::Pin<&mut Self>,
770        cx: &mut std::task::Context<'_>,
771    ) -> std::task::Poll<Option<Self::Item>> {
772        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
773            &mut self.event_receiver,
774            cx
775        )?) {
776            Some(buf) => std::task::Poll::Ready(Some(DiscoveryEvent::decode(buf))),
777            None => std::task::Poll::Ready(None),
778        }
779    }
780}
781
782#[derive(Debug)]
783pub enum DiscoveryEvent {}
784
785impl DiscoveryEvent {
786    /// Decodes a message buffer as a [`DiscoveryEvent`].
787    fn decode(
788        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
789    ) -> Result<DiscoveryEvent, fidl::Error> {
790        let (bytes, _handles) = buf.split_mut();
791        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
792        debug_assert_eq!(tx_header.tx_id, 0);
793        match tx_header.ordinal {
794            _ => Err(fidl::Error::UnknownOrdinal {
795                ordinal: tx_header.ordinal,
796                protocol_name: <DiscoveryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
797            }),
798        }
799    }
800}
801
802/// A Stream of incoming requests for fuchsia.media.sessions2/Discovery.
803pub struct DiscoveryRequestStream {
804    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
805    is_terminated: bool,
806}
807
808impl std::marker::Unpin for DiscoveryRequestStream {}
809
810impl futures::stream::FusedStream for DiscoveryRequestStream {
811    fn is_terminated(&self) -> bool {
812        self.is_terminated
813    }
814}
815
816impl fidl::endpoints::RequestStream for DiscoveryRequestStream {
817    type Protocol = DiscoveryMarker;
818    type ControlHandle = DiscoveryControlHandle;
819
820    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
821        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
822    }
823
824    fn control_handle(&self) -> Self::ControlHandle {
825        DiscoveryControlHandle { inner: self.inner.clone() }
826    }
827
828    fn into_inner(
829        self,
830    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
831    {
832        (self.inner, self.is_terminated)
833    }
834
835    fn from_inner(
836        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
837        is_terminated: bool,
838    ) -> Self {
839        Self { inner, is_terminated }
840    }
841}
842
843impl futures::Stream for DiscoveryRequestStream {
844    type Item = Result<DiscoveryRequest, fidl::Error>;
845
846    fn poll_next(
847        mut self: std::pin::Pin<&mut Self>,
848        cx: &mut std::task::Context<'_>,
849    ) -> std::task::Poll<Option<Self::Item>> {
850        let this = &mut *self;
851        if this.inner.check_shutdown(cx) {
852            this.is_terminated = true;
853            return std::task::Poll::Ready(None);
854        }
855        if this.is_terminated {
856            panic!("polled DiscoveryRequestStream after completion");
857        }
858        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
859            |bytes, handles| {
860                match this.inner.channel().read_etc(cx, bytes, handles) {
861                    std::task::Poll::Ready(Ok(())) => {}
862                    std::task::Poll::Pending => return std::task::Poll::Pending,
863                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
864                        this.is_terminated = true;
865                        return std::task::Poll::Ready(None);
866                    }
867                    std::task::Poll::Ready(Err(e)) => {
868                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
869                            e.into(),
870                        ))))
871                    }
872                }
873
874                // A message has been received from the channel
875                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
876
877                std::task::Poll::Ready(Some(match header.ordinal {
878                    0x4231b30d98dcd2fe => {
879                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
880                        let mut req = fidl::new_empty!(
881                            DiscoveryWatchSessionsRequest,
882                            fidl::encoding::DefaultFuchsiaResourceDialect
883                        );
884                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DiscoveryWatchSessionsRequest>(&header, _body_bytes, handles, &mut req)?;
885                        let control_handle = DiscoveryControlHandle { inner: this.inner.clone() };
886                        Ok(DiscoveryRequest::WatchSessions {
887                            watch_options: req.watch_options,
888                            session_watcher: req.session_watcher,
889
890                            control_handle,
891                        })
892                    }
893                    0x37da54e09f63ca3d => {
894                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
895                        let mut req = fidl::new_empty!(
896                            DiscoveryConnectToSessionRequest,
897                            fidl::encoding::DefaultFuchsiaResourceDialect
898                        );
899                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DiscoveryConnectToSessionRequest>(&header, _body_bytes, handles, &mut req)?;
900                        let control_handle = DiscoveryControlHandle { inner: this.inner.clone() };
901                        Ok(DiscoveryRequest::ConnectToSession {
902                            session_id: req.session_id,
903                            session_control_request: req.session_control_request,
904
905                            control_handle,
906                        })
907                    }
908                    _ => Err(fidl::Error::UnknownOrdinal {
909                        ordinal: header.ordinal,
910                        protocol_name:
911                            <DiscoveryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
912                    }),
913                }))
914            },
915        )
916    }
917}
918
919/// `Discovery` observes the collection of published media sessions
920/// and connects clients to them.
921#[derive(Debug)]
922pub enum DiscoveryRequest {
923    /// Connects a session watcher configured with the given options.
924    WatchSessions {
925        watch_options: WatchOptions,
926        session_watcher: fidl::endpoints::ClientEnd<SessionsWatcherMarker>,
927        control_handle: DiscoveryControlHandle,
928    },
929    /// Connects to a `SessionControl` for `session_id` if present. Drops the
930    /// given channel otherwise.
931    ConnectToSession {
932        session_id: u64,
933        session_control_request: fidl::endpoints::ServerEnd<SessionControlMarker>,
934        control_handle: DiscoveryControlHandle,
935    },
936}
937
938impl DiscoveryRequest {
939    #[allow(irrefutable_let_patterns)]
940    pub fn into_watch_sessions(
941        self,
942    ) -> Option<(
943        WatchOptions,
944        fidl::endpoints::ClientEnd<SessionsWatcherMarker>,
945        DiscoveryControlHandle,
946    )> {
947        if let DiscoveryRequest::WatchSessions { watch_options, session_watcher, control_handle } =
948            self
949        {
950            Some((watch_options, session_watcher, control_handle))
951        } else {
952            None
953        }
954    }
955
956    #[allow(irrefutable_let_patterns)]
957    pub fn into_connect_to_session(
958        self,
959    ) -> Option<(u64, fidl::endpoints::ServerEnd<SessionControlMarker>, DiscoveryControlHandle)>
960    {
961        if let DiscoveryRequest::ConnectToSession {
962            session_id,
963            session_control_request,
964            control_handle,
965        } = self
966        {
967            Some((session_id, session_control_request, control_handle))
968        } else {
969            None
970        }
971    }
972
973    /// Name of the method defined in FIDL
974    pub fn method_name(&self) -> &'static str {
975        match *self {
976            DiscoveryRequest::WatchSessions { .. } => "watch_sessions",
977            DiscoveryRequest::ConnectToSession { .. } => "connect_to_session",
978        }
979    }
980}
981
982#[derive(Debug, Clone)]
983pub struct DiscoveryControlHandle {
984    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
985}
986
987impl fidl::endpoints::ControlHandle for DiscoveryControlHandle {
988    fn shutdown(&self) {
989        self.inner.shutdown()
990    }
991    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
992        self.inner.shutdown_with_epitaph(status)
993    }
994
995    fn is_closed(&self) -> bool {
996        self.inner.channel().is_closed()
997    }
998    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
999        self.inner.channel().on_closed()
1000    }
1001
1002    #[cfg(target_os = "fuchsia")]
1003    fn signal_peer(
1004        &self,
1005        clear_mask: zx::Signals,
1006        set_mask: zx::Signals,
1007    ) -> Result<(), zx_status::Status> {
1008        use fidl::Peered;
1009        self.inner.channel().signal_peer(clear_mask, set_mask)
1010    }
1011}
1012
1013impl DiscoveryControlHandle {}
1014
1015#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1016pub struct ObserverDiscoveryMarker;
1017
1018impl fidl::endpoints::ProtocolMarker for ObserverDiscoveryMarker {
1019    type Proxy = ObserverDiscoveryProxy;
1020    type RequestStream = ObserverDiscoveryRequestStream;
1021    #[cfg(target_os = "fuchsia")]
1022    type SynchronousProxy = ObserverDiscoverySynchronousProxy;
1023
1024    const DEBUG_NAME: &'static str = "fuchsia.media.sessions2.ObserverDiscovery";
1025}
1026impl fidl::endpoints::DiscoverableProtocolMarker for ObserverDiscoveryMarker {}
1027
1028pub trait ObserverDiscoveryProxyInterface: Send + Sync {
1029    fn r#watch_sessions(
1030        &self,
1031        watch_options: &WatchOptions,
1032        sessions_watcher: fidl::endpoints::ClientEnd<SessionsWatcherMarker>,
1033    ) -> Result<(), fidl::Error>;
1034    fn r#connect_to_session(
1035        &self,
1036        session_id: u64,
1037        session_request: fidl::endpoints::ServerEnd<SessionObserverMarker>,
1038    ) -> Result<(), fidl::Error>;
1039}
1040#[derive(Debug)]
1041#[cfg(target_os = "fuchsia")]
1042pub struct ObserverDiscoverySynchronousProxy {
1043    client: fidl::client::sync::Client,
1044}
1045
1046#[cfg(target_os = "fuchsia")]
1047impl fidl::endpoints::SynchronousProxy for ObserverDiscoverySynchronousProxy {
1048    type Proxy = ObserverDiscoveryProxy;
1049    type Protocol = ObserverDiscoveryMarker;
1050
1051    fn from_channel(inner: fidl::Channel) -> Self {
1052        Self::new(inner)
1053    }
1054
1055    fn into_channel(self) -> fidl::Channel {
1056        self.client.into_channel()
1057    }
1058
1059    fn as_channel(&self) -> &fidl::Channel {
1060        self.client.as_channel()
1061    }
1062}
1063
1064#[cfg(target_os = "fuchsia")]
1065impl ObserverDiscoverySynchronousProxy {
1066    pub fn new(channel: fidl::Channel) -> Self {
1067        let protocol_name =
1068            <ObserverDiscoveryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1069        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1070    }
1071
1072    pub fn into_channel(self) -> fidl::Channel {
1073        self.client.into_channel()
1074    }
1075
1076    /// Waits until an event arrives and returns it. It is safe for other
1077    /// threads to make concurrent requests while waiting for an event.
1078    pub fn wait_for_event(
1079        &self,
1080        deadline: zx::MonotonicInstant,
1081    ) -> Result<ObserverDiscoveryEvent, fidl::Error> {
1082        ObserverDiscoveryEvent::decode(self.client.wait_for_event(deadline)?)
1083    }
1084
1085    /// Connects a session watcher configured with the given options.
1086    pub fn r#watch_sessions(
1087        &self,
1088        mut watch_options: &WatchOptions,
1089        mut sessions_watcher: fidl::endpoints::ClientEnd<SessionsWatcherMarker>,
1090    ) -> Result<(), fidl::Error> {
1091        self.client.send::<ObserverDiscoveryWatchSessionsRequest>(
1092            (watch_options, sessions_watcher),
1093            0x3d95eaa20624a1fe,
1094            fidl::encoding::DynamicFlags::empty(),
1095        )
1096    }
1097
1098    /// Connects to a `SessionObserver` for `session_id` if present. Drops the
1099    /// given channel otherwise.
1100    pub fn r#connect_to_session(
1101        &self,
1102        mut session_id: u64,
1103        mut session_request: fidl::endpoints::ServerEnd<SessionObserverMarker>,
1104    ) -> Result<(), fidl::Error> {
1105        self.client.send::<ObserverDiscoveryConnectToSessionRequest>(
1106            (session_id, session_request),
1107            0x2c9b99aacfaac87a,
1108            fidl::encoding::DynamicFlags::empty(),
1109        )
1110    }
1111}
1112
1113#[cfg(target_os = "fuchsia")]
1114impl From<ObserverDiscoverySynchronousProxy> for zx::Handle {
1115    fn from(value: ObserverDiscoverySynchronousProxy) -> Self {
1116        value.into_channel().into()
1117    }
1118}
1119
1120#[cfg(target_os = "fuchsia")]
1121impl From<fidl::Channel> for ObserverDiscoverySynchronousProxy {
1122    fn from(value: fidl::Channel) -> Self {
1123        Self::new(value)
1124    }
1125}
1126
1127#[derive(Debug, Clone)]
1128pub struct ObserverDiscoveryProxy {
1129    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1130}
1131
1132impl fidl::endpoints::Proxy for ObserverDiscoveryProxy {
1133    type Protocol = ObserverDiscoveryMarker;
1134
1135    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1136        Self::new(inner)
1137    }
1138
1139    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1140        self.client.into_channel().map_err(|client| Self { client })
1141    }
1142
1143    fn as_channel(&self) -> &::fidl::AsyncChannel {
1144        self.client.as_channel()
1145    }
1146}
1147
1148impl ObserverDiscoveryProxy {
1149    /// Create a new Proxy for fuchsia.media.sessions2/ObserverDiscovery.
1150    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1151        let protocol_name =
1152            <ObserverDiscoveryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1153        Self { client: fidl::client::Client::new(channel, protocol_name) }
1154    }
1155
1156    /// Get a Stream of events from the remote end of the protocol.
1157    ///
1158    /// # Panics
1159    ///
1160    /// Panics if the event stream was already taken.
1161    pub fn take_event_stream(&self) -> ObserverDiscoveryEventStream {
1162        ObserverDiscoveryEventStream { event_receiver: self.client.take_event_receiver() }
1163    }
1164
1165    /// Connects a session watcher configured with the given options.
1166    pub fn r#watch_sessions(
1167        &self,
1168        mut watch_options: &WatchOptions,
1169        mut sessions_watcher: fidl::endpoints::ClientEnd<SessionsWatcherMarker>,
1170    ) -> Result<(), fidl::Error> {
1171        ObserverDiscoveryProxyInterface::r#watch_sessions(self, watch_options, sessions_watcher)
1172    }
1173
1174    /// Connects to a `SessionObserver` for `session_id` if present. Drops the
1175    /// given channel otherwise.
1176    pub fn r#connect_to_session(
1177        &self,
1178        mut session_id: u64,
1179        mut session_request: fidl::endpoints::ServerEnd<SessionObserverMarker>,
1180    ) -> Result<(), fidl::Error> {
1181        ObserverDiscoveryProxyInterface::r#connect_to_session(self, session_id, session_request)
1182    }
1183}
1184
1185impl ObserverDiscoveryProxyInterface for ObserverDiscoveryProxy {
1186    fn r#watch_sessions(
1187        &self,
1188        mut watch_options: &WatchOptions,
1189        mut sessions_watcher: fidl::endpoints::ClientEnd<SessionsWatcherMarker>,
1190    ) -> Result<(), fidl::Error> {
1191        self.client.send::<ObserverDiscoveryWatchSessionsRequest>(
1192            (watch_options, sessions_watcher),
1193            0x3d95eaa20624a1fe,
1194            fidl::encoding::DynamicFlags::empty(),
1195        )
1196    }
1197
1198    fn r#connect_to_session(
1199        &self,
1200        mut session_id: u64,
1201        mut session_request: fidl::endpoints::ServerEnd<SessionObserverMarker>,
1202    ) -> Result<(), fidl::Error> {
1203        self.client.send::<ObserverDiscoveryConnectToSessionRequest>(
1204            (session_id, session_request),
1205            0x2c9b99aacfaac87a,
1206            fidl::encoding::DynamicFlags::empty(),
1207        )
1208    }
1209}
1210
1211pub struct ObserverDiscoveryEventStream {
1212    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1213}
1214
1215impl std::marker::Unpin for ObserverDiscoveryEventStream {}
1216
1217impl futures::stream::FusedStream for ObserverDiscoveryEventStream {
1218    fn is_terminated(&self) -> bool {
1219        self.event_receiver.is_terminated()
1220    }
1221}
1222
1223impl futures::Stream for ObserverDiscoveryEventStream {
1224    type Item = Result<ObserverDiscoveryEvent, fidl::Error>;
1225
1226    fn poll_next(
1227        mut self: std::pin::Pin<&mut Self>,
1228        cx: &mut std::task::Context<'_>,
1229    ) -> std::task::Poll<Option<Self::Item>> {
1230        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1231            &mut self.event_receiver,
1232            cx
1233        )?) {
1234            Some(buf) => std::task::Poll::Ready(Some(ObserverDiscoveryEvent::decode(buf))),
1235            None => std::task::Poll::Ready(None),
1236        }
1237    }
1238}
1239
1240#[derive(Debug)]
1241pub enum ObserverDiscoveryEvent {}
1242
1243impl ObserverDiscoveryEvent {
1244    /// Decodes a message buffer as a [`ObserverDiscoveryEvent`].
1245    fn decode(
1246        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1247    ) -> Result<ObserverDiscoveryEvent, fidl::Error> {
1248        let (bytes, _handles) = buf.split_mut();
1249        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1250        debug_assert_eq!(tx_header.tx_id, 0);
1251        match tx_header.ordinal {
1252            _ => Err(fidl::Error::UnknownOrdinal {
1253                ordinal: tx_header.ordinal,
1254                protocol_name:
1255                    <ObserverDiscoveryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1256            }),
1257        }
1258    }
1259}
1260
1261/// A Stream of incoming requests for fuchsia.media.sessions2/ObserverDiscovery.
1262pub struct ObserverDiscoveryRequestStream {
1263    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1264    is_terminated: bool,
1265}
1266
1267impl std::marker::Unpin for ObserverDiscoveryRequestStream {}
1268
1269impl futures::stream::FusedStream for ObserverDiscoveryRequestStream {
1270    fn is_terminated(&self) -> bool {
1271        self.is_terminated
1272    }
1273}
1274
1275impl fidl::endpoints::RequestStream for ObserverDiscoveryRequestStream {
1276    type Protocol = ObserverDiscoveryMarker;
1277    type ControlHandle = ObserverDiscoveryControlHandle;
1278
1279    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1280        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1281    }
1282
1283    fn control_handle(&self) -> Self::ControlHandle {
1284        ObserverDiscoveryControlHandle { inner: self.inner.clone() }
1285    }
1286
1287    fn into_inner(
1288        self,
1289    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1290    {
1291        (self.inner, self.is_terminated)
1292    }
1293
1294    fn from_inner(
1295        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1296        is_terminated: bool,
1297    ) -> Self {
1298        Self { inner, is_terminated }
1299    }
1300}
1301
1302impl futures::Stream for ObserverDiscoveryRequestStream {
1303    type Item = Result<ObserverDiscoveryRequest, fidl::Error>;
1304
1305    fn poll_next(
1306        mut self: std::pin::Pin<&mut Self>,
1307        cx: &mut std::task::Context<'_>,
1308    ) -> std::task::Poll<Option<Self::Item>> {
1309        let this = &mut *self;
1310        if this.inner.check_shutdown(cx) {
1311            this.is_terminated = true;
1312            return std::task::Poll::Ready(None);
1313        }
1314        if this.is_terminated {
1315            panic!("polled ObserverDiscoveryRequestStream after completion");
1316        }
1317        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1318            |bytes, handles| {
1319                match this.inner.channel().read_etc(cx, bytes, handles) {
1320                    std::task::Poll::Ready(Ok(())) => {}
1321                    std::task::Poll::Pending => return std::task::Poll::Pending,
1322                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1323                        this.is_terminated = true;
1324                        return std::task::Poll::Ready(None);
1325                    }
1326                    std::task::Poll::Ready(Err(e)) => {
1327                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1328                            e.into(),
1329                        ))))
1330                    }
1331                }
1332
1333                // A message has been received from the channel
1334                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1335
1336                std::task::Poll::Ready(Some(match header.ordinal {
1337                    0x3d95eaa20624a1fe => {
1338                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1339                        let mut req = fidl::new_empty!(
1340                            ObserverDiscoveryWatchSessionsRequest,
1341                            fidl::encoding::DefaultFuchsiaResourceDialect
1342                        );
1343                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ObserverDiscoveryWatchSessionsRequest>(&header, _body_bytes, handles, &mut req)?;
1344                        let control_handle =
1345                            ObserverDiscoveryControlHandle { inner: this.inner.clone() };
1346                        Ok(ObserverDiscoveryRequest::WatchSessions {
1347                            watch_options: req.watch_options,
1348                            sessions_watcher: req.sessions_watcher,
1349
1350                            control_handle,
1351                        })
1352                    }
1353                    0x2c9b99aacfaac87a => {
1354                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1355                        let mut req = fidl::new_empty!(
1356                            ObserverDiscoveryConnectToSessionRequest,
1357                            fidl::encoding::DefaultFuchsiaResourceDialect
1358                        );
1359                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ObserverDiscoveryConnectToSessionRequest>(&header, _body_bytes, handles, &mut req)?;
1360                        let control_handle =
1361                            ObserverDiscoveryControlHandle { inner: this.inner.clone() };
1362                        Ok(ObserverDiscoveryRequest::ConnectToSession {
1363                            session_id: req.session_id,
1364                            session_request: req.session_request,
1365
1366                            control_handle,
1367                        })
1368                    }
1369                    _ => Err(fidl::Error::UnknownOrdinal {
1370                        ordinal: header.ordinal,
1371                        protocol_name:
1372                            <ObserverDiscoveryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1373                    }),
1374                }))
1375            },
1376        )
1377    }
1378}
1379
1380/// `ObserverDiscovery` observes the collection of published media sessions
1381/// and connects clients to them for observation without playback controls.
1382#[derive(Debug)]
1383pub enum ObserverDiscoveryRequest {
1384    /// Connects a session watcher configured with the given options.
1385    WatchSessions {
1386        watch_options: WatchOptions,
1387        sessions_watcher: fidl::endpoints::ClientEnd<SessionsWatcherMarker>,
1388        control_handle: ObserverDiscoveryControlHandle,
1389    },
1390    /// Connects to a `SessionObserver` for `session_id` if present. Drops the
1391    /// given channel otherwise.
1392    ConnectToSession {
1393        session_id: u64,
1394        session_request: fidl::endpoints::ServerEnd<SessionObserverMarker>,
1395        control_handle: ObserverDiscoveryControlHandle,
1396    },
1397}
1398
1399impl ObserverDiscoveryRequest {
1400    #[allow(irrefutable_let_patterns)]
1401    pub fn into_watch_sessions(
1402        self,
1403    ) -> Option<(
1404        WatchOptions,
1405        fidl::endpoints::ClientEnd<SessionsWatcherMarker>,
1406        ObserverDiscoveryControlHandle,
1407    )> {
1408        if let ObserverDiscoveryRequest::WatchSessions {
1409            watch_options,
1410            sessions_watcher,
1411            control_handle,
1412        } = self
1413        {
1414            Some((watch_options, sessions_watcher, control_handle))
1415        } else {
1416            None
1417        }
1418    }
1419
1420    #[allow(irrefutable_let_patterns)]
1421    pub fn into_connect_to_session(
1422        self,
1423    ) -> Option<(
1424        u64,
1425        fidl::endpoints::ServerEnd<SessionObserverMarker>,
1426        ObserverDiscoveryControlHandle,
1427    )> {
1428        if let ObserverDiscoveryRequest::ConnectToSession {
1429            session_id,
1430            session_request,
1431            control_handle,
1432        } = self
1433        {
1434            Some((session_id, session_request, control_handle))
1435        } else {
1436            None
1437        }
1438    }
1439
1440    /// Name of the method defined in FIDL
1441    pub fn method_name(&self) -> &'static str {
1442        match *self {
1443            ObserverDiscoveryRequest::WatchSessions { .. } => "watch_sessions",
1444            ObserverDiscoveryRequest::ConnectToSession { .. } => "connect_to_session",
1445        }
1446    }
1447}
1448
1449#[derive(Debug, Clone)]
1450pub struct ObserverDiscoveryControlHandle {
1451    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1452}
1453
1454impl fidl::endpoints::ControlHandle for ObserverDiscoveryControlHandle {
1455    fn shutdown(&self) {
1456        self.inner.shutdown()
1457    }
1458    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1459        self.inner.shutdown_with_epitaph(status)
1460    }
1461
1462    fn is_closed(&self) -> bool {
1463        self.inner.channel().is_closed()
1464    }
1465    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1466        self.inner.channel().on_closed()
1467    }
1468
1469    #[cfg(target_os = "fuchsia")]
1470    fn signal_peer(
1471        &self,
1472        clear_mask: zx::Signals,
1473        set_mask: zx::Signals,
1474    ) -> Result<(), zx_status::Status> {
1475        use fidl::Peered;
1476        self.inner.channel().signal_peer(clear_mask, set_mask)
1477    }
1478}
1479
1480impl ObserverDiscoveryControlHandle {}
1481
1482#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1483pub struct PlayerMarker;
1484
1485impl fidl::endpoints::ProtocolMarker for PlayerMarker {
1486    type Proxy = PlayerProxy;
1487    type RequestStream = PlayerRequestStream;
1488    #[cfg(target_os = "fuchsia")]
1489    type SynchronousProxy = PlayerSynchronousProxy;
1490
1491    const DEBUG_NAME: &'static str = "(anonymous) Player";
1492}
1493
1494pub trait PlayerProxyInterface: Send + Sync {
1495    fn r#play(&self) -> Result<(), fidl::Error>;
1496    fn r#pause(&self) -> Result<(), fidl::Error>;
1497    fn r#stop(&self) -> Result<(), fidl::Error>;
1498    fn r#seek(&self, position: i64) -> Result<(), fidl::Error>;
1499    fn r#skip_forward(&self) -> Result<(), fidl::Error>;
1500    fn r#skip_reverse(&self) -> Result<(), fidl::Error>;
1501    fn r#next_item(&self) -> Result<(), fidl::Error>;
1502    fn r#prev_item(&self) -> Result<(), fidl::Error>;
1503    fn r#set_playback_rate(&self, playback_rate: f32) -> Result<(), fidl::Error>;
1504    fn r#set_repeat_mode(&self, repeat_mode: RepeatMode) -> Result<(), fidl::Error>;
1505    fn r#set_shuffle_mode(&self, shuffle_on: bool) -> Result<(), fidl::Error>;
1506    fn r#bind_volume_control(
1507        &self,
1508        volume_control_request: fidl::endpoints::ServerEnd<
1509            fidl_fuchsia_media_audio::VolumeControlMarker,
1510        >,
1511    ) -> Result<(), fidl::Error>;
1512    type WatchInfoChangeResponseFut: std::future::Future<Output = Result<PlayerInfoDelta, fidl::Error>>
1513        + Send;
1514    fn r#watch_info_change(&self) -> Self::WatchInfoChangeResponseFut;
1515}
1516#[derive(Debug)]
1517#[cfg(target_os = "fuchsia")]
1518pub struct PlayerSynchronousProxy {
1519    client: fidl::client::sync::Client,
1520}
1521
1522#[cfg(target_os = "fuchsia")]
1523impl fidl::endpoints::SynchronousProxy for PlayerSynchronousProxy {
1524    type Proxy = PlayerProxy;
1525    type Protocol = PlayerMarker;
1526
1527    fn from_channel(inner: fidl::Channel) -> Self {
1528        Self::new(inner)
1529    }
1530
1531    fn into_channel(self) -> fidl::Channel {
1532        self.client.into_channel()
1533    }
1534
1535    fn as_channel(&self) -> &fidl::Channel {
1536        self.client.as_channel()
1537    }
1538}
1539
1540#[cfg(target_os = "fuchsia")]
1541impl PlayerSynchronousProxy {
1542    pub fn new(channel: fidl::Channel) -> Self {
1543        let protocol_name = <PlayerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1544        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1545    }
1546
1547    pub fn into_channel(self) -> fidl::Channel {
1548        self.client.into_channel()
1549    }
1550
1551    /// Waits until an event arrives and returns it. It is safe for other
1552    /// threads to make concurrent requests while waiting for an event.
1553    pub fn wait_for_event(
1554        &self,
1555        deadline: zx::MonotonicInstant,
1556    ) -> Result<PlayerEvent, fidl::Error> {
1557        PlayerEvent::decode(self.client.wait_for_event(deadline)?)
1558    }
1559
1560    /// Plays media. If this method is not supported as indicated by the absence of the `PLAY`
1561    /// flag in `PlayerCapabilities`, this method does nothing.
1562    pub fn r#play(&self) -> Result<(), fidl::Error> {
1563        self.client.send::<fidl::encoding::EmptyPayload>(
1564            (),
1565            0x164120d5bdb26f8e,
1566            fidl::encoding::DynamicFlags::empty(),
1567        )
1568    }
1569
1570    /// Pauses playback and retains position in media. If this method is not supported as indicated
1571    /// by the absence of the `PAUSE` flag in `PlayerCapabilities`, this method does nothing.
1572    pub fn r#pause(&self) -> Result<(), fidl::Error> {
1573        self.client.send::<fidl::encoding::EmptyPayload>(
1574            (),
1575            0x1536d16f202ece1,
1576            fidl::encoding::DynamicFlags::empty(),
1577        )
1578    }
1579
1580    /// Stops playback. The session should close.
1581    pub fn r#stop(&self) -> Result<(), fidl::Error> {
1582        self.client.send::<fidl::encoding::EmptyPayload>(
1583            (),
1584            0x1946e5fc6c2362ae,
1585            fidl::encoding::DynamicFlags::empty(),
1586        )
1587    }
1588
1589    /// Seeks to a specific position in media. Implementations are free to
1590    /// enter an error state if the position is out of bounds. `position`
1591    /// is an offset from the beginning of the media. If this method is not supported as indicated
1592    /// by the absence of the `SEEK` flag in `PlayerCapabilities`, this method does nothing.
1593    pub fn r#seek(&self, mut position: i64) -> Result<(), fidl::Error> {
1594        self.client.send::<PlayerControlSeekRequest>(
1595            (position,),
1596            0x4e7237d293e22125,
1597            fidl::encoding::DynamicFlags::empty(),
1598        )
1599    }
1600
1601    /// Skips forward in media by the player's default skip amount. If this method is not supported
1602    /// as indicated by the absence of the `SKIP_FORWARD` flag in `PlayerCapabilities`, this method
1603    /// does nothing.
1604    pub fn r#skip_forward(&self) -> Result<(), fidl::Error> {
1605        self.client.send::<fidl::encoding::EmptyPayload>(
1606            (),
1607            0x6ee04477076dac1b,
1608            fidl::encoding::DynamicFlags::empty(),
1609        )
1610    }
1611
1612    /// Skips in reverse in media by the player's default skip amount. If this method is not
1613    /// supported as indicated by the absence of the `SKIP_REVERSE` flag in `PlayerCapabilities`,
1614    /// this method does nothing.
1615    pub fn r#skip_reverse(&self) -> Result<(), fidl::Error> {
1616        self.client.send::<fidl::encoding::EmptyPayload>(
1617            (),
1618            0xa4e05644ce33a28,
1619            fidl::encoding::DynamicFlags::empty(),
1620        )
1621    }
1622
1623    /// Changes media to the next item (e.g. next song in playlist). If this method is not
1624    /// supported as indicated by the absence of the `CHANGE_TO_NEXT_ITEM` flag in
1625    /// `PlayerCapabilities`, this method does nothing.
1626    pub fn r#next_item(&self) -> Result<(), fidl::Error> {
1627        self.client.send::<fidl::encoding::EmptyPayload>(
1628            (),
1629            0x73307b32e35ff260,
1630            fidl::encoding::DynamicFlags::empty(),
1631        )
1632    }
1633
1634    /// Changes media to the previous item. If this method is not
1635    /// supported as indicated by the absence of the `CHANGE_TO_PREV_ITEM` flag in
1636    /// `PlayerCapabilities`, this method does nothing.
1637    pub fn r#prev_item(&self) -> Result<(), fidl::Error> {
1638        self.client.send::<fidl::encoding::EmptyPayload>(
1639            (),
1640            0x680444f03a759a3c,
1641            fidl::encoding::DynamicFlags::empty(),
1642        )
1643    }
1644
1645    /// Sets the playback rate of the media. This will not change the playback mode. If this method
1646    /// is not supported as indicated by the absense of the `SET_PLAYBACK_RATE` flag in
1647    /// `PlayerCapabilities`, this method does nothing.
1648    pub fn r#set_playback_rate(&self, mut playback_rate: f32) -> Result<(), fidl::Error> {
1649        self.client.send::<PlayerControlSetPlaybackRateRequest>(
1650            (playback_rate,),
1651            0x3831b8b161e1bccf,
1652            fidl::encoding::DynamicFlags::empty(),
1653        )
1654    }
1655
1656    /// Sets repeat mode to any of the supported repeat modes.
1657    /// Whether this method takes effect depends on the `PlayerCapabilities` and `repeat_mode`:
1658    ///   * [`OFF`] is always supported.
1659    ///   * [`GROUP`] requires the `REPEAT_GROUPS` capability, and is otherwise ignored.
1660    ///   * [`SINGLE`] requires the `REPEAT_SINGLE` capability, and is otherwise ignored.
1661    pub fn r#set_repeat_mode(&self, mut repeat_mode: RepeatMode) -> Result<(), fidl::Error> {
1662        self.client.send::<PlayerControlSetRepeatModeRequest>(
1663            (repeat_mode,),
1664            0x21b9b1b17b7f01c2,
1665            fidl::encoding::DynamicFlags::empty(),
1666        )
1667    }
1668
1669    /// Sets shuffle mode. If this method is not supported as indicated by the absence of the
1670    /// `SHUFFLE` flag in `PlayerCapabilities`, this method does nothing.
1671    pub fn r#set_shuffle_mode(&self, mut shuffle_on: bool) -> Result<(), fidl::Error> {
1672        self.client.send::<PlayerControlSetShuffleModeRequest>(
1673            (shuffle_on,),
1674            0x7451a349ddb543c,
1675            fidl::encoding::DynamicFlags::empty(),
1676        )
1677    }
1678
1679    /// Binds to the session's volume control for control and notifications. If this method is not
1680    /// supported as indicated by the absence of the `HAS_GAIN_CONTROL` flag in
1681    /// `PlayerCapabilities`, the channel handle passed as `volume_control_request` is closed
1682    /// by the service.
1683    pub fn r#bind_volume_control(
1684        &self,
1685        mut volume_control_request: fidl::endpoints::ServerEnd<
1686            fidl_fuchsia_media_audio::VolumeControlMarker,
1687        >,
1688    ) -> Result<(), fidl::Error> {
1689        self.client.send::<PlayerControlBindVolumeControlRequest>(
1690            (volume_control_request,),
1691            0x11d61e878cf808bc,
1692            fidl::encoding::DynamicFlags::empty(),
1693        )
1694    }
1695
1696    /// Gets the net player info change using the hanging get pattern.
1697    pub fn r#watch_info_change(
1698        &self,
1699        ___deadline: zx::MonotonicInstant,
1700    ) -> Result<PlayerInfoDelta, fidl::Error> {
1701        let _response =
1702            self.client.send_query::<fidl::encoding::EmptyPayload, PlayerWatchInfoChangeResponse>(
1703                (),
1704                0x69196e240c62a732,
1705                fidl::encoding::DynamicFlags::empty(),
1706                ___deadline,
1707            )?;
1708        Ok(_response.player_info_delta)
1709    }
1710}
1711
1712#[cfg(target_os = "fuchsia")]
1713impl From<PlayerSynchronousProxy> for zx::Handle {
1714    fn from(value: PlayerSynchronousProxy) -> Self {
1715        value.into_channel().into()
1716    }
1717}
1718
1719#[cfg(target_os = "fuchsia")]
1720impl From<fidl::Channel> for PlayerSynchronousProxy {
1721    fn from(value: fidl::Channel) -> Self {
1722        Self::new(value)
1723    }
1724}
1725
1726#[derive(Debug, Clone)]
1727pub struct PlayerProxy {
1728    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1729}
1730
1731impl fidl::endpoints::Proxy for PlayerProxy {
1732    type Protocol = PlayerMarker;
1733
1734    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1735        Self::new(inner)
1736    }
1737
1738    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1739        self.client.into_channel().map_err(|client| Self { client })
1740    }
1741
1742    fn as_channel(&self) -> &::fidl::AsyncChannel {
1743        self.client.as_channel()
1744    }
1745}
1746
1747impl PlayerProxy {
1748    /// Create a new Proxy for fuchsia.media.sessions2/Player.
1749    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1750        let protocol_name = <PlayerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1751        Self { client: fidl::client::Client::new(channel, protocol_name) }
1752    }
1753
1754    /// Get a Stream of events from the remote end of the protocol.
1755    ///
1756    /// # Panics
1757    ///
1758    /// Panics if the event stream was already taken.
1759    pub fn take_event_stream(&self) -> PlayerEventStream {
1760        PlayerEventStream { event_receiver: self.client.take_event_receiver() }
1761    }
1762
1763    /// Plays media. If this method is not supported as indicated by the absence of the `PLAY`
1764    /// flag in `PlayerCapabilities`, this method does nothing.
1765    pub fn r#play(&self) -> Result<(), fidl::Error> {
1766        PlayerProxyInterface::r#play(self)
1767    }
1768
1769    /// Pauses playback and retains position in media. If this method is not supported as indicated
1770    /// by the absence of the `PAUSE` flag in `PlayerCapabilities`, this method does nothing.
1771    pub fn r#pause(&self) -> Result<(), fidl::Error> {
1772        PlayerProxyInterface::r#pause(self)
1773    }
1774
1775    /// Stops playback. The session should close.
1776    pub fn r#stop(&self) -> Result<(), fidl::Error> {
1777        PlayerProxyInterface::r#stop(self)
1778    }
1779
1780    /// Seeks to a specific position in media. Implementations are free to
1781    /// enter an error state if the position is out of bounds. `position`
1782    /// is an offset from the beginning of the media. If this method is not supported as indicated
1783    /// by the absence of the `SEEK` flag in `PlayerCapabilities`, this method does nothing.
1784    pub fn r#seek(&self, mut position: i64) -> Result<(), fidl::Error> {
1785        PlayerProxyInterface::r#seek(self, position)
1786    }
1787
1788    /// Skips forward in media by the player's default skip amount. If this method is not supported
1789    /// as indicated by the absence of the `SKIP_FORWARD` flag in `PlayerCapabilities`, this method
1790    /// does nothing.
1791    pub fn r#skip_forward(&self) -> Result<(), fidl::Error> {
1792        PlayerProxyInterface::r#skip_forward(self)
1793    }
1794
1795    /// Skips in reverse in media by the player's default skip amount. If this method is not
1796    /// supported as indicated by the absence of the `SKIP_REVERSE` flag in `PlayerCapabilities`,
1797    /// this method does nothing.
1798    pub fn r#skip_reverse(&self) -> Result<(), fidl::Error> {
1799        PlayerProxyInterface::r#skip_reverse(self)
1800    }
1801
1802    /// Changes media to the next item (e.g. next song in playlist). If this method is not
1803    /// supported as indicated by the absence of the `CHANGE_TO_NEXT_ITEM` flag in
1804    /// `PlayerCapabilities`, this method does nothing.
1805    pub fn r#next_item(&self) -> Result<(), fidl::Error> {
1806        PlayerProxyInterface::r#next_item(self)
1807    }
1808
1809    /// Changes media to the previous item. If this method is not
1810    /// supported as indicated by the absence of the `CHANGE_TO_PREV_ITEM` flag in
1811    /// `PlayerCapabilities`, this method does nothing.
1812    pub fn r#prev_item(&self) -> Result<(), fidl::Error> {
1813        PlayerProxyInterface::r#prev_item(self)
1814    }
1815
1816    /// Sets the playback rate of the media. This will not change the playback mode. If this method
1817    /// is not supported as indicated by the absense of the `SET_PLAYBACK_RATE` flag in
1818    /// `PlayerCapabilities`, this method does nothing.
1819    pub fn r#set_playback_rate(&self, mut playback_rate: f32) -> Result<(), fidl::Error> {
1820        PlayerProxyInterface::r#set_playback_rate(self, playback_rate)
1821    }
1822
1823    /// Sets repeat mode to any of the supported repeat modes.
1824    /// Whether this method takes effect depends on the `PlayerCapabilities` and `repeat_mode`:
1825    ///   * [`OFF`] is always supported.
1826    ///   * [`GROUP`] requires the `REPEAT_GROUPS` capability, and is otherwise ignored.
1827    ///   * [`SINGLE`] requires the `REPEAT_SINGLE` capability, and is otherwise ignored.
1828    pub fn r#set_repeat_mode(&self, mut repeat_mode: RepeatMode) -> Result<(), fidl::Error> {
1829        PlayerProxyInterface::r#set_repeat_mode(self, repeat_mode)
1830    }
1831
1832    /// Sets shuffle mode. If this method is not supported as indicated by the absence of the
1833    /// `SHUFFLE` flag in `PlayerCapabilities`, this method does nothing.
1834    pub fn r#set_shuffle_mode(&self, mut shuffle_on: bool) -> Result<(), fidl::Error> {
1835        PlayerProxyInterface::r#set_shuffle_mode(self, shuffle_on)
1836    }
1837
1838    /// Binds to the session's volume control for control and notifications. If this method is not
1839    /// supported as indicated by the absence of the `HAS_GAIN_CONTROL` flag in
1840    /// `PlayerCapabilities`, the channel handle passed as `volume_control_request` is closed
1841    /// by the service.
1842    pub fn r#bind_volume_control(
1843        &self,
1844        mut volume_control_request: fidl::endpoints::ServerEnd<
1845            fidl_fuchsia_media_audio::VolumeControlMarker,
1846        >,
1847    ) -> Result<(), fidl::Error> {
1848        PlayerProxyInterface::r#bind_volume_control(self, volume_control_request)
1849    }
1850
1851    /// Gets the net player info change using the hanging get pattern.
1852    pub fn r#watch_info_change(
1853        &self,
1854    ) -> fidl::client::QueryResponseFut<
1855        PlayerInfoDelta,
1856        fidl::encoding::DefaultFuchsiaResourceDialect,
1857    > {
1858        PlayerProxyInterface::r#watch_info_change(self)
1859    }
1860}
1861
1862impl PlayerProxyInterface for PlayerProxy {
1863    fn r#play(&self) -> Result<(), fidl::Error> {
1864        self.client.send::<fidl::encoding::EmptyPayload>(
1865            (),
1866            0x164120d5bdb26f8e,
1867            fidl::encoding::DynamicFlags::empty(),
1868        )
1869    }
1870
1871    fn r#pause(&self) -> Result<(), fidl::Error> {
1872        self.client.send::<fidl::encoding::EmptyPayload>(
1873            (),
1874            0x1536d16f202ece1,
1875            fidl::encoding::DynamicFlags::empty(),
1876        )
1877    }
1878
1879    fn r#stop(&self) -> Result<(), fidl::Error> {
1880        self.client.send::<fidl::encoding::EmptyPayload>(
1881            (),
1882            0x1946e5fc6c2362ae,
1883            fidl::encoding::DynamicFlags::empty(),
1884        )
1885    }
1886
1887    fn r#seek(&self, mut position: i64) -> Result<(), fidl::Error> {
1888        self.client.send::<PlayerControlSeekRequest>(
1889            (position,),
1890            0x4e7237d293e22125,
1891            fidl::encoding::DynamicFlags::empty(),
1892        )
1893    }
1894
1895    fn r#skip_forward(&self) -> Result<(), fidl::Error> {
1896        self.client.send::<fidl::encoding::EmptyPayload>(
1897            (),
1898            0x6ee04477076dac1b,
1899            fidl::encoding::DynamicFlags::empty(),
1900        )
1901    }
1902
1903    fn r#skip_reverse(&self) -> Result<(), fidl::Error> {
1904        self.client.send::<fidl::encoding::EmptyPayload>(
1905            (),
1906            0xa4e05644ce33a28,
1907            fidl::encoding::DynamicFlags::empty(),
1908        )
1909    }
1910
1911    fn r#next_item(&self) -> Result<(), fidl::Error> {
1912        self.client.send::<fidl::encoding::EmptyPayload>(
1913            (),
1914            0x73307b32e35ff260,
1915            fidl::encoding::DynamicFlags::empty(),
1916        )
1917    }
1918
1919    fn r#prev_item(&self) -> Result<(), fidl::Error> {
1920        self.client.send::<fidl::encoding::EmptyPayload>(
1921            (),
1922            0x680444f03a759a3c,
1923            fidl::encoding::DynamicFlags::empty(),
1924        )
1925    }
1926
1927    fn r#set_playback_rate(&self, mut playback_rate: f32) -> Result<(), fidl::Error> {
1928        self.client.send::<PlayerControlSetPlaybackRateRequest>(
1929            (playback_rate,),
1930            0x3831b8b161e1bccf,
1931            fidl::encoding::DynamicFlags::empty(),
1932        )
1933    }
1934
1935    fn r#set_repeat_mode(&self, mut repeat_mode: RepeatMode) -> Result<(), fidl::Error> {
1936        self.client.send::<PlayerControlSetRepeatModeRequest>(
1937            (repeat_mode,),
1938            0x21b9b1b17b7f01c2,
1939            fidl::encoding::DynamicFlags::empty(),
1940        )
1941    }
1942
1943    fn r#set_shuffle_mode(&self, mut shuffle_on: bool) -> Result<(), fidl::Error> {
1944        self.client.send::<PlayerControlSetShuffleModeRequest>(
1945            (shuffle_on,),
1946            0x7451a349ddb543c,
1947            fidl::encoding::DynamicFlags::empty(),
1948        )
1949    }
1950
1951    fn r#bind_volume_control(
1952        &self,
1953        mut volume_control_request: fidl::endpoints::ServerEnd<
1954            fidl_fuchsia_media_audio::VolumeControlMarker,
1955        >,
1956    ) -> Result<(), fidl::Error> {
1957        self.client.send::<PlayerControlBindVolumeControlRequest>(
1958            (volume_control_request,),
1959            0x11d61e878cf808bc,
1960            fidl::encoding::DynamicFlags::empty(),
1961        )
1962    }
1963
1964    type WatchInfoChangeResponseFut = fidl::client::QueryResponseFut<
1965        PlayerInfoDelta,
1966        fidl::encoding::DefaultFuchsiaResourceDialect,
1967    >;
1968    fn r#watch_info_change(&self) -> Self::WatchInfoChangeResponseFut {
1969        fn _decode(
1970            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1971        ) -> Result<PlayerInfoDelta, fidl::Error> {
1972            let _response = fidl::client::decode_transaction_body::<
1973                PlayerWatchInfoChangeResponse,
1974                fidl::encoding::DefaultFuchsiaResourceDialect,
1975                0x69196e240c62a732,
1976            >(_buf?)?;
1977            Ok(_response.player_info_delta)
1978        }
1979        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PlayerInfoDelta>(
1980            (),
1981            0x69196e240c62a732,
1982            fidl::encoding::DynamicFlags::empty(),
1983            _decode,
1984        )
1985    }
1986}
1987
1988pub struct PlayerEventStream {
1989    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1990}
1991
1992impl std::marker::Unpin for PlayerEventStream {}
1993
1994impl futures::stream::FusedStream for PlayerEventStream {
1995    fn is_terminated(&self) -> bool {
1996        self.event_receiver.is_terminated()
1997    }
1998}
1999
2000impl futures::Stream for PlayerEventStream {
2001    type Item = Result<PlayerEvent, fidl::Error>;
2002
2003    fn poll_next(
2004        mut self: std::pin::Pin<&mut Self>,
2005        cx: &mut std::task::Context<'_>,
2006    ) -> std::task::Poll<Option<Self::Item>> {
2007        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2008            &mut self.event_receiver,
2009            cx
2010        )?) {
2011            Some(buf) => std::task::Poll::Ready(Some(PlayerEvent::decode(buf))),
2012            None => std::task::Poll::Ready(None),
2013        }
2014    }
2015}
2016
2017#[derive(Debug)]
2018pub enum PlayerEvent {}
2019
2020impl PlayerEvent {
2021    /// Decodes a message buffer as a [`PlayerEvent`].
2022    fn decode(
2023        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2024    ) -> Result<PlayerEvent, fidl::Error> {
2025        let (bytes, _handles) = buf.split_mut();
2026        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2027        debug_assert_eq!(tx_header.tx_id, 0);
2028        match tx_header.ordinal {
2029            _ => Err(fidl::Error::UnknownOrdinal {
2030                ordinal: tx_header.ordinal,
2031                protocol_name: <PlayerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2032            }),
2033        }
2034    }
2035}
2036
2037/// A Stream of incoming requests for fuchsia.media.sessions2/Player.
2038pub struct PlayerRequestStream {
2039    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2040    is_terminated: bool,
2041}
2042
2043impl std::marker::Unpin for PlayerRequestStream {}
2044
2045impl futures::stream::FusedStream for PlayerRequestStream {
2046    fn is_terminated(&self) -> bool {
2047        self.is_terminated
2048    }
2049}
2050
2051impl fidl::endpoints::RequestStream for PlayerRequestStream {
2052    type Protocol = PlayerMarker;
2053    type ControlHandle = PlayerControlHandle;
2054
2055    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2056        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2057    }
2058
2059    fn control_handle(&self) -> Self::ControlHandle {
2060        PlayerControlHandle { inner: self.inner.clone() }
2061    }
2062
2063    fn into_inner(
2064        self,
2065    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2066    {
2067        (self.inner, self.is_terminated)
2068    }
2069
2070    fn from_inner(
2071        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2072        is_terminated: bool,
2073    ) -> Self {
2074        Self { inner, is_terminated }
2075    }
2076}
2077
2078impl futures::Stream for PlayerRequestStream {
2079    type Item = Result<PlayerRequest, fidl::Error>;
2080
2081    fn poll_next(
2082        mut self: std::pin::Pin<&mut Self>,
2083        cx: &mut std::task::Context<'_>,
2084    ) -> std::task::Poll<Option<Self::Item>> {
2085        let this = &mut *self;
2086        if this.inner.check_shutdown(cx) {
2087            this.is_terminated = true;
2088            return std::task::Poll::Ready(None);
2089        }
2090        if this.is_terminated {
2091            panic!("polled PlayerRequestStream after completion");
2092        }
2093        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2094            |bytes, handles| {
2095                match this.inner.channel().read_etc(cx, bytes, handles) {
2096                    std::task::Poll::Ready(Ok(())) => {}
2097                    std::task::Poll::Pending => return std::task::Poll::Pending,
2098                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2099                        this.is_terminated = true;
2100                        return std::task::Poll::Ready(None);
2101                    }
2102                    std::task::Poll::Ready(Err(e)) => {
2103                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2104                            e.into(),
2105                        ))))
2106                    }
2107                }
2108
2109                // A message has been received from the channel
2110                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2111
2112                std::task::Poll::Ready(Some(match header.ordinal {
2113                    0x164120d5bdb26f8e => {
2114                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2115                        let mut req = fidl::new_empty!(
2116                            fidl::encoding::EmptyPayload,
2117                            fidl::encoding::DefaultFuchsiaResourceDialect
2118                        );
2119                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2120                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
2121                        Ok(PlayerRequest::Play { control_handle })
2122                    }
2123                    0x1536d16f202ece1 => {
2124                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2125                        let mut req = fidl::new_empty!(
2126                            fidl::encoding::EmptyPayload,
2127                            fidl::encoding::DefaultFuchsiaResourceDialect
2128                        );
2129                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2130                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
2131                        Ok(PlayerRequest::Pause { control_handle })
2132                    }
2133                    0x1946e5fc6c2362ae => {
2134                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2135                        let mut req = fidl::new_empty!(
2136                            fidl::encoding::EmptyPayload,
2137                            fidl::encoding::DefaultFuchsiaResourceDialect
2138                        );
2139                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2140                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
2141                        Ok(PlayerRequest::Stop { control_handle })
2142                    }
2143                    0x4e7237d293e22125 => {
2144                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2145                        let mut req = fidl::new_empty!(
2146                            PlayerControlSeekRequest,
2147                            fidl::encoding::DefaultFuchsiaResourceDialect
2148                        );
2149                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerControlSeekRequest>(&header, _body_bytes, handles, &mut req)?;
2150                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
2151                        Ok(PlayerRequest::Seek { position: req.position, control_handle })
2152                    }
2153                    0x6ee04477076dac1b => {
2154                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2155                        let mut req = fidl::new_empty!(
2156                            fidl::encoding::EmptyPayload,
2157                            fidl::encoding::DefaultFuchsiaResourceDialect
2158                        );
2159                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2160                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
2161                        Ok(PlayerRequest::SkipForward { control_handle })
2162                    }
2163                    0xa4e05644ce33a28 => {
2164                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2165                        let mut req = fidl::new_empty!(
2166                            fidl::encoding::EmptyPayload,
2167                            fidl::encoding::DefaultFuchsiaResourceDialect
2168                        );
2169                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2170                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
2171                        Ok(PlayerRequest::SkipReverse { control_handle })
2172                    }
2173                    0x73307b32e35ff260 => {
2174                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2175                        let mut req = fidl::new_empty!(
2176                            fidl::encoding::EmptyPayload,
2177                            fidl::encoding::DefaultFuchsiaResourceDialect
2178                        );
2179                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2180                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
2181                        Ok(PlayerRequest::NextItem { control_handle })
2182                    }
2183                    0x680444f03a759a3c => {
2184                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2185                        let mut req = fidl::new_empty!(
2186                            fidl::encoding::EmptyPayload,
2187                            fidl::encoding::DefaultFuchsiaResourceDialect
2188                        );
2189                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2190                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
2191                        Ok(PlayerRequest::PrevItem { control_handle })
2192                    }
2193                    0x3831b8b161e1bccf => {
2194                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2195                        let mut req = fidl::new_empty!(
2196                            PlayerControlSetPlaybackRateRequest,
2197                            fidl::encoding::DefaultFuchsiaResourceDialect
2198                        );
2199                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerControlSetPlaybackRateRequest>(&header, _body_bytes, handles, &mut req)?;
2200                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
2201                        Ok(PlayerRequest::SetPlaybackRate {
2202                            playback_rate: req.playback_rate,
2203
2204                            control_handle,
2205                        })
2206                    }
2207                    0x21b9b1b17b7f01c2 => {
2208                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2209                        let mut req = fidl::new_empty!(
2210                            PlayerControlSetRepeatModeRequest,
2211                            fidl::encoding::DefaultFuchsiaResourceDialect
2212                        );
2213                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerControlSetRepeatModeRequest>(&header, _body_bytes, handles, &mut req)?;
2214                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
2215                        Ok(PlayerRequest::SetRepeatMode {
2216                            repeat_mode: req.repeat_mode,
2217
2218                            control_handle,
2219                        })
2220                    }
2221                    0x7451a349ddb543c => {
2222                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2223                        let mut req = fidl::new_empty!(
2224                            PlayerControlSetShuffleModeRequest,
2225                            fidl::encoding::DefaultFuchsiaResourceDialect
2226                        );
2227                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerControlSetShuffleModeRequest>(&header, _body_bytes, handles, &mut req)?;
2228                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
2229                        Ok(PlayerRequest::SetShuffleMode {
2230                            shuffle_on: req.shuffle_on,
2231
2232                            control_handle,
2233                        })
2234                    }
2235                    0x11d61e878cf808bc => {
2236                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2237                        let mut req = fidl::new_empty!(
2238                            PlayerControlBindVolumeControlRequest,
2239                            fidl::encoding::DefaultFuchsiaResourceDialect
2240                        );
2241                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerControlBindVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
2242                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
2243                        Ok(PlayerRequest::BindVolumeControl {
2244                            volume_control_request: req.volume_control_request,
2245
2246                            control_handle,
2247                        })
2248                    }
2249                    0x69196e240c62a732 => {
2250                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2251                        let mut req = fidl::new_empty!(
2252                            fidl::encoding::EmptyPayload,
2253                            fidl::encoding::DefaultFuchsiaResourceDialect
2254                        );
2255                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2256                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
2257                        Ok(PlayerRequest::WatchInfoChange {
2258                            responder: PlayerWatchInfoChangeResponder {
2259                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2260                                tx_id: header.tx_id,
2261                            },
2262                        })
2263                    }
2264                    _ => Err(fidl::Error::UnknownOrdinal {
2265                        ordinal: header.ordinal,
2266                        protocol_name:
2267                            <PlayerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2268                    }),
2269                }))
2270            },
2271        )
2272    }
2273}
2274
2275/// `Player` is a handle for a media player. Unsupported commands are
2276/// no-ops.  Consult `PlaybackCapabilities`, sent by to learn which
2277/// commands are supported.
2278#[derive(Debug)]
2279pub enum PlayerRequest {
2280    /// Plays media. If this method is not supported as indicated by the absence of the `PLAY`
2281    /// flag in `PlayerCapabilities`, this method does nothing.
2282    Play { control_handle: PlayerControlHandle },
2283    /// Pauses playback and retains position in media. If this method is not supported as indicated
2284    /// by the absence of the `PAUSE` flag in `PlayerCapabilities`, this method does nothing.
2285    Pause { control_handle: PlayerControlHandle },
2286    /// Stops playback. The session should close.
2287    Stop { control_handle: PlayerControlHandle },
2288    /// Seeks to a specific position in media. Implementations are free to
2289    /// enter an error state if the position is out of bounds. `position`
2290    /// is an offset from the beginning of the media. If this method is not supported as indicated
2291    /// by the absence of the `SEEK` flag in `PlayerCapabilities`, this method does nothing.
2292    Seek { position: i64, control_handle: PlayerControlHandle },
2293    /// Skips forward in media by the player's default skip amount. If this method is not supported
2294    /// as indicated by the absence of the `SKIP_FORWARD` flag in `PlayerCapabilities`, this method
2295    /// does nothing.
2296    SkipForward { control_handle: PlayerControlHandle },
2297    /// Skips in reverse in media by the player's default skip amount. If this method is not
2298    /// supported as indicated by the absence of the `SKIP_REVERSE` flag in `PlayerCapabilities`,
2299    /// this method does nothing.
2300    SkipReverse { control_handle: PlayerControlHandle },
2301    /// Changes media to the next item (e.g. next song in playlist). If this method is not
2302    /// supported as indicated by the absence of the `CHANGE_TO_NEXT_ITEM` flag in
2303    /// `PlayerCapabilities`, this method does nothing.
2304    NextItem { control_handle: PlayerControlHandle },
2305    /// Changes media to the previous item. If this method is not
2306    /// supported as indicated by the absence of the `CHANGE_TO_PREV_ITEM` flag in
2307    /// `PlayerCapabilities`, this method does nothing.
2308    PrevItem { control_handle: PlayerControlHandle },
2309    /// Sets the playback rate of the media. This will not change the playback mode. If this method
2310    /// is not supported as indicated by the absense of the `SET_PLAYBACK_RATE` flag in
2311    /// `PlayerCapabilities`, this method does nothing.
2312    SetPlaybackRate { playback_rate: f32, control_handle: PlayerControlHandle },
2313    /// Sets repeat mode to any of the supported repeat modes.
2314    /// Whether this method takes effect depends on the `PlayerCapabilities` and `repeat_mode`:
2315    ///   * [`OFF`] is always supported.
2316    ///   * [`GROUP`] requires the `REPEAT_GROUPS` capability, and is otherwise ignored.
2317    ///   * [`SINGLE`] requires the `REPEAT_SINGLE` capability, and is otherwise ignored.
2318    SetRepeatMode { repeat_mode: RepeatMode, control_handle: PlayerControlHandle },
2319    /// Sets shuffle mode. If this method is not supported as indicated by the absence of the
2320    /// `SHUFFLE` flag in `PlayerCapabilities`, this method does nothing.
2321    SetShuffleMode { shuffle_on: bool, control_handle: PlayerControlHandle },
2322    /// Binds to the session's volume control for control and notifications. If this method is not
2323    /// supported as indicated by the absence of the `HAS_GAIN_CONTROL` flag in
2324    /// `PlayerCapabilities`, the channel handle passed as `volume_control_request` is closed
2325    /// by the service.
2326    BindVolumeControl {
2327        volume_control_request:
2328            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
2329        control_handle: PlayerControlHandle,
2330    },
2331    /// Gets the net player info change using the hanging get pattern.
2332    WatchInfoChange { responder: PlayerWatchInfoChangeResponder },
2333}
2334
2335impl PlayerRequest {
2336    #[allow(irrefutable_let_patterns)]
2337    pub fn into_play(self) -> Option<(PlayerControlHandle)> {
2338        if let PlayerRequest::Play { control_handle } = self {
2339            Some((control_handle))
2340        } else {
2341            None
2342        }
2343    }
2344
2345    #[allow(irrefutable_let_patterns)]
2346    pub fn into_pause(self) -> Option<(PlayerControlHandle)> {
2347        if let PlayerRequest::Pause { control_handle } = self {
2348            Some((control_handle))
2349        } else {
2350            None
2351        }
2352    }
2353
2354    #[allow(irrefutable_let_patterns)]
2355    pub fn into_stop(self) -> Option<(PlayerControlHandle)> {
2356        if let PlayerRequest::Stop { control_handle } = self {
2357            Some((control_handle))
2358        } else {
2359            None
2360        }
2361    }
2362
2363    #[allow(irrefutable_let_patterns)]
2364    pub fn into_seek(self) -> Option<(i64, PlayerControlHandle)> {
2365        if let PlayerRequest::Seek { position, control_handle } = self {
2366            Some((position, control_handle))
2367        } else {
2368            None
2369        }
2370    }
2371
2372    #[allow(irrefutable_let_patterns)]
2373    pub fn into_skip_forward(self) -> Option<(PlayerControlHandle)> {
2374        if let PlayerRequest::SkipForward { control_handle } = self {
2375            Some((control_handle))
2376        } else {
2377            None
2378        }
2379    }
2380
2381    #[allow(irrefutable_let_patterns)]
2382    pub fn into_skip_reverse(self) -> Option<(PlayerControlHandle)> {
2383        if let PlayerRequest::SkipReverse { control_handle } = self {
2384            Some((control_handle))
2385        } else {
2386            None
2387        }
2388    }
2389
2390    #[allow(irrefutable_let_patterns)]
2391    pub fn into_next_item(self) -> Option<(PlayerControlHandle)> {
2392        if let PlayerRequest::NextItem { control_handle } = self {
2393            Some((control_handle))
2394        } else {
2395            None
2396        }
2397    }
2398
2399    #[allow(irrefutable_let_patterns)]
2400    pub fn into_prev_item(self) -> Option<(PlayerControlHandle)> {
2401        if let PlayerRequest::PrevItem { control_handle } = self {
2402            Some((control_handle))
2403        } else {
2404            None
2405        }
2406    }
2407
2408    #[allow(irrefutable_let_patterns)]
2409    pub fn into_set_playback_rate(self) -> Option<(f32, PlayerControlHandle)> {
2410        if let PlayerRequest::SetPlaybackRate { playback_rate, control_handle } = self {
2411            Some((playback_rate, control_handle))
2412        } else {
2413            None
2414        }
2415    }
2416
2417    #[allow(irrefutable_let_patterns)]
2418    pub fn into_set_repeat_mode(self) -> Option<(RepeatMode, PlayerControlHandle)> {
2419        if let PlayerRequest::SetRepeatMode { repeat_mode, control_handle } = self {
2420            Some((repeat_mode, control_handle))
2421        } else {
2422            None
2423        }
2424    }
2425
2426    #[allow(irrefutable_let_patterns)]
2427    pub fn into_set_shuffle_mode(self) -> Option<(bool, PlayerControlHandle)> {
2428        if let PlayerRequest::SetShuffleMode { shuffle_on, control_handle } = self {
2429            Some((shuffle_on, control_handle))
2430        } else {
2431            None
2432        }
2433    }
2434
2435    #[allow(irrefutable_let_patterns)]
2436    pub fn into_bind_volume_control(
2437        self,
2438    ) -> Option<(
2439        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
2440        PlayerControlHandle,
2441    )> {
2442        if let PlayerRequest::BindVolumeControl { volume_control_request, control_handle } = self {
2443            Some((volume_control_request, control_handle))
2444        } else {
2445            None
2446        }
2447    }
2448
2449    #[allow(irrefutable_let_patterns)]
2450    pub fn into_watch_info_change(self) -> Option<(PlayerWatchInfoChangeResponder)> {
2451        if let PlayerRequest::WatchInfoChange { responder } = self {
2452            Some((responder))
2453        } else {
2454            None
2455        }
2456    }
2457
2458    /// Name of the method defined in FIDL
2459    pub fn method_name(&self) -> &'static str {
2460        match *self {
2461            PlayerRequest::Play { .. } => "play",
2462            PlayerRequest::Pause { .. } => "pause",
2463            PlayerRequest::Stop { .. } => "stop",
2464            PlayerRequest::Seek { .. } => "seek",
2465            PlayerRequest::SkipForward { .. } => "skip_forward",
2466            PlayerRequest::SkipReverse { .. } => "skip_reverse",
2467            PlayerRequest::NextItem { .. } => "next_item",
2468            PlayerRequest::PrevItem { .. } => "prev_item",
2469            PlayerRequest::SetPlaybackRate { .. } => "set_playback_rate",
2470            PlayerRequest::SetRepeatMode { .. } => "set_repeat_mode",
2471            PlayerRequest::SetShuffleMode { .. } => "set_shuffle_mode",
2472            PlayerRequest::BindVolumeControl { .. } => "bind_volume_control",
2473            PlayerRequest::WatchInfoChange { .. } => "watch_info_change",
2474        }
2475    }
2476}
2477
2478#[derive(Debug, Clone)]
2479pub struct PlayerControlHandle {
2480    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2481}
2482
2483impl fidl::endpoints::ControlHandle for PlayerControlHandle {
2484    fn shutdown(&self) {
2485        self.inner.shutdown()
2486    }
2487    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2488        self.inner.shutdown_with_epitaph(status)
2489    }
2490
2491    fn is_closed(&self) -> bool {
2492        self.inner.channel().is_closed()
2493    }
2494    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2495        self.inner.channel().on_closed()
2496    }
2497
2498    #[cfg(target_os = "fuchsia")]
2499    fn signal_peer(
2500        &self,
2501        clear_mask: zx::Signals,
2502        set_mask: zx::Signals,
2503    ) -> Result<(), zx_status::Status> {
2504        use fidl::Peered;
2505        self.inner.channel().signal_peer(clear_mask, set_mask)
2506    }
2507}
2508
2509impl PlayerControlHandle {}
2510
2511#[must_use = "FIDL methods require a response to be sent"]
2512#[derive(Debug)]
2513pub struct PlayerWatchInfoChangeResponder {
2514    control_handle: std::mem::ManuallyDrop<PlayerControlHandle>,
2515    tx_id: u32,
2516}
2517
2518/// Set the the channel to be shutdown (see [`PlayerControlHandle::shutdown`])
2519/// if the responder is dropped without sending a response, so that the client
2520/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2521impl std::ops::Drop for PlayerWatchInfoChangeResponder {
2522    fn drop(&mut self) {
2523        self.control_handle.shutdown();
2524        // Safety: drops once, never accessed again
2525        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2526    }
2527}
2528
2529impl fidl::endpoints::Responder for PlayerWatchInfoChangeResponder {
2530    type ControlHandle = PlayerControlHandle;
2531
2532    fn control_handle(&self) -> &PlayerControlHandle {
2533        &self.control_handle
2534    }
2535
2536    fn drop_without_shutdown(mut self) {
2537        // Safety: drops once, never accessed again due to mem::forget
2538        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2539        // Prevent Drop from running (which would shut down the channel)
2540        std::mem::forget(self);
2541    }
2542}
2543
2544impl PlayerWatchInfoChangeResponder {
2545    /// Sends a response to the FIDL transaction.
2546    ///
2547    /// Sets the channel to shutdown if an error occurs.
2548    pub fn send(self, mut player_info_delta: &PlayerInfoDelta) -> Result<(), fidl::Error> {
2549        let _result = self.send_raw(player_info_delta);
2550        if _result.is_err() {
2551            self.control_handle.shutdown();
2552        }
2553        self.drop_without_shutdown();
2554        _result
2555    }
2556
2557    /// Similar to "send" but does not shutdown the channel if an error occurs.
2558    pub fn send_no_shutdown_on_err(
2559        self,
2560        mut player_info_delta: &PlayerInfoDelta,
2561    ) -> Result<(), fidl::Error> {
2562        let _result = self.send_raw(player_info_delta);
2563        self.drop_without_shutdown();
2564        _result
2565    }
2566
2567    fn send_raw(&self, mut player_info_delta: &PlayerInfoDelta) -> Result<(), fidl::Error> {
2568        self.control_handle.inner.send::<PlayerWatchInfoChangeResponse>(
2569            (player_info_delta,),
2570            self.tx_id,
2571            0x69196e240c62a732,
2572            fidl::encoding::DynamicFlags::empty(),
2573        )
2574    }
2575}
2576
2577#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2578pub struct PlayerControlMarker;
2579
2580impl fidl::endpoints::ProtocolMarker for PlayerControlMarker {
2581    type Proxy = PlayerControlProxy;
2582    type RequestStream = PlayerControlRequestStream;
2583    #[cfg(target_os = "fuchsia")]
2584    type SynchronousProxy = PlayerControlSynchronousProxy;
2585
2586    const DEBUG_NAME: &'static str = "(anonymous) PlayerControl";
2587}
2588
2589pub trait PlayerControlProxyInterface: Send + Sync {
2590    fn r#play(&self) -> Result<(), fidl::Error>;
2591    fn r#pause(&self) -> Result<(), fidl::Error>;
2592    fn r#stop(&self) -> Result<(), fidl::Error>;
2593    fn r#seek(&self, position: i64) -> Result<(), fidl::Error>;
2594    fn r#skip_forward(&self) -> Result<(), fidl::Error>;
2595    fn r#skip_reverse(&self) -> Result<(), fidl::Error>;
2596    fn r#next_item(&self) -> Result<(), fidl::Error>;
2597    fn r#prev_item(&self) -> Result<(), fidl::Error>;
2598    fn r#set_playback_rate(&self, playback_rate: f32) -> Result<(), fidl::Error>;
2599    fn r#set_repeat_mode(&self, repeat_mode: RepeatMode) -> Result<(), fidl::Error>;
2600    fn r#set_shuffle_mode(&self, shuffle_on: bool) -> Result<(), fidl::Error>;
2601    fn r#bind_volume_control(
2602        &self,
2603        volume_control_request: fidl::endpoints::ServerEnd<
2604            fidl_fuchsia_media_audio::VolumeControlMarker,
2605        >,
2606    ) -> Result<(), fidl::Error>;
2607}
2608#[derive(Debug)]
2609#[cfg(target_os = "fuchsia")]
2610pub struct PlayerControlSynchronousProxy {
2611    client: fidl::client::sync::Client,
2612}
2613
2614#[cfg(target_os = "fuchsia")]
2615impl fidl::endpoints::SynchronousProxy for PlayerControlSynchronousProxy {
2616    type Proxy = PlayerControlProxy;
2617    type Protocol = PlayerControlMarker;
2618
2619    fn from_channel(inner: fidl::Channel) -> Self {
2620        Self::new(inner)
2621    }
2622
2623    fn into_channel(self) -> fidl::Channel {
2624        self.client.into_channel()
2625    }
2626
2627    fn as_channel(&self) -> &fidl::Channel {
2628        self.client.as_channel()
2629    }
2630}
2631
2632#[cfg(target_os = "fuchsia")]
2633impl PlayerControlSynchronousProxy {
2634    pub fn new(channel: fidl::Channel) -> Self {
2635        let protocol_name = <PlayerControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2636        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2637    }
2638
2639    pub fn into_channel(self) -> fidl::Channel {
2640        self.client.into_channel()
2641    }
2642
2643    /// Waits until an event arrives and returns it. It is safe for other
2644    /// threads to make concurrent requests while waiting for an event.
2645    pub fn wait_for_event(
2646        &self,
2647        deadline: zx::MonotonicInstant,
2648    ) -> Result<PlayerControlEvent, fidl::Error> {
2649        PlayerControlEvent::decode(self.client.wait_for_event(deadline)?)
2650    }
2651
2652    /// Plays media. If this method is not supported as indicated by the absence of the `PLAY`
2653    /// flag in `PlayerCapabilities`, this method does nothing.
2654    pub fn r#play(&self) -> Result<(), fidl::Error> {
2655        self.client.send::<fidl::encoding::EmptyPayload>(
2656            (),
2657            0x164120d5bdb26f8e,
2658            fidl::encoding::DynamicFlags::empty(),
2659        )
2660    }
2661
2662    /// Pauses playback and retains position in media. If this method is not supported as indicated
2663    /// by the absence of the `PAUSE` flag in `PlayerCapabilities`, this method does nothing.
2664    pub fn r#pause(&self) -> Result<(), fidl::Error> {
2665        self.client.send::<fidl::encoding::EmptyPayload>(
2666            (),
2667            0x1536d16f202ece1,
2668            fidl::encoding::DynamicFlags::empty(),
2669        )
2670    }
2671
2672    /// Stops playback. The session should close.
2673    pub fn r#stop(&self) -> Result<(), fidl::Error> {
2674        self.client.send::<fidl::encoding::EmptyPayload>(
2675            (),
2676            0x1946e5fc6c2362ae,
2677            fidl::encoding::DynamicFlags::empty(),
2678        )
2679    }
2680
2681    /// Seeks to a specific position in media. Implementations are free to
2682    /// enter an error state if the position is out of bounds. `position`
2683    /// is an offset from the beginning of the media. If this method is not supported as indicated
2684    /// by the absence of the `SEEK` flag in `PlayerCapabilities`, this method does nothing.
2685    pub fn r#seek(&self, mut position: i64) -> Result<(), fidl::Error> {
2686        self.client.send::<PlayerControlSeekRequest>(
2687            (position,),
2688            0x4e7237d293e22125,
2689            fidl::encoding::DynamicFlags::empty(),
2690        )
2691    }
2692
2693    /// Skips forward in media by the player's default skip amount. If this method is not supported
2694    /// as indicated by the absence of the `SKIP_FORWARD` flag in `PlayerCapabilities`, this method
2695    /// does nothing.
2696    pub fn r#skip_forward(&self) -> Result<(), fidl::Error> {
2697        self.client.send::<fidl::encoding::EmptyPayload>(
2698            (),
2699            0x6ee04477076dac1b,
2700            fidl::encoding::DynamicFlags::empty(),
2701        )
2702    }
2703
2704    /// Skips in reverse in media by the player's default skip amount. If this method is not
2705    /// supported as indicated by the absence of the `SKIP_REVERSE` flag in `PlayerCapabilities`,
2706    /// this method does nothing.
2707    pub fn r#skip_reverse(&self) -> Result<(), fidl::Error> {
2708        self.client.send::<fidl::encoding::EmptyPayload>(
2709            (),
2710            0xa4e05644ce33a28,
2711            fidl::encoding::DynamicFlags::empty(),
2712        )
2713    }
2714
2715    /// Changes media to the next item (e.g. next song in playlist). If this method is not
2716    /// supported as indicated by the absence of the `CHANGE_TO_NEXT_ITEM` flag in
2717    /// `PlayerCapabilities`, this method does nothing.
2718    pub fn r#next_item(&self) -> Result<(), fidl::Error> {
2719        self.client.send::<fidl::encoding::EmptyPayload>(
2720            (),
2721            0x73307b32e35ff260,
2722            fidl::encoding::DynamicFlags::empty(),
2723        )
2724    }
2725
2726    /// Changes media to the previous item. If this method is not
2727    /// supported as indicated by the absence of the `CHANGE_TO_PREV_ITEM` flag in
2728    /// `PlayerCapabilities`, this method does nothing.
2729    pub fn r#prev_item(&self) -> Result<(), fidl::Error> {
2730        self.client.send::<fidl::encoding::EmptyPayload>(
2731            (),
2732            0x680444f03a759a3c,
2733            fidl::encoding::DynamicFlags::empty(),
2734        )
2735    }
2736
2737    /// Sets the playback rate of the media. This will not change the playback mode. If this method
2738    /// is not supported as indicated by the absense of the `SET_PLAYBACK_RATE` flag in
2739    /// `PlayerCapabilities`, this method does nothing.
2740    pub fn r#set_playback_rate(&self, mut playback_rate: f32) -> Result<(), fidl::Error> {
2741        self.client.send::<PlayerControlSetPlaybackRateRequest>(
2742            (playback_rate,),
2743            0x3831b8b161e1bccf,
2744            fidl::encoding::DynamicFlags::empty(),
2745        )
2746    }
2747
2748    /// Sets repeat mode to any of the supported repeat modes.
2749    /// Whether this method takes effect depends on the `PlayerCapabilities` and `repeat_mode`:
2750    ///   * [`OFF`] is always supported.
2751    ///   * [`GROUP`] requires the `REPEAT_GROUPS` capability, and is otherwise ignored.
2752    ///   * [`SINGLE`] requires the `REPEAT_SINGLE` capability, and is otherwise ignored.
2753    pub fn r#set_repeat_mode(&self, mut repeat_mode: RepeatMode) -> Result<(), fidl::Error> {
2754        self.client.send::<PlayerControlSetRepeatModeRequest>(
2755            (repeat_mode,),
2756            0x21b9b1b17b7f01c2,
2757            fidl::encoding::DynamicFlags::empty(),
2758        )
2759    }
2760
2761    /// Sets shuffle mode. If this method is not supported as indicated by the absence of the
2762    /// `SHUFFLE` flag in `PlayerCapabilities`, this method does nothing.
2763    pub fn r#set_shuffle_mode(&self, mut shuffle_on: bool) -> Result<(), fidl::Error> {
2764        self.client.send::<PlayerControlSetShuffleModeRequest>(
2765            (shuffle_on,),
2766            0x7451a349ddb543c,
2767            fidl::encoding::DynamicFlags::empty(),
2768        )
2769    }
2770
2771    /// Binds to the session's volume control for control and notifications. If this method is not
2772    /// supported as indicated by the absence of the `HAS_GAIN_CONTROL` flag in
2773    /// `PlayerCapabilities`, the channel handle passed as `volume_control_request` is closed
2774    /// by the service.
2775    pub fn r#bind_volume_control(
2776        &self,
2777        mut volume_control_request: fidl::endpoints::ServerEnd<
2778            fidl_fuchsia_media_audio::VolumeControlMarker,
2779        >,
2780    ) -> Result<(), fidl::Error> {
2781        self.client.send::<PlayerControlBindVolumeControlRequest>(
2782            (volume_control_request,),
2783            0x11d61e878cf808bc,
2784            fidl::encoding::DynamicFlags::empty(),
2785        )
2786    }
2787}
2788
2789#[cfg(target_os = "fuchsia")]
2790impl From<PlayerControlSynchronousProxy> for zx::Handle {
2791    fn from(value: PlayerControlSynchronousProxy) -> Self {
2792        value.into_channel().into()
2793    }
2794}
2795
2796#[cfg(target_os = "fuchsia")]
2797impl From<fidl::Channel> for PlayerControlSynchronousProxy {
2798    fn from(value: fidl::Channel) -> Self {
2799        Self::new(value)
2800    }
2801}
2802
2803#[derive(Debug, Clone)]
2804pub struct PlayerControlProxy {
2805    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2806}
2807
2808impl fidl::endpoints::Proxy for PlayerControlProxy {
2809    type Protocol = PlayerControlMarker;
2810
2811    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2812        Self::new(inner)
2813    }
2814
2815    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2816        self.client.into_channel().map_err(|client| Self { client })
2817    }
2818
2819    fn as_channel(&self) -> &::fidl::AsyncChannel {
2820        self.client.as_channel()
2821    }
2822}
2823
2824impl PlayerControlProxy {
2825    /// Create a new Proxy for fuchsia.media.sessions2/PlayerControl.
2826    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2827        let protocol_name = <PlayerControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2828        Self { client: fidl::client::Client::new(channel, protocol_name) }
2829    }
2830
2831    /// Get a Stream of events from the remote end of the protocol.
2832    ///
2833    /// # Panics
2834    ///
2835    /// Panics if the event stream was already taken.
2836    pub fn take_event_stream(&self) -> PlayerControlEventStream {
2837        PlayerControlEventStream { event_receiver: self.client.take_event_receiver() }
2838    }
2839
2840    /// Plays media. If this method is not supported as indicated by the absence of the `PLAY`
2841    /// flag in `PlayerCapabilities`, this method does nothing.
2842    pub fn r#play(&self) -> Result<(), fidl::Error> {
2843        PlayerControlProxyInterface::r#play(self)
2844    }
2845
2846    /// Pauses playback and retains position in media. If this method is not supported as indicated
2847    /// by the absence of the `PAUSE` flag in `PlayerCapabilities`, this method does nothing.
2848    pub fn r#pause(&self) -> Result<(), fidl::Error> {
2849        PlayerControlProxyInterface::r#pause(self)
2850    }
2851
2852    /// Stops playback. The session should close.
2853    pub fn r#stop(&self) -> Result<(), fidl::Error> {
2854        PlayerControlProxyInterface::r#stop(self)
2855    }
2856
2857    /// Seeks to a specific position in media. Implementations are free to
2858    /// enter an error state if the position is out of bounds. `position`
2859    /// is an offset from the beginning of the media. If this method is not supported as indicated
2860    /// by the absence of the `SEEK` flag in `PlayerCapabilities`, this method does nothing.
2861    pub fn r#seek(&self, mut position: i64) -> Result<(), fidl::Error> {
2862        PlayerControlProxyInterface::r#seek(self, position)
2863    }
2864
2865    /// Skips forward in media by the player's default skip amount. If this method is not supported
2866    /// as indicated by the absence of the `SKIP_FORWARD` flag in `PlayerCapabilities`, this method
2867    /// does nothing.
2868    pub fn r#skip_forward(&self) -> Result<(), fidl::Error> {
2869        PlayerControlProxyInterface::r#skip_forward(self)
2870    }
2871
2872    /// Skips in reverse in media by the player's default skip amount. If this method is not
2873    /// supported as indicated by the absence of the `SKIP_REVERSE` flag in `PlayerCapabilities`,
2874    /// this method does nothing.
2875    pub fn r#skip_reverse(&self) -> Result<(), fidl::Error> {
2876        PlayerControlProxyInterface::r#skip_reverse(self)
2877    }
2878
2879    /// Changes media to the next item (e.g. next song in playlist). If this method is not
2880    /// supported as indicated by the absence of the `CHANGE_TO_NEXT_ITEM` flag in
2881    /// `PlayerCapabilities`, this method does nothing.
2882    pub fn r#next_item(&self) -> Result<(), fidl::Error> {
2883        PlayerControlProxyInterface::r#next_item(self)
2884    }
2885
2886    /// Changes media to the previous item. If this method is not
2887    /// supported as indicated by the absence of the `CHANGE_TO_PREV_ITEM` flag in
2888    /// `PlayerCapabilities`, this method does nothing.
2889    pub fn r#prev_item(&self) -> Result<(), fidl::Error> {
2890        PlayerControlProxyInterface::r#prev_item(self)
2891    }
2892
2893    /// Sets the playback rate of the media. This will not change the playback mode. If this method
2894    /// is not supported as indicated by the absense of the `SET_PLAYBACK_RATE` flag in
2895    /// `PlayerCapabilities`, this method does nothing.
2896    pub fn r#set_playback_rate(&self, mut playback_rate: f32) -> Result<(), fidl::Error> {
2897        PlayerControlProxyInterface::r#set_playback_rate(self, playback_rate)
2898    }
2899
2900    /// Sets repeat mode to any of the supported repeat modes.
2901    /// Whether this method takes effect depends on the `PlayerCapabilities` and `repeat_mode`:
2902    ///   * [`OFF`] is always supported.
2903    ///   * [`GROUP`] requires the `REPEAT_GROUPS` capability, and is otherwise ignored.
2904    ///   * [`SINGLE`] requires the `REPEAT_SINGLE` capability, and is otherwise ignored.
2905    pub fn r#set_repeat_mode(&self, mut repeat_mode: RepeatMode) -> Result<(), fidl::Error> {
2906        PlayerControlProxyInterface::r#set_repeat_mode(self, repeat_mode)
2907    }
2908
2909    /// Sets shuffle mode. If this method is not supported as indicated by the absence of the
2910    /// `SHUFFLE` flag in `PlayerCapabilities`, this method does nothing.
2911    pub fn r#set_shuffle_mode(&self, mut shuffle_on: bool) -> Result<(), fidl::Error> {
2912        PlayerControlProxyInterface::r#set_shuffle_mode(self, shuffle_on)
2913    }
2914
2915    /// Binds to the session's volume control for control and notifications. If this method is not
2916    /// supported as indicated by the absence of the `HAS_GAIN_CONTROL` flag in
2917    /// `PlayerCapabilities`, the channel handle passed as `volume_control_request` is closed
2918    /// by the service.
2919    pub fn r#bind_volume_control(
2920        &self,
2921        mut volume_control_request: fidl::endpoints::ServerEnd<
2922            fidl_fuchsia_media_audio::VolumeControlMarker,
2923        >,
2924    ) -> Result<(), fidl::Error> {
2925        PlayerControlProxyInterface::r#bind_volume_control(self, volume_control_request)
2926    }
2927}
2928
2929impl PlayerControlProxyInterface for PlayerControlProxy {
2930    fn r#play(&self) -> Result<(), fidl::Error> {
2931        self.client.send::<fidl::encoding::EmptyPayload>(
2932            (),
2933            0x164120d5bdb26f8e,
2934            fidl::encoding::DynamicFlags::empty(),
2935        )
2936    }
2937
2938    fn r#pause(&self) -> Result<(), fidl::Error> {
2939        self.client.send::<fidl::encoding::EmptyPayload>(
2940            (),
2941            0x1536d16f202ece1,
2942            fidl::encoding::DynamicFlags::empty(),
2943        )
2944    }
2945
2946    fn r#stop(&self) -> Result<(), fidl::Error> {
2947        self.client.send::<fidl::encoding::EmptyPayload>(
2948            (),
2949            0x1946e5fc6c2362ae,
2950            fidl::encoding::DynamicFlags::empty(),
2951        )
2952    }
2953
2954    fn r#seek(&self, mut position: i64) -> Result<(), fidl::Error> {
2955        self.client.send::<PlayerControlSeekRequest>(
2956            (position,),
2957            0x4e7237d293e22125,
2958            fidl::encoding::DynamicFlags::empty(),
2959        )
2960    }
2961
2962    fn r#skip_forward(&self) -> Result<(), fidl::Error> {
2963        self.client.send::<fidl::encoding::EmptyPayload>(
2964            (),
2965            0x6ee04477076dac1b,
2966            fidl::encoding::DynamicFlags::empty(),
2967        )
2968    }
2969
2970    fn r#skip_reverse(&self) -> Result<(), fidl::Error> {
2971        self.client.send::<fidl::encoding::EmptyPayload>(
2972            (),
2973            0xa4e05644ce33a28,
2974            fidl::encoding::DynamicFlags::empty(),
2975        )
2976    }
2977
2978    fn r#next_item(&self) -> Result<(), fidl::Error> {
2979        self.client.send::<fidl::encoding::EmptyPayload>(
2980            (),
2981            0x73307b32e35ff260,
2982            fidl::encoding::DynamicFlags::empty(),
2983        )
2984    }
2985
2986    fn r#prev_item(&self) -> Result<(), fidl::Error> {
2987        self.client.send::<fidl::encoding::EmptyPayload>(
2988            (),
2989            0x680444f03a759a3c,
2990            fidl::encoding::DynamicFlags::empty(),
2991        )
2992    }
2993
2994    fn r#set_playback_rate(&self, mut playback_rate: f32) -> Result<(), fidl::Error> {
2995        self.client.send::<PlayerControlSetPlaybackRateRequest>(
2996            (playback_rate,),
2997            0x3831b8b161e1bccf,
2998            fidl::encoding::DynamicFlags::empty(),
2999        )
3000    }
3001
3002    fn r#set_repeat_mode(&self, mut repeat_mode: RepeatMode) -> Result<(), fidl::Error> {
3003        self.client.send::<PlayerControlSetRepeatModeRequest>(
3004            (repeat_mode,),
3005            0x21b9b1b17b7f01c2,
3006            fidl::encoding::DynamicFlags::empty(),
3007        )
3008    }
3009
3010    fn r#set_shuffle_mode(&self, mut shuffle_on: bool) -> Result<(), fidl::Error> {
3011        self.client.send::<PlayerControlSetShuffleModeRequest>(
3012            (shuffle_on,),
3013            0x7451a349ddb543c,
3014            fidl::encoding::DynamicFlags::empty(),
3015        )
3016    }
3017
3018    fn r#bind_volume_control(
3019        &self,
3020        mut volume_control_request: fidl::endpoints::ServerEnd<
3021            fidl_fuchsia_media_audio::VolumeControlMarker,
3022        >,
3023    ) -> Result<(), fidl::Error> {
3024        self.client.send::<PlayerControlBindVolumeControlRequest>(
3025            (volume_control_request,),
3026            0x11d61e878cf808bc,
3027            fidl::encoding::DynamicFlags::empty(),
3028        )
3029    }
3030}
3031
3032pub struct PlayerControlEventStream {
3033    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3034}
3035
3036impl std::marker::Unpin for PlayerControlEventStream {}
3037
3038impl futures::stream::FusedStream for PlayerControlEventStream {
3039    fn is_terminated(&self) -> bool {
3040        self.event_receiver.is_terminated()
3041    }
3042}
3043
3044impl futures::Stream for PlayerControlEventStream {
3045    type Item = Result<PlayerControlEvent, fidl::Error>;
3046
3047    fn poll_next(
3048        mut self: std::pin::Pin<&mut Self>,
3049        cx: &mut std::task::Context<'_>,
3050    ) -> std::task::Poll<Option<Self::Item>> {
3051        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3052            &mut self.event_receiver,
3053            cx
3054        )?) {
3055            Some(buf) => std::task::Poll::Ready(Some(PlayerControlEvent::decode(buf))),
3056            None => std::task::Poll::Ready(None),
3057        }
3058    }
3059}
3060
3061#[derive(Debug)]
3062pub enum PlayerControlEvent {}
3063
3064impl PlayerControlEvent {
3065    /// Decodes a message buffer as a [`PlayerControlEvent`].
3066    fn decode(
3067        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3068    ) -> Result<PlayerControlEvent, fidl::Error> {
3069        let (bytes, _handles) = buf.split_mut();
3070        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3071        debug_assert_eq!(tx_header.tx_id, 0);
3072        match tx_header.ordinal {
3073            _ => Err(fidl::Error::UnknownOrdinal {
3074                ordinal: tx_header.ordinal,
3075                protocol_name: <PlayerControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3076            }),
3077        }
3078    }
3079}
3080
3081/// A Stream of incoming requests for fuchsia.media.sessions2/PlayerControl.
3082pub struct PlayerControlRequestStream {
3083    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3084    is_terminated: bool,
3085}
3086
3087impl std::marker::Unpin for PlayerControlRequestStream {}
3088
3089impl futures::stream::FusedStream for PlayerControlRequestStream {
3090    fn is_terminated(&self) -> bool {
3091        self.is_terminated
3092    }
3093}
3094
3095impl fidl::endpoints::RequestStream for PlayerControlRequestStream {
3096    type Protocol = PlayerControlMarker;
3097    type ControlHandle = PlayerControlControlHandle;
3098
3099    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3100        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3101    }
3102
3103    fn control_handle(&self) -> Self::ControlHandle {
3104        PlayerControlControlHandle { inner: self.inner.clone() }
3105    }
3106
3107    fn into_inner(
3108        self,
3109    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3110    {
3111        (self.inner, self.is_terminated)
3112    }
3113
3114    fn from_inner(
3115        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3116        is_terminated: bool,
3117    ) -> Self {
3118        Self { inner, is_terminated }
3119    }
3120}
3121
3122impl futures::Stream for PlayerControlRequestStream {
3123    type Item = Result<PlayerControlRequest, fidl::Error>;
3124
3125    fn poll_next(
3126        mut self: std::pin::Pin<&mut Self>,
3127        cx: &mut std::task::Context<'_>,
3128    ) -> std::task::Poll<Option<Self::Item>> {
3129        let this = &mut *self;
3130        if this.inner.check_shutdown(cx) {
3131            this.is_terminated = true;
3132            return std::task::Poll::Ready(None);
3133        }
3134        if this.is_terminated {
3135            panic!("polled PlayerControlRequestStream after completion");
3136        }
3137        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3138            |bytes, handles| {
3139                match this.inner.channel().read_etc(cx, bytes, handles) {
3140                    std::task::Poll::Ready(Ok(())) => {}
3141                    std::task::Poll::Pending => return std::task::Poll::Pending,
3142                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3143                        this.is_terminated = true;
3144                        return std::task::Poll::Ready(None);
3145                    }
3146                    std::task::Poll::Ready(Err(e)) => {
3147                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3148                            e.into(),
3149                        ))))
3150                    }
3151                }
3152
3153                // A message has been received from the channel
3154                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3155
3156                std::task::Poll::Ready(Some(match header.ordinal {
3157                    0x164120d5bdb26f8e => {
3158                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3159                        let mut req = fidl::new_empty!(
3160                            fidl::encoding::EmptyPayload,
3161                            fidl::encoding::DefaultFuchsiaResourceDialect
3162                        );
3163                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3164                        let control_handle =
3165                            PlayerControlControlHandle { inner: this.inner.clone() };
3166                        Ok(PlayerControlRequest::Play { control_handle })
3167                    }
3168                    0x1536d16f202ece1 => {
3169                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3170                        let mut req = fidl::new_empty!(
3171                            fidl::encoding::EmptyPayload,
3172                            fidl::encoding::DefaultFuchsiaResourceDialect
3173                        );
3174                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3175                        let control_handle =
3176                            PlayerControlControlHandle { inner: this.inner.clone() };
3177                        Ok(PlayerControlRequest::Pause { control_handle })
3178                    }
3179                    0x1946e5fc6c2362ae => {
3180                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3181                        let mut req = fidl::new_empty!(
3182                            fidl::encoding::EmptyPayload,
3183                            fidl::encoding::DefaultFuchsiaResourceDialect
3184                        );
3185                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3186                        let control_handle =
3187                            PlayerControlControlHandle { inner: this.inner.clone() };
3188                        Ok(PlayerControlRequest::Stop { control_handle })
3189                    }
3190                    0x4e7237d293e22125 => {
3191                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3192                        let mut req = fidl::new_empty!(
3193                            PlayerControlSeekRequest,
3194                            fidl::encoding::DefaultFuchsiaResourceDialect
3195                        );
3196                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerControlSeekRequest>(&header, _body_bytes, handles, &mut req)?;
3197                        let control_handle =
3198                            PlayerControlControlHandle { inner: this.inner.clone() };
3199                        Ok(PlayerControlRequest::Seek { position: req.position, control_handle })
3200                    }
3201                    0x6ee04477076dac1b => {
3202                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3203                        let mut req = fidl::new_empty!(
3204                            fidl::encoding::EmptyPayload,
3205                            fidl::encoding::DefaultFuchsiaResourceDialect
3206                        );
3207                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3208                        let control_handle =
3209                            PlayerControlControlHandle { inner: this.inner.clone() };
3210                        Ok(PlayerControlRequest::SkipForward { control_handle })
3211                    }
3212                    0xa4e05644ce33a28 => {
3213                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3214                        let mut req = fidl::new_empty!(
3215                            fidl::encoding::EmptyPayload,
3216                            fidl::encoding::DefaultFuchsiaResourceDialect
3217                        );
3218                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3219                        let control_handle =
3220                            PlayerControlControlHandle { inner: this.inner.clone() };
3221                        Ok(PlayerControlRequest::SkipReverse { control_handle })
3222                    }
3223                    0x73307b32e35ff260 => {
3224                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3225                        let mut req = fidl::new_empty!(
3226                            fidl::encoding::EmptyPayload,
3227                            fidl::encoding::DefaultFuchsiaResourceDialect
3228                        );
3229                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3230                        let control_handle =
3231                            PlayerControlControlHandle { inner: this.inner.clone() };
3232                        Ok(PlayerControlRequest::NextItem { control_handle })
3233                    }
3234                    0x680444f03a759a3c => {
3235                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3236                        let mut req = fidl::new_empty!(
3237                            fidl::encoding::EmptyPayload,
3238                            fidl::encoding::DefaultFuchsiaResourceDialect
3239                        );
3240                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3241                        let control_handle =
3242                            PlayerControlControlHandle { inner: this.inner.clone() };
3243                        Ok(PlayerControlRequest::PrevItem { control_handle })
3244                    }
3245                    0x3831b8b161e1bccf => {
3246                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3247                        let mut req = fidl::new_empty!(
3248                            PlayerControlSetPlaybackRateRequest,
3249                            fidl::encoding::DefaultFuchsiaResourceDialect
3250                        );
3251                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerControlSetPlaybackRateRequest>(&header, _body_bytes, handles, &mut req)?;
3252                        let control_handle =
3253                            PlayerControlControlHandle { inner: this.inner.clone() };
3254                        Ok(PlayerControlRequest::SetPlaybackRate {
3255                            playback_rate: req.playback_rate,
3256
3257                            control_handle,
3258                        })
3259                    }
3260                    0x21b9b1b17b7f01c2 => {
3261                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3262                        let mut req = fidl::new_empty!(
3263                            PlayerControlSetRepeatModeRequest,
3264                            fidl::encoding::DefaultFuchsiaResourceDialect
3265                        );
3266                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerControlSetRepeatModeRequest>(&header, _body_bytes, handles, &mut req)?;
3267                        let control_handle =
3268                            PlayerControlControlHandle { inner: this.inner.clone() };
3269                        Ok(PlayerControlRequest::SetRepeatMode {
3270                            repeat_mode: req.repeat_mode,
3271
3272                            control_handle,
3273                        })
3274                    }
3275                    0x7451a349ddb543c => {
3276                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3277                        let mut req = fidl::new_empty!(
3278                            PlayerControlSetShuffleModeRequest,
3279                            fidl::encoding::DefaultFuchsiaResourceDialect
3280                        );
3281                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerControlSetShuffleModeRequest>(&header, _body_bytes, handles, &mut req)?;
3282                        let control_handle =
3283                            PlayerControlControlHandle { inner: this.inner.clone() };
3284                        Ok(PlayerControlRequest::SetShuffleMode {
3285                            shuffle_on: req.shuffle_on,
3286
3287                            control_handle,
3288                        })
3289                    }
3290                    0x11d61e878cf808bc => {
3291                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3292                        let mut req = fidl::new_empty!(
3293                            PlayerControlBindVolumeControlRequest,
3294                            fidl::encoding::DefaultFuchsiaResourceDialect
3295                        );
3296                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerControlBindVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
3297                        let control_handle =
3298                            PlayerControlControlHandle { inner: this.inner.clone() };
3299                        Ok(PlayerControlRequest::BindVolumeControl {
3300                            volume_control_request: req.volume_control_request,
3301
3302                            control_handle,
3303                        })
3304                    }
3305                    _ => Err(fidl::Error::UnknownOrdinal {
3306                        ordinal: header.ordinal,
3307                        protocol_name:
3308                            <PlayerControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3309                    }),
3310                }))
3311            },
3312        )
3313    }
3314}
3315
3316/// Controls for a media player. `PlayerCapabilities` expresses which of the methods in this
3317/// protocol are supported by the player. Because capabilties are dynamic, and a client cannot
3318/// always know what capabilities will be supported when the method call reaches the service,
3319/// calling a method that is not supported is simply ignored. In general, clients should not
3320/// expect methods to work unless the player indicates sustained support.
3321#[derive(Debug)]
3322pub enum PlayerControlRequest {
3323    /// Plays media. If this method is not supported as indicated by the absence of the `PLAY`
3324    /// flag in `PlayerCapabilities`, this method does nothing.
3325    Play { control_handle: PlayerControlControlHandle },
3326    /// Pauses playback and retains position in media. If this method is not supported as indicated
3327    /// by the absence of the `PAUSE` flag in `PlayerCapabilities`, this method does nothing.
3328    Pause { control_handle: PlayerControlControlHandle },
3329    /// Stops playback. The session should close.
3330    Stop { control_handle: PlayerControlControlHandle },
3331    /// Seeks to a specific position in media. Implementations are free to
3332    /// enter an error state if the position is out of bounds. `position`
3333    /// is an offset from the beginning of the media. If this method is not supported as indicated
3334    /// by the absence of the `SEEK` flag in `PlayerCapabilities`, this method does nothing.
3335    Seek { position: i64, control_handle: PlayerControlControlHandle },
3336    /// Skips forward in media by the player's default skip amount. If this method is not supported
3337    /// as indicated by the absence of the `SKIP_FORWARD` flag in `PlayerCapabilities`, this method
3338    /// does nothing.
3339    SkipForward { control_handle: PlayerControlControlHandle },
3340    /// Skips in reverse in media by the player's default skip amount. If this method is not
3341    /// supported as indicated by the absence of the `SKIP_REVERSE` flag in `PlayerCapabilities`,
3342    /// this method does nothing.
3343    SkipReverse { control_handle: PlayerControlControlHandle },
3344    /// Changes media to the next item (e.g. next song in playlist). If this method is not
3345    /// supported as indicated by the absence of the `CHANGE_TO_NEXT_ITEM` flag in
3346    /// `PlayerCapabilities`, this method does nothing.
3347    NextItem { control_handle: PlayerControlControlHandle },
3348    /// Changes media to the previous item. If this method is not
3349    /// supported as indicated by the absence of the `CHANGE_TO_PREV_ITEM` flag in
3350    /// `PlayerCapabilities`, this method does nothing.
3351    PrevItem { control_handle: PlayerControlControlHandle },
3352    /// Sets the playback rate of the media. This will not change the playback mode. If this method
3353    /// is not supported as indicated by the absense of the `SET_PLAYBACK_RATE` flag in
3354    /// `PlayerCapabilities`, this method does nothing.
3355    SetPlaybackRate { playback_rate: f32, control_handle: PlayerControlControlHandle },
3356    /// Sets repeat mode to any of the supported repeat modes.
3357    /// Whether this method takes effect depends on the `PlayerCapabilities` and `repeat_mode`:
3358    ///   * [`OFF`] is always supported.
3359    ///   * [`GROUP`] requires the `REPEAT_GROUPS` capability, and is otherwise ignored.
3360    ///   * [`SINGLE`] requires the `REPEAT_SINGLE` capability, and is otherwise ignored.
3361    SetRepeatMode { repeat_mode: RepeatMode, control_handle: PlayerControlControlHandle },
3362    /// Sets shuffle mode. If this method is not supported as indicated by the absence of the
3363    /// `SHUFFLE` flag in `PlayerCapabilities`, this method does nothing.
3364    SetShuffleMode { shuffle_on: bool, control_handle: PlayerControlControlHandle },
3365    /// Binds to the session's volume control for control and notifications. If this method is not
3366    /// supported as indicated by the absence of the `HAS_GAIN_CONTROL` flag in
3367    /// `PlayerCapabilities`, the channel handle passed as `volume_control_request` is closed
3368    /// by the service.
3369    BindVolumeControl {
3370        volume_control_request:
3371            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
3372        control_handle: PlayerControlControlHandle,
3373    },
3374}
3375
3376impl PlayerControlRequest {
3377    #[allow(irrefutable_let_patterns)]
3378    pub fn into_play(self) -> Option<(PlayerControlControlHandle)> {
3379        if let PlayerControlRequest::Play { control_handle } = self {
3380            Some((control_handle))
3381        } else {
3382            None
3383        }
3384    }
3385
3386    #[allow(irrefutable_let_patterns)]
3387    pub fn into_pause(self) -> Option<(PlayerControlControlHandle)> {
3388        if let PlayerControlRequest::Pause { control_handle } = self {
3389            Some((control_handle))
3390        } else {
3391            None
3392        }
3393    }
3394
3395    #[allow(irrefutable_let_patterns)]
3396    pub fn into_stop(self) -> Option<(PlayerControlControlHandle)> {
3397        if let PlayerControlRequest::Stop { control_handle } = self {
3398            Some((control_handle))
3399        } else {
3400            None
3401        }
3402    }
3403
3404    #[allow(irrefutable_let_patterns)]
3405    pub fn into_seek(self) -> Option<(i64, PlayerControlControlHandle)> {
3406        if let PlayerControlRequest::Seek { position, control_handle } = self {
3407            Some((position, control_handle))
3408        } else {
3409            None
3410        }
3411    }
3412
3413    #[allow(irrefutable_let_patterns)]
3414    pub fn into_skip_forward(self) -> Option<(PlayerControlControlHandle)> {
3415        if let PlayerControlRequest::SkipForward { control_handle } = self {
3416            Some((control_handle))
3417        } else {
3418            None
3419        }
3420    }
3421
3422    #[allow(irrefutable_let_patterns)]
3423    pub fn into_skip_reverse(self) -> Option<(PlayerControlControlHandle)> {
3424        if let PlayerControlRequest::SkipReverse { control_handle } = self {
3425            Some((control_handle))
3426        } else {
3427            None
3428        }
3429    }
3430
3431    #[allow(irrefutable_let_patterns)]
3432    pub fn into_next_item(self) -> Option<(PlayerControlControlHandle)> {
3433        if let PlayerControlRequest::NextItem { control_handle } = self {
3434            Some((control_handle))
3435        } else {
3436            None
3437        }
3438    }
3439
3440    #[allow(irrefutable_let_patterns)]
3441    pub fn into_prev_item(self) -> Option<(PlayerControlControlHandle)> {
3442        if let PlayerControlRequest::PrevItem { control_handle } = self {
3443            Some((control_handle))
3444        } else {
3445            None
3446        }
3447    }
3448
3449    #[allow(irrefutable_let_patterns)]
3450    pub fn into_set_playback_rate(self) -> Option<(f32, PlayerControlControlHandle)> {
3451        if let PlayerControlRequest::SetPlaybackRate { playback_rate, control_handle } = self {
3452            Some((playback_rate, control_handle))
3453        } else {
3454            None
3455        }
3456    }
3457
3458    #[allow(irrefutable_let_patterns)]
3459    pub fn into_set_repeat_mode(self) -> Option<(RepeatMode, PlayerControlControlHandle)> {
3460        if let PlayerControlRequest::SetRepeatMode { repeat_mode, control_handle } = self {
3461            Some((repeat_mode, control_handle))
3462        } else {
3463            None
3464        }
3465    }
3466
3467    #[allow(irrefutable_let_patterns)]
3468    pub fn into_set_shuffle_mode(self) -> Option<(bool, PlayerControlControlHandle)> {
3469        if let PlayerControlRequest::SetShuffleMode { shuffle_on, control_handle } = self {
3470            Some((shuffle_on, control_handle))
3471        } else {
3472            None
3473        }
3474    }
3475
3476    #[allow(irrefutable_let_patterns)]
3477    pub fn into_bind_volume_control(
3478        self,
3479    ) -> Option<(
3480        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
3481        PlayerControlControlHandle,
3482    )> {
3483        if let PlayerControlRequest::BindVolumeControl { volume_control_request, control_handle } =
3484            self
3485        {
3486            Some((volume_control_request, control_handle))
3487        } else {
3488            None
3489        }
3490    }
3491
3492    /// Name of the method defined in FIDL
3493    pub fn method_name(&self) -> &'static str {
3494        match *self {
3495            PlayerControlRequest::Play { .. } => "play",
3496            PlayerControlRequest::Pause { .. } => "pause",
3497            PlayerControlRequest::Stop { .. } => "stop",
3498            PlayerControlRequest::Seek { .. } => "seek",
3499            PlayerControlRequest::SkipForward { .. } => "skip_forward",
3500            PlayerControlRequest::SkipReverse { .. } => "skip_reverse",
3501            PlayerControlRequest::NextItem { .. } => "next_item",
3502            PlayerControlRequest::PrevItem { .. } => "prev_item",
3503            PlayerControlRequest::SetPlaybackRate { .. } => "set_playback_rate",
3504            PlayerControlRequest::SetRepeatMode { .. } => "set_repeat_mode",
3505            PlayerControlRequest::SetShuffleMode { .. } => "set_shuffle_mode",
3506            PlayerControlRequest::BindVolumeControl { .. } => "bind_volume_control",
3507        }
3508    }
3509}
3510
3511#[derive(Debug, Clone)]
3512pub struct PlayerControlControlHandle {
3513    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3514}
3515
3516impl fidl::endpoints::ControlHandle for PlayerControlControlHandle {
3517    fn shutdown(&self) {
3518        self.inner.shutdown()
3519    }
3520    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3521        self.inner.shutdown_with_epitaph(status)
3522    }
3523
3524    fn is_closed(&self) -> bool {
3525        self.inner.channel().is_closed()
3526    }
3527    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3528        self.inner.channel().on_closed()
3529    }
3530
3531    #[cfg(target_os = "fuchsia")]
3532    fn signal_peer(
3533        &self,
3534        clear_mask: zx::Signals,
3535        set_mask: zx::Signals,
3536    ) -> Result<(), zx_status::Status> {
3537        use fidl::Peered;
3538        self.inner.channel().signal_peer(clear_mask, set_mask)
3539    }
3540}
3541
3542impl PlayerControlControlHandle {}
3543
3544#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3545pub struct PublisherMarker;
3546
3547impl fidl::endpoints::ProtocolMarker for PublisherMarker {
3548    type Proxy = PublisherProxy;
3549    type RequestStream = PublisherRequestStream;
3550    #[cfg(target_os = "fuchsia")]
3551    type SynchronousProxy = PublisherSynchronousProxy;
3552
3553    const DEBUG_NAME: &'static str = "fuchsia.media.sessions2.Publisher";
3554}
3555impl fidl::endpoints::DiscoverableProtocolMarker for PublisherMarker {}
3556
3557pub trait PublisherProxyInterface: Send + Sync {
3558    type PublishResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
3559    fn r#publish(
3560        &self,
3561        player: fidl::endpoints::ClientEnd<PlayerMarker>,
3562        registration: &PlayerRegistration,
3563    ) -> Self::PublishResponseFut;
3564}
3565#[derive(Debug)]
3566#[cfg(target_os = "fuchsia")]
3567pub struct PublisherSynchronousProxy {
3568    client: fidl::client::sync::Client,
3569}
3570
3571#[cfg(target_os = "fuchsia")]
3572impl fidl::endpoints::SynchronousProxy for PublisherSynchronousProxy {
3573    type Proxy = PublisherProxy;
3574    type Protocol = PublisherMarker;
3575
3576    fn from_channel(inner: fidl::Channel) -> Self {
3577        Self::new(inner)
3578    }
3579
3580    fn into_channel(self) -> fidl::Channel {
3581        self.client.into_channel()
3582    }
3583
3584    fn as_channel(&self) -> &fidl::Channel {
3585        self.client.as_channel()
3586    }
3587}
3588
3589#[cfg(target_os = "fuchsia")]
3590impl PublisherSynchronousProxy {
3591    pub fn new(channel: fidl::Channel) -> Self {
3592        let protocol_name = <PublisherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3593        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3594    }
3595
3596    pub fn into_channel(self) -> fidl::Channel {
3597        self.client.into_channel()
3598    }
3599
3600    /// Waits until an event arrives and returns it. It is safe for other
3601    /// threads to make concurrent requests while waiting for an event.
3602    pub fn wait_for_event(
3603        &self,
3604        deadline: zx::MonotonicInstant,
3605    ) -> Result<PublisherEvent, fidl::Error> {
3606        PublisherEvent::decode(self.client.wait_for_event(deadline)?)
3607    }
3608
3609    pub fn r#publish(
3610        &self,
3611        mut player: fidl::endpoints::ClientEnd<PlayerMarker>,
3612        mut registration: &PlayerRegistration,
3613        ___deadline: zx::MonotonicInstant,
3614    ) -> Result<u64, fidl::Error> {
3615        let _response =
3616            self.client.send_query::<PublisherPublishRequest, PublisherPublishResponse>(
3617                (player, registration),
3618                0x2e4a501ede5a1ad3,
3619                fidl::encoding::DynamicFlags::empty(),
3620                ___deadline,
3621            )?;
3622        Ok(_response.session_id)
3623    }
3624}
3625
3626#[cfg(target_os = "fuchsia")]
3627impl From<PublisherSynchronousProxy> for zx::Handle {
3628    fn from(value: PublisherSynchronousProxy) -> Self {
3629        value.into_channel().into()
3630    }
3631}
3632
3633#[cfg(target_os = "fuchsia")]
3634impl From<fidl::Channel> for PublisherSynchronousProxy {
3635    fn from(value: fidl::Channel) -> Self {
3636        Self::new(value)
3637    }
3638}
3639
3640#[derive(Debug, Clone)]
3641pub struct PublisherProxy {
3642    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3643}
3644
3645impl fidl::endpoints::Proxy for PublisherProxy {
3646    type Protocol = PublisherMarker;
3647
3648    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3649        Self::new(inner)
3650    }
3651
3652    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3653        self.client.into_channel().map_err(|client| Self { client })
3654    }
3655
3656    fn as_channel(&self) -> &::fidl::AsyncChannel {
3657        self.client.as_channel()
3658    }
3659}
3660
3661impl PublisherProxy {
3662    /// Create a new Proxy for fuchsia.media.sessions2/Publisher.
3663    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3664        let protocol_name = <PublisherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3665        Self { client: fidl::client::Client::new(channel, protocol_name) }
3666    }
3667
3668    /// Get a Stream of events from the remote end of the protocol.
3669    ///
3670    /// # Panics
3671    ///
3672    /// Panics if the event stream was already taken.
3673    pub fn take_event_stream(&self) -> PublisherEventStream {
3674        PublisherEventStream { event_receiver: self.client.take_event_receiver() }
3675    }
3676
3677    pub fn r#publish(
3678        &self,
3679        mut player: fidl::endpoints::ClientEnd<PlayerMarker>,
3680        mut registration: &PlayerRegistration,
3681    ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
3682        PublisherProxyInterface::r#publish(self, player, registration)
3683    }
3684}
3685
3686impl PublisherProxyInterface for PublisherProxy {
3687    type PublishResponseFut =
3688        fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
3689    fn r#publish(
3690        &self,
3691        mut player: fidl::endpoints::ClientEnd<PlayerMarker>,
3692        mut registration: &PlayerRegistration,
3693    ) -> Self::PublishResponseFut {
3694        fn _decode(
3695            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3696        ) -> Result<u64, fidl::Error> {
3697            let _response = fidl::client::decode_transaction_body::<
3698                PublisherPublishResponse,
3699                fidl::encoding::DefaultFuchsiaResourceDialect,
3700                0x2e4a501ede5a1ad3,
3701            >(_buf?)?;
3702            Ok(_response.session_id)
3703        }
3704        self.client.send_query_and_decode::<PublisherPublishRequest, u64>(
3705            (player, registration),
3706            0x2e4a501ede5a1ad3,
3707            fidl::encoding::DynamicFlags::empty(),
3708            _decode,
3709        )
3710    }
3711}
3712
3713pub struct PublisherEventStream {
3714    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3715}
3716
3717impl std::marker::Unpin for PublisherEventStream {}
3718
3719impl futures::stream::FusedStream for PublisherEventStream {
3720    fn is_terminated(&self) -> bool {
3721        self.event_receiver.is_terminated()
3722    }
3723}
3724
3725impl futures::Stream for PublisherEventStream {
3726    type Item = Result<PublisherEvent, fidl::Error>;
3727
3728    fn poll_next(
3729        mut self: std::pin::Pin<&mut Self>,
3730        cx: &mut std::task::Context<'_>,
3731    ) -> std::task::Poll<Option<Self::Item>> {
3732        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3733            &mut self.event_receiver,
3734            cx
3735        )?) {
3736            Some(buf) => std::task::Poll::Ready(Some(PublisherEvent::decode(buf))),
3737            None => std::task::Poll::Ready(None),
3738        }
3739    }
3740}
3741
3742#[derive(Debug)]
3743pub enum PublisherEvent {}
3744
3745impl PublisherEvent {
3746    /// Decodes a message buffer as a [`PublisherEvent`].
3747    fn decode(
3748        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3749    ) -> Result<PublisherEvent, fidl::Error> {
3750        let (bytes, _handles) = buf.split_mut();
3751        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3752        debug_assert_eq!(tx_header.tx_id, 0);
3753        match tx_header.ordinal {
3754            _ => Err(fidl::Error::UnknownOrdinal {
3755                ordinal: tx_header.ordinal,
3756                protocol_name: <PublisherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3757            }),
3758        }
3759    }
3760}
3761
3762/// A Stream of incoming requests for fuchsia.media.sessions2/Publisher.
3763pub struct PublisherRequestStream {
3764    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3765    is_terminated: bool,
3766}
3767
3768impl std::marker::Unpin for PublisherRequestStream {}
3769
3770impl futures::stream::FusedStream for PublisherRequestStream {
3771    fn is_terminated(&self) -> bool {
3772        self.is_terminated
3773    }
3774}
3775
3776impl fidl::endpoints::RequestStream for PublisherRequestStream {
3777    type Protocol = PublisherMarker;
3778    type ControlHandle = PublisherControlHandle;
3779
3780    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3781        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3782    }
3783
3784    fn control_handle(&self) -> Self::ControlHandle {
3785        PublisherControlHandle { inner: self.inner.clone() }
3786    }
3787
3788    fn into_inner(
3789        self,
3790    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3791    {
3792        (self.inner, self.is_terminated)
3793    }
3794
3795    fn from_inner(
3796        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3797        is_terminated: bool,
3798    ) -> Self {
3799        Self { inner, is_terminated }
3800    }
3801}
3802
3803impl futures::Stream for PublisherRequestStream {
3804    type Item = Result<PublisherRequest, fidl::Error>;
3805
3806    fn poll_next(
3807        mut self: std::pin::Pin<&mut Self>,
3808        cx: &mut std::task::Context<'_>,
3809    ) -> std::task::Poll<Option<Self::Item>> {
3810        let this = &mut *self;
3811        if this.inner.check_shutdown(cx) {
3812            this.is_terminated = true;
3813            return std::task::Poll::Ready(None);
3814        }
3815        if this.is_terminated {
3816            panic!("polled PublisherRequestStream after completion");
3817        }
3818        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3819            |bytes, handles| {
3820                match this.inner.channel().read_etc(cx, bytes, handles) {
3821                    std::task::Poll::Ready(Ok(())) => {}
3822                    std::task::Poll::Pending => return std::task::Poll::Pending,
3823                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3824                        this.is_terminated = true;
3825                        return std::task::Poll::Ready(None);
3826                    }
3827                    std::task::Poll::Ready(Err(e)) => {
3828                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3829                            e.into(),
3830                        ))))
3831                    }
3832                }
3833
3834                // A message has been received from the channel
3835                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3836
3837                std::task::Poll::Ready(Some(match header.ordinal {
3838                    0x2e4a501ede5a1ad3 => {
3839                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3840                        let mut req = fidl::new_empty!(
3841                            PublisherPublishRequest,
3842                            fidl::encoding::DefaultFuchsiaResourceDialect
3843                        );
3844                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PublisherPublishRequest>(&header, _body_bytes, handles, &mut req)?;
3845                        let control_handle = PublisherControlHandle { inner: this.inner.clone() };
3846                        Ok(PublisherRequest::Publish {
3847                            player: req.player,
3848                            registration: req.registration,
3849
3850                            responder: PublisherPublishResponder {
3851                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3852                                tx_id: header.tx_id,
3853                            },
3854                        })
3855                    }
3856                    _ => Err(fidl::Error::UnknownOrdinal {
3857                        ordinal: header.ordinal,
3858                        protocol_name:
3859                            <PublisherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3860                    }),
3861                }))
3862            },
3863        )
3864    }
3865}
3866
3867/// `Publisher` publishes media players so they may be discovered and
3868/// controlled by clients who have permission to do so.
3869#[derive(Debug)]
3870pub enum PublisherRequest {
3871    Publish {
3872        player: fidl::endpoints::ClientEnd<PlayerMarker>,
3873        registration: PlayerRegistration,
3874        responder: PublisherPublishResponder,
3875    },
3876}
3877
3878impl PublisherRequest {
3879    #[allow(irrefutable_let_patterns)]
3880    pub fn into_publish(
3881        self,
3882    ) -> Option<(
3883        fidl::endpoints::ClientEnd<PlayerMarker>,
3884        PlayerRegistration,
3885        PublisherPublishResponder,
3886    )> {
3887        if let PublisherRequest::Publish { player, registration, responder } = self {
3888            Some((player, registration, responder))
3889        } else {
3890            None
3891        }
3892    }
3893
3894    /// Name of the method defined in FIDL
3895    pub fn method_name(&self) -> &'static str {
3896        match *self {
3897            PublisherRequest::Publish { .. } => "publish",
3898        }
3899    }
3900}
3901
3902#[derive(Debug, Clone)]
3903pub struct PublisherControlHandle {
3904    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3905}
3906
3907impl fidl::endpoints::ControlHandle for PublisherControlHandle {
3908    fn shutdown(&self) {
3909        self.inner.shutdown()
3910    }
3911    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3912        self.inner.shutdown_with_epitaph(status)
3913    }
3914
3915    fn is_closed(&self) -> bool {
3916        self.inner.channel().is_closed()
3917    }
3918    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3919        self.inner.channel().on_closed()
3920    }
3921
3922    #[cfg(target_os = "fuchsia")]
3923    fn signal_peer(
3924        &self,
3925        clear_mask: zx::Signals,
3926        set_mask: zx::Signals,
3927    ) -> Result<(), zx_status::Status> {
3928        use fidl::Peered;
3929        self.inner.channel().signal_peer(clear_mask, set_mask)
3930    }
3931}
3932
3933impl PublisherControlHandle {}
3934
3935#[must_use = "FIDL methods require a response to be sent"]
3936#[derive(Debug)]
3937pub struct PublisherPublishResponder {
3938    control_handle: std::mem::ManuallyDrop<PublisherControlHandle>,
3939    tx_id: u32,
3940}
3941
3942/// Set the the channel to be shutdown (see [`PublisherControlHandle::shutdown`])
3943/// if the responder is dropped without sending a response, so that the client
3944/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3945impl std::ops::Drop for PublisherPublishResponder {
3946    fn drop(&mut self) {
3947        self.control_handle.shutdown();
3948        // Safety: drops once, never accessed again
3949        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3950    }
3951}
3952
3953impl fidl::endpoints::Responder for PublisherPublishResponder {
3954    type ControlHandle = PublisherControlHandle;
3955
3956    fn control_handle(&self) -> &PublisherControlHandle {
3957        &self.control_handle
3958    }
3959
3960    fn drop_without_shutdown(mut self) {
3961        // Safety: drops once, never accessed again due to mem::forget
3962        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3963        // Prevent Drop from running (which would shut down the channel)
3964        std::mem::forget(self);
3965    }
3966}
3967
3968impl PublisherPublishResponder {
3969    /// Sends a response to the FIDL transaction.
3970    ///
3971    /// Sets the channel to shutdown if an error occurs.
3972    pub fn send(self, mut session_id: u64) -> Result<(), fidl::Error> {
3973        let _result = self.send_raw(session_id);
3974        if _result.is_err() {
3975            self.control_handle.shutdown();
3976        }
3977        self.drop_without_shutdown();
3978        _result
3979    }
3980
3981    /// Similar to "send" but does not shutdown the channel if an error occurs.
3982    pub fn send_no_shutdown_on_err(self, mut session_id: u64) -> Result<(), fidl::Error> {
3983        let _result = self.send_raw(session_id);
3984        self.drop_without_shutdown();
3985        _result
3986    }
3987
3988    fn send_raw(&self, mut session_id: u64) -> Result<(), fidl::Error> {
3989        self.control_handle.inner.send::<PublisherPublishResponse>(
3990            (session_id,),
3991            self.tx_id,
3992            0x2e4a501ede5a1ad3,
3993            fidl::encoding::DynamicFlags::empty(),
3994        )
3995    }
3996}
3997
3998#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3999pub struct SessionControlMarker;
4000
4001impl fidl::endpoints::ProtocolMarker for SessionControlMarker {
4002    type Proxy = SessionControlProxy;
4003    type RequestStream = SessionControlRequestStream;
4004    #[cfg(target_os = "fuchsia")]
4005    type SynchronousProxy = SessionControlSynchronousProxy;
4006
4007    const DEBUG_NAME: &'static str = "(anonymous) SessionControl";
4008}
4009
4010pub trait SessionControlProxyInterface: Send + Sync {
4011    fn r#play(&self) -> Result<(), fidl::Error>;
4012    fn r#pause(&self) -> Result<(), fidl::Error>;
4013    fn r#stop(&self) -> Result<(), fidl::Error>;
4014    fn r#seek(&self, position: i64) -> Result<(), fidl::Error>;
4015    fn r#skip_forward(&self) -> Result<(), fidl::Error>;
4016    fn r#skip_reverse(&self) -> Result<(), fidl::Error>;
4017    fn r#next_item(&self) -> Result<(), fidl::Error>;
4018    fn r#prev_item(&self) -> Result<(), fidl::Error>;
4019    fn r#set_playback_rate(&self, playback_rate: f32) -> Result<(), fidl::Error>;
4020    fn r#set_repeat_mode(&self, repeat_mode: RepeatMode) -> Result<(), fidl::Error>;
4021    fn r#set_shuffle_mode(&self, shuffle_on: bool) -> Result<(), fidl::Error>;
4022    fn r#bind_volume_control(
4023        &self,
4024        volume_control_request: fidl::endpoints::ServerEnd<
4025            fidl_fuchsia_media_audio::VolumeControlMarker,
4026        >,
4027    ) -> Result<(), fidl::Error>;
4028    type WatchStatusResponseFut: std::future::Future<Output = Result<SessionInfoDelta, fidl::Error>>
4029        + Send;
4030    fn r#watch_status(&self) -> Self::WatchStatusResponseFut;
4031}
4032#[derive(Debug)]
4033#[cfg(target_os = "fuchsia")]
4034pub struct SessionControlSynchronousProxy {
4035    client: fidl::client::sync::Client,
4036}
4037
4038#[cfg(target_os = "fuchsia")]
4039impl fidl::endpoints::SynchronousProxy for SessionControlSynchronousProxy {
4040    type Proxy = SessionControlProxy;
4041    type Protocol = SessionControlMarker;
4042
4043    fn from_channel(inner: fidl::Channel) -> Self {
4044        Self::new(inner)
4045    }
4046
4047    fn into_channel(self) -> fidl::Channel {
4048        self.client.into_channel()
4049    }
4050
4051    fn as_channel(&self) -> &fidl::Channel {
4052        self.client.as_channel()
4053    }
4054}
4055
4056#[cfg(target_os = "fuchsia")]
4057impl SessionControlSynchronousProxy {
4058    pub fn new(channel: fidl::Channel) -> Self {
4059        let protocol_name = <SessionControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4060        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4061    }
4062
4063    pub fn into_channel(self) -> fidl::Channel {
4064        self.client.into_channel()
4065    }
4066
4067    /// Waits until an event arrives and returns it. It is safe for other
4068    /// threads to make concurrent requests while waiting for an event.
4069    pub fn wait_for_event(
4070        &self,
4071        deadline: zx::MonotonicInstant,
4072    ) -> Result<SessionControlEvent, fidl::Error> {
4073        SessionControlEvent::decode(self.client.wait_for_event(deadline)?)
4074    }
4075
4076    /// Plays media.
4077    pub fn r#play(&self) -> Result<(), fidl::Error> {
4078        self.client.send::<fidl::encoding::EmptyPayload>(
4079            (),
4080            0x43c91c558f7b2946,
4081            fidl::encoding::DynamicFlags::empty(),
4082        )
4083    }
4084
4085    /// Pauses playback and retains position in media
4086    pub fn r#pause(&self) -> Result<(), fidl::Error> {
4087        self.client.send::<fidl::encoding::EmptyPayload>(
4088            (),
4089            0x4e2d75c91ff7d22d,
4090            fidl::encoding::DynamicFlags::empty(),
4091        )
4092    }
4093
4094    /// Stops playback. The session should close.
4095    pub fn r#stop(&self) -> Result<(), fidl::Error> {
4096        self.client.send::<fidl::encoding::EmptyPayload>(
4097            (),
4098            0x53da6661beb2e817,
4099            fidl::encoding::DynamicFlags::empty(),
4100        )
4101    }
4102
4103    /// Seeks to a specific position in media. Implementations are free to
4104    /// enter an error state if the position is out of bounds. `position`
4105    /// is an offset from the beginning of the media.
4106    pub fn r#seek(&self, mut position: i64) -> Result<(), fidl::Error> {
4107        self.client.send::<SessionControlSeekRequest>(
4108            (position,),
4109            0x380280556aba53d4,
4110            fidl::encoding::DynamicFlags::empty(),
4111        )
4112    }
4113
4114    /// Skips forward in media by the player's default skip amount.
4115    pub fn r#skip_forward(&self) -> Result<(), fidl::Error> {
4116        self.client.send::<fidl::encoding::EmptyPayload>(
4117            (),
4118            0x3674bb00f0f12079,
4119            fidl::encoding::DynamicFlags::empty(),
4120        )
4121    }
4122
4123    /// Skips in reverse in media by the player's default skip amount.
4124    pub fn r#skip_reverse(&self) -> Result<(), fidl::Error> {
4125        self.client.send::<fidl::encoding::EmptyPayload>(
4126            (),
4127            0x5edc786c1a6b087c,
4128            fidl::encoding::DynamicFlags::empty(),
4129        )
4130    }
4131
4132    /// Changes media to the next item (e.g. next song in playlist).
4133    pub fn r#next_item(&self) -> Result<(), fidl::Error> {
4134        self.client.send::<fidl::encoding::EmptyPayload>(
4135            (),
4136            0x13cab0e8bc316138,
4137            fidl::encoding::DynamicFlags::empty(),
4138        )
4139    }
4140
4141    /// Changes media to the previous item.
4142    pub fn r#prev_item(&self) -> Result<(), fidl::Error> {
4143        self.client.send::<fidl::encoding::EmptyPayload>(
4144            (),
4145            0x7f7150e8bd6082cc,
4146            fidl::encoding::DynamicFlags::empty(),
4147        )
4148    }
4149
4150    /// Sets the playback rate of the media. This will not change the
4151    /// playback mode.
4152    pub fn r#set_playback_rate(&self, mut playback_rate: f32) -> Result<(), fidl::Error> {
4153        self.client.send::<SessionControlSetPlaybackRateRequest>(
4154            (playback_rate,),
4155            0x3e382e2b70c5121d,
4156            fidl::encoding::DynamicFlags::empty(),
4157        )
4158    }
4159
4160    /// Sets repeat mode to any of the supported repeat modes.
4161    pub fn r#set_repeat_mode(&self, mut repeat_mode: RepeatMode) -> Result<(), fidl::Error> {
4162        self.client.send::<SessionControlSetRepeatModeRequest>(
4163            (repeat_mode,),
4164            0x29381bedf7f29e5,
4165            fidl::encoding::DynamicFlags::empty(),
4166        )
4167    }
4168
4169    /// Sets shuffle mode.
4170    pub fn r#set_shuffle_mode(&self, mut shuffle_on: bool) -> Result<(), fidl::Error> {
4171        self.client.send::<SessionControlSetShuffleModeRequest>(
4172            (shuffle_on,),
4173            0x34d8d4c0f35e89e,
4174            fidl::encoding::DynamicFlags::empty(),
4175        )
4176    }
4177
4178    /// Binds to the session's volume control for control and notifications.
4179    pub fn r#bind_volume_control(
4180        &self,
4181        mut volume_control_request: fidl::endpoints::ServerEnd<
4182            fidl_fuchsia_media_audio::VolumeControlMarker,
4183        >,
4184    ) -> Result<(), fidl::Error> {
4185        self.client.send::<SessionControlBindVolumeControlRequest>(
4186            (volume_control_request,),
4187            0x1e3c091a08e88710,
4188            fidl::encoding::DynamicFlags::empty(),
4189        )
4190    }
4191
4192    /// Watches the session status. Leave a request hanging to receive a reply when
4193    /// the session status changes. The first request will be answered immediately with
4194    /// the current state.
4195    pub fn r#watch_status(
4196        &self,
4197        ___deadline: zx::MonotonicInstant,
4198    ) -> Result<SessionInfoDelta, fidl::Error> {
4199        let _response = self
4200            .client
4201            .send_query::<fidl::encoding::EmptyPayload, SessionControlWatchStatusResponse>(
4202                (),
4203                0x4ce5727251eb4b74,
4204                fidl::encoding::DynamicFlags::empty(),
4205                ___deadline,
4206            )?;
4207        Ok(_response.session_info_delta)
4208    }
4209}
4210
4211#[cfg(target_os = "fuchsia")]
4212impl From<SessionControlSynchronousProxy> for zx::Handle {
4213    fn from(value: SessionControlSynchronousProxy) -> Self {
4214        value.into_channel().into()
4215    }
4216}
4217
4218#[cfg(target_os = "fuchsia")]
4219impl From<fidl::Channel> for SessionControlSynchronousProxy {
4220    fn from(value: fidl::Channel) -> Self {
4221        Self::new(value)
4222    }
4223}
4224
4225#[derive(Debug, Clone)]
4226pub struct SessionControlProxy {
4227    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4228}
4229
4230impl fidl::endpoints::Proxy for SessionControlProxy {
4231    type Protocol = SessionControlMarker;
4232
4233    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4234        Self::new(inner)
4235    }
4236
4237    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4238        self.client.into_channel().map_err(|client| Self { client })
4239    }
4240
4241    fn as_channel(&self) -> &::fidl::AsyncChannel {
4242        self.client.as_channel()
4243    }
4244}
4245
4246impl SessionControlProxy {
4247    /// Create a new Proxy for fuchsia.media.sessions2/SessionControl.
4248    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4249        let protocol_name = <SessionControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4250        Self { client: fidl::client::Client::new(channel, protocol_name) }
4251    }
4252
4253    /// Get a Stream of events from the remote end of the protocol.
4254    ///
4255    /// # Panics
4256    ///
4257    /// Panics if the event stream was already taken.
4258    pub fn take_event_stream(&self) -> SessionControlEventStream {
4259        SessionControlEventStream { event_receiver: self.client.take_event_receiver() }
4260    }
4261
4262    /// Plays media.
4263    pub fn r#play(&self) -> Result<(), fidl::Error> {
4264        SessionControlProxyInterface::r#play(self)
4265    }
4266
4267    /// Pauses playback and retains position in media
4268    pub fn r#pause(&self) -> Result<(), fidl::Error> {
4269        SessionControlProxyInterface::r#pause(self)
4270    }
4271
4272    /// Stops playback. The session should close.
4273    pub fn r#stop(&self) -> Result<(), fidl::Error> {
4274        SessionControlProxyInterface::r#stop(self)
4275    }
4276
4277    /// Seeks to a specific position in media. Implementations are free to
4278    /// enter an error state if the position is out of bounds. `position`
4279    /// is an offset from the beginning of the media.
4280    pub fn r#seek(&self, mut position: i64) -> Result<(), fidl::Error> {
4281        SessionControlProxyInterface::r#seek(self, position)
4282    }
4283
4284    /// Skips forward in media by the player's default skip amount.
4285    pub fn r#skip_forward(&self) -> Result<(), fidl::Error> {
4286        SessionControlProxyInterface::r#skip_forward(self)
4287    }
4288
4289    /// Skips in reverse in media by the player's default skip amount.
4290    pub fn r#skip_reverse(&self) -> Result<(), fidl::Error> {
4291        SessionControlProxyInterface::r#skip_reverse(self)
4292    }
4293
4294    /// Changes media to the next item (e.g. next song in playlist).
4295    pub fn r#next_item(&self) -> Result<(), fidl::Error> {
4296        SessionControlProxyInterface::r#next_item(self)
4297    }
4298
4299    /// Changes media to the previous item.
4300    pub fn r#prev_item(&self) -> Result<(), fidl::Error> {
4301        SessionControlProxyInterface::r#prev_item(self)
4302    }
4303
4304    /// Sets the playback rate of the media. This will not change the
4305    /// playback mode.
4306    pub fn r#set_playback_rate(&self, mut playback_rate: f32) -> Result<(), fidl::Error> {
4307        SessionControlProxyInterface::r#set_playback_rate(self, playback_rate)
4308    }
4309
4310    /// Sets repeat mode to any of the supported repeat modes.
4311    pub fn r#set_repeat_mode(&self, mut repeat_mode: RepeatMode) -> Result<(), fidl::Error> {
4312        SessionControlProxyInterface::r#set_repeat_mode(self, repeat_mode)
4313    }
4314
4315    /// Sets shuffle mode.
4316    pub fn r#set_shuffle_mode(&self, mut shuffle_on: bool) -> Result<(), fidl::Error> {
4317        SessionControlProxyInterface::r#set_shuffle_mode(self, shuffle_on)
4318    }
4319
4320    /// Binds to the session's volume control for control and notifications.
4321    pub fn r#bind_volume_control(
4322        &self,
4323        mut volume_control_request: fidl::endpoints::ServerEnd<
4324            fidl_fuchsia_media_audio::VolumeControlMarker,
4325        >,
4326    ) -> Result<(), fidl::Error> {
4327        SessionControlProxyInterface::r#bind_volume_control(self, volume_control_request)
4328    }
4329
4330    /// Watches the session status. Leave a request hanging to receive a reply when
4331    /// the session status changes. The first request will be answered immediately with
4332    /// the current state.
4333    pub fn r#watch_status(
4334        &self,
4335    ) -> fidl::client::QueryResponseFut<
4336        SessionInfoDelta,
4337        fidl::encoding::DefaultFuchsiaResourceDialect,
4338    > {
4339        SessionControlProxyInterface::r#watch_status(self)
4340    }
4341}
4342
4343impl SessionControlProxyInterface for SessionControlProxy {
4344    fn r#play(&self) -> Result<(), fidl::Error> {
4345        self.client.send::<fidl::encoding::EmptyPayload>(
4346            (),
4347            0x43c91c558f7b2946,
4348            fidl::encoding::DynamicFlags::empty(),
4349        )
4350    }
4351
4352    fn r#pause(&self) -> Result<(), fidl::Error> {
4353        self.client.send::<fidl::encoding::EmptyPayload>(
4354            (),
4355            0x4e2d75c91ff7d22d,
4356            fidl::encoding::DynamicFlags::empty(),
4357        )
4358    }
4359
4360    fn r#stop(&self) -> Result<(), fidl::Error> {
4361        self.client.send::<fidl::encoding::EmptyPayload>(
4362            (),
4363            0x53da6661beb2e817,
4364            fidl::encoding::DynamicFlags::empty(),
4365        )
4366    }
4367
4368    fn r#seek(&self, mut position: i64) -> Result<(), fidl::Error> {
4369        self.client.send::<SessionControlSeekRequest>(
4370            (position,),
4371            0x380280556aba53d4,
4372            fidl::encoding::DynamicFlags::empty(),
4373        )
4374    }
4375
4376    fn r#skip_forward(&self) -> Result<(), fidl::Error> {
4377        self.client.send::<fidl::encoding::EmptyPayload>(
4378            (),
4379            0x3674bb00f0f12079,
4380            fidl::encoding::DynamicFlags::empty(),
4381        )
4382    }
4383
4384    fn r#skip_reverse(&self) -> Result<(), fidl::Error> {
4385        self.client.send::<fidl::encoding::EmptyPayload>(
4386            (),
4387            0x5edc786c1a6b087c,
4388            fidl::encoding::DynamicFlags::empty(),
4389        )
4390    }
4391
4392    fn r#next_item(&self) -> Result<(), fidl::Error> {
4393        self.client.send::<fidl::encoding::EmptyPayload>(
4394            (),
4395            0x13cab0e8bc316138,
4396            fidl::encoding::DynamicFlags::empty(),
4397        )
4398    }
4399
4400    fn r#prev_item(&self) -> Result<(), fidl::Error> {
4401        self.client.send::<fidl::encoding::EmptyPayload>(
4402            (),
4403            0x7f7150e8bd6082cc,
4404            fidl::encoding::DynamicFlags::empty(),
4405        )
4406    }
4407
4408    fn r#set_playback_rate(&self, mut playback_rate: f32) -> Result<(), fidl::Error> {
4409        self.client.send::<SessionControlSetPlaybackRateRequest>(
4410            (playback_rate,),
4411            0x3e382e2b70c5121d,
4412            fidl::encoding::DynamicFlags::empty(),
4413        )
4414    }
4415
4416    fn r#set_repeat_mode(&self, mut repeat_mode: RepeatMode) -> Result<(), fidl::Error> {
4417        self.client.send::<SessionControlSetRepeatModeRequest>(
4418            (repeat_mode,),
4419            0x29381bedf7f29e5,
4420            fidl::encoding::DynamicFlags::empty(),
4421        )
4422    }
4423
4424    fn r#set_shuffle_mode(&self, mut shuffle_on: bool) -> Result<(), fidl::Error> {
4425        self.client.send::<SessionControlSetShuffleModeRequest>(
4426            (shuffle_on,),
4427            0x34d8d4c0f35e89e,
4428            fidl::encoding::DynamicFlags::empty(),
4429        )
4430    }
4431
4432    fn r#bind_volume_control(
4433        &self,
4434        mut volume_control_request: fidl::endpoints::ServerEnd<
4435            fidl_fuchsia_media_audio::VolumeControlMarker,
4436        >,
4437    ) -> Result<(), fidl::Error> {
4438        self.client.send::<SessionControlBindVolumeControlRequest>(
4439            (volume_control_request,),
4440            0x1e3c091a08e88710,
4441            fidl::encoding::DynamicFlags::empty(),
4442        )
4443    }
4444
4445    type WatchStatusResponseFut = fidl::client::QueryResponseFut<
4446        SessionInfoDelta,
4447        fidl::encoding::DefaultFuchsiaResourceDialect,
4448    >;
4449    fn r#watch_status(&self) -> Self::WatchStatusResponseFut {
4450        fn _decode(
4451            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4452        ) -> Result<SessionInfoDelta, fidl::Error> {
4453            let _response = fidl::client::decode_transaction_body::<
4454                SessionControlWatchStatusResponse,
4455                fidl::encoding::DefaultFuchsiaResourceDialect,
4456                0x4ce5727251eb4b74,
4457            >(_buf?)?;
4458            Ok(_response.session_info_delta)
4459        }
4460        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, SessionInfoDelta>(
4461            (),
4462            0x4ce5727251eb4b74,
4463            fidl::encoding::DynamicFlags::empty(),
4464            _decode,
4465        )
4466    }
4467}
4468
4469pub struct SessionControlEventStream {
4470    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4471}
4472
4473impl std::marker::Unpin for SessionControlEventStream {}
4474
4475impl futures::stream::FusedStream for SessionControlEventStream {
4476    fn is_terminated(&self) -> bool {
4477        self.event_receiver.is_terminated()
4478    }
4479}
4480
4481impl futures::Stream for SessionControlEventStream {
4482    type Item = Result<SessionControlEvent, fidl::Error>;
4483
4484    fn poll_next(
4485        mut self: std::pin::Pin<&mut Self>,
4486        cx: &mut std::task::Context<'_>,
4487    ) -> std::task::Poll<Option<Self::Item>> {
4488        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4489            &mut self.event_receiver,
4490            cx
4491        )?) {
4492            Some(buf) => std::task::Poll::Ready(Some(SessionControlEvent::decode(buf))),
4493            None => std::task::Poll::Ready(None),
4494        }
4495    }
4496}
4497
4498#[derive(Debug)]
4499pub enum SessionControlEvent {}
4500
4501impl SessionControlEvent {
4502    /// Decodes a message buffer as a [`SessionControlEvent`].
4503    fn decode(
4504        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4505    ) -> Result<SessionControlEvent, fidl::Error> {
4506        let (bytes, _handles) = buf.split_mut();
4507        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4508        debug_assert_eq!(tx_header.tx_id, 0);
4509        match tx_header.ordinal {
4510            _ => Err(fidl::Error::UnknownOrdinal {
4511                ordinal: tx_header.ordinal,
4512                protocol_name:
4513                    <SessionControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4514            }),
4515        }
4516    }
4517}
4518
4519/// A Stream of incoming requests for fuchsia.media.sessions2/SessionControl.
4520pub struct SessionControlRequestStream {
4521    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4522    is_terminated: bool,
4523}
4524
4525impl std::marker::Unpin for SessionControlRequestStream {}
4526
4527impl futures::stream::FusedStream for SessionControlRequestStream {
4528    fn is_terminated(&self) -> bool {
4529        self.is_terminated
4530    }
4531}
4532
4533impl fidl::endpoints::RequestStream for SessionControlRequestStream {
4534    type Protocol = SessionControlMarker;
4535    type ControlHandle = SessionControlControlHandle;
4536
4537    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4538        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4539    }
4540
4541    fn control_handle(&self) -> Self::ControlHandle {
4542        SessionControlControlHandle { inner: self.inner.clone() }
4543    }
4544
4545    fn into_inner(
4546        self,
4547    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4548    {
4549        (self.inner, self.is_terminated)
4550    }
4551
4552    fn from_inner(
4553        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4554        is_terminated: bool,
4555    ) -> Self {
4556        Self { inner, is_terminated }
4557    }
4558}
4559
4560impl futures::Stream for SessionControlRequestStream {
4561    type Item = Result<SessionControlRequest, fidl::Error>;
4562
4563    fn poll_next(
4564        mut self: std::pin::Pin<&mut Self>,
4565        cx: &mut std::task::Context<'_>,
4566    ) -> std::task::Poll<Option<Self::Item>> {
4567        let this = &mut *self;
4568        if this.inner.check_shutdown(cx) {
4569            this.is_terminated = true;
4570            return std::task::Poll::Ready(None);
4571        }
4572        if this.is_terminated {
4573            panic!("polled SessionControlRequestStream after completion");
4574        }
4575        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4576            |bytes, handles| {
4577                match this.inner.channel().read_etc(cx, bytes, handles) {
4578                    std::task::Poll::Ready(Ok(())) => {}
4579                    std::task::Poll::Pending => return std::task::Poll::Pending,
4580                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4581                        this.is_terminated = true;
4582                        return std::task::Poll::Ready(None);
4583                    }
4584                    std::task::Poll::Ready(Err(e)) => {
4585                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4586                            e.into(),
4587                        ))))
4588                    }
4589                }
4590
4591                // A message has been received from the channel
4592                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4593
4594                std::task::Poll::Ready(Some(match header.ordinal {
4595                    0x43c91c558f7b2946 => {
4596                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4597                        let mut req = fidl::new_empty!(
4598                            fidl::encoding::EmptyPayload,
4599                            fidl::encoding::DefaultFuchsiaResourceDialect
4600                        );
4601                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4602                        let control_handle =
4603                            SessionControlControlHandle { inner: this.inner.clone() };
4604                        Ok(SessionControlRequest::Play { control_handle })
4605                    }
4606                    0x4e2d75c91ff7d22d => {
4607                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4608                        let mut req = fidl::new_empty!(
4609                            fidl::encoding::EmptyPayload,
4610                            fidl::encoding::DefaultFuchsiaResourceDialect
4611                        );
4612                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4613                        let control_handle =
4614                            SessionControlControlHandle { inner: this.inner.clone() };
4615                        Ok(SessionControlRequest::Pause { control_handle })
4616                    }
4617                    0x53da6661beb2e817 => {
4618                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4619                        let mut req = fidl::new_empty!(
4620                            fidl::encoding::EmptyPayload,
4621                            fidl::encoding::DefaultFuchsiaResourceDialect
4622                        );
4623                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4624                        let control_handle =
4625                            SessionControlControlHandle { inner: this.inner.clone() };
4626                        Ok(SessionControlRequest::Stop { control_handle })
4627                    }
4628                    0x380280556aba53d4 => {
4629                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4630                        let mut req = fidl::new_empty!(
4631                            SessionControlSeekRequest,
4632                            fidl::encoding::DefaultFuchsiaResourceDialect
4633                        );
4634                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionControlSeekRequest>(&header, _body_bytes, handles, &mut req)?;
4635                        let control_handle =
4636                            SessionControlControlHandle { inner: this.inner.clone() };
4637                        Ok(SessionControlRequest::Seek { position: req.position, control_handle })
4638                    }
4639                    0x3674bb00f0f12079 => {
4640                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4641                        let mut req = fidl::new_empty!(
4642                            fidl::encoding::EmptyPayload,
4643                            fidl::encoding::DefaultFuchsiaResourceDialect
4644                        );
4645                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4646                        let control_handle =
4647                            SessionControlControlHandle { inner: this.inner.clone() };
4648                        Ok(SessionControlRequest::SkipForward { control_handle })
4649                    }
4650                    0x5edc786c1a6b087c => {
4651                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4652                        let mut req = fidl::new_empty!(
4653                            fidl::encoding::EmptyPayload,
4654                            fidl::encoding::DefaultFuchsiaResourceDialect
4655                        );
4656                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4657                        let control_handle =
4658                            SessionControlControlHandle { inner: this.inner.clone() };
4659                        Ok(SessionControlRequest::SkipReverse { control_handle })
4660                    }
4661                    0x13cab0e8bc316138 => {
4662                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4663                        let mut req = fidl::new_empty!(
4664                            fidl::encoding::EmptyPayload,
4665                            fidl::encoding::DefaultFuchsiaResourceDialect
4666                        );
4667                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4668                        let control_handle =
4669                            SessionControlControlHandle { inner: this.inner.clone() };
4670                        Ok(SessionControlRequest::NextItem { control_handle })
4671                    }
4672                    0x7f7150e8bd6082cc => {
4673                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4674                        let mut req = fidl::new_empty!(
4675                            fidl::encoding::EmptyPayload,
4676                            fidl::encoding::DefaultFuchsiaResourceDialect
4677                        );
4678                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4679                        let control_handle =
4680                            SessionControlControlHandle { inner: this.inner.clone() };
4681                        Ok(SessionControlRequest::PrevItem { control_handle })
4682                    }
4683                    0x3e382e2b70c5121d => {
4684                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4685                        let mut req = fidl::new_empty!(
4686                            SessionControlSetPlaybackRateRequest,
4687                            fidl::encoding::DefaultFuchsiaResourceDialect
4688                        );
4689                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionControlSetPlaybackRateRequest>(&header, _body_bytes, handles, &mut req)?;
4690                        let control_handle =
4691                            SessionControlControlHandle { inner: this.inner.clone() };
4692                        Ok(SessionControlRequest::SetPlaybackRate {
4693                            playback_rate: req.playback_rate,
4694
4695                            control_handle,
4696                        })
4697                    }
4698                    0x29381bedf7f29e5 => {
4699                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4700                        let mut req = fidl::new_empty!(
4701                            SessionControlSetRepeatModeRequest,
4702                            fidl::encoding::DefaultFuchsiaResourceDialect
4703                        );
4704                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionControlSetRepeatModeRequest>(&header, _body_bytes, handles, &mut req)?;
4705                        let control_handle =
4706                            SessionControlControlHandle { inner: this.inner.clone() };
4707                        Ok(SessionControlRequest::SetRepeatMode {
4708                            repeat_mode: req.repeat_mode,
4709
4710                            control_handle,
4711                        })
4712                    }
4713                    0x34d8d4c0f35e89e => {
4714                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4715                        let mut req = fidl::new_empty!(
4716                            SessionControlSetShuffleModeRequest,
4717                            fidl::encoding::DefaultFuchsiaResourceDialect
4718                        );
4719                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionControlSetShuffleModeRequest>(&header, _body_bytes, handles, &mut req)?;
4720                        let control_handle =
4721                            SessionControlControlHandle { inner: this.inner.clone() };
4722                        Ok(SessionControlRequest::SetShuffleMode {
4723                            shuffle_on: req.shuffle_on,
4724
4725                            control_handle,
4726                        })
4727                    }
4728                    0x1e3c091a08e88710 => {
4729                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4730                        let mut req = fidl::new_empty!(
4731                            SessionControlBindVolumeControlRequest,
4732                            fidl::encoding::DefaultFuchsiaResourceDialect
4733                        );
4734                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionControlBindVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
4735                        let control_handle =
4736                            SessionControlControlHandle { inner: this.inner.clone() };
4737                        Ok(SessionControlRequest::BindVolumeControl {
4738                            volume_control_request: req.volume_control_request,
4739
4740                            control_handle,
4741                        })
4742                    }
4743                    0x4ce5727251eb4b74 => {
4744                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4745                        let mut req = fidl::new_empty!(
4746                            fidl::encoding::EmptyPayload,
4747                            fidl::encoding::DefaultFuchsiaResourceDialect
4748                        );
4749                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4750                        let control_handle =
4751                            SessionControlControlHandle { inner: this.inner.clone() };
4752                        Ok(SessionControlRequest::WatchStatus {
4753                            responder: SessionControlWatchStatusResponder {
4754                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4755                                tx_id: header.tx_id,
4756                            },
4757                        })
4758                    }
4759                    _ => Err(fidl::Error::UnknownOrdinal {
4760                        ordinal: header.ordinal,
4761                        protocol_name:
4762                            <SessionControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4763                    }),
4764                }))
4765            },
4766        )
4767    }
4768}
4769
4770/// Controls a media session and views its status.
4771///
4772/// The channel will close if the media session is stopped.
4773#[derive(Debug)]
4774pub enum SessionControlRequest {
4775    /// Plays media.
4776    Play { control_handle: SessionControlControlHandle },
4777    /// Pauses playback and retains position in media
4778    Pause { control_handle: SessionControlControlHandle },
4779    /// Stops playback. The session should close.
4780    Stop { control_handle: SessionControlControlHandle },
4781    /// Seeks to a specific position in media. Implementations are free to
4782    /// enter an error state if the position is out of bounds. `position`
4783    /// is an offset from the beginning of the media.
4784    Seek { position: i64, control_handle: SessionControlControlHandle },
4785    /// Skips forward in media by the player's default skip amount.
4786    SkipForward { control_handle: SessionControlControlHandle },
4787    /// Skips in reverse in media by the player's default skip amount.
4788    SkipReverse { control_handle: SessionControlControlHandle },
4789    /// Changes media to the next item (e.g. next song in playlist).
4790    NextItem { control_handle: SessionControlControlHandle },
4791    /// Changes media to the previous item.
4792    PrevItem { control_handle: SessionControlControlHandle },
4793    /// Sets the playback rate of the media. This will not change the
4794    /// playback mode.
4795    SetPlaybackRate { playback_rate: f32, control_handle: SessionControlControlHandle },
4796    /// Sets repeat mode to any of the supported repeat modes.
4797    SetRepeatMode { repeat_mode: RepeatMode, control_handle: SessionControlControlHandle },
4798    /// Sets shuffle mode.
4799    SetShuffleMode { shuffle_on: bool, control_handle: SessionControlControlHandle },
4800    /// Binds to the session's volume control for control and notifications.
4801    BindVolumeControl {
4802        volume_control_request:
4803            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4804        control_handle: SessionControlControlHandle,
4805    },
4806    /// Watches the session status. Leave a request hanging to receive a reply when
4807    /// the session status changes. The first request will be answered immediately with
4808    /// the current state.
4809    WatchStatus { responder: SessionControlWatchStatusResponder },
4810}
4811
4812impl SessionControlRequest {
4813    #[allow(irrefutable_let_patterns)]
4814    pub fn into_play(self) -> Option<(SessionControlControlHandle)> {
4815        if let SessionControlRequest::Play { control_handle } = self {
4816            Some((control_handle))
4817        } else {
4818            None
4819        }
4820    }
4821
4822    #[allow(irrefutable_let_patterns)]
4823    pub fn into_pause(self) -> Option<(SessionControlControlHandle)> {
4824        if let SessionControlRequest::Pause { control_handle } = self {
4825            Some((control_handle))
4826        } else {
4827            None
4828        }
4829    }
4830
4831    #[allow(irrefutable_let_patterns)]
4832    pub fn into_stop(self) -> Option<(SessionControlControlHandle)> {
4833        if let SessionControlRequest::Stop { control_handle } = self {
4834            Some((control_handle))
4835        } else {
4836            None
4837        }
4838    }
4839
4840    #[allow(irrefutable_let_patterns)]
4841    pub fn into_seek(self) -> Option<(i64, SessionControlControlHandle)> {
4842        if let SessionControlRequest::Seek { position, control_handle } = self {
4843            Some((position, control_handle))
4844        } else {
4845            None
4846        }
4847    }
4848
4849    #[allow(irrefutable_let_patterns)]
4850    pub fn into_skip_forward(self) -> Option<(SessionControlControlHandle)> {
4851        if let SessionControlRequest::SkipForward { control_handle } = self {
4852            Some((control_handle))
4853        } else {
4854            None
4855        }
4856    }
4857
4858    #[allow(irrefutable_let_patterns)]
4859    pub fn into_skip_reverse(self) -> Option<(SessionControlControlHandle)> {
4860        if let SessionControlRequest::SkipReverse { control_handle } = self {
4861            Some((control_handle))
4862        } else {
4863            None
4864        }
4865    }
4866
4867    #[allow(irrefutable_let_patterns)]
4868    pub fn into_next_item(self) -> Option<(SessionControlControlHandle)> {
4869        if let SessionControlRequest::NextItem { control_handle } = self {
4870            Some((control_handle))
4871        } else {
4872            None
4873        }
4874    }
4875
4876    #[allow(irrefutable_let_patterns)]
4877    pub fn into_prev_item(self) -> Option<(SessionControlControlHandle)> {
4878        if let SessionControlRequest::PrevItem { control_handle } = self {
4879            Some((control_handle))
4880        } else {
4881            None
4882        }
4883    }
4884
4885    #[allow(irrefutable_let_patterns)]
4886    pub fn into_set_playback_rate(self) -> Option<(f32, SessionControlControlHandle)> {
4887        if let SessionControlRequest::SetPlaybackRate { playback_rate, control_handle } = self {
4888            Some((playback_rate, control_handle))
4889        } else {
4890            None
4891        }
4892    }
4893
4894    #[allow(irrefutable_let_patterns)]
4895    pub fn into_set_repeat_mode(self) -> Option<(RepeatMode, SessionControlControlHandle)> {
4896        if let SessionControlRequest::SetRepeatMode { repeat_mode, control_handle } = self {
4897            Some((repeat_mode, control_handle))
4898        } else {
4899            None
4900        }
4901    }
4902
4903    #[allow(irrefutable_let_patterns)]
4904    pub fn into_set_shuffle_mode(self) -> Option<(bool, SessionControlControlHandle)> {
4905        if let SessionControlRequest::SetShuffleMode { shuffle_on, control_handle } = self {
4906            Some((shuffle_on, control_handle))
4907        } else {
4908            None
4909        }
4910    }
4911
4912    #[allow(irrefutable_let_patterns)]
4913    pub fn into_bind_volume_control(
4914        self,
4915    ) -> Option<(
4916        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4917        SessionControlControlHandle,
4918    )> {
4919        if let SessionControlRequest::BindVolumeControl { volume_control_request, control_handle } =
4920            self
4921        {
4922            Some((volume_control_request, control_handle))
4923        } else {
4924            None
4925        }
4926    }
4927
4928    #[allow(irrefutable_let_patterns)]
4929    pub fn into_watch_status(self) -> Option<(SessionControlWatchStatusResponder)> {
4930        if let SessionControlRequest::WatchStatus { responder } = self {
4931            Some((responder))
4932        } else {
4933            None
4934        }
4935    }
4936
4937    /// Name of the method defined in FIDL
4938    pub fn method_name(&self) -> &'static str {
4939        match *self {
4940            SessionControlRequest::Play { .. } => "play",
4941            SessionControlRequest::Pause { .. } => "pause",
4942            SessionControlRequest::Stop { .. } => "stop",
4943            SessionControlRequest::Seek { .. } => "seek",
4944            SessionControlRequest::SkipForward { .. } => "skip_forward",
4945            SessionControlRequest::SkipReverse { .. } => "skip_reverse",
4946            SessionControlRequest::NextItem { .. } => "next_item",
4947            SessionControlRequest::PrevItem { .. } => "prev_item",
4948            SessionControlRequest::SetPlaybackRate { .. } => "set_playback_rate",
4949            SessionControlRequest::SetRepeatMode { .. } => "set_repeat_mode",
4950            SessionControlRequest::SetShuffleMode { .. } => "set_shuffle_mode",
4951            SessionControlRequest::BindVolumeControl { .. } => "bind_volume_control",
4952            SessionControlRequest::WatchStatus { .. } => "watch_status",
4953        }
4954    }
4955}
4956
4957#[derive(Debug, Clone)]
4958pub struct SessionControlControlHandle {
4959    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4960}
4961
4962impl fidl::endpoints::ControlHandle for SessionControlControlHandle {
4963    fn shutdown(&self) {
4964        self.inner.shutdown()
4965    }
4966    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4967        self.inner.shutdown_with_epitaph(status)
4968    }
4969
4970    fn is_closed(&self) -> bool {
4971        self.inner.channel().is_closed()
4972    }
4973    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4974        self.inner.channel().on_closed()
4975    }
4976
4977    #[cfg(target_os = "fuchsia")]
4978    fn signal_peer(
4979        &self,
4980        clear_mask: zx::Signals,
4981        set_mask: zx::Signals,
4982    ) -> Result<(), zx_status::Status> {
4983        use fidl::Peered;
4984        self.inner.channel().signal_peer(clear_mask, set_mask)
4985    }
4986}
4987
4988impl SessionControlControlHandle {}
4989
4990#[must_use = "FIDL methods require a response to be sent"]
4991#[derive(Debug)]
4992pub struct SessionControlWatchStatusResponder {
4993    control_handle: std::mem::ManuallyDrop<SessionControlControlHandle>,
4994    tx_id: u32,
4995}
4996
4997/// Set the the channel to be shutdown (see [`SessionControlControlHandle::shutdown`])
4998/// if the responder is dropped without sending a response, so that the client
4999/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5000impl std::ops::Drop for SessionControlWatchStatusResponder {
5001    fn drop(&mut self) {
5002        self.control_handle.shutdown();
5003        // Safety: drops once, never accessed again
5004        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5005    }
5006}
5007
5008impl fidl::endpoints::Responder for SessionControlWatchStatusResponder {
5009    type ControlHandle = SessionControlControlHandle;
5010
5011    fn control_handle(&self) -> &SessionControlControlHandle {
5012        &self.control_handle
5013    }
5014
5015    fn drop_without_shutdown(mut self) {
5016        // Safety: drops once, never accessed again due to mem::forget
5017        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5018        // Prevent Drop from running (which would shut down the channel)
5019        std::mem::forget(self);
5020    }
5021}
5022
5023impl SessionControlWatchStatusResponder {
5024    /// Sends a response to the FIDL transaction.
5025    ///
5026    /// Sets the channel to shutdown if an error occurs.
5027    pub fn send(self, mut session_info_delta: &SessionInfoDelta) -> Result<(), fidl::Error> {
5028        let _result = self.send_raw(session_info_delta);
5029        if _result.is_err() {
5030            self.control_handle.shutdown();
5031        }
5032        self.drop_without_shutdown();
5033        _result
5034    }
5035
5036    /// Similar to "send" but does not shutdown the channel if an error occurs.
5037    pub fn send_no_shutdown_on_err(
5038        self,
5039        mut session_info_delta: &SessionInfoDelta,
5040    ) -> Result<(), fidl::Error> {
5041        let _result = self.send_raw(session_info_delta);
5042        self.drop_without_shutdown();
5043        _result
5044    }
5045
5046    fn send_raw(&self, mut session_info_delta: &SessionInfoDelta) -> Result<(), fidl::Error> {
5047        self.control_handle.inner.send::<SessionControlWatchStatusResponse>(
5048            (session_info_delta,),
5049            self.tx_id,
5050            0x4ce5727251eb4b74,
5051            fidl::encoding::DynamicFlags::empty(),
5052        )
5053    }
5054}
5055
5056#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5057pub struct SessionObserverMarker;
5058
5059impl fidl::endpoints::ProtocolMarker for SessionObserverMarker {
5060    type Proxy = SessionObserverProxy;
5061    type RequestStream = SessionObserverRequestStream;
5062    #[cfg(target_os = "fuchsia")]
5063    type SynchronousProxy = SessionObserverSynchronousProxy;
5064
5065    const DEBUG_NAME: &'static str = "(anonymous) SessionObserver";
5066}
5067
5068pub trait SessionObserverProxyInterface: Send + Sync {
5069    type WatchStatusResponseFut: std::future::Future<Output = Result<SessionInfoDelta, fidl::Error>>
5070        + Send;
5071    fn r#watch_status(&self) -> Self::WatchStatusResponseFut;
5072}
5073#[derive(Debug)]
5074#[cfg(target_os = "fuchsia")]
5075pub struct SessionObserverSynchronousProxy {
5076    client: fidl::client::sync::Client,
5077}
5078
5079#[cfg(target_os = "fuchsia")]
5080impl fidl::endpoints::SynchronousProxy for SessionObserverSynchronousProxy {
5081    type Proxy = SessionObserverProxy;
5082    type Protocol = SessionObserverMarker;
5083
5084    fn from_channel(inner: fidl::Channel) -> Self {
5085        Self::new(inner)
5086    }
5087
5088    fn into_channel(self) -> fidl::Channel {
5089        self.client.into_channel()
5090    }
5091
5092    fn as_channel(&self) -> &fidl::Channel {
5093        self.client.as_channel()
5094    }
5095}
5096
5097#[cfg(target_os = "fuchsia")]
5098impl SessionObserverSynchronousProxy {
5099    pub fn new(channel: fidl::Channel) -> Self {
5100        let protocol_name = <SessionObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5101        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5102    }
5103
5104    pub fn into_channel(self) -> fidl::Channel {
5105        self.client.into_channel()
5106    }
5107
5108    /// Waits until an event arrives and returns it. It is safe for other
5109    /// threads to make concurrent requests while waiting for an event.
5110    pub fn wait_for_event(
5111        &self,
5112        deadline: zx::MonotonicInstant,
5113    ) -> Result<SessionObserverEvent, fidl::Error> {
5114        SessionObserverEvent::decode(self.client.wait_for_event(deadline)?)
5115    }
5116
5117    /// Watches the session status. Leave a request hanging to receive a reply when
5118    /// the session status changes. The first request will be answered immediately with
5119    /// the current state.
5120    pub fn r#watch_status(
5121        &self,
5122        ___deadline: zx::MonotonicInstant,
5123    ) -> Result<SessionInfoDelta, fidl::Error> {
5124        let _response = self
5125            .client
5126            .send_query::<fidl::encoding::EmptyPayload, SessionObserverWatchStatusResponse>(
5127                (),
5128                0x24618b709ca18f4d,
5129                fidl::encoding::DynamicFlags::empty(),
5130                ___deadline,
5131            )?;
5132        Ok(_response.session_info_delta)
5133    }
5134}
5135
5136#[cfg(target_os = "fuchsia")]
5137impl From<SessionObserverSynchronousProxy> for zx::Handle {
5138    fn from(value: SessionObserverSynchronousProxy) -> Self {
5139        value.into_channel().into()
5140    }
5141}
5142
5143#[cfg(target_os = "fuchsia")]
5144impl From<fidl::Channel> for SessionObserverSynchronousProxy {
5145    fn from(value: fidl::Channel) -> Self {
5146        Self::new(value)
5147    }
5148}
5149
5150#[derive(Debug, Clone)]
5151pub struct SessionObserverProxy {
5152    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5153}
5154
5155impl fidl::endpoints::Proxy for SessionObserverProxy {
5156    type Protocol = SessionObserverMarker;
5157
5158    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5159        Self::new(inner)
5160    }
5161
5162    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5163        self.client.into_channel().map_err(|client| Self { client })
5164    }
5165
5166    fn as_channel(&self) -> &::fidl::AsyncChannel {
5167        self.client.as_channel()
5168    }
5169}
5170
5171impl SessionObserverProxy {
5172    /// Create a new Proxy for fuchsia.media.sessions2/SessionObserver.
5173    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5174        let protocol_name = <SessionObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5175        Self { client: fidl::client::Client::new(channel, protocol_name) }
5176    }
5177
5178    /// Get a Stream of events from the remote end of the protocol.
5179    ///
5180    /// # Panics
5181    ///
5182    /// Panics if the event stream was already taken.
5183    pub fn take_event_stream(&self) -> SessionObserverEventStream {
5184        SessionObserverEventStream { event_receiver: self.client.take_event_receiver() }
5185    }
5186
5187    /// Watches the session status. Leave a request hanging to receive a reply when
5188    /// the session status changes. The first request will be answered immediately with
5189    /// the current state.
5190    pub fn r#watch_status(
5191        &self,
5192    ) -> fidl::client::QueryResponseFut<
5193        SessionInfoDelta,
5194        fidl::encoding::DefaultFuchsiaResourceDialect,
5195    > {
5196        SessionObserverProxyInterface::r#watch_status(self)
5197    }
5198}
5199
5200impl SessionObserverProxyInterface for SessionObserverProxy {
5201    type WatchStatusResponseFut = fidl::client::QueryResponseFut<
5202        SessionInfoDelta,
5203        fidl::encoding::DefaultFuchsiaResourceDialect,
5204    >;
5205    fn r#watch_status(&self) -> Self::WatchStatusResponseFut {
5206        fn _decode(
5207            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5208        ) -> Result<SessionInfoDelta, fidl::Error> {
5209            let _response = fidl::client::decode_transaction_body::<
5210                SessionObserverWatchStatusResponse,
5211                fidl::encoding::DefaultFuchsiaResourceDialect,
5212                0x24618b709ca18f4d,
5213            >(_buf?)?;
5214            Ok(_response.session_info_delta)
5215        }
5216        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, SessionInfoDelta>(
5217            (),
5218            0x24618b709ca18f4d,
5219            fidl::encoding::DynamicFlags::empty(),
5220            _decode,
5221        )
5222    }
5223}
5224
5225pub struct SessionObserverEventStream {
5226    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5227}
5228
5229impl std::marker::Unpin for SessionObserverEventStream {}
5230
5231impl futures::stream::FusedStream for SessionObserverEventStream {
5232    fn is_terminated(&self) -> bool {
5233        self.event_receiver.is_terminated()
5234    }
5235}
5236
5237impl futures::Stream for SessionObserverEventStream {
5238    type Item = Result<SessionObserverEvent, fidl::Error>;
5239
5240    fn poll_next(
5241        mut self: std::pin::Pin<&mut Self>,
5242        cx: &mut std::task::Context<'_>,
5243    ) -> std::task::Poll<Option<Self::Item>> {
5244        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5245            &mut self.event_receiver,
5246            cx
5247        )?) {
5248            Some(buf) => std::task::Poll::Ready(Some(SessionObserverEvent::decode(buf))),
5249            None => std::task::Poll::Ready(None),
5250        }
5251    }
5252}
5253
5254#[derive(Debug)]
5255pub enum SessionObserverEvent {}
5256
5257impl SessionObserverEvent {
5258    /// Decodes a message buffer as a [`SessionObserverEvent`].
5259    fn decode(
5260        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5261    ) -> Result<SessionObserverEvent, fidl::Error> {
5262        let (bytes, _handles) = buf.split_mut();
5263        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5264        debug_assert_eq!(tx_header.tx_id, 0);
5265        match tx_header.ordinal {
5266            _ => Err(fidl::Error::UnknownOrdinal {
5267                ordinal: tx_header.ordinal,
5268                protocol_name:
5269                    <SessionObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5270            }),
5271        }
5272    }
5273}
5274
5275/// A Stream of incoming requests for fuchsia.media.sessions2/SessionObserver.
5276pub struct SessionObserverRequestStream {
5277    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5278    is_terminated: bool,
5279}
5280
5281impl std::marker::Unpin for SessionObserverRequestStream {}
5282
5283impl futures::stream::FusedStream for SessionObserverRequestStream {
5284    fn is_terminated(&self) -> bool {
5285        self.is_terminated
5286    }
5287}
5288
5289impl fidl::endpoints::RequestStream for SessionObserverRequestStream {
5290    type Protocol = SessionObserverMarker;
5291    type ControlHandle = SessionObserverControlHandle;
5292
5293    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5294        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5295    }
5296
5297    fn control_handle(&self) -> Self::ControlHandle {
5298        SessionObserverControlHandle { inner: self.inner.clone() }
5299    }
5300
5301    fn into_inner(
5302        self,
5303    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5304    {
5305        (self.inner, self.is_terminated)
5306    }
5307
5308    fn from_inner(
5309        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5310        is_terminated: bool,
5311    ) -> Self {
5312        Self { inner, is_terminated }
5313    }
5314}
5315
5316impl futures::Stream for SessionObserverRequestStream {
5317    type Item = Result<SessionObserverRequest, fidl::Error>;
5318
5319    fn poll_next(
5320        mut self: std::pin::Pin<&mut Self>,
5321        cx: &mut std::task::Context<'_>,
5322    ) -> std::task::Poll<Option<Self::Item>> {
5323        let this = &mut *self;
5324        if this.inner.check_shutdown(cx) {
5325            this.is_terminated = true;
5326            return std::task::Poll::Ready(None);
5327        }
5328        if this.is_terminated {
5329            panic!("polled SessionObserverRequestStream after completion");
5330        }
5331        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5332            |bytes, handles| {
5333                match this.inner.channel().read_etc(cx, bytes, handles) {
5334                    std::task::Poll::Ready(Ok(())) => {}
5335                    std::task::Poll::Pending => return std::task::Poll::Pending,
5336                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5337                        this.is_terminated = true;
5338                        return std::task::Poll::Ready(None);
5339                    }
5340                    std::task::Poll::Ready(Err(e)) => {
5341                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5342                            e.into(),
5343                        ))))
5344                    }
5345                }
5346
5347                // A message has been received from the channel
5348                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5349
5350                std::task::Poll::Ready(Some(match header.ordinal {
5351                    0x24618b709ca18f4d => {
5352                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5353                        let mut req = fidl::new_empty!(
5354                            fidl::encoding::EmptyPayload,
5355                            fidl::encoding::DefaultFuchsiaResourceDialect
5356                        );
5357                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5358                        let control_handle =
5359                            SessionObserverControlHandle { inner: this.inner.clone() };
5360                        Ok(SessionObserverRequest::WatchStatus {
5361                            responder: SessionObserverWatchStatusResponder {
5362                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5363                                tx_id: header.tx_id,
5364                            },
5365                        })
5366                    }
5367                    _ => Err(fidl::Error::UnknownOrdinal {
5368                        ordinal: header.ordinal,
5369                        protocol_name:
5370                            <SessionObserverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5371                    }),
5372                }))
5373            },
5374        )
5375    }
5376}
5377
5378/// Views a media session's status.
5379///
5380/// The channel will close if the media session is stopped.
5381#[derive(Debug)]
5382pub enum SessionObserverRequest {
5383    /// Watches the session status. Leave a request hanging to receive a reply when
5384    /// the session status changes. The first request will be answered immediately with
5385    /// the current state.
5386    WatchStatus { responder: SessionObserverWatchStatusResponder },
5387}
5388
5389impl SessionObserverRequest {
5390    #[allow(irrefutable_let_patterns)]
5391    pub fn into_watch_status(self) -> Option<(SessionObserverWatchStatusResponder)> {
5392        if let SessionObserverRequest::WatchStatus { responder } = self {
5393            Some((responder))
5394        } else {
5395            None
5396        }
5397    }
5398
5399    /// Name of the method defined in FIDL
5400    pub fn method_name(&self) -> &'static str {
5401        match *self {
5402            SessionObserverRequest::WatchStatus { .. } => "watch_status",
5403        }
5404    }
5405}
5406
5407#[derive(Debug, Clone)]
5408pub struct SessionObserverControlHandle {
5409    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5410}
5411
5412impl fidl::endpoints::ControlHandle for SessionObserverControlHandle {
5413    fn shutdown(&self) {
5414        self.inner.shutdown()
5415    }
5416    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5417        self.inner.shutdown_with_epitaph(status)
5418    }
5419
5420    fn is_closed(&self) -> bool {
5421        self.inner.channel().is_closed()
5422    }
5423    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5424        self.inner.channel().on_closed()
5425    }
5426
5427    #[cfg(target_os = "fuchsia")]
5428    fn signal_peer(
5429        &self,
5430        clear_mask: zx::Signals,
5431        set_mask: zx::Signals,
5432    ) -> Result<(), zx_status::Status> {
5433        use fidl::Peered;
5434        self.inner.channel().signal_peer(clear_mask, set_mask)
5435    }
5436}
5437
5438impl SessionObserverControlHandle {}
5439
5440#[must_use = "FIDL methods require a response to be sent"]
5441#[derive(Debug)]
5442pub struct SessionObserverWatchStatusResponder {
5443    control_handle: std::mem::ManuallyDrop<SessionObserverControlHandle>,
5444    tx_id: u32,
5445}
5446
5447/// Set the the channel to be shutdown (see [`SessionObserverControlHandle::shutdown`])
5448/// if the responder is dropped without sending a response, so that the client
5449/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5450impl std::ops::Drop for SessionObserverWatchStatusResponder {
5451    fn drop(&mut self) {
5452        self.control_handle.shutdown();
5453        // Safety: drops once, never accessed again
5454        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5455    }
5456}
5457
5458impl fidl::endpoints::Responder for SessionObserverWatchStatusResponder {
5459    type ControlHandle = SessionObserverControlHandle;
5460
5461    fn control_handle(&self) -> &SessionObserverControlHandle {
5462        &self.control_handle
5463    }
5464
5465    fn drop_without_shutdown(mut self) {
5466        // Safety: drops once, never accessed again due to mem::forget
5467        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5468        // Prevent Drop from running (which would shut down the channel)
5469        std::mem::forget(self);
5470    }
5471}
5472
5473impl SessionObserverWatchStatusResponder {
5474    /// Sends a response to the FIDL transaction.
5475    ///
5476    /// Sets the channel to shutdown if an error occurs.
5477    pub fn send(self, mut session_info_delta: &SessionInfoDelta) -> Result<(), fidl::Error> {
5478        let _result = self.send_raw(session_info_delta);
5479        if _result.is_err() {
5480            self.control_handle.shutdown();
5481        }
5482        self.drop_without_shutdown();
5483        _result
5484    }
5485
5486    /// Similar to "send" but does not shutdown the channel if an error occurs.
5487    pub fn send_no_shutdown_on_err(
5488        self,
5489        mut session_info_delta: &SessionInfoDelta,
5490    ) -> Result<(), fidl::Error> {
5491        let _result = self.send_raw(session_info_delta);
5492        self.drop_without_shutdown();
5493        _result
5494    }
5495
5496    fn send_raw(&self, mut session_info_delta: &SessionInfoDelta) -> Result<(), fidl::Error> {
5497        self.control_handle.inner.send::<SessionObserverWatchStatusResponse>(
5498            (session_info_delta,),
5499            self.tx_id,
5500            0x24618b709ca18f4d,
5501            fidl::encoding::DynamicFlags::empty(),
5502        )
5503    }
5504}
5505
5506#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5507pub struct SessionsWatcherMarker;
5508
5509impl fidl::endpoints::ProtocolMarker for SessionsWatcherMarker {
5510    type Proxy = SessionsWatcherProxy;
5511    type RequestStream = SessionsWatcherRequestStream;
5512    #[cfg(target_os = "fuchsia")]
5513    type SynchronousProxy = SessionsWatcherSynchronousProxy;
5514
5515    const DEBUG_NAME: &'static str = "(anonymous) SessionsWatcher";
5516}
5517
5518pub trait SessionsWatcherProxyInterface: Send + Sync {
5519    type SessionUpdatedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5520    fn r#session_updated(
5521        &self,
5522        session_id: u64,
5523        session_info_delta: &SessionInfoDelta,
5524    ) -> Self::SessionUpdatedResponseFut;
5525    type SessionRemovedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5526    fn r#session_removed(&self, session_id: u64) -> Self::SessionRemovedResponseFut;
5527}
5528#[derive(Debug)]
5529#[cfg(target_os = "fuchsia")]
5530pub struct SessionsWatcherSynchronousProxy {
5531    client: fidl::client::sync::Client,
5532}
5533
5534#[cfg(target_os = "fuchsia")]
5535impl fidl::endpoints::SynchronousProxy for SessionsWatcherSynchronousProxy {
5536    type Proxy = SessionsWatcherProxy;
5537    type Protocol = SessionsWatcherMarker;
5538
5539    fn from_channel(inner: fidl::Channel) -> Self {
5540        Self::new(inner)
5541    }
5542
5543    fn into_channel(self) -> fidl::Channel {
5544        self.client.into_channel()
5545    }
5546
5547    fn as_channel(&self) -> &fidl::Channel {
5548        self.client.as_channel()
5549    }
5550}
5551
5552#[cfg(target_os = "fuchsia")]
5553impl SessionsWatcherSynchronousProxy {
5554    pub fn new(channel: fidl::Channel) -> Self {
5555        let protocol_name = <SessionsWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5556        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5557    }
5558
5559    pub fn into_channel(self) -> fidl::Channel {
5560        self.client.into_channel()
5561    }
5562
5563    /// Waits until an event arrives and returns it. It is safe for other
5564    /// threads to make concurrent requests while waiting for an event.
5565    pub fn wait_for_event(
5566        &self,
5567        deadline: zx::MonotonicInstant,
5568    ) -> Result<SessionsWatcherEvent, fidl::Error> {
5569        SessionsWatcherEvent::decode(self.client.wait_for_event(deadline)?)
5570    }
5571
5572    /// Called by the registry service when a session is updated. On first connection,
5573    /// this will be called as many times as needed to communicate the state of the
5574    /// world.
5575    ///
5576    /// `SessionsWatcher` must reply to acknowledge receipt of the session info delta.
5577    /// Delinquent watchers who do not reply will eventually be disconnected.
5578    pub fn r#session_updated(
5579        &self,
5580        mut session_id: u64,
5581        mut session_info_delta: &SessionInfoDelta,
5582        ___deadline: zx::MonotonicInstant,
5583    ) -> Result<(), fidl::Error> {
5584        let _response = self
5585            .client
5586            .send_query::<SessionsWatcherSessionUpdatedRequest, fidl::encoding::EmptyPayload>(
5587                (session_id, session_info_delta),
5588                0x47d25ef93c58c2d9,
5589                fidl::encoding::DynamicFlags::empty(),
5590                ___deadline,
5591            )?;
5592        Ok(_response)
5593    }
5594
5595    /// Called by the registry service when a session is removed from the registered
5596    /// collection.
5597    ///
5598    /// `SessionsWatcher` must reply to acknlowledge receipt of the session removal.
5599    /// Delinquent watchers who do not reply will eventually be disconnected.
5600    pub fn r#session_removed(
5601        &self,
5602        mut session_id: u64,
5603        ___deadline: zx::MonotonicInstant,
5604    ) -> Result<(), fidl::Error> {
5605        let _response = self
5606            .client
5607            .send_query::<SessionsWatcherSessionRemovedRequest, fidl::encoding::EmptyPayload>(
5608                (session_id,),
5609                0x407556ecd5a2400e,
5610                fidl::encoding::DynamicFlags::empty(),
5611                ___deadline,
5612            )?;
5613        Ok(_response)
5614    }
5615}
5616
5617#[cfg(target_os = "fuchsia")]
5618impl From<SessionsWatcherSynchronousProxy> for zx::Handle {
5619    fn from(value: SessionsWatcherSynchronousProxy) -> Self {
5620        value.into_channel().into()
5621    }
5622}
5623
5624#[cfg(target_os = "fuchsia")]
5625impl From<fidl::Channel> for SessionsWatcherSynchronousProxy {
5626    fn from(value: fidl::Channel) -> Self {
5627        Self::new(value)
5628    }
5629}
5630
5631#[derive(Debug, Clone)]
5632pub struct SessionsWatcherProxy {
5633    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5634}
5635
5636impl fidl::endpoints::Proxy for SessionsWatcherProxy {
5637    type Protocol = SessionsWatcherMarker;
5638
5639    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5640        Self::new(inner)
5641    }
5642
5643    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5644        self.client.into_channel().map_err(|client| Self { client })
5645    }
5646
5647    fn as_channel(&self) -> &::fidl::AsyncChannel {
5648        self.client.as_channel()
5649    }
5650}
5651
5652impl SessionsWatcherProxy {
5653    /// Create a new Proxy for fuchsia.media.sessions2/SessionsWatcher.
5654    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5655        let protocol_name = <SessionsWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5656        Self { client: fidl::client::Client::new(channel, protocol_name) }
5657    }
5658
5659    /// Get a Stream of events from the remote end of the protocol.
5660    ///
5661    /// # Panics
5662    ///
5663    /// Panics if the event stream was already taken.
5664    pub fn take_event_stream(&self) -> SessionsWatcherEventStream {
5665        SessionsWatcherEventStream { event_receiver: self.client.take_event_receiver() }
5666    }
5667
5668    /// Called by the registry service when a session is updated. On first connection,
5669    /// this will be called as many times as needed to communicate the state of the
5670    /// world.
5671    ///
5672    /// `SessionsWatcher` must reply to acknowledge receipt of the session info delta.
5673    /// Delinquent watchers who do not reply will eventually be disconnected.
5674    pub fn r#session_updated(
5675        &self,
5676        mut session_id: u64,
5677        mut session_info_delta: &SessionInfoDelta,
5678    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5679        SessionsWatcherProxyInterface::r#session_updated(self, session_id, session_info_delta)
5680    }
5681
5682    /// Called by the registry service when a session is removed from the registered
5683    /// collection.
5684    ///
5685    /// `SessionsWatcher` must reply to acknlowledge receipt of the session removal.
5686    /// Delinquent watchers who do not reply will eventually be disconnected.
5687    pub fn r#session_removed(
5688        &self,
5689        mut session_id: u64,
5690    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5691        SessionsWatcherProxyInterface::r#session_removed(self, session_id)
5692    }
5693}
5694
5695impl SessionsWatcherProxyInterface for SessionsWatcherProxy {
5696    type SessionUpdatedResponseFut =
5697        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5698    fn r#session_updated(
5699        &self,
5700        mut session_id: u64,
5701        mut session_info_delta: &SessionInfoDelta,
5702    ) -> Self::SessionUpdatedResponseFut {
5703        fn _decode(
5704            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5705        ) -> Result<(), fidl::Error> {
5706            let _response = fidl::client::decode_transaction_body::<
5707                fidl::encoding::EmptyPayload,
5708                fidl::encoding::DefaultFuchsiaResourceDialect,
5709                0x47d25ef93c58c2d9,
5710            >(_buf?)?;
5711            Ok(_response)
5712        }
5713        self.client.send_query_and_decode::<SessionsWatcherSessionUpdatedRequest, ()>(
5714            (session_id, session_info_delta),
5715            0x47d25ef93c58c2d9,
5716            fidl::encoding::DynamicFlags::empty(),
5717            _decode,
5718        )
5719    }
5720
5721    type SessionRemovedResponseFut =
5722        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5723    fn r#session_removed(&self, mut session_id: u64) -> Self::SessionRemovedResponseFut {
5724        fn _decode(
5725            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5726        ) -> Result<(), fidl::Error> {
5727            let _response = fidl::client::decode_transaction_body::<
5728                fidl::encoding::EmptyPayload,
5729                fidl::encoding::DefaultFuchsiaResourceDialect,
5730                0x407556ecd5a2400e,
5731            >(_buf?)?;
5732            Ok(_response)
5733        }
5734        self.client.send_query_and_decode::<SessionsWatcherSessionRemovedRequest, ()>(
5735            (session_id,),
5736            0x407556ecd5a2400e,
5737            fidl::encoding::DynamicFlags::empty(),
5738            _decode,
5739        )
5740    }
5741}
5742
5743pub struct SessionsWatcherEventStream {
5744    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5745}
5746
5747impl std::marker::Unpin for SessionsWatcherEventStream {}
5748
5749impl futures::stream::FusedStream for SessionsWatcherEventStream {
5750    fn is_terminated(&self) -> bool {
5751        self.event_receiver.is_terminated()
5752    }
5753}
5754
5755impl futures::Stream for SessionsWatcherEventStream {
5756    type Item = Result<SessionsWatcherEvent, fidl::Error>;
5757
5758    fn poll_next(
5759        mut self: std::pin::Pin<&mut Self>,
5760        cx: &mut std::task::Context<'_>,
5761    ) -> std::task::Poll<Option<Self::Item>> {
5762        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5763            &mut self.event_receiver,
5764            cx
5765        )?) {
5766            Some(buf) => std::task::Poll::Ready(Some(SessionsWatcherEvent::decode(buf))),
5767            None => std::task::Poll::Ready(None),
5768        }
5769    }
5770}
5771
5772#[derive(Debug)]
5773pub enum SessionsWatcherEvent {}
5774
5775impl SessionsWatcherEvent {
5776    /// Decodes a message buffer as a [`SessionsWatcherEvent`].
5777    fn decode(
5778        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5779    ) -> Result<SessionsWatcherEvent, fidl::Error> {
5780        let (bytes, _handles) = buf.split_mut();
5781        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5782        debug_assert_eq!(tx_header.tx_id, 0);
5783        match tx_header.ordinal {
5784            _ => Err(fidl::Error::UnknownOrdinal {
5785                ordinal: tx_header.ordinal,
5786                protocol_name:
5787                    <SessionsWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5788            }),
5789        }
5790    }
5791}
5792
5793/// A Stream of incoming requests for fuchsia.media.sessions2/SessionsWatcher.
5794pub struct SessionsWatcherRequestStream {
5795    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5796    is_terminated: bool,
5797}
5798
5799impl std::marker::Unpin for SessionsWatcherRequestStream {}
5800
5801impl futures::stream::FusedStream for SessionsWatcherRequestStream {
5802    fn is_terminated(&self) -> bool {
5803        self.is_terminated
5804    }
5805}
5806
5807impl fidl::endpoints::RequestStream for SessionsWatcherRequestStream {
5808    type Protocol = SessionsWatcherMarker;
5809    type ControlHandle = SessionsWatcherControlHandle;
5810
5811    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5812        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5813    }
5814
5815    fn control_handle(&self) -> Self::ControlHandle {
5816        SessionsWatcherControlHandle { inner: self.inner.clone() }
5817    }
5818
5819    fn into_inner(
5820        self,
5821    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5822    {
5823        (self.inner, self.is_terminated)
5824    }
5825
5826    fn from_inner(
5827        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5828        is_terminated: bool,
5829    ) -> Self {
5830        Self { inner, is_terminated }
5831    }
5832}
5833
5834impl futures::Stream for SessionsWatcherRequestStream {
5835    type Item = Result<SessionsWatcherRequest, fidl::Error>;
5836
5837    fn poll_next(
5838        mut self: std::pin::Pin<&mut Self>,
5839        cx: &mut std::task::Context<'_>,
5840    ) -> std::task::Poll<Option<Self::Item>> {
5841        let this = &mut *self;
5842        if this.inner.check_shutdown(cx) {
5843            this.is_terminated = true;
5844            return std::task::Poll::Ready(None);
5845        }
5846        if this.is_terminated {
5847            panic!("polled SessionsWatcherRequestStream after completion");
5848        }
5849        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5850            |bytes, handles| {
5851                match this.inner.channel().read_etc(cx, bytes, handles) {
5852                    std::task::Poll::Ready(Ok(())) => {}
5853                    std::task::Poll::Pending => return std::task::Poll::Pending,
5854                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5855                        this.is_terminated = true;
5856                        return std::task::Poll::Ready(None);
5857                    }
5858                    std::task::Poll::Ready(Err(e)) => {
5859                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5860                            e.into(),
5861                        ))))
5862                    }
5863                }
5864
5865                // A message has been received from the channel
5866                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5867
5868                std::task::Poll::Ready(Some(match header.ordinal {
5869                    0x47d25ef93c58c2d9 => {
5870                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5871                        let mut req = fidl::new_empty!(
5872                            SessionsWatcherSessionUpdatedRequest,
5873                            fidl::encoding::DefaultFuchsiaResourceDialect
5874                        );
5875                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionsWatcherSessionUpdatedRequest>(&header, _body_bytes, handles, &mut req)?;
5876                        let control_handle =
5877                            SessionsWatcherControlHandle { inner: this.inner.clone() };
5878                        Ok(SessionsWatcherRequest::SessionUpdated {
5879                            session_id: req.session_id,
5880                            session_info_delta: req.session_info_delta,
5881
5882                            responder: SessionsWatcherSessionUpdatedResponder {
5883                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5884                                tx_id: header.tx_id,
5885                            },
5886                        })
5887                    }
5888                    0x407556ecd5a2400e => {
5889                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5890                        let mut req = fidl::new_empty!(
5891                            SessionsWatcherSessionRemovedRequest,
5892                            fidl::encoding::DefaultFuchsiaResourceDialect
5893                        );
5894                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionsWatcherSessionRemovedRequest>(&header, _body_bytes, handles, &mut req)?;
5895                        let control_handle =
5896                            SessionsWatcherControlHandle { inner: this.inner.clone() };
5897                        Ok(SessionsWatcherRequest::SessionRemoved {
5898                            session_id: req.session_id,
5899
5900                            responder: SessionsWatcherSessionRemovedResponder {
5901                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5902                                tx_id: header.tx_id,
5903                            },
5904                        })
5905                    }
5906                    _ => Err(fidl::Error::UnknownOrdinal {
5907                        ordinal: header.ordinal,
5908                        protocol_name:
5909                            <SessionsWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5910                    }),
5911                }))
5912            },
5913        )
5914    }
5915}
5916
5917/// `SessionsWatcher` watches the collection of published sessions.
5918#[derive(Debug)]
5919pub enum SessionsWatcherRequest {
5920    /// Called by the registry service when a session is updated. On first connection,
5921    /// this will be called as many times as needed to communicate the state of the
5922    /// world.
5923    ///
5924    /// `SessionsWatcher` must reply to acknowledge receipt of the session info delta.
5925    /// Delinquent watchers who do not reply will eventually be disconnected.
5926    SessionUpdated {
5927        session_id: u64,
5928        session_info_delta: SessionInfoDelta,
5929        responder: SessionsWatcherSessionUpdatedResponder,
5930    },
5931    /// Called by the registry service when a session is removed from the registered
5932    /// collection.
5933    ///
5934    /// `SessionsWatcher` must reply to acknlowledge receipt of the session removal.
5935    /// Delinquent watchers who do not reply will eventually be disconnected.
5936    SessionRemoved { session_id: u64, responder: SessionsWatcherSessionRemovedResponder },
5937}
5938
5939impl SessionsWatcherRequest {
5940    #[allow(irrefutable_let_patterns)]
5941    pub fn into_session_updated(
5942        self,
5943    ) -> Option<(u64, SessionInfoDelta, SessionsWatcherSessionUpdatedResponder)> {
5944        if let SessionsWatcherRequest::SessionUpdated {
5945            session_id,
5946            session_info_delta,
5947            responder,
5948        } = self
5949        {
5950            Some((session_id, session_info_delta, responder))
5951        } else {
5952            None
5953        }
5954    }
5955
5956    #[allow(irrefutable_let_patterns)]
5957    pub fn into_session_removed(self) -> Option<(u64, SessionsWatcherSessionRemovedResponder)> {
5958        if let SessionsWatcherRequest::SessionRemoved { session_id, responder } = self {
5959            Some((session_id, responder))
5960        } else {
5961            None
5962        }
5963    }
5964
5965    /// Name of the method defined in FIDL
5966    pub fn method_name(&self) -> &'static str {
5967        match *self {
5968            SessionsWatcherRequest::SessionUpdated { .. } => "session_updated",
5969            SessionsWatcherRequest::SessionRemoved { .. } => "session_removed",
5970        }
5971    }
5972}
5973
5974#[derive(Debug, Clone)]
5975pub struct SessionsWatcherControlHandle {
5976    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5977}
5978
5979impl fidl::endpoints::ControlHandle for SessionsWatcherControlHandle {
5980    fn shutdown(&self) {
5981        self.inner.shutdown()
5982    }
5983    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5984        self.inner.shutdown_with_epitaph(status)
5985    }
5986
5987    fn is_closed(&self) -> bool {
5988        self.inner.channel().is_closed()
5989    }
5990    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5991        self.inner.channel().on_closed()
5992    }
5993
5994    #[cfg(target_os = "fuchsia")]
5995    fn signal_peer(
5996        &self,
5997        clear_mask: zx::Signals,
5998        set_mask: zx::Signals,
5999    ) -> Result<(), zx_status::Status> {
6000        use fidl::Peered;
6001        self.inner.channel().signal_peer(clear_mask, set_mask)
6002    }
6003}
6004
6005impl SessionsWatcherControlHandle {}
6006
6007#[must_use = "FIDL methods require a response to be sent"]
6008#[derive(Debug)]
6009pub struct SessionsWatcherSessionUpdatedResponder {
6010    control_handle: std::mem::ManuallyDrop<SessionsWatcherControlHandle>,
6011    tx_id: u32,
6012}
6013
6014/// Set the the channel to be shutdown (see [`SessionsWatcherControlHandle::shutdown`])
6015/// if the responder is dropped without sending a response, so that the client
6016/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6017impl std::ops::Drop for SessionsWatcherSessionUpdatedResponder {
6018    fn drop(&mut self) {
6019        self.control_handle.shutdown();
6020        // Safety: drops once, never accessed again
6021        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6022    }
6023}
6024
6025impl fidl::endpoints::Responder for SessionsWatcherSessionUpdatedResponder {
6026    type ControlHandle = SessionsWatcherControlHandle;
6027
6028    fn control_handle(&self) -> &SessionsWatcherControlHandle {
6029        &self.control_handle
6030    }
6031
6032    fn drop_without_shutdown(mut self) {
6033        // Safety: drops once, never accessed again due to mem::forget
6034        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6035        // Prevent Drop from running (which would shut down the channel)
6036        std::mem::forget(self);
6037    }
6038}
6039
6040impl SessionsWatcherSessionUpdatedResponder {
6041    /// Sends a response to the FIDL transaction.
6042    ///
6043    /// Sets the channel to shutdown if an error occurs.
6044    pub fn send(self) -> Result<(), fidl::Error> {
6045        let _result = self.send_raw();
6046        if _result.is_err() {
6047            self.control_handle.shutdown();
6048        }
6049        self.drop_without_shutdown();
6050        _result
6051    }
6052
6053    /// Similar to "send" but does not shutdown the channel if an error occurs.
6054    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6055        let _result = self.send_raw();
6056        self.drop_without_shutdown();
6057        _result
6058    }
6059
6060    fn send_raw(&self) -> Result<(), fidl::Error> {
6061        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6062            (),
6063            self.tx_id,
6064            0x47d25ef93c58c2d9,
6065            fidl::encoding::DynamicFlags::empty(),
6066        )
6067    }
6068}
6069
6070#[must_use = "FIDL methods require a response to be sent"]
6071#[derive(Debug)]
6072pub struct SessionsWatcherSessionRemovedResponder {
6073    control_handle: std::mem::ManuallyDrop<SessionsWatcherControlHandle>,
6074    tx_id: u32,
6075}
6076
6077/// Set the the channel to be shutdown (see [`SessionsWatcherControlHandle::shutdown`])
6078/// if the responder is dropped without sending a response, so that the client
6079/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6080impl std::ops::Drop for SessionsWatcherSessionRemovedResponder {
6081    fn drop(&mut self) {
6082        self.control_handle.shutdown();
6083        // Safety: drops once, never accessed again
6084        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6085    }
6086}
6087
6088impl fidl::endpoints::Responder for SessionsWatcherSessionRemovedResponder {
6089    type ControlHandle = SessionsWatcherControlHandle;
6090
6091    fn control_handle(&self) -> &SessionsWatcherControlHandle {
6092        &self.control_handle
6093    }
6094
6095    fn drop_without_shutdown(mut self) {
6096        // Safety: drops once, never accessed again due to mem::forget
6097        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6098        // Prevent Drop from running (which would shut down the channel)
6099        std::mem::forget(self);
6100    }
6101}
6102
6103impl SessionsWatcherSessionRemovedResponder {
6104    /// Sends a response to the FIDL transaction.
6105    ///
6106    /// Sets the channel to shutdown if an error occurs.
6107    pub fn send(self) -> Result<(), fidl::Error> {
6108        let _result = self.send_raw();
6109        if _result.is_err() {
6110            self.control_handle.shutdown();
6111        }
6112        self.drop_without_shutdown();
6113        _result
6114    }
6115
6116    /// Similar to "send" but does not shutdown the channel if an error occurs.
6117    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6118        let _result = self.send_raw();
6119        self.drop_without_shutdown();
6120        _result
6121    }
6122
6123    fn send_raw(&self) -> Result<(), fidl::Error> {
6124        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6125            (),
6126            self.tx_id,
6127            0x407556ecd5a2400e,
6128            fidl::encoding::DynamicFlags::empty(),
6129        )
6130    }
6131}
6132
6133mod internal {
6134    use super::*;
6135
6136    impl fidl::encoding::ResourceTypeMarker for ActiveSessionWatchActiveSessionResponse {
6137        type Borrowed<'a> = &'a mut Self;
6138        fn take_or_borrow<'a>(
6139            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6140        ) -> Self::Borrowed<'a> {
6141            value
6142        }
6143    }
6144
6145    unsafe impl fidl::encoding::TypeMarker for ActiveSessionWatchActiveSessionResponse {
6146        type Owned = Self;
6147
6148        #[inline(always)]
6149        fn inline_align(_context: fidl::encoding::Context) -> usize {
6150            4
6151        }
6152
6153        #[inline(always)]
6154        fn inline_size(_context: fidl::encoding::Context) -> usize {
6155            4
6156        }
6157    }
6158
6159    unsafe impl
6160        fidl::encoding::Encode<
6161            ActiveSessionWatchActiveSessionResponse,
6162            fidl::encoding::DefaultFuchsiaResourceDialect,
6163        > for &mut ActiveSessionWatchActiveSessionResponse
6164    {
6165        #[inline]
6166        unsafe fn encode(
6167            self,
6168            encoder: &mut fidl::encoding::Encoder<
6169                '_,
6170                fidl::encoding::DefaultFuchsiaResourceDialect,
6171            >,
6172            offset: usize,
6173            _depth: fidl::encoding::Depth,
6174        ) -> fidl::Result<()> {
6175            encoder.debug_check_bounds::<ActiveSessionWatchActiveSessionResponse>(offset);
6176            // Delegate to tuple encoding.
6177            fidl::encoding::Encode::<
6178                ActiveSessionWatchActiveSessionResponse,
6179                fidl::encoding::DefaultFuchsiaResourceDialect,
6180            >::encode(
6181                (<fidl::encoding::Optional<
6182                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionControlMarker>>,
6183                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6184                    &mut self.session
6185                ),),
6186                encoder,
6187                offset,
6188                _depth,
6189            )
6190        }
6191    }
6192    unsafe impl<
6193            T0: fidl::encoding::Encode<
6194                fidl::encoding::Optional<
6195                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionControlMarker>>,
6196                >,
6197                fidl::encoding::DefaultFuchsiaResourceDialect,
6198            >,
6199        >
6200        fidl::encoding::Encode<
6201            ActiveSessionWatchActiveSessionResponse,
6202            fidl::encoding::DefaultFuchsiaResourceDialect,
6203        > for (T0,)
6204    {
6205        #[inline]
6206        unsafe fn encode(
6207            self,
6208            encoder: &mut fidl::encoding::Encoder<
6209                '_,
6210                fidl::encoding::DefaultFuchsiaResourceDialect,
6211            >,
6212            offset: usize,
6213            depth: fidl::encoding::Depth,
6214        ) -> fidl::Result<()> {
6215            encoder.debug_check_bounds::<ActiveSessionWatchActiveSessionResponse>(offset);
6216            // Zero out padding regions. There's no need to apply masks
6217            // because the unmasked parts will be overwritten by fields.
6218            // Write the fields.
6219            self.0.encode(encoder, offset + 0, depth)?;
6220            Ok(())
6221        }
6222    }
6223
6224    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6225        for ActiveSessionWatchActiveSessionResponse
6226    {
6227        #[inline(always)]
6228        fn new_empty() -> Self {
6229            Self {
6230                session: fidl::new_empty!(
6231                    fidl::encoding::Optional<
6232                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionControlMarker>>,
6233                    >,
6234                    fidl::encoding::DefaultFuchsiaResourceDialect
6235                ),
6236            }
6237        }
6238
6239        #[inline]
6240        unsafe fn decode(
6241            &mut self,
6242            decoder: &mut fidl::encoding::Decoder<
6243                '_,
6244                fidl::encoding::DefaultFuchsiaResourceDialect,
6245            >,
6246            offset: usize,
6247            _depth: fidl::encoding::Depth,
6248        ) -> fidl::Result<()> {
6249            decoder.debug_check_bounds::<Self>(offset);
6250            // Verify that padding bytes are zero.
6251            fidl::decode!(
6252                fidl::encoding::Optional<
6253                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionControlMarker>>,
6254                >,
6255                fidl::encoding::DefaultFuchsiaResourceDialect,
6256                &mut self.session,
6257                decoder,
6258                offset + 0,
6259                _depth
6260            )?;
6261            Ok(())
6262        }
6263    }
6264
6265    impl fidl::encoding::ResourceTypeMarker for DiscoveryConnectToSessionRequest {
6266        type Borrowed<'a> = &'a mut Self;
6267        fn take_or_borrow<'a>(
6268            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6269        ) -> Self::Borrowed<'a> {
6270            value
6271        }
6272    }
6273
6274    unsafe impl fidl::encoding::TypeMarker for DiscoveryConnectToSessionRequest {
6275        type Owned = Self;
6276
6277        #[inline(always)]
6278        fn inline_align(_context: fidl::encoding::Context) -> usize {
6279            8
6280        }
6281
6282        #[inline(always)]
6283        fn inline_size(_context: fidl::encoding::Context) -> usize {
6284            16
6285        }
6286    }
6287
6288    unsafe impl
6289        fidl::encoding::Encode<
6290            DiscoveryConnectToSessionRequest,
6291            fidl::encoding::DefaultFuchsiaResourceDialect,
6292        > for &mut DiscoveryConnectToSessionRequest
6293    {
6294        #[inline]
6295        unsafe fn encode(
6296            self,
6297            encoder: &mut fidl::encoding::Encoder<
6298                '_,
6299                fidl::encoding::DefaultFuchsiaResourceDialect,
6300            >,
6301            offset: usize,
6302            _depth: fidl::encoding::Depth,
6303        ) -> fidl::Result<()> {
6304            encoder.debug_check_bounds::<DiscoveryConnectToSessionRequest>(offset);
6305            // Delegate to tuple encoding.
6306            fidl::encoding::Encode::<DiscoveryConnectToSessionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6307                (
6308                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.session_id),
6309                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionControlMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session_control_request),
6310                ),
6311                encoder, offset, _depth
6312            )
6313        }
6314    }
6315    unsafe impl<
6316            T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
6317            T1: fidl::encoding::Encode<
6318                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionControlMarker>>,
6319                fidl::encoding::DefaultFuchsiaResourceDialect,
6320            >,
6321        >
6322        fidl::encoding::Encode<
6323            DiscoveryConnectToSessionRequest,
6324            fidl::encoding::DefaultFuchsiaResourceDialect,
6325        > for (T0, T1)
6326    {
6327        #[inline]
6328        unsafe fn encode(
6329            self,
6330            encoder: &mut fidl::encoding::Encoder<
6331                '_,
6332                fidl::encoding::DefaultFuchsiaResourceDialect,
6333            >,
6334            offset: usize,
6335            depth: fidl::encoding::Depth,
6336        ) -> fidl::Result<()> {
6337            encoder.debug_check_bounds::<DiscoveryConnectToSessionRequest>(offset);
6338            // Zero out padding regions. There's no need to apply masks
6339            // because the unmasked parts will be overwritten by fields.
6340            unsafe {
6341                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
6342                (ptr as *mut u64).write_unaligned(0);
6343            }
6344            // Write the fields.
6345            self.0.encode(encoder, offset + 0, depth)?;
6346            self.1.encode(encoder, offset + 8, depth)?;
6347            Ok(())
6348        }
6349    }
6350
6351    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6352        for DiscoveryConnectToSessionRequest
6353    {
6354        #[inline(always)]
6355        fn new_empty() -> Self {
6356            Self {
6357                session_id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
6358                session_control_request: fidl::new_empty!(
6359                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionControlMarker>>,
6360                    fidl::encoding::DefaultFuchsiaResourceDialect
6361                ),
6362            }
6363        }
6364
6365        #[inline]
6366        unsafe fn decode(
6367            &mut self,
6368            decoder: &mut fidl::encoding::Decoder<
6369                '_,
6370                fidl::encoding::DefaultFuchsiaResourceDialect,
6371            >,
6372            offset: usize,
6373            _depth: fidl::encoding::Depth,
6374        ) -> fidl::Result<()> {
6375            decoder.debug_check_bounds::<Self>(offset);
6376            // Verify that padding bytes are zero.
6377            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
6378            let padval = unsafe { (ptr as *const u64).read_unaligned() };
6379            let mask = 0xffffffff00000000u64;
6380            let maskedval = padval & mask;
6381            if maskedval != 0 {
6382                return Err(fidl::Error::NonZeroPadding {
6383                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
6384                });
6385            }
6386            fidl::decode!(
6387                u64,
6388                fidl::encoding::DefaultFuchsiaResourceDialect,
6389                &mut self.session_id,
6390                decoder,
6391                offset + 0,
6392                _depth
6393            )?;
6394            fidl::decode!(
6395                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionControlMarker>>,
6396                fidl::encoding::DefaultFuchsiaResourceDialect,
6397                &mut self.session_control_request,
6398                decoder,
6399                offset + 8,
6400                _depth
6401            )?;
6402            Ok(())
6403        }
6404    }
6405
6406    impl fidl::encoding::ResourceTypeMarker for DiscoveryWatchSessionsRequest {
6407        type Borrowed<'a> = &'a mut Self;
6408        fn take_or_borrow<'a>(
6409            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6410        ) -> Self::Borrowed<'a> {
6411            value
6412        }
6413    }
6414
6415    unsafe impl fidl::encoding::TypeMarker for DiscoveryWatchSessionsRequest {
6416        type Owned = Self;
6417
6418        #[inline(always)]
6419        fn inline_align(_context: fidl::encoding::Context) -> usize {
6420            8
6421        }
6422
6423        #[inline(always)]
6424        fn inline_size(_context: fidl::encoding::Context) -> usize {
6425            24
6426        }
6427    }
6428
6429    unsafe impl
6430        fidl::encoding::Encode<
6431            DiscoveryWatchSessionsRequest,
6432            fidl::encoding::DefaultFuchsiaResourceDialect,
6433        > for &mut DiscoveryWatchSessionsRequest
6434    {
6435        #[inline]
6436        unsafe fn encode(
6437            self,
6438            encoder: &mut fidl::encoding::Encoder<
6439                '_,
6440                fidl::encoding::DefaultFuchsiaResourceDialect,
6441            >,
6442            offset: usize,
6443            _depth: fidl::encoding::Depth,
6444        ) -> fidl::Result<()> {
6445            encoder.debug_check_bounds::<DiscoveryWatchSessionsRequest>(offset);
6446            // Delegate to tuple encoding.
6447            fidl::encoding::Encode::<DiscoveryWatchSessionsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6448                (
6449                    <WatchOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.watch_options),
6450                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionsWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session_watcher),
6451                ),
6452                encoder, offset, _depth
6453            )
6454        }
6455    }
6456    unsafe impl<
6457            T0: fidl::encoding::Encode<WatchOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
6458            T1: fidl::encoding::Encode<
6459                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionsWatcherMarker>>,
6460                fidl::encoding::DefaultFuchsiaResourceDialect,
6461            >,
6462        >
6463        fidl::encoding::Encode<
6464            DiscoveryWatchSessionsRequest,
6465            fidl::encoding::DefaultFuchsiaResourceDialect,
6466        > for (T0, T1)
6467    {
6468        #[inline]
6469        unsafe fn encode(
6470            self,
6471            encoder: &mut fidl::encoding::Encoder<
6472                '_,
6473                fidl::encoding::DefaultFuchsiaResourceDialect,
6474            >,
6475            offset: usize,
6476            depth: fidl::encoding::Depth,
6477        ) -> fidl::Result<()> {
6478            encoder.debug_check_bounds::<DiscoveryWatchSessionsRequest>(offset);
6479            // Zero out padding regions. There's no need to apply masks
6480            // because the unmasked parts will be overwritten by fields.
6481            unsafe {
6482                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
6483                (ptr as *mut u64).write_unaligned(0);
6484            }
6485            // Write the fields.
6486            self.0.encode(encoder, offset + 0, depth)?;
6487            self.1.encode(encoder, offset + 16, depth)?;
6488            Ok(())
6489        }
6490    }
6491
6492    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6493        for DiscoveryWatchSessionsRequest
6494    {
6495        #[inline(always)]
6496        fn new_empty() -> Self {
6497            Self {
6498                watch_options: fidl::new_empty!(
6499                    WatchOptions,
6500                    fidl::encoding::DefaultFuchsiaResourceDialect
6501                ),
6502                session_watcher: fidl::new_empty!(
6503                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionsWatcherMarker>>,
6504                    fidl::encoding::DefaultFuchsiaResourceDialect
6505                ),
6506            }
6507        }
6508
6509        #[inline]
6510        unsafe fn decode(
6511            &mut self,
6512            decoder: &mut fidl::encoding::Decoder<
6513                '_,
6514                fidl::encoding::DefaultFuchsiaResourceDialect,
6515            >,
6516            offset: usize,
6517            _depth: fidl::encoding::Depth,
6518        ) -> fidl::Result<()> {
6519            decoder.debug_check_bounds::<Self>(offset);
6520            // Verify that padding bytes are zero.
6521            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
6522            let padval = unsafe { (ptr as *const u64).read_unaligned() };
6523            let mask = 0xffffffff00000000u64;
6524            let maskedval = padval & mask;
6525            if maskedval != 0 {
6526                return Err(fidl::Error::NonZeroPadding {
6527                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
6528                });
6529            }
6530            fidl::decode!(
6531                WatchOptions,
6532                fidl::encoding::DefaultFuchsiaResourceDialect,
6533                &mut self.watch_options,
6534                decoder,
6535                offset + 0,
6536                _depth
6537            )?;
6538            fidl::decode!(
6539                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionsWatcherMarker>>,
6540                fidl::encoding::DefaultFuchsiaResourceDialect,
6541                &mut self.session_watcher,
6542                decoder,
6543                offset + 16,
6544                _depth
6545            )?;
6546            Ok(())
6547        }
6548    }
6549
6550    impl fidl::encoding::ResourceTypeMarker for ObserverDiscoveryConnectToSessionRequest {
6551        type Borrowed<'a> = &'a mut Self;
6552        fn take_or_borrow<'a>(
6553            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6554        ) -> Self::Borrowed<'a> {
6555            value
6556        }
6557    }
6558
6559    unsafe impl fidl::encoding::TypeMarker for ObserverDiscoveryConnectToSessionRequest {
6560        type Owned = Self;
6561
6562        #[inline(always)]
6563        fn inline_align(_context: fidl::encoding::Context) -> usize {
6564            8
6565        }
6566
6567        #[inline(always)]
6568        fn inline_size(_context: fidl::encoding::Context) -> usize {
6569            16
6570        }
6571    }
6572
6573    unsafe impl
6574        fidl::encoding::Encode<
6575            ObserverDiscoveryConnectToSessionRequest,
6576            fidl::encoding::DefaultFuchsiaResourceDialect,
6577        > for &mut ObserverDiscoveryConnectToSessionRequest
6578    {
6579        #[inline]
6580        unsafe fn encode(
6581            self,
6582            encoder: &mut fidl::encoding::Encoder<
6583                '_,
6584                fidl::encoding::DefaultFuchsiaResourceDialect,
6585            >,
6586            offset: usize,
6587            _depth: fidl::encoding::Depth,
6588        ) -> fidl::Result<()> {
6589            encoder.debug_check_bounds::<ObserverDiscoveryConnectToSessionRequest>(offset);
6590            // Delegate to tuple encoding.
6591            fidl::encoding::Encode::<ObserverDiscoveryConnectToSessionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6592                (
6593                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.session_id),
6594                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionObserverMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session_request),
6595                ),
6596                encoder, offset, _depth
6597            )
6598        }
6599    }
6600    unsafe impl<
6601            T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
6602            T1: fidl::encoding::Encode<
6603                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionObserverMarker>>,
6604                fidl::encoding::DefaultFuchsiaResourceDialect,
6605            >,
6606        >
6607        fidl::encoding::Encode<
6608            ObserverDiscoveryConnectToSessionRequest,
6609            fidl::encoding::DefaultFuchsiaResourceDialect,
6610        > for (T0, T1)
6611    {
6612        #[inline]
6613        unsafe fn encode(
6614            self,
6615            encoder: &mut fidl::encoding::Encoder<
6616                '_,
6617                fidl::encoding::DefaultFuchsiaResourceDialect,
6618            >,
6619            offset: usize,
6620            depth: fidl::encoding::Depth,
6621        ) -> fidl::Result<()> {
6622            encoder.debug_check_bounds::<ObserverDiscoveryConnectToSessionRequest>(offset);
6623            // Zero out padding regions. There's no need to apply masks
6624            // because the unmasked parts will be overwritten by fields.
6625            unsafe {
6626                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
6627                (ptr as *mut u64).write_unaligned(0);
6628            }
6629            // Write the fields.
6630            self.0.encode(encoder, offset + 0, depth)?;
6631            self.1.encode(encoder, offset + 8, depth)?;
6632            Ok(())
6633        }
6634    }
6635
6636    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6637        for ObserverDiscoveryConnectToSessionRequest
6638    {
6639        #[inline(always)]
6640        fn new_empty() -> Self {
6641            Self {
6642                session_id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
6643                session_request: fidl::new_empty!(
6644                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionObserverMarker>>,
6645                    fidl::encoding::DefaultFuchsiaResourceDialect
6646                ),
6647            }
6648        }
6649
6650        #[inline]
6651        unsafe fn decode(
6652            &mut self,
6653            decoder: &mut fidl::encoding::Decoder<
6654                '_,
6655                fidl::encoding::DefaultFuchsiaResourceDialect,
6656            >,
6657            offset: usize,
6658            _depth: fidl::encoding::Depth,
6659        ) -> fidl::Result<()> {
6660            decoder.debug_check_bounds::<Self>(offset);
6661            // Verify that padding bytes are zero.
6662            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
6663            let padval = unsafe { (ptr as *const u64).read_unaligned() };
6664            let mask = 0xffffffff00000000u64;
6665            let maskedval = padval & mask;
6666            if maskedval != 0 {
6667                return Err(fidl::Error::NonZeroPadding {
6668                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
6669                });
6670            }
6671            fidl::decode!(
6672                u64,
6673                fidl::encoding::DefaultFuchsiaResourceDialect,
6674                &mut self.session_id,
6675                decoder,
6676                offset + 0,
6677                _depth
6678            )?;
6679            fidl::decode!(
6680                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionObserverMarker>>,
6681                fidl::encoding::DefaultFuchsiaResourceDialect,
6682                &mut self.session_request,
6683                decoder,
6684                offset + 8,
6685                _depth
6686            )?;
6687            Ok(())
6688        }
6689    }
6690
6691    impl fidl::encoding::ResourceTypeMarker for ObserverDiscoveryWatchSessionsRequest {
6692        type Borrowed<'a> = &'a mut Self;
6693        fn take_or_borrow<'a>(
6694            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6695        ) -> Self::Borrowed<'a> {
6696            value
6697        }
6698    }
6699
6700    unsafe impl fidl::encoding::TypeMarker for ObserverDiscoveryWatchSessionsRequest {
6701        type Owned = Self;
6702
6703        #[inline(always)]
6704        fn inline_align(_context: fidl::encoding::Context) -> usize {
6705            8
6706        }
6707
6708        #[inline(always)]
6709        fn inline_size(_context: fidl::encoding::Context) -> usize {
6710            24
6711        }
6712    }
6713
6714    unsafe impl
6715        fidl::encoding::Encode<
6716            ObserverDiscoveryWatchSessionsRequest,
6717            fidl::encoding::DefaultFuchsiaResourceDialect,
6718        > for &mut ObserverDiscoveryWatchSessionsRequest
6719    {
6720        #[inline]
6721        unsafe fn encode(
6722            self,
6723            encoder: &mut fidl::encoding::Encoder<
6724                '_,
6725                fidl::encoding::DefaultFuchsiaResourceDialect,
6726            >,
6727            offset: usize,
6728            _depth: fidl::encoding::Depth,
6729        ) -> fidl::Result<()> {
6730            encoder.debug_check_bounds::<ObserverDiscoveryWatchSessionsRequest>(offset);
6731            // Delegate to tuple encoding.
6732            fidl::encoding::Encode::<ObserverDiscoveryWatchSessionsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6733                (
6734                    <WatchOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.watch_options),
6735                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionsWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.sessions_watcher),
6736                ),
6737                encoder, offset, _depth
6738            )
6739        }
6740    }
6741    unsafe impl<
6742            T0: fidl::encoding::Encode<WatchOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
6743            T1: fidl::encoding::Encode<
6744                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionsWatcherMarker>>,
6745                fidl::encoding::DefaultFuchsiaResourceDialect,
6746            >,
6747        >
6748        fidl::encoding::Encode<
6749            ObserverDiscoveryWatchSessionsRequest,
6750            fidl::encoding::DefaultFuchsiaResourceDialect,
6751        > for (T0, T1)
6752    {
6753        #[inline]
6754        unsafe fn encode(
6755            self,
6756            encoder: &mut fidl::encoding::Encoder<
6757                '_,
6758                fidl::encoding::DefaultFuchsiaResourceDialect,
6759            >,
6760            offset: usize,
6761            depth: fidl::encoding::Depth,
6762        ) -> fidl::Result<()> {
6763            encoder.debug_check_bounds::<ObserverDiscoveryWatchSessionsRequest>(offset);
6764            // Zero out padding regions. There's no need to apply masks
6765            // because the unmasked parts will be overwritten by fields.
6766            unsafe {
6767                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
6768                (ptr as *mut u64).write_unaligned(0);
6769            }
6770            // Write the fields.
6771            self.0.encode(encoder, offset + 0, depth)?;
6772            self.1.encode(encoder, offset + 16, depth)?;
6773            Ok(())
6774        }
6775    }
6776
6777    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6778        for ObserverDiscoveryWatchSessionsRequest
6779    {
6780        #[inline(always)]
6781        fn new_empty() -> Self {
6782            Self {
6783                watch_options: fidl::new_empty!(
6784                    WatchOptions,
6785                    fidl::encoding::DefaultFuchsiaResourceDialect
6786                ),
6787                sessions_watcher: fidl::new_empty!(
6788                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionsWatcherMarker>>,
6789                    fidl::encoding::DefaultFuchsiaResourceDialect
6790                ),
6791            }
6792        }
6793
6794        #[inline]
6795        unsafe fn decode(
6796            &mut self,
6797            decoder: &mut fidl::encoding::Decoder<
6798                '_,
6799                fidl::encoding::DefaultFuchsiaResourceDialect,
6800            >,
6801            offset: usize,
6802            _depth: fidl::encoding::Depth,
6803        ) -> fidl::Result<()> {
6804            decoder.debug_check_bounds::<Self>(offset);
6805            // Verify that padding bytes are zero.
6806            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
6807            let padval = unsafe { (ptr as *const u64).read_unaligned() };
6808            let mask = 0xffffffff00000000u64;
6809            let maskedval = padval & mask;
6810            if maskedval != 0 {
6811                return Err(fidl::Error::NonZeroPadding {
6812                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
6813                });
6814            }
6815            fidl::decode!(
6816                WatchOptions,
6817                fidl::encoding::DefaultFuchsiaResourceDialect,
6818                &mut self.watch_options,
6819                decoder,
6820                offset + 0,
6821                _depth
6822            )?;
6823            fidl::decode!(
6824                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionsWatcherMarker>>,
6825                fidl::encoding::DefaultFuchsiaResourceDialect,
6826                &mut self.sessions_watcher,
6827                decoder,
6828                offset + 16,
6829                _depth
6830            )?;
6831            Ok(())
6832        }
6833    }
6834
6835    impl fidl::encoding::ResourceTypeMarker for PlayerControlBindVolumeControlRequest {
6836        type Borrowed<'a> = &'a mut Self;
6837        fn take_or_borrow<'a>(
6838            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6839        ) -> Self::Borrowed<'a> {
6840            value
6841        }
6842    }
6843
6844    unsafe impl fidl::encoding::TypeMarker for PlayerControlBindVolumeControlRequest {
6845        type Owned = Self;
6846
6847        #[inline(always)]
6848        fn inline_align(_context: fidl::encoding::Context) -> usize {
6849            4
6850        }
6851
6852        #[inline(always)]
6853        fn inline_size(_context: fidl::encoding::Context) -> usize {
6854            4
6855        }
6856    }
6857
6858    unsafe impl
6859        fidl::encoding::Encode<
6860            PlayerControlBindVolumeControlRequest,
6861            fidl::encoding::DefaultFuchsiaResourceDialect,
6862        > for &mut PlayerControlBindVolumeControlRequest
6863    {
6864        #[inline]
6865        unsafe fn encode(
6866            self,
6867            encoder: &mut fidl::encoding::Encoder<
6868                '_,
6869                fidl::encoding::DefaultFuchsiaResourceDialect,
6870            >,
6871            offset: usize,
6872            _depth: fidl::encoding::Depth,
6873        ) -> fidl::Result<()> {
6874            encoder.debug_check_bounds::<PlayerControlBindVolumeControlRequest>(offset);
6875            // Delegate to tuple encoding.
6876            fidl::encoding::Encode::<
6877                PlayerControlBindVolumeControlRequest,
6878                fidl::encoding::DefaultFuchsiaResourceDialect,
6879            >::encode(
6880                (<fidl::encoding::Endpoint<
6881                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6882                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6883                    &mut self.volume_control_request,
6884                ),),
6885                encoder,
6886                offset,
6887                _depth,
6888            )
6889        }
6890    }
6891    unsafe impl<
6892            T0: fidl::encoding::Encode<
6893                fidl::encoding::Endpoint<
6894                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6895                >,
6896                fidl::encoding::DefaultFuchsiaResourceDialect,
6897            >,
6898        >
6899        fidl::encoding::Encode<
6900            PlayerControlBindVolumeControlRequest,
6901            fidl::encoding::DefaultFuchsiaResourceDialect,
6902        > for (T0,)
6903    {
6904        #[inline]
6905        unsafe fn encode(
6906            self,
6907            encoder: &mut fidl::encoding::Encoder<
6908                '_,
6909                fidl::encoding::DefaultFuchsiaResourceDialect,
6910            >,
6911            offset: usize,
6912            depth: fidl::encoding::Depth,
6913        ) -> fidl::Result<()> {
6914            encoder.debug_check_bounds::<PlayerControlBindVolumeControlRequest>(offset);
6915            // Zero out padding regions. There's no need to apply masks
6916            // because the unmasked parts will be overwritten by fields.
6917            // Write the fields.
6918            self.0.encode(encoder, offset + 0, depth)?;
6919            Ok(())
6920        }
6921    }
6922
6923    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6924        for PlayerControlBindVolumeControlRequest
6925    {
6926        #[inline(always)]
6927        fn new_empty() -> Self {
6928            Self {
6929                volume_control_request: fidl::new_empty!(
6930                    fidl::encoding::Endpoint<
6931                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6932                    >,
6933                    fidl::encoding::DefaultFuchsiaResourceDialect
6934                ),
6935            }
6936        }
6937
6938        #[inline]
6939        unsafe fn decode(
6940            &mut self,
6941            decoder: &mut fidl::encoding::Decoder<
6942                '_,
6943                fidl::encoding::DefaultFuchsiaResourceDialect,
6944            >,
6945            offset: usize,
6946            _depth: fidl::encoding::Depth,
6947        ) -> fidl::Result<()> {
6948            decoder.debug_check_bounds::<Self>(offset);
6949            // Verify that padding bytes are zero.
6950            fidl::decode!(
6951                fidl::encoding::Endpoint<
6952                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6953                >,
6954                fidl::encoding::DefaultFuchsiaResourceDialect,
6955                &mut self.volume_control_request,
6956                decoder,
6957                offset + 0,
6958                _depth
6959            )?;
6960            Ok(())
6961        }
6962    }
6963
6964    impl fidl::encoding::ResourceTypeMarker for PublisherPublishRequest {
6965        type Borrowed<'a> = &'a mut Self;
6966        fn take_or_borrow<'a>(
6967            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6968        ) -> Self::Borrowed<'a> {
6969            value
6970        }
6971    }
6972
6973    unsafe impl fidl::encoding::TypeMarker for PublisherPublishRequest {
6974        type Owned = Self;
6975
6976        #[inline(always)]
6977        fn inline_align(_context: fidl::encoding::Context) -> usize {
6978            8
6979        }
6980
6981        #[inline(always)]
6982        fn inline_size(_context: fidl::encoding::Context) -> usize {
6983            24
6984        }
6985    }
6986
6987    unsafe impl
6988        fidl::encoding::Encode<
6989            PublisherPublishRequest,
6990            fidl::encoding::DefaultFuchsiaResourceDialect,
6991        > for &mut PublisherPublishRequest
6992    {
6993        #[inline]
6994        unsafe fn encode(
6995            self,
6996            encoder: &mut fidl::encoding::Encoder<
6997                '_,
6998                fidl::encoding::DefaultFuchsiaResourceDialect,
6999            >,
7000            offset: usize,
7001            _depth: fidl::encoding::Depth,
7002        ) -> fidl::Result<()> {
7003            encoder.debug_check_bounds::<PublisherPublishRequest>(offset);
7004            // Delegate to tuple encoding.
7005            fidl::encoding::Encode::<PublisherPublishRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7006                (
7007                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PlayerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.player),
7008                    <PlayerRegistration as fidl::encoding::ValueTypeMarker>::borrow(&self.registration),
7009                ),
7010                encoder, offset, _depth
7011            )
7012        }
7013    }
7014    unsafe impl<
7015            T0: fidl::encoding::Encode<
7016                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PlayerMarker>>,
7017                fidl::encoding::DefaultFuchsiaResourceDialect,
7018            >,
7019            T1: fidl::encoding::Encode<
7020                PlayerRegistration,
7021                fidl::encoding::DefaultFuchsiaResourceDialect,
7022            >,
7023        >
7024        fidl::encoding::Encode<
7025            PublisherPublishRequest,
7026            fidl::encoding::DefaultFuchsiaResourceDialect,
7027        > for (T0, T1)
7028    {
7029        #[inline]
7030        unsafe fn encode(
7031            self,
7032            encoder: &mut fidl::encoding::Encoder<
7033                '_,
7034                fidl::encoding::DefaultFuchsiaResourceDialect,
7035            >,
7036            offset: usize,
7037            depth: fidl::encoding::Depth,
7038        ) -> fidl::Result<()> {
7039            encoder.debug_check_bounds::<PublisherPublishRequest>(offset);
7040            // Zero out padding regions. There's no need to apply masks
7041            // because the unmasked parts will be overwritten by fields.
7042            unsafe {
7043                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
7044                (ptr as *mut u64).write_unaligned(0);
7045            }
7046            // Write the fields.
7047            self.0.encode(encoder, offset + 0, depth)?;
7048            self.1.encode(encoder, offset + 8, depth)?;
7049            Ok(())
7050        }
7051    }
7052
7053    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7054        for PublisherPublishRequest
7055    {
7056        #[inline(always)]
7057        fn new_empty() -> Self {
7058            Self {
7059                player: fidl::new_empty!(
7060                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PlayerMarker>>,
7061                    fidl::encoding::DefaultFuchsiaResourceDialect
7062                ),
7063                registration: fidl::new_empty!(
7064                    PlayerRegistration,
7065                    fidl::encoding::DefaultFuchsiaResourceDialect
7066                ),
7067            }
7068        }
7069
7070        #[inline]
7071        unsafe fn decode(
7072            &mut self,
7073            decoder: &mut fidl::encoding::Decoder<
7074                '_,
7075                fidl::encoding::DefaultFuchsiaResourceDialect,
7076            >,
7077            offset: usize,
7078            _depth: fidl::encoding::Depth,
7079        ) -> fidl::Result<()> {
7080            decoder.debug_check_bounds::<Self>(offset);
7081            // Verify that padding bytes are zero.
7082            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
7083            let padval = unsafe { (ptr as *const u64).read_unaligned() };
7084            let mask = 0xffffffff00000000u64;
7085            let maskedval = padval & mask;
7086            if maskedval != 0 {
7087                return Err(fidl::Error::NonZeroPadding {
7088                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
7089                });
7090            }
7091            fidl::decode!(
7092                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PlayerMarker>>,
7093                fidl::encoding::DefaultFuchsiaResourceDialect,
7094                &mut self.player,
7095                decoder,
7096                offset + 0,
7097                _depth
7098            )?;
7099            fidl::decode!(
7100                PlayerRegistration,
7101                fidl::encoding::DefaultFuchsiaResourceDialect,
7102                &mut self.registration,
7103                decoder,
7104                offset + 8,
7105                _depth
7106            )?;
7107            Ok(())
7108        }
7109    }
7110
7111    impl fidl::encoding::ResourceTypeMarker for SessionControlBindVolumeControlRequest {
7112        type Borrowed<'a> = &'a mut Self;
7113        fn take_or_borrow<'a>(
7114            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7115        ) -> Self::Borrowed<'a> {
7116            value
7117        }
7118    }
7119
7120    unsafe impl fidl::encoding::TypeMarker for SessionControlBindVolumeControlRequest {
7121        type Owned = Self;
7122
7123        #[inline(always)]
7124        fn inline_align(_context: fidl::encoding::Context) -> usize {
7125            4
7126        }
7127
7128        #[inline(always)]
7129        fn inline_size(_context: fidl::encoding::Context) -> usize {
7130            4
7131        }
7132    }
7133
7134    unsafe impl
7135        fidl::encoding::Encode<
7136            SessionControlBindVolumeControlRequest,
7137            fidl::encoding::DefaultFuchsiaResourceDialect,
7138        > for &mut SessionControlBindVolumeControlRequest
7139    {
7140        #[inline]
7141        unsafe fn encode(
7142            self,
7143            encoder: &mut fidl::encoding::Encoder<
7144                '_,
7145                fidl::encoding::DefaultFuchsiaResourceDialect,
7146            >,
7147            offset: usize,
7148            _depth: fidl::encoding::Depth,
7149        ) -> fidl::Result<()> {
7150            encoder.debug_check_bounds::<SessionControlBindVolumeControlRequest>(offset);
7151            // Delegate to tuple encoding.
7152            fidl::encoding::Encode::<
7153                SessionControlBindVolumeControlRequest,
7154                fidl::encoding::DefaultFuchsiaResourceDialect,
7155            >::encode(
7156                (<fidl::encoding::Endpoint<
7157                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
7158                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7159                    &mut self.volume_control_request,
7160                ),),
7161                encoder,
7162                offset,
7163                _depth,
7164            )
7165        }
7166    }
7167    unsafe impl<
7168            T0: fidl::encoding::Encode<
7169                fidl::encoding::Endpoint<
7170                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
7171                >,
7172                fidl::encoding::DefaultFuchsiaResourceDialect,
7173            >,
7174        >
7175        fidl::encoding::Encode<
7176            SessionControlBindVolumeControlRequest,
7177            fidl::encoding::DefaultFuchsiaResourceDialect,
7178        > for (T0,)
7179    {
7180        #[inline]
7181        unsafe fn encode(
7182            self,
7183            encoder: &mut fidl::encoding::Encoder<
7184                '_,
7185                fidl::encoding::DefaultFuchsiaResourceDialect,
7186            >,
7187            offset: usize,
7188            depth: fidl::encoding::Depth,
7189        ) -> fidl::Result<()> {
7190            encoder.debug_check_bounds::<SessionControlBindVolumeControlRequest>(offset);
7191            // Zero out padding regions. There's no need to apply masks
7192            // because the unmasked parts will be overwritten by fields.
7193            // Write the fields.
7194            self.0.encode(encoder, offset + 0, depth)?;
7195            Ok(())
7196        }
7197    }
7198
7199    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7200        for SessionControlBindVolumeControlRequest
7201    {
7202        #[inline(always)]
7203        fn new_empty() -> Self {
7204            Self {
7205                volume_control_request: fidl::new_empty!(
7206                    fidl::encoding::Endpoint<
7207                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
7208                    >,
7209                    fidl::encoding::DefaultFuchsiaResourceDialect
7210                ),
7211            }
7212        }
7213
7214        #[inline]
7215        unsafe fn decode(
7216            &mut self,
7217            decoder: &mut fidl::encoding::Decoder<
7218                '_,
7219                fidl::encoding::DefaultFuchsiaResourceDialect,
7220            >,
7221            offset: usize,
7222            _depth: fidl::encoding::Depth,
7223        ) -> fidl::Result<()> {
7224            decoder.debug_check_bounds::<Self>(offset);
7225            // Verify that padding bytes are zero.
7226            fidl::decode!(
7227                fidl::encoding::Endpoint<
7228                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
7229                >,
7230                fidl::encoding::DefaultFuchsiaResourceDialect,
7231                &mut self.volume_control_request,
7232                decoder,
7233                offset + 0,
7234                _depth
7235            )?;
7236            Ok(())
7237        }
7238    }
7239}