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