Skip to main content

fdomain_fuchsia_media_audio/
fdomain_fuchsia_media_audio.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 fdomain_client::fidl::{ControlHandle as _, FDomainFlexibleIntoResult as _, Responder as _};
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9pub use fidl_fuchsia_media_audio_common::*;
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
14pub struct EffectsControllerMarker;
15
16impl fdomain_client::fidl::ProtocolMarker for EffectsControllerMarker {
17    type Proxy = EffectsControllerProxy;
18    type RequestStream = EffectsControllerRequestStream;
19
20    const DEBUG_NAME: &'static str = "fuchsia.media.audio.EffectsController";
21}
22impl fdomain_client::fidl::DiscoverableProtocolMarker for EffectsControllerMarker {}
23pub type EffectsControllerUpdateEffectResult = Result<(), UpdateEffectError>;
24
25pub trait EffectsControllerProxyInterface: Send + Sync {
26    type UpdateEffectResponseFut: std::future::Future<Output = Result<EffectsControllerUpdateEffectResult, fidl::Error>>
27        + Send;
28    fn r#update_effect(&self, effect_name: &str, config: &str) -> Self::UpdateEffectResponseFut;
29}
30
31#[derive(Debug, Clone)]
32pub struct EffectsControllerProxy {
33    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
34}
35
36impl fdomain_client::fidl::Proxy for EffectsControllerProxy {
37    type Protocol = EffectsControllerMarker;
38
39    fn from_channel(inner: fdomain_client::Channel) -> Self {
40        Self::new(inner)
41    }
42
43    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
44        self.client.into_channel().map_err(|client| Self { client })
45    }
46
47    fn as_channel(&self) -> &fdomain_client::Channel {
48        self.client.as_channel()
49    }
50}
51
52impl EffectsControllerProxy {
53    /// Create a new Proxy for fuchsia.media.audio/EffectsController.
54    pub fn new(channel: fdomain_client::Channel) -> Self {
55        let protocol_name =
56            <EffectsControllerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
57        Self { client: fidl::client::Client::new(channel, protocol_name) }
58    }
59
60    /// Get a Stream of events from the remote end of the protocol.
61    ///
62    /// # Panics
63    ///
64    /// Panics if the event stream was already taken.
65    pub fn take_event_stream(&self) -> EffectsControllerEventStream {
66        EffectsControllerEventStream { event_receiver: self.client.take_event_receiver() }
67    }
68
69    /// Sends the `config` message to an audio effect named `effect_name`. If the
70    /// server closes the `EffectsController` connection for any reason, that
71    /// indicates that the effects have been reset and any state associated with
72    /// previous `UpdateEffect` messages have been lost. Clients who wish to re-apply
73    /// state should respond by reconnecting and resending any needed `UpdateEffect`
74    /// messages. If a client closes the connection, no state will be lost but the
75    /// client will also be unable to determine if and when any state associated with
76    /// previous messages have been lost.
77    ///
78    /// Returns success (empty response) if the message was accepted by an
79    /// effect named `effect_name`.
80    ///
81    /// Returns `UpdateEffectError.INVALID_CONFIG` if an effect with the name
82    /// `effect_name` was found, but the `config` message was rejected.
83    ///
84    /// Returns `UpdateEffectError.NOT_FOUND` if no effect with name `effect_name`
85    /// could be located.
86    pub fn r#update_effect(
87        &self,
88        mut effect_name: &str,
89        mut config: &str,
90    ) -> fidl::client::QueryResponseFut<
91        EffectsControllerUpdateEffectResult,
92        fdomain_client::fidl::FDomainResourceDialect,
93    > {
94        EffectsControllerProxyInterface::r#update_effect(self, effect_name, config)
95    }
96}
97
98impl EffectsControllerProxyInterface for EffectsControllerProxy {
99    type UpdateEffectResponseFut = fidl::client::QueryResponseFut<
100        EffectsControllerUpdateEffectResult,
101        fdomain_client::fidl::FDomainResourceDialect,
102    >;
103    fn r#update_effect(
104        &self,
105        mut effect_name: &str,
106        mut config: &str,
107    ) -> Self::UpdateEffectResponseFut {
108        fn _decode(
109            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
110        ) -> Result<EffectsControllerUpdateEffectResult, fidl::Error> {
111            let _response = fidl::client::decode_transaction_body::<
112                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, UpdateEffectError>,
113                fdomain_client::fidl::FDomainResourceDialect,
114                0x4e39e4b5e6279125,
115            >(_buf?)?;
116            Ok(_response.map(|x| x))
117        }
118        self.client.send_query_and_decode::<
119            EffectsControllerUpdateEffectRequest,
120            EffectsControllerUpdateEffectResult,
121        >(
122            (effect_name, config,),
123            0x4e39e4b5e6279125,
124            fidl::encoding::DynamicFlags::empty(),
125            _decode,
126        )
127    }
128}
129
130pub struct EffectsControllerEventStream {
131    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
132}
133
134impl std::marker::Unpin for EffectsControllerEventStream {}
135
136impl futures::stream::FusedStream for EffectsControllerEventStream {
137    fn is_terminated(&self) -> bool {
138        self.event_receiver.is_terminated()
139    }
140}
141
142impl futures::Stream for EffectsControllerEventStream {
143    type Item = Result<EffectsControllerEvent, fidl::Error>;
144
145    fn poll_next(
146        mut self: std::pin::Pin<&mut Self>,
147        cx: &mut std::task::Context<'_>,
148    ) -> std::task::Poll<Option<Self::Item>> {
149        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
150            &mut self.event_receiver,
151            cx
152        )?) {
153            Some(buf) => std::task::Poll::Ready(Some(EffectsControllerEvent::decode(buf))),
154            None => std::task::Poll::Ready(None),
155        }
156    }
157}
158
159#[derive(Debug)]
160pub enum EffectsControllerEvent {}
161
162impl EffectsControllerEvent {
163    /// Decodes a message buffer as a [`EffectsControllerEvent`].
164    fn decode(
165        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
166    ) -> Result<EffectsControllerEvent, fidl::Error> {
167        let (bytes, _handles) = buf.split_mut();
168        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
169        debug_assert_eq!(tx_header.tx_id, 0);
170        match tx_header.ordinal {
171            _ => Err(fidl::Error::UnknownOrdinal {
172                ordinal: tx_header.ordinal,
173                protocol_name:
174                    <EffectsControllerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
175            }),
176        }
177    }
178}
179
180/// A Stream of incoming requests for fuchsia.media.audio/EffectsController.
181pub struct EffectsControllerRequestStream {
182    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
183    is_terminated: bool,
184}
185
186impl std::marker::Unpin for EffectsControllerRequestStream {}
187
188impl futures::stream::FusedStream for EffectsControllerRequestStream {
189    fn is_terminated(&self) -> bool {
190        self.is_terminated
191    }
192}
193
194impl fdomain_client::fidl::RequestStream for EffectsControllerRequestStream {
195    type Protocol = EffectsControllerMarker;
196    type ControlHandle = EffectsControllerControlHandle;
197
198    fn from_channel(channel: fdomain_client::Channel) -> Self {
199        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
200    }
201
202    fn control_handle(&self) -> Self::ControlHandle {
203        EffectsControllerControlHandle { inner: self.inner.clone() }
204    }
205
206    fn into_inner(
207        self,
208    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
209    {
210        (self.inner, self.is_terminated)
211    }
212
213    fn from_inner(
214        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
215        is_terminated: bool,
216    ) -> Self {
217        Self { inner, is_terminated }
218    }
219}
220
221impl futures::Stream for EffectsControllerRequestStream {
222    type Item = Result<EffectsControllerRequest, fidl::Error>;
223
224    fn poll_next(
225        mut self: std::pin::Pin<&mut Self>,
226        cx: &mut std::task::Context<'_>,
227    ) -> std::task::Poll<Option<Self::Item>> {
228        let this = &mut *self;
229        if this.inner.check_shutdown(cx) {
230            this.is_terminated = true;
231            return std::task::Poll::Ready(None);
232        }
233        if this.is_terminated {
234            panic!("polled EffectsControllerRequestStream after completion");
235        }
236        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
237            |bytes, handles| {
238                match this.inner.channel().read_etc(cx, bytes, handles) {
239                    std::task::Poll::Ready(Ok(())) => {}
240                    std::task::Poll::Pending => return std::task::Poll::Pending,
241                    std::task::Poll::Ready(Err(None)) => {
242                        this.is_terminated = true;
243                        return std::task::Poll::Ready(None);
244                    }
245                    std::task::Poll::Ready(Err(Some(e))) => {
246                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
247                            e.into(),
248                        ))));
249                    }
250                }
251
252                // A message has been received from the channel
253                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
254
255                std::task::Poll::Ready(Some(match header.ordinal {
256                0x4e39e4b5e6279125 => {
257                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
258                    let mut req = fidl::new_empty!(EffectsControllerUpdateEffectRequest, fdomain_client::fidl::FDomainResourceDialect);
259                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<EffectsControllerUpdateEffectRequest>(&header, _body_bytes, handles, &mut req)?;
260                    let control_handle = EffectsControllerControlHandle {
261                        inner: this.inner.clone(),
262                    };
263                    Ok(EffectsControllerRequest::UpdateEffect {effect_name: req.effect_name,
264config: req.config,
265
266                        responder: EffectsControllerUpdateEffectResponder {
267                            control_handle: std::mem::ManuallyDrop::new(control_handle),
268                            tx_id: header.tx_id,
269                        },
270                    })
271                }
272                _ => Err(fidl::Error::UnknownOrdinal {
273                    ordinal: header.ordinal,
274                    protocol_name: <EffectsControllerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
275                }),
276            }))
277            },
278        )
279    }
280}
281
282#[derive(Debug)]
283pub enum EffectsControllerRequest {
284    /// Sends the `config` message to an audio effect named `effect_name`. If the
285    /// server closes the `EffectsController` connection for any reason, that
286    /// indicates that the effects have been reset and any state associated with
287    /// previous `UpdateEffect` messages have been lost. Clients who wish to re-apply
288    /// state should respond by reconnecting and resending any needed `UpdateEffect`
289    /// messages. If a client closes the connection, no state will be lost but the
290    /// client will also be unable to determine if and when any state associated with
291    /// previous messages have been lost.
292    ///
293    /// Returns success (empty response) if the message was accepted by an
294    /// effect named `effect_name`.
295    ///
296    /// Returns `UpdateEffectError.INVALID_CONFIG` if an effect with the name
297    /// `effect_name` was found, but the `config` message was rejected.
298    ///
299    /// Returns `UpdateEffectError.NOT_FOUND` if no effect with name `effect_name`
300    /// could be located.
301    UpdateEffect {
302        effect_name: String,
303        config: String,
304        responder: EffectsControllerUpdateEffectResponder,
305    },
306}
307
308impl EffectsControllerRequest {
309    #[allow(irrefutable_let_patterns)]
310    pub fn into_update_effect(
311        self,
312    ) -> Option<(String, String, EffectsControllerUpdateEffectResponder)> {
313        if let EffectsControllerRequest::UpdateEffect { effect_name, config, responder } = self {
314            Some((effect_name, config, responder))
315        } else {
316            None
317        }
318    }
319
320    /// Name of the method defined in FIDL
321    pub fn method_name(&self) -> &'static str {
322        match *self {
323            EffectsControllerRequest::UpdateEffect { .. } => "update_effect",
324        }
325    }
326}
327
328#[derive(Debug, Clone)]
329pub struct EffectsControllerControlHandle {
330    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
331}
332
333impl EffectsControllerControlHandle {
334    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
335        self.inner.shutdown_with_epitaph(status.into())
336    }
337}
338
339impl fdomain_client::fidl::ControlHandle for EffectsControllerControlHandle {
340    fn shutdown(&self) {
341        self.inner.shutdown()
342    }
343
344    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
345        self.inner.shutdown_with_epitaph(status)
346    }
347
348    fn is_closed(&self) -> bool {
349        self.inner.channel().is_closed()
350    }
351    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
352        self.inner.channel().on_closed()
353    }
354}
355
356impl EffectsControllerControlHandle {}
357
358#[must_use = "FIDL methods require a response to be sent"]
359#[derive(Debug)]
360pub struct EffectsControllerUpdateEffectResponder {
361    control_handle: std::mem::ManuallyDrop<EffectsControllerControlHandle>,
362    tx_id: u32,
363}
364
365/// Set the the channel to be shutdown (see [`EffectsControllerControlHandle::shutdown`])
366/// if the responder is dropped without sending a response, so that the client
367/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
368impl std::ops::Drop for EffectsControllerUpdateEffectResponder {
369    fn drop(&mut self) {
370        self.control_handle.shutdown();
371        // Safety: drops once, never accessed again
372        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
373    }
374}
375
376impl fdomain_client::fidl::Responder for EffectsControllerUpdateEffectResponder {
377    type ControlHandle = EffectsControllerControlHandle;
378
379    fn control_handle(&self) -> &EffectsControllerControlHandle {
380        &self.control_handle
381    }
382
383    fn drop_without_shutdown(mut self) {
384        // Safety: drops once, never accessed again due to mem::forget
385        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
386        // Prevent Drop from running (which would shut down the channel)
387        std::mem::forget(self);
388    }
389}
390
391impl EffectsControllerUpdateEffectResponder {
392    /// Sends a response to the FIDL transaction.
393    ///
394    /// Sets the channel to shutdown if an error occurs.
395    pub fn send(self, mut result: Result<(), UpdateEffectError>) -> Result<(), fidl::Error> {
396        let _result = self.send_raw(result);
397        if _result.is_err() {
398            self.control_handle.shutdown();
399        }
400        self.drop_without_shutdown();
401        _result
402    }
403
404    /// Similar to "send" but does not shutdown the channel if an error occurs.
405    pub fn send_no_shutdown_on_err(
406        self,
407        mut result: Result<(), UpdateEffectError>,
408    ) -> Result<(), fidl::Error> {
409        let _result = self.send_raw(result);
410        self.drop_without_shutdown();
411        _result
412    }
413
414    fn send_raw(&self, mut result: Result<(), UpdateEffectError>) -> Result<(), fidl::Error> {
415        self.control_handle.inner.send::<fidl::encoding::ResultType<
416            fidl::encoding::EmptyStruct,
417            UpdateEffectError,
418        >>(
419            result,
420            self.tx_id,
421            0x4e39e4b5e6279125,
422            fidl::encoding::DynamicFlags::empty(),
423        )
424    }
425}
426
427#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
428pub struct GainControlMarker;
429
430impl fdomain_client::fidl::ProtocolMarker for GainControlMarker {
431    type Proxy = GainControlProxy;
432    type RequestStream = GainControlRequestStream;
433
434    const DEBUG_NAME: &'static str = "(anonymous) GainControl";
435}
436
437pub trait GainControlProxyInterface: Send + Sync {
438    fn r#set_gain(&self, gain_db: f32) -> Result<(), fidl::Error>;
439    fn r#set_gain_with_ramp(
440        &self,
441        gain_db: f32,
442        duration: i64,
443        ramp_type: RampType,
444    ) -> Result<(), fidl::Error>;
445    fn r#set_mute(&self, muted: bool) -> Result<(), fidl::Error>;
446}
447
448#[derive(Debug, Clone)]
449pub struct GainControlProxy {
450    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
451}
452
453impl fdomain_client::fidl::Proxy for GainControlProxy {
454    type Protocol = GainControlMarker;
455
456    fn from_channel(inner: fdomain_client::Channel) -> Self {
457        Self::new(inner)
458    }
459
460    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
461        self.client.into_channel().map_err(|client| Self { client })
462    }
463
464    fn as_channel(&self) -> &fdomain_client::Channel {
465        self.client.as_channel()
466    }
467}
468
469impl GainControlProxy {
470    /// Create a new Proxy for fuchsia.media.audio/GainControl.
471    pub fn new(channel: fdomain_client::Channel) -> Self {
472        let protocol_name = <GainControlMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
473        Self { client: fidl::client::Client::new(channel, protocol_name) }
474    }
475
476    /// Get a Stream of events from the remote end of the protocol.
477    ///
478    /// # Panics
479    ///
480    /// Panics if the event stream was already taken.
481    pub fn take_event_stream(&self) -> GainControlEventStream {
482        GainControlEventStream { event_receiver: self.client.take_event_receiver() }
483    }
484
485    /// Sets the gain in decibels.
486    pub fn r#set_gain(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
487        GainControlProxyInterface::r#set_gain(self, gain_db)
488    }
489
490    /// Smoothly changes gain from its current value to specified value, over the
491    /// specified duration (in milliseconds). If 'duration_ns' is 0, gain changes
492    /// immediately. Otherwise, gain changes only while the stream is running.
493    ///
494    /// Any active or pending ramp is cancelled by subsequent call to SetGain.
495    ///
496    /// There can be at most 1 active ramp at any time. Any active or pending
497    /// ramp is replaced by a later call to SetGainWithRamp (even if duration is
498    /// 0). In this case gain would ramps directly from its most recent
499    /// (mid-ramp) value to the newly-specified one, over the new duration,
500    /// using the new easing.
501    ///
502    /// Usage example (using time in seconds):
503    ///  Time 0
504    ///      SetGainWithRamp(`MUTED_GAIN_DB`, 0, SCALE_LINEAR)         // Ramp 1
505    ///      SetGainWithRamp(0.0f, `ZX_SEC`(4), SCALE_LINEAR)          // Ramp 2
506    ///  Time 3
507    ///      PlayNoReply(kNoTimestamp, any_media_time)
508    ///  Time 4
509    ///      PauseNoReply()
510    ///  Time 7
511    ///      PlayNoReply(kNoTimestamp, any_media_time)
512    ///  Time 8
513    ///      SetGainWithRamp(`MUTED_GAIN_DB`, ZX_SEC(1), SCALE_LINEAR) // Ramp 3
514    ///
515    ///
516    /// Time 0: Ramp 1 completes immediately, changing the gain to `MUTED_GAIN_DB`.
517    ///         Ramp 2 is pending, since we are not in playback.
518    /// Time 3, Ramp 2 begins ramping from `MUTED_GAIN_DB` to 0 dB
519    ///         (scale 0.0=>1.0).
520    /// Time 4: Ramp 2 pauses (3s remain). Per `SCALE_LINEAR`, scale is approx.
521    ///         0.25.
522    /// Time 7: Ramp 2 resumes from most recent value toward the target.
523    /// Time 8: Ramp 3 replaces Ramp 2 and starts from current scale
524    ///         (approx 0.5).
525    /// Time 9: Ramp 3 completes; current scale value is now 0.0 (`MUTED_GAIN_DB`).
526    pub fn r#set_gain_with_ramp(
527        &self,
528        mut gain_db: f32,
529        mut duration: i64,
530        mut ramp_type: RampType,
531    ) -> Result<(), fidl::Error> {
532        GainControlProxyInterface::r#set_gain_with_ramp(self, gain_db, duration, ramp_type)
533    }
534
535    /// Sets the mute value. Ramping and mute are fully independent, although
536    /// they both affect the scaling that is applied.
537    pub fn r#set_mute(&self, mut muted: bool) -> Result<(), fidl::Error> {
538        GainControlProxyInterface::r#set_mute(self, muted)
539    }
540}
541
542impl GainControlProxyInterface for GainControlProxy {
543    fn r#set_gain(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
544        self.client.send::<GainControlSetGainRequest>(
545            (gain_db,),
546            0x2fc070871d033f64,
547            fidl::encoding::DynamicFlags::empty(),
548        )
549    }
550
551    fn r#set_gain_with_ramp(
552        &self,
553        mut gain_db: f32,
554        mut duration: i64,
555        mut ramp_type: RampType,
556    ) -> Result<(), fidl::Error> {
557        self.client.send::<GainControlSetGainWithRampRequest>(
558            (gain_db, duration, ramp_type),
559            0x3a175b2d6979e8ea,
560            fidl::encoding::DynamicFlags::empty(),
561        )
562    }
563
564    fn r#set_mute(&self, mut muted: bool) -> Result<(), fidl::Error> {
565        self.client.send::<GainControlSetMuteRequest>(
566            (muted,),
567            0x5415723c1e31448,
568            fidl::encoding::DynamicFlags::empty(),
569        )
570    }
571}
572
573pub struct GainControlEventStream {
574    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
575}
576
577impl std::marker::Unpin for GainControlEventStream {}
578
579impl futures::stream::FusedStream for GainControlEventStream {
580    fn is_terminated(&self) -> bool {
581        self.event_receiver.is_terminated()
582    }
583}
584
585impl futures::Stream for GainControlEventStream {
586    type Item = Result<GainControlEvent, fidl::Error>;
587
588    fn poll_next(
589        mut self: std::pin::Pin<&mut Self>,
590        cx: &mut std::task::Context<'_>,
591    ) -> std::task::Poll<Option<Self::Item>> {
592        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
593            &mut self.event_receiver,
594            cx
595        )?) {
596            Some(buf) => std::task::Poll::Ready(Some(GainControlEvent::decode(buf))),
597            None => std::task::Poll::Ready(None),
598        }
599    }
600}
601
602#[derive(Debug)]
603pub enum GainControlEvent {
604    OnGainMuteChanged { gain_db: f32, muted: bool },
605}
606
607impl GainControlEvent {
608    #[allow(irrefutable_let_patterns)]
609    pub fn into_on_gain_mute_changed(self) -> Option<(f32, bool)> {
610        if let GainControlEvent::OnGainMuteChanged { gain_db, muted } = self {
611            Some((gain_db, muted))
612        } else {
613            None
614        }
615    }
616
617    /// Decodes a message buffer as a [`GainControlEvent`].
618    fn decode(
619        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
620    ) -> Result<GainControlEvent, fidl::Error> {
621        let (bytes, _handles) = buf.split_mut();
622        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
623        debug_assert_eq!(tx_header.tx_id, 0);
624        match tx_header.ordinal {
625            0x66d528cad4e0d753 => {
626                let mut out = fidl::new_empty!(
627                    GainControlOnGainMuteChangedRequest,
628                    fdomain_client::fidl::FDomainResourceDialect
629                );
630                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<GainControlOnGainMuteChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
631                Ok((GainControlEvent::OnGainMuteChanged { gain_db: out.gain_db, muted: out.muted }))
632            }
633            _ => Err(fidl::Error::UnknownOrdinal {
634                ordinal: tx_header.ordinal,
635                protocol_name:
636                    <GainControlMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
637            }),
638        }
639    }
640}
641
642/// A Stream of incoming requests for fuchsia.media.audio/GainControl.
643pub struct GainControlRequestStream {
644    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
645    is_terminated: bool,
646}
647
648impl std::marker::Unpin for GainControlRequestStream {}
649
650impl futures::stream::FusedStream for GainControlRequestStream {
651    fn is_terminated(&self) -> bool {
652        self.is_terminated
653    }
654}
655
656impl fdomain_client::fidl::RequestStream for GainControlRequestStream {
657    type Protocol = GainControlMarker;
658    type ControlHandle = GainControlControlHandle;
659
660    fn from_channel(channel: fdomain_client::Channel) -> Self {
661        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
662    }
663
664    fn control_handle(&self) -> Self::ControlHandle {
665        GainControlControlHandle { inner: self.inner.clone() }
666    }
667
668    fn into_inner(
669        self,
670    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
671    {
672        (self.inner, self.is_terminated)
673    }
674
675    fn from_inner(
676        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
677        is_terminated: bool,
678    ) -> Self {
679        Self { inner, is_terminated }
680    }
681}
682
683impl futures::Stream for GainControlRequestStream {
684    type Item = Result<GainControlRequest, fidl::Error>;
685
686    fn poll_next(
687        mut self: std::pin::Pin<&mut Self>,
688        cx: &mut std::task::Context<'_>,
689    ) -> std::task::Poll<Option<Self::Item>> {
690        let this = &mut *self;
691        if this.inner.check_shutdown(cx) {
692            this.is_terminated = true;
693            return std::task::Poll::Ready(None);
694        }
695        if this.is_terminated {
696            panic!("polled GainControlRequestStream after completion");
697        }
698        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
699            |bytes, handles| {
700                match this.inner.channel().read_etc(cx, bytes, handles) {
701                    std::task::Poll::Ready(Ok(())) => {}
702                    std::task::Poll::Pending => return std::task::Poll::Pending,
703                    std::task::Poll::Ready(Err(None)) => {
704                        this.is_terminated = true;
705                        return std::task::Poll::Ready(None);
706                    }
707                    std::task::Poll::Ready(Err(Some(e))) => {
708                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
709                            e.into(),
710                        ))));
711                    }
712                }
713
714                // A message has been received from the channel
715                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
716
717                std::task::Poll::Ready(Some(match header.ordinal {
718                    0x2fc070871d033f64 => {
719                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
720                        let mut req = fidl::new_empty!(
721                            GainControlSetGainRequest,
722                            fdomain_client::fidl::FDomainResourceDialect
723                        );
724                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<GainControlSetGainRequest>(&header, _body_bytes, handles, &mut req)?;
725                        let control_handle = GainControlControlHandle { inner: this.inner.clone() };
726                        Ok(GainControlRequest::SetGain { gain_db: req.gain_db, control_handle })
727                    }
728                    0x3a175b2d6979e8ea => {
729                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
730                        let mut req = fidl::new_empty!(
731                            GainControlSetGainWithRampRequest,
732                            fdomain_client::fidl::FDomainResourceDialect
733                        );
734                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<GainControlSetGainWithRampRequest>(&header, _body_bytes, handles, &mut req)?;
735                        let control_handle = GainControlControlHandle { inner: this.inner.clone() };
736                        Ok(GainControlRequest::SetGainWithRamp {
737                            gain_db: req.gain_db,
738                            duration: req.duration,
739                            ramp_type: req.ramp_type,
740
741                            control_handle,
742                        })
743                    }
744                    0x5415723c1e31448 => {
745                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
746                        let mut req = fidl::new_empty!(
747                            GainControlSetMuteRequest,
748                            fdomain_client::fidl::FDomainResourceDialect
749                        );
750                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<GainControlSetMuteRequest>(&header, _body_bytes, handles, &mut req)?;
751                        let control_handle = GainControlControlHandle { inner: this.inner.clone() };
752                        Ok(GainControlRequest::SetMute { muted: req.muted, control_handle })
753                    }
754                    _ => Err(fidl::Error::UnknownOrdinal {
755                        ordinal: header.ordinal,
756                        protocol_name:
757                            <GainControlMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
758                    }),
759                }))
760            },
761        )
762    }
763}
764
765/// Enables control and monitoring of audio gain. This interface is typically
766/// a tear-off of other interfaces. For example, `fuchsia.media.audio.Renderer`
767/// has a `BindGainControl` method that binds to a gain control that controls
768/// gain for the renderer.
769#[derive(Debug)]
770pub enum GainControlRequest {
771    /// Sets the gain in decibels.
772    SetGain { gain_db: f32, control_handle: GainControlControlHandle },
773    /// Smoothly changes gain from its current value to specified value, over the
774    /// specified duration (in milliseconds). If 'duration_ns' is 0, gain changes
775    /// immediately. Otherwise, gain changes only while the stream is running.
776    ///
777    /// Any active or pending ramp is cancelled by subsequent call to SetGain.
778    ///
779    /// There can be at most 1 active ramp at any time. Any active or pending
780    /// ramp is replaced by a later call to SetGainWithRamp (even if duration is
781    /// 0). In this case gain would ramps directly from its most recent
782    /// (mid-ramp) value to the newly-specified one, over the new duration,
783    /// using the new easing.
784    ///
785    /// Usage example (using time in seconds):
786    ///  Time 0
787    ///      SetGainWithRamp(`MUTED_GAIN_DB`, 0, SCALE_LINEAR)         // Ramp 1
788    ///      SetGainWithRamp(0.0f, `ZX_SEC`(4), SCALE_LINEAR)          // Ramp 2
789    ///  Time 3
790    ///      PlayNoReply(kNoTimestamp, any_media_time)
791    ///  Time 4
792    ///      PauseNoReply()
793    ///  Time 7
794    ///      PlayNoReply(kNoTimestamp, any_media_time)
795    ///  Time 8
796    ///      SetGainWithRamp(`MUTED_GAIN_DB`, ZX_SEC(1), SCALE_LINEAR) // Ramp 3
797    ///
798    ///
799    /// Time 0: Ramp 1 completes immediately, changing the gain to `MUTED_GAIN_DB`.
800    ///         Ramp 2 is pending, since we are not in playback.
801    /// Time 3, Ramp 2 begins ramping from `MUTED_GAIN_DB` to 0 dB
802    ///         (scale 0.0=>1.0).
803    /// Time 4: Ramp 2 pauses (3s remain). Per `SCALE_LINEAR`, scale is approx.
804    ///         0.25.
805    /// Time 7: Ramp 2 resumes from most recent value toward the target.
806    /// Time 8: Ramp 3 replaces Ramp 2 and starts from current scale
807    ///         (approx 0.5).
808    /// Time 9: Ramp 3 completes; current scale value is now 0.0 (`MUTED_GAIN_DB`).
809    SetGainWithRamp {
810        gain_db: f32,
811        duration: i64,
812        ramp_type: RampType,
813        control_handle: GainControlControlHandle,
814    },
815    /// Sets the mute value. Ramping and mute are fully independent, although
816    /// they both affect the scaling that is applied.
817    SetMute { muted: bool, control_handle: GainControlControlHandle },
818}
819
820impl GainControlRequest {
821    #[allow(irrefutable_let_patterns)]
822    pub fn into_set_gain(self) -> Option<(f32, GainControlControlHandle)> {
823        if let GainControlRequest::SetGain { gain_db, control_handle } = self {
824            Some((gain_db, control_handle))
825        } else {
826            None
827        }
828    }
829
830    #[allow(irrefutable_let_patterns)]
831    pub fn into_set_gain_with_ramp(self) -> Option<(f32, i64, RampType, GainControlControlHandle)> {
832        if let GainControlRequest::SetGainWithRamp {
833            gain_db,
834            duration,
835            ramp_type,
836            control_handle,
837        } = self
838        {
839            Some((gain_db, duration, ramp_type, control_handle))
840        } else {
841            None
842        }
843    }
844
845    #[allow(irrefutable_let_patterns)]
846    pub fn into_set_mute(self) -> Option<(bool, GainControlControlHandle)> {
847        if let GainControlRequest::SetMute { muted, control_handle } = self {
848            Some((muted, control_handle))
849        } else {
850            None
851        }
852    }
853
854    /// Name of the method defined in FIDL
855    pub fn method_name(&self) -> &'static str {
856        match *self {
857            GainControlRequest::SetGain { .. } => "set_gain",
858            GainControlRequest::SetGainWithRamp { .. } => "set_gain_with_ramp",
859            GainControlRequest::SetMute { .. } => "set_mute",
860        }
861    }
862}
863
864#[derive(Debug, Clone)]
865pub struct GainControlControlHandle {
866    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
867}
868
869impl GainControlControlHandle {
870    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
871        self.inner.shutdown_with_epitaph(status.into())
872    }
873}
874
875impl fdomain_client::fidl::ControlHandle for GainControlControlHandle {
876    fn shutdown(&self) {
877        self.inner.shutdown()
878    }
879
880    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
881        self.inner.shutdown_with_epitaph(status)
882    }
883
884    fn is_closed(&self) -> bool {
885        self.inner.channel().is_closed()
886    }
887    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
888        self.inner.channel().on_closed()
889    }
890}
891
892impl GainControlControlHandle {
893    pub fn send_on_gain_mute_changed(
894        &self,
895        mut gain_db: f32,
896        mut muted: bool,
897    ) -> Result<(), fidl::Error> {
898        self.inner.send::<GainControlOnGainMuteChangedRequest>(
899            (gain_db, muted),
900            0,
901            0x66d528cad4e0d753,
902            fidl::encoding::DynamicFlags::empty(),
903        )
904    }
905}
906
907#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
908pub struct VolumeControlMarker;
909
910impl fdomain_client::fidl::ProtocolMarker for VolumeControlMarker {
911    type Proxy = VolumeControlProxy;
912    type RequestStream = VolumeControlRequestStream;
913
914    const DEBUG_NAME: &'static str = "(anonymous) VolumeControl";
915}
916
917pub trait VolumeControlProxyInterface: Send + Sync {
918    fn r#set_volume(&self, volume: f32) -> Result<(), fidl::Error>;
919    fn r#set_mute(&self, mute: bool) -> Result<(), fidl::Error>;
920}
921
922#[derive(Debug, Clone)]
923pub struct VolumeControlProxy {
924    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
925}
926
927impl fdomain_client::fidl::Proxy for VolumeControlProxy {
928    type Protocol = VolumeControlMarker;
929
930    fn from_channel(inner: fdomain_client::Channel) -> Self {
931        Self::new(inner)
932    }
933
934    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
935        self.client.into_channel().map_err(|client| Self { client })
936    }
937
938    fn as_channel(&self) -> &fdomain_client::Channel {
939        self.client.as_channel()
940    }
941}
942
943impl VolumeControlProxy {
944    /// Create a new Proxy for fuchsia.media.audio/VolumeControl.
945    pub fn new(channel: fdomain_client::Channel) -> Self {
946        let protocol_name =
947            <VolumeControlMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
948        Self { client: fidl::client::Client::new(channel, protocol_name) }
949    }
950
951    /// Get a Stream of events from the remote end of the protocol.
952    ///
953    /// # Panics
954    ///
955    /// Panics if the event stream was already taken.
956    pub fn take_event_stream(&self) -> VolumeControlEventStream {
957        VolumeControlEventStream { event_receiver: self.client.take_event_receiver() }
958    }
959
960    /// Sets the volume of the audio element to the given value in
961    /// [0.0, 1.0]. If the value is provided is outside of [0.0, 1.0],
962    /// the value is clamped before application.
963    pub fn r#set_volume(&self, mut volume: f32) -> Result<(), fidl::Error> {
964        VolumeControlProxyInterface::r#set_volume(self, volume)
965    }
966
967    /// Sets whether the controlled element is muted. Mute is not the same
968    /// as setting volume to 0.0; volume will persist for the duration of
969    /// a mute. If volume was 0.5 before mute, volume will resume at 0.5
970    /// following unmute.
971    pub fn r#set_mute(&self, mut mute: bool) -> Result<(), fidl::Error> {
972        VolumeControlProxyInterface::r#set_mute(self, mute)
973    }
974}
975
976impl VolumeControlProxyInterface for VolumeControlProxy {
977    fn r#set_volume(&self, mut volume: f32) -> Result<(), fidl::Error> {
978        self.client.send::<VolumeControlSetVolumeRequest>(
979            (volume,),
980            0x6ff4231809a697da,
981            fidl::encoding::DynamicFlags::empty(),
982        )
983    }
984
985    fn r#set_mute(&self, mut mute: bool) -> Result<(), fidl::Error> {
986        self.client.send::<VolumeControlSetMuteRequest>(
987            (mute,),
988            0x50c10c28bba46425,
989            fidl::encoding::DynamicFlags::empty(),
990        )
991    }
992}
993
994pub struct VolumeControlEventStream {
995    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
996}
997
998impl std::marker::Unpin for VolumeControlEventStream {}
999
1000impl futures::stream::FusedStream for VolumeControlEventStream {
1001    fn is_terminated(&self) -> bool {
1002        self.event_receiver.is_terminated()
1003    }
1004}
1005
1006impl futures::Stream for VolumeControlEventStream {
1007    type Item = Result<VolumeControlEvent, fidl::Error>;
1008
1009    fn poll_next(
1010        mut self: std::pin::Pin<&mut Self>,
1011        cx: &mut std::task::Context<'_>,
1012    ) -> std::task::Poll<Option<Self::Item>> {
1013        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1014            &mut self.event_receiver,
1015            cx
1016        )?) {
1017            Some(buf) => std::task::Poll::Ready(Some(VolumeControlEvent::decode(buf))),
1018            None => std::task::Poll::Ready(None),
1019        }
1020    }
1021}
1022
1023#[derive(Debug)]
1024pub enum VolumeControlEvent {
1025    OnVolumeMuteChanged { new_volume: f32, new_muted: bool },
1026}
1027
1028impl VolumeControlEvent {
1029    #[allow(irrefutable_let_patterns)]
1030    pub fn into_on_volume_mute_changed(self) -> Option<(f32, bool)> {
1031        if let VolumeControlEvent::OnVolumeMuteChanged { new_volume, new_muted } = self {
1032            Some((new_volume, new_muted))
1033        } else {
1034            None
1035        }
1036    }
1037
1038    /// Decodes a message buffer as a [`VolumeControlEvent`].
1039    fn decode(
1040        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1041    ) -> Result<VolumeControlEvent, fidl::Error> {
1042        let (bytes, _handles) = buf.split_mut();
1043        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1044        debug_assert_eq!(tx_header.tx_id, 0);
1045        match tx_header.ordinal {
1046            0x9cea352bd86c171 => {
1047                let mut out = fidl::new_empty!(
1048                    VolumeControlOnVolumeMuteChangedRequest,
1049                    fdomain_client::fidl::FDomainResourceDialect
1050                );
1051                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<VolumeControlOnVolumeMuteChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1052                Ok((VolumeControlEvent::OnVolumeMuteChanged {
1053                    new_volume: out.new_volume,
1054                    new_muted: out.new_muted,
1055                }))
1056            }
1057            _ => Err(fidl::Error::UnknownOrdinal {
1058                ordinal: tx_header.ordinal,
1059                protocol_name:
1060                    <VolumeControlMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1061            }),
1062        }
1063    }
1064}
1065
1066/// A Stream of incoming requests for fuchsia.media.audio/VolumeControl.
1067pub struct VolumeControlRequestStream {
1068    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1069    is_terminated: bool,
1070}
1071
1072impl std::marker::Unpin for VolumeControlRequestStream {}
1073
1074impl futures::stream::FusedStream for VolumeControlRequestStream {
1075    fn is_terminated(&self) -> bool {
1076        self.is_terminated
1077    }
1078}
1079
1080impl fdomain_client::fidl::RequestStream for VolumeControlRequestStream {
1081    type Protocol = VolumeControlMarker;
1082    type ControlHandle = VolumeControlControlHandle;
1083
1084    fn from_channel(channel: fdomain_client::Channel) -> Self {
1085        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1086    }
1087
1088    fn control_handle(&self) -> Self::ControlHandle {
1089        VolumeControlControlHandle { inner: self.inner.clone() }
1090    }
1091
1092    fn into_inner(
1093        self,
1094    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
1095    {
1096        (self.inner, self.is_terminated)
1097    }
1098
1099    fn from_inner(
1100        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1101        is_terminated: bool,
1102    ) -> Self {
1103        Self { inner, is_terminated }
1104    }
1105}
1106
1107impl futures::Stream for VolumeControlRequestStream {
1108    type Item = Result<VolumeControlRequest, fidl::Error>;
1109
1110    fn poll_next(
1111        mut self: std::pin::Pin<&mut Self>,
1112        cx: &mut std::task::Context<'_>,
1113    ) -> std::task::Poll<Option<Self::Item>> {
1114        let this = &mut *self;
1115        if this.inner.check_shutdown(cx) {
1116            this.is_terminated = true;
1117            return std::task::Poll::Ready(None);
1118        }
1119        if this.is_terminated {
1120            panic!("polled VolumeControlRequestStream after completion");
1121        }
1122        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
1123            |bytes, handles| {
1124                match this.inner.channel().read_etc(cx, bytes, handles) {
1125                    std::task::Poll::Ready(Ok(())) => {}
1126                    std::task::Poll::Pending => return std::task::Poll::Pending,
1127                    std::task::Poll::Ready(Err(None)) => {
1128                        this.is_terminated = true;
1129                        return std::task::Poll::Ready(None);
1130                    }
1131                    std::task::Poll::Ready(Err(Some(e))) => {
1132                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1133                            e.into(),
1134                        ))));
1135                    }
1136                }
1137
1138                // A message has been received from the channel
1139                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1140
1141                std::task::Poll::Ready(Some(match header.ordinal {
1142                0x6ff4231809a697da => {
1143                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1144                    let mut req = fidl::new_empty!(VolumeControlSetVolumeRequest, fdomain_client::fidl::FDomainResourceDialect);
1145                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<VolumeControlSetVolumeRequest>(&header, _body_bytes, handles, &mut req)?;
1146                    let control_handle = VolumeControlControlHandle {
1147                        inner: this.inner.clone(),
1148                    };
1149                    Ok(VolumeControlRequest::SetVolume {volume: req.volume,
1150
1151                        control_handle,
1152                    })
1153                }
1154                0x50c10c28bba46425 => {
1155                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1156                    let mut req = fidl::new_empty!(VolumeControlSetMuteRequest, fdomain_client::fidl::FDomainResourceDialect);
1157                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<VolumeControlSetMuteRequest>(&header, _body_bytes, handles, &mut req)?;
1158                    let control_handle = VolumeControlControlHandle {
1159                        inner: this.inner.clone(),
1160                    };
1161                    Ok(VolumeControlRequest::SetMute {mute: req.mute,
1162
1163                        control_handle,
1164                    })
1165                }
1166                _ => Err(fidl::Error::UnknownOrdinal {
1167                    ordinal: header.ordinal,
1168                    protocol_name: <VolumeControlMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1169                }),
1170            }))
1171            },
1172        )
1173    }
1174}
1175
1176/// A protocol for controlling volume.
1177#[derive(Debug)]
1178pub enum VolumeControlRequest {
1179    /// Sets the volume of the audio element to the given value in
1180    /// [0.0, 1.0]. If the value is provided is outside of [0.0, 1.0],
1181    /// the value is clamped before application.
1182    SetVolume { volume: f32, control_handle: VolumeControlControlHandle },
1183    /// Sets whether the controlled element is muted. Mute is not the same
1184    /// as setting volume to 0.0; volume will persist for the duration of
1185    /// a mute. If volume was 0.5 before mute, volume will resume at 0.5
1186    /// following unmute.
1187    SetMute { mute: bool, control_handle: VolumeControlControlHandle },
1188}
1189
1190impl VolumeControlRequest {
1191    #[allow(irrefutable_let_patterns)]
1192    pub fn into_set_volume(self) -> Option<(f32, VolumeControlControlHandle)> {
1193        if let VolumeControlRequest::SetVolume { volume, control_handle } = self {
1194            Some((volume, control_handle))
1195        } else {
1196            None
1197        }
1198    }
1199
1200    #[allow(irrefutable_let_patterns)]
1201    pub fn into_set_mute(self) -> Option<(bool, VolumeControlControlHandle)> {
1202        if let VolumeControlRequest::SetMute { mute, control_handle } = self {
1203            Some((mute, control_handle))
1204        } else {
1205            None
1206        }
1207    }
1208
1209    /// Name of the method defined in FIDL
1210    pub fn method_name(&self) -> &'static str {
1211        match *self {
1212            VolumeControlRequest::SetVolume { .. } => "set_volume",
1213            VolumeControlRequest::SetMute { .. } => "set_mute",
1214        }
1215    }
1216}
1217
1218#[derive(Debug, Clone)]
1219pub struct VolumeControlControlHandle {
1220    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1221}
1222
1223impl VolumeControlControlHandle {
1224    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1225        self.inner.shutdown_with_epitaph(status.into())
1226    }
1227}
1228
1229impl fdomain_client::fidl::ControlHandle for VolumeControlControlHandle {
1230    fn shutdown(&self) {
1231        self.inner.shutdown()
1232    }
1233
1234    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1235        self.inner.shutdown_with_epitaph(status)
1236    }
1237
1238    fn is_closed(&self) -> bool {
1239        self.inner.channel().is_closed()
1240    }
1241    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1242        self.inner.channel().on_closed()
1243    }
1244}
1245
1246impl VolumeControlControlHandle {
1247    pub fn send_on_volume_mute_changed(
1248        &self,
1249        mut new_volume: f32,
1250        mut new_muted: bool,
1251    ) -> Result<(), fidl::Error> {
1252        self.inner.send::<VolumeControlOnVolumeMuteChangedRequest>(
1253            (new_volume, new_muted),
1254            0,
1255            0x9cea352bd86c171,
1256            fidl::encoding::DynamicFlags::empty(),
1257        )
1258    }
1259}
1260
1261mod internal {
1262    use super::*;
1263}