Skip to main content

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