fidl_fuchsia_bluetooth_hfp/
fidl_fuchsia_bluetooth_hfp.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_bluetooth_hfp_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct CallManagerPeerConnectedRequest {
16    pub id: fidl_fuchsia_bluetooth::PeerId,
17    pub handle: fidl::endpoints::ServerEnd<PeerHandlerMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for CallManagerPeerConnectedRequest
22{
23}
24
25#[derive(Debug, PartialEq)]
26pub struct HandsFreeWatchPeerConnectedResponse {
27    pub id: fidl_fuchsia_bluetooth::PeerId,
28    pub handle: fidl::endpoints::ClientEnd<PeerHandlerMarker>,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
32    for HandsFreeWatchPeerConnectedResponse
33{
34}
35
36#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
37pub struct HfpRegisterRequest {
38    pub manager: fidl::endpoints::ClientEnd<CallManagerMarker>,
39}
40
41impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for HfpRegisterRequest {}
42
43#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
44pub struct PeerHandlerGainControlRequest {
45    pub control: fidl::endpoints::ClientEnd<HeadsetGainMarker>,
46}
47
48impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
49    for PeerHandlerGainControlRequest
50{
51}
52
53#[derive(Debug, PartialEq)]
54pub struct PeerHandlerWatchNextCallResponse {
55    pub call: NextCall,
56}
57
58impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
59    for PeerHandlerWatchNextCallResponse
60{
61}
62
63/// Information for the next call reported by a Peer Handler.
64#[derive(Debug, Default, PartialEq)]
65pub struct NextCall {
66    /// Channel for this call.
67    /// This field is required.
68    pub call: Option<fidl::endpoints::ClientEnd<CallMarker>>,
69    /// The Number of the remote party on the call.
70    /// This field is required.
71    pub remote: Option<String>,
72    /// State of the call when it is reported by the Peer Handler.
73    /// This field is required.
74    pub state: Option<CallState>,
75    /// Direction of the call's initiation. See `CallDirection` documentation
76    /// for more information.
77    /// This field is required.
78    pub direction: Option<CallDirection>,
79    #[doc(hidden)]
80    pub __source_breaking: fidl::marker::SourceBreaking,
81}
82
83impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NextCall {}
84
85#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
86pub struct CallMarker;
87
88impl fidl::endpoints::ProtocolMarker for CallMarker {
89    type Proxy = CallProxy;
90    type RequestStream = CallRequestStream;
91    #[cfg(target_os = "fuchsia")]
92    type SynchronousProxy = CallSynchronousProxy;
93
94    const DEBUG_NAME: &'static str = "(anonymous) Call";
95}
96pub type CallSendDtmfCodeResult = Result<(), i32>;
97
98pub trait CallProxyInterface: Send + Sync {
99    type WatchStateResponseFut: std::future::Future<Output = Result<CallState, fidl::Error>> + Send;
100    fn r#watch_state(&self) -> Self::WatchStateResponseFut;
101    fn r#request_hold(&self) -> Result<(), fidl::Error>;
102    fn r#request_active(&self) -> Result<(), fidl::Error>;
103    fn r#request_terminate(&self) -> Result<(), fidl::Error>;
104    fn r#request_transfer_audio(&self) -> Result<(), fidl::Error>;
105    type SendDtmfCodeResponseFut: std::future::Future<Output = Result<CallSendDtmfCodeResult, fidl::Error>>
106        + Send;
107    fn r#send_dtmf_code(&self, code: DtmfCode) -> Self::SendDtmfCodeResponseFut;
108}
109#[derive(Debug)]
110#[cfg(target_os = "fuchsia")]
111pub struct CallSynchronousProxy {
112    client: fidl::client::sync::Client,
113}
114
115#[cfg(target_os = "fuchsia")]
116impl fidl::endpoints::SynchronousProxy for CallSynchronousProxy {
117    type Proxy = CallProxy;
118    type Protocol = CallMarker;
119
120    fn from_channel(inner: fidl::Channel) -> Self {
121        Self::new(inner)
122    }
123
124    fn into_channel(self) -> fidl::Channel {
125        self.client.into_channel()
126    }
127
128    fn as_channel(&self) -> &fidl::Channel {
129        self.client.as_channel()
130    }
131}
132
133#[cfg(target_os = "fuchsia")]
134impl CallSynchronousProxy {
135    pub fn new(channel: fidl::Channel) -> Self {
136        let protocol_name = <CallMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
137        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
138    }
139
140    pub fn into_channel(self) -> fidl::Channel {
141        self.client.into_channel()
142    }
143
144    /// Waits until an event arrives and returns it. It is safe for other
145    /// threads to make concurrent requests while waiting for an event.
146    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<CallEvent, fidl::Error> {
147        CallEvent::decode(self.client.wait_for_event(deadline)?)
148    }
149
150    /// A hanging get method for call state. See the `CallState` documentation
151    /// for information on possible states.
152    pub fn r#watch_state(
153        &self,
154        ___deadline: zx::MonotonicInstant,
155    ) -> Result<CallState, fidl::Error> {
156        let _response =
157            self.client.send_query::<fidl::encoding::EmptyPayload, CallWatchStateResponse>(
158                (),
159                0x5262bcc909bdaeb5,
160                fidl::encoding::DynamicFlags::empty(),
161                ___deadline,
162            )?;
163        Ok(_response.state)
164    }
165
166    /// Request that the Call be set to the ONGOING_HELD CallState
167    pub fn r#request_hold(&self) -> Result<(), fidl::Error> {
168        self.client.send::<fidl::encoding::EmptyPayload>(
169            (),
170            0x35ade403017d20eb,
171            fidl::encoding::DynamicFlags::empty(),
172        )
173    }
174
175    /// Request that the Call be set to the ONGOING_ACTIVE CallState.
176    /// This has the side effect of placing all other Calls that are routed to
177    /// this peer in the ONGOING_HELD call state if it succeeds.
178    pub fn r#request_active(&self) -> Result<(), fidl::Error> {
179        self.client.send::<fidl::encoding::EmptyPayload>(
180            (),
181            0x248518f967f1fe6e,
182            fidl::encoding::DynamicFlags::empty(),
183        )
184    }
185
186    /// Request that the Call be TERMINATED.
187    pub fn r#request_terminate(&self) -> Result<(), fidl::Error> {
188        self.client.send::<fidl::encoding::EmptyPayload>(
189            (),
190            0x4940915197ee4916,
191            fidl::encoding::DynamicFlags::empty(),
192        )
193    }
194
195    /// Request that the Call's audio be transfered to the Audio Gateway and
196    /// the call state set to TRANSFERRED_TO_AG.
197    pub fn r#request_transfer_audio(&self) -> Result<(), fidl::Error> {
198        self.client.send::<fidl::encoding::EmptyPayload>(
199            (),
200            0xb0ca6649f2e104c,
201            fidl::encoding::DynamicFlags::empty(),
202        )
203    }
204
205    /// Send a code that the call manager or remote audio gateway peer should
206    /// transmit to its network connection. The request returns after the code
207    /// has been transmitted to the network.
208    ///
209    /// Can return an error if the call manager or peer failed to transmit the
210    /// code to the network.
211    pub fn r#send_dtmf_code(
212        &self,
213        mut code: DtmfCode,
214        ___deadline: zx::MonotonicInstant,
215    ) -> Result<CallSendDtmfCodeResult, fidl::Error> {
216        let _response = self.client.send_query::<
217            CallSendDtmfCodeRequest,
218            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
219        >(
220            (code,),
221            0x50768933ca33fcd6,
222            fidl::encoding::DynamicFlags::empty(),
223            ___deadline,
224        )?;
225        Ok(_response.map(|x| x))
226    }
227}
228
229#[derive(Debug, Clone)]
230pub struct CallProxy {
231    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
232}
233
234impl fidl::endpoints::Proxy for CallProxy {
235    type Protocol = CallMarker;
236
237    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
238        Self::new(inner)
239    }
240
241    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
242        self.client.into_channel().map_err(|client| Self { client })
243    }
244
245    fn as_channel(&self) -> &::fidl::AsyncChannel {
246        self.client.as_channel()
247    }
248}
249
250impl CallProxy {
251    /// Create a new Proxy for fuchsia.bluetooth.hfp/Call.
252    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
253        let protocol_name = <CallMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
254        Self { client: fidl::client::Client::new(channel, protocol_name) }
255    }
256
257    /// Get a Stream of events from the remote end of the protocol.
258    ///
259    /// # Panics
260    ///
261    /// Panics if the event stream was already taken.
262    pub fn take_event_stream(&self) -> CallEventStream {
263        CallEventStream { event_receiver: self.client.take_event_receiver() }
264    }
265
266    /// A hanging get method for call state. See the `CallState` documentation
267    /// for information on possible states.
268    pub fn r#watch_state(
269        &self,
270    ) -> fidl::client::QueryResponseFut<CallState, fidl::encoding::DefaultFuchsiaResourceDialect>
271    {
272        CallProxyInterface::r#watch_state(self)
273    }
274
275    /// Request that the Call be set to the ONGOING_HELD CallState
276    pub fn r#request_hold(&self) -> Result<(), fidl::Error> {
277        CallProxyInterface::r#request_hold(self)
278    }
279
280    /// Request that the Call be set to the ONGOING_ACTIVE CallState.
281    /// This has the side effect of placing all other Calls that are routed to
282    /// this peer in the ONGOING_HELD call state if it succeeds.
283    pub fn r#request_active(&self) -> Result<(), fidl::Error> {
284        CallProxyInterface::r#request_active(self)
285    }
286
287    /// Request that the Call be TERMINATED.
288    pub fn r#request_terminate(&self) -> Result<(), fidl::Error> {
289        CallProxyInterface::r#request_terminate(self)
290    }
291
292    /// Request that the Call's audio be transfered to the Audio Gateway and
293    /// the call state set to TRANSFERRED_TO_AG.
294    pub fn r#request_transfer_audio(&self) -> Result<(), fidl::Error> {
295        CallProxyInterface::r#request_transfer_audio(self)
296    }
297
298    /// Send a code that the call manager or remote audio gateway peer should
299    /// transmit to its network connection. The request returns after the code
300    /// has been transmitted to the network.
301    ///
302    /// Can return an error if the call manager or peer failed to transmit the
303    /// code to the network.
304    pub fn r#send_dtmf_code(
305        &self,
306        mut code: DtmfCode,
307    ) -> fidl::client::QueryResponseFut<
308        CallSendDtmfCodeResult,
309        fidl::encoding::DefaultFuchsiaResourceDialect,
310    > {
311        CallProxyInterface::r#send_dtmf_code(self, code)
312    }
313}
314
315impl CallProxyInterface for CallProxy {
316    type WatchStateResponseFut =
317        fidl::client::QueryResponseFut<CallState, fidl::encoding::DefaultFuchsiaResourceDialect>;
318    fn r#watch_state(&self) -> Self::WatchStateResponseFut {
319        fn _decode(
320            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
321        ) -> Result<CallState, fidl::Error> {
322            let _response = fidl::client::decode_transaction_body::<
323                CallWatchStateResponse,
324                fidl::encoding::DefaultFuchsiaResourceDialect,
325                0x5262bcc909bdaeb5,
326            >(_buf?)?;
327            Ok(_response.state)
328        }
329        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, CallState>(
330            (),
331            0x5262bcc909bdaeb5,
332            fidl::encoding::DynamicFlags::empty(),
333            _decode,
334        )
335    }
336
337    fn r#request_hold(&self) -> Result<(), fidl::Error> {
338        self.client.send::<fidl::encoding::EmptyPayload>(
339            (),
340            0x35ade403017d20eb,
341            fidl::encoding::DynamicFlags::empty(),
342        )
343    }
344
345    fn r#request_active(&self) -> Result<(), fidl::Error> {
346        self.client.send::<fidl::encoding::EmptyPayload>(
347            (),
348            0x248518f967f1fe6e,
349            fidl::encoding::DynamicFlags::empty(),
350        )
351    }
352
353    fn r#request_terminate(&self) -> Result<(), fidl::Error> {
354        self.client.send::<fidl::encoding::EmptyPayload>(
355            (),
356            0x4940915197ee4916,
357            fidl::encoding::DynamicFlags::empty(),
358        )
359    }
360
361    fn r#request_transfer_audio(&self) -> Result<(), fidl::Error> {
362        self.client.send::<fidl::encoding::EmptyPayload>(
363            (),
364            0xb0ca6649f2e104c,
365            fidl::encoding::DynamicFlags::empty(),
366        )
367    }
368
369    type SendDtmfCodeResponseFut = fidl::client::QueryResponseFut<
370        CallSendDtmfCodeResult,
371        fidl::encoding::DefaultFuchsiaResourceDialect,
372    >;
373    fn r#send_dtmf_code(&self, mut code: DtmfCode) -> Self::SendDtmfCodeResponseFut {
374        fn _decode(
375            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
376        ) -> Result<CallSendDtmfCodeResult, fidl::Error> {
377            let _response = fidl::client::decode_transaction_body::<
378                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
379                fidl::encoding::DefaultFuchsiaResourceDialect,
380                0x50768933ca33fcd6,
381            >(_buf?)?;
382            Ok(_response.map(|x| x))
383        }
384        self.client.send_query_and_decode::<CallSendDtmfCodeRequest, CallSendDtmfCodeResult>(
385            (code,),
386            0x50768933ca33fcd6,
387            fidl::encoding::DynamicFlags::empty(),
388            _decode,
389        )
390    }
391}
392
393pub struct CallEventStream {
394    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
395}
396
397impl std::marker::Unpin for CallEventStream {}
398
399impl futures::stream::FusedStream for CallEventStream {
400    fn is_terminated(&self) -> bool {
401        self.event_receiver.is_terminated()
402    }
403}
404
405impl futures::Stream for CallEventStream {
406    type Item = Result<CallEvent, fidl::Error>;
407
408    fn poll_next(
409        mut self: std::pin::Pin<&mut Self>,
410        cx: &mut std::task::Context<'_>,
411    ) -> std::task::Poll<Option<Self::Item>> {
412        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
413            &mut self.event_receiver,
414            cx
415        )?) {
416            Some(buf) => std::task::Poll::Ready(Some(CallEvent::decode(buf))),
417            None => std::task::Poll::Ready(None),
418        }
419    }
420}
421
422#[derive(Debug)]
423pub enum CallEvent {}
424
425impl CallEvent {
426    /// Decodes a message buffer as a [`CallEvent`].
427    fn decode(
428        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
429    ) -> Result<CallEvent, fidl::Error> {
430        let (bytes, _handles) = buf.split_mut();
431        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
432        debug_assert_eq!(tx_header.tx_id, 0);
433        match tx_header.ordinal {
434            _ => Err(fidl::Error::UnknownOrdinal {
435                ordinal: tx_header.ordinal,
436                protocol_name: <CallMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
437            }),
438        }
439    }
440}
441
442/// A Stream of incoming requests for fuchsia.bluetooth.hfp/Call.
443pub struct CallRequestStream {
444    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
445    is_terminated: bool,
446}
447
448impl std::marker::Unpin for CallRequestStream {}
449
450impl futures::stream::FusedStream for CallRequestStream {
451    fn is_terminated(&self) -> bool {
452        self.is_terminated
453    }
454}
455
456impl fidl::endpoints::RequestStream for CallRequestStream {
457    type Protocol = CallMarker;
458    type ControlHandle = CallControlHandle;
459
460    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
461        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
462    }
463
464    fn control_handle(&self) -> Self::ControlHandle {
465        CallControlHandle { inner: self.inner.clone() }
466    }
467
468    fn into_inner(
469        self,
470    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
471    {
472        (self.inner, self.is_terminated)
473    }
474
475    fn from_inner(
476        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
477        is_terminated: bool,
478    ) -> Self {
479        Self { inner, is_terminated }
480    }
481}
482
483impl futures::Stream for CallRequestStream {
484    type Item = Result<CallRequest, fidl::Error>;
485
486    fn poll_next(
487        mut self: std::pin::Pin<&mut Self>,
488        cx: &mut std::task::Context<'_>,
489    ) -> std::task::Poll<Option<Self::Item>> {
490        let this = &mut *self;
491        if this.inner.check_shutdown(cx) {
492            this.is_terminated = true;
493            return std::task::Poll::Ready(None);
494        }
495        if this.is_terminated {
496            panic!("polled CallRequestStream after completion");
497        }
498        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
499            |bytes, handles| {
500                match this.inner.channel().read_etc(cx, bytes, handles) {
501                    std::task::Poll::Ready(Ok(())) => {}
502                    std::task::Poll::Pending => return std::task::Poll::Pending,
503                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
504                        this.is_terminated = true;
505                        return std::task::Poll::Ready(None);
506                    }
507                    std::task::Poll::Ready(Err(e)) => {
508                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
509                            e.into(),
510                        ))))
511                    }
512                }
513
514                // A message has been received from the channel
515                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
516
517                std::task::Poll::Ready(Some(match header.ordinal {
518                    0x5262bcc909bdaeb5 => {
519                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
520                        let mut req = fidl::new_empty!(
521                            fidl::encoding::EmptyPayload,
522                            fidl::encoding::DefaultFuchsiaResourceDialect
523                        );
524                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
525                        let control_handle = CallControlHandle { inner: this.inner.clone() };
526                        Ok(CallRequest::WatchState {
527                            responder: CallWatchStateResponder {
528                                control_handle: std::mem::ManuallyDrop::new(control_handle),
529                                tx_id: header.tx_id,
530                            },
531                        })
532                    }
533                    0x35ade403017d20eb => {
534                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
535                        let mut req = fidl::new_empty!(
536                            fidl::encoding::EmptyPayload,
537                            fidl::encoding::DefaultFuchsiaResourceDialect
538                        );
539                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
540                        let control_handle = CallControlHandle { inner: this.inner.clone() };
541                        Ok(CallRequest::RequestHold { control_handle })
542                    }
543                    0x248518f967f1fe6e => {
544                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
545                        let mut req = fidl::new_empty!(
546                            fidl::encoding::EmptyPayload,
547                            fidl::encoding::DefaultFuchsiaResourceDialect
548                        );
549                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
550                        let control_handle = CallControlHandle { inner: this.inner.clone() };
551                        Ok(CallRequest::RequestActive { control_handle })
552                    }
553                    0x4940915197ee4916 => {
554                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
555                        let mut req = fidl::new_empty!(
556                            fidl::encoding::EmptyPayload,
557                            fidl::encoding::DefaultFuchsiaResourceDialect
558                        );
559                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
560                        let control_handle = CallControlHandle { inner: this.inner.clone() };
561                        Ok(CallRequest::RequestTerminate { control_handle })
562                    }
563                    0xb0ca6649f2e104c => {
564                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
565                        let mut req = fidl::new_empty!(
566                            fidl::encoding::EmptyPayload,
567                            fidl::encoding::DefaultFuchsiaResourceDialect
568                        );
569                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
570                        let control_handle = CallControlHandle { inner: this.inner.clone() };
571                        Ok(CallRequest::RequestTransferAudio { control_handle })
572                    }
573                    0x50768933ca33fcd6 => {
574                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
575                        let mut req = fidl::new_empty!(
576                            CallSendDtmfCodeRequest,
577                            fidl::encoding::DefaultFuchsiaResourceDialect
578                        );
579                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CallSendDtmfCodeRequest>(&header, _body_bytes, handles, &mut req)?;
580                        let control_handle = CallControlHandle { inner: this.inner.clone() };
581                        Ok(CallRequest::SendDtmfCode {
582                            code: req.code,
583
584                            responder: CallSendDtmfCodeResponder {
585                                control_handle: std::mem::ManuallyDrop::new(control_handle),
586                                tx_id: header.tx_id,
587                            },
588                        })
589                    }
590                    _ => Err(fidl::Error::UnknownOrdinal {
591                        ordinal: header.ordinal,
592                        protocol_name: <CallMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
593                    }),
594                }))
595            },
596        )
597    }
598}
599
600/// Controls the lifecycle of a call that has been routed through a headset.
601#[derive(Debug)]
602pub enum CallRequest {
603    /// A hanging get method for call state. See the `CallState` documentation
604    /// for information on possible states.
605    WatchState { responder: CallWatchStateResponder },
606    /// Request that the Call be set to the ONGOING_HELD CallState
607    RequestHold { control_handle: CallControlHandle },
608    /// Request that the Call be set to the ONGOING_ACTIVE CallState.
609    /// This has the side effect of placing all other Calls that are routed to
610    /// this peer in the ONGOING_HELD call state if it succeeds.
611    RequestActive { control_handle: CallControlHandle },
612    /// Request that the Call be TERMINATED.
613    RequestTerminate { control_handle: CallControlHandle },
614    /// Request that the Call's audio be transfered to the Audio Gateway and
615    /// the call state set to TRANSFERRED_TO_AG.
616    RequestTransferAudio { control_handle: CallControlHandle },
617    /// Send a code that the call manager or remote audio gateway peer should
618    /// transmit to its network connection. The request returns after the code
619    /// has been transmitted to the network.
620    ///
621    /// Can return an error if the call manager or peer failed to transmit the
622    /// code to the network.
623    SendDtmfCode { code: DtmfCode, responder: CallSendDtmfCodeResponder },
624}
625
626impl CallRequest {
627    #[allow(irrefutable_let_patterns)]
628    pub fn into_watch_state(self) -> Option<(CallWatchStateResponder)> {
629        if let CallRequest::WatchState { responder } = self {
630            Some((responder))
631        } else {
632            None
633        }
634    }
635
636    #[allow(irrefutable_let_patterns)]
637    pub fn into_request_hold(self) -> Option<(CallControlHandle)> {
638        if let CallRequest::RequestHold { control_handle } = self {
639            Some((control_handle))
640        } else {
641            None
642        }
643    }
644
645    #[allow(irrefutable_let_patterns)]
646    pub fn into_request_active(self) -> Option<(CallControlHandle)> {
647        if let CallRequest::RequestActive { control_handle } = self {
648            Some((control_handle))
649        } else {
650            None
651        }
652    }
653
654    #[allow(irrefutable_let_patterns)]
655    pub fn into_request_terminate(self) -> Option<(CallControlHandle)> {
656        if let CallRequest::RequestTerminate { control_handle } = self {
657            Some((control_handle))
658        } else {
659            None
660        }
661    }
662
663    #[allow(irrefutable_let_patterns)]
664    pub fn into_request_transfer_audio(self) -> Option<(CallControlHandle)> {
665        if let CallRequest::RequestTransferAudio { control_handle } = self {
666            Some((control_handle))
667        } else {
668            None
669        }
670    }
671
672    #[allow(irrefutable_let_patterns)]
673    pub fn into_send_dtmf_code(self) -> Option<(DtmfCode, CallSendDtmfCodeResponder)> {
674        if let CallRequest::SendDtmfCode { code, responder } = self {
675            Some((code, responder))
676        } else {
677            None
678        }
679    }
680
681    /// Name of the method defined in FIDL
682    pub fn method_name(&self) -> &'static str {
683        match *self {
684            CallRequest::WatchState { .. } => "watch_state",
685            CallRequest::RequestHold { .. } => "request_hold",
686            CallRequest::RequestActive { .. } => "request_active",
687            CallRequest::RequestTerminate { .. } => "request_terminate",
688            CallRequest::RequestTransferAudio { .. } => "request_transfer_audio",
689            CallRequest::SendDtmfCode { .. } => "send_dtmf_code",
690        }
691    }
692}
693
694#[derive(Debug, Clone)]
695pub struct CallControlHandle {
696    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
697}
698
699impl fidl::endpoints::ControlHandle for CallControlHandle {
700    fn shutdown(&self) {
701        self.inner.shutdown()
702    }
703    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
704        self.inner.shutdown_with_epitaph(status)
705    }
706
707    fn is_closed(&self) -> bool {
708        self.inner.channel().is_closed()
709    }
710    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
711        self.inner.channel().on_closed()
712    }
713
714    #[cfg(target_os = "fuchsia")]
715    fn signal_peer(
716        &self,
717        clear_mask: zx::Signals,
718        set_mask: zx::Signals,
719    ) -> Result<(), zx_status::Status> {
720        use fidl::Peered;
721        self.inner.channel().signal_peer(clear_mask, set_mask)
722    }
723}
724
725impl CallControlHandle {}
726
727#[must_use = "FIDL methods require a response to be sent"]
728#[derive(Debug)]
729pub struct CallWatchStateResponder {
730    control_handle: std::mem::ManuallyDrop<CallControlHandle>,
731    tx_id: u32,
732}
733
734/// Set the the channel to be shutdown (see [`CallControlHandle::shutdown`])
735/// if the responder is dropped without sending a response, so that the client
736/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
737impl std::ops::Drop for CallWatchStateResponder {
738    fn drop(&mut self) {
739        self.control_handle.shutdown();
740        // Safety: drops once, never accessed again
741        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
742    }
743}
744
745impl fidl::endpoints::Responder for CallWatchStateResponder {
746    type ControlHandle = CallControlHandle;
747
748    fn control_handle(&self) -> &CallControlHandle {
749        &self.control_handle
750    }
751
752    fn drop_without_shutdown(mut self) {
753        // Safety: drops once, never accessed again due to mem::forget
754        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
755        // Prevent Drop from running (which would shut down the channel)
756        std::mem::forget(self);
757    }
758}
759
760impl CallWatchStateResponder {
761    /// Sends a response to the FIDL transaction.
762    ///
763    /// Sets the channel to shutdown if an error occurs.
764    pub fn send(self, mut state: CallState) -> Result<(), fidl::Error> {
765        let _result = self.send_raw(state);
766        if _result.is_err() {
767            self.control_handle.shutdown();
768        }
769        self.drop_without_shutdown();
770        _result
771    }
772
773    /// Similar to "send" but does not shutdown the channel if an error occurs.
774    pub fn send_no_shutdown_on_err(self, mut state: CallState) -> Result<(), fidl::Error> {
775        let _result = self.send_raw(state);
776        self.drop_without_shutdown();
777        _result
778    }
779
780    fn send_raw(&self, mut state: CallState) -> Result<(), fidl::Error> {
781        self.control_handle.inner.send::<CallWatchStateResponse>(
782            (state,),
783            self.tx_id,
784            0x5262bcc909bdaeb5,
785            fidl::encoding::DynamicFlags::empty(),
786        )
787    }
788}
789
790#[must_use = "FIDL methods require a response to be sent"]
791#[derive(Debug)]
792pub struct CallSendDtmfCodeResponder {
793    control_handle: std::mem::ManuallyDrop<CallControlHandle>,
794    tx_id: u32,
795}
796
797/// Set the the channel to be shutdown (see [`CallControlHandle::shutdown`])
798/// if the responder is dropped without sending a response, so that the client
799/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
800impl std::ops::Drop for CallSendDtmfCodeResponder {
801    fn drop(&mut self) {
802        self.control_handle.shutdown();
803        // Safety: drops once, never accessed again
804        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
805    }
806}
807
808impl fidl::endpoints::Responder for CallSendDtmfCodeResponder {
809    type ControlHandle = CallControlHandle;
810
811    fn control_handle(&self) -> &CallControlHandle {
812        &self.control_handle
813    }
814
815    fn drop_without_shutdown(mut self) {
816        // Safety: drops once, never accessed again due to mem::forget
817        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
818        // Prevent Drop from running (which would shut down the channel)
819        std::mem::forget(self);
820    }
821}
822
823impl CallSendDtmfCodeResponder {
824    /// Sends a response to the FIDL transaction.
825    ///
826    /// Sets the channel to shutdown if an error occurs.
827    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
828        let _result = self.send_raw(result);
829        if _result.is_err() {
830            self.control_handle.shutdown();
831        }
832        self.drop_without_shutdown();
833        _result
834    }
835
836    /// Similar to "send" but does not shutdown the channel if an error occurs.
837    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
838        let _result = self.send_raw(result);
839        self.drop_without_shutdown();
840        _result
841    }
842
843    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
844        self.control_handle
845            .inner
846            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
847                result,
848                self.tx_id,
849                0x50768933ca33fcd6,
850                fidl::encoding::DynamicFlags::empty(),
851            )
852    }
853}
854
855#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
856pub struct CallManagerMarker;
857
858impl fidl::endpoints::ProtocolMarker for CallManagerMarker {
859    type Proxy = CallManagerProxy;
860    type RequestStream = CallManagerRequestStream;
861    #[cfg(target_os = "fuchsia")]
862    type SynchronousProxy = CallManagerSynchronousProxy;
863
864    const DEBUG_NAME: &'static str = "(anonymous) CallManager";
865}
866
867pub trait CallManagerProxyInterface: Send + Sync {
868    type PeerConnectedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
869    fn r#peer_connected(
870        &self,
871        id: &fidl_fuchsia_bluetooth::PeerId,
872        handle: fidl::endpoints::ServerEnd<PeerHandlerMarker>,
873    ) -> Self::PeerConnectedResponseFut;
874}
875#[derive(Debug)]
876#[cfg(target_os = "fuchsia")]
877pub struct CallManagerSynchronousProxy {
878    client: fidl::client::sync::Client,
879}
880
881#[cfg(target_os = "fuchsia")]
882impl fidl::endpoints::SynchronousProxy for CallManagerSynchronousProxy {
883    type Proxy = CallManagerProxy;
884    type Protocol = CallManagerMarker;
885
886    fn from_channel(inner: fidl::Channel) -> Self {
887        Self::new(inner)
888    }
889
890    fn into_channel(self) -> fidl::Channel {
891        self.client.into_channel()
892    }
893
894    fn as_channel(&self) -> &fidl::Channel {
895        self.client.as_channel()
896    }
897}
898
899#[cfg(target_os = "fuchsia")]
900impl CallManagerSynchronousProxy {
901    pub fn new(channel: fidl::Channel) -> Self {
902        let protocol_name = <CallManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
903        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
904    }
905
906    pub fn into_channel(self) -> fidl::Channel {
907        self.client.into_channel()
908    }
909
910    /// Waits until an event arrives and returns it. It is safe for other
911    /// threads to make concurrent requests while waiting for an event.
912    pub fn wait_for_event(
913        &self,
914        deadline: zx::MonotonicInstant,
915    ) -> Result<CallManagerEvent, fidl::Error> {
916        CallManagerEvent::decode(self.client.wait_for_event(deadline)?)
917    }
918
919    /// Signal that a peer that supports the HFP Hands-Free role is connected.
920    ///
921    /// `id` is the unique identifier associated with the peer.
922    /// `handle` is the channel that the call manager should use to manage
923    /// a the peer. If the call manager does not intend to handle a given peer,
924    /// it must close the handle with a `ZX_ERR_UNAVAILABLE` epitaph.
925    ///
926    /// Multiple concurrent PeerConnected requests can be made by the client.
927    /// The empty response is used as a flow control mechanism to allow the
928    /// client to limit the number of pending PeerConnected requests.
929    pub fn r#peer_connected(
930        &self,
931        mut id: &fidl_fuchsia_bluetooth::PeerId,
932        mut handle: fidl::endpoints::ServerEnd<PeerHandlerMarker>,
933        ___deadline: zx::MonotonicInstant,
934    ) -> Result<(), fidl::Error> {
935        let _response = self
936            .client
937            .send_query::<CallManagerPeerConnectedRequest, fidl::encoding::EmptyPayload>(
938                (id, handle),
939                0x1431cc24b2980086,
940                fidl::encoding::DynamicFlags::empty(),
941                ___deadline,
942            )?;
943        Ok(_response)
944    }
945}
946
947#[derive(Debug, Clone)]
948pub struct CallManagerProxy {
949    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
950}
951
952impl fidl::endpoints::Proxy for CallManagerProxy {
953    type Protocol = CallManagerMarker;
954
955    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
956        Self::new(inner)
957    }
958
959    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
960        self.client.into_channel().map_err(|client| Self { client })
961    }
962
963    fn as_channel(&self) -> &::fidl::AsyncChannel {
964        self.client.as_channel()
965    }
966}
967
968impl CallManagerProxy {
969    /// Create a new Proxy for fuchsia.bluetooth.hfp/CallManager.
970    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
971        let protocol_name = <CallManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
972        Self { client: fidl::client::Client::new(channel, protocol_name) }
973    }
974
975    /// Get a Stream of events from the remote end of the protocol.
976    ///
977    /// # Panics
978    ///
979    /// Panics if the event stream was already taken.
980    pub fn take_event_stream(&self) -> CallManagerEventStream {
981        CallManagerEventStream { event_receiver: self.client.take_event_receiver() }
982    }
983
984    /// Signal that a peer that supports the HFP Hands-Free role is connected.
985    ///
986    /// `id` is the unique identifier associated with the peer.
987    /// `handle` is the channel that the call manager should use to manage
988    /// a the peer. If the call manager does not intend to handle a given peer,
989    /// it must close the handle with a `ZX_ERR_UNAVAILABLE` epitaph.
990    ///
991    /// Multiple concurrent PeerConnected requests can be made by the client.
992    /// The empty response is used as a flow control mechanism to allow the
993    /// client to limit the number of pending PeerConnected requests.
994    pub fn r#peer_connected(
995        &self,
996        mut id: &fidl_fuchsia_bluetooth::PeerId,
997        mut handle: fidl::endpoints::ServerEnd<PeerHandlerMarker>,
998    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
999        CallManagerProxyInterface::r#peer_connected(self, id, handle)
1000    }
1001}
1002
1003impl CallManagerProxyInterface for CallManagerProxy {
1004    type PeerConnectedResponseFut =
1005        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1006    fn r#peer_connected(
1007        &self,
1008        mut id: &fidl_fuchsia_bluetooth::PeerId,
1009        mut handle: fidl::endpoints::ServerEnd<PeerHandlerMarker>,
1010    ) -> Self::PeerConnectedResponseFut {
1011        fn _decode(
1012            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1013        ) -> Result<(), fidl::Error> {
1014            let _response = fidl::client::decode_transaction_body::<
1015                fidl::encoding::EmptyPayload,
1016                fidl::encoding::DefaultFuchsiaResourceDialect,
1017                0x1431cc24b2980086,
1018            >(_buf?)?;
1019            Ok(_response)
1020        }
1021        self.client.send_query_and_decode::<CallManagerPeerConnectedRequest, ()>(
1022            (id, handle),
1023            0x1431cc24b2980086,
1024            fidl::encoding::DynamicFlags::empty(),
1025            _decode,
1026        )
1027    }
1028}
1029
1030pub struct CallManagerEventStream {
1031    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1032}
1033
1034impl std::marker::Unpin for CallManagerEventStream {}
1035
1036impl futures::stream::FusedStream for CallManagerEventStream {
1037    fn is_terminated(&self) -> bool {
1038        self.event_receiver.is_terminated()
1039    }
1040}
1041
1042impl futures::Stream for CallManagerEventStream {
1043    type Item = Result<CallManagerEvent, fidl::Error>;
1044
1045    fn poll_next(
1046        mut self: std::pin::Pin<&mut Self>,
1047        cx: &mut std::task::Context<'_>,
1048    ) -> std::task::Poll<Option<Self::Item>> {
1049        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1050            &mut self.event_receiver,
1051            cx
1052        )?) {
1053            Some(buf) => std::task::Poll::Ready(Some(CallManagerEvent::decode(buf))),
1054            None => std::task::Poll::Ready(None),
1055        }
1056    }
1057}
1058
1059#[derive(Debug)]
1060pub enum CallManagerEvent {}
1061
1062impl CallManagerEvent {
1063    /// Decodes a message buffer as a [`CallManagerEvent`].
1064    fn decode(
1065        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1066    ) -> Result<CallManagerEvent, fidl::Error> {
1067        let (bytes, _handles) = buf.split_mut();
1068        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1069        debug_assert_eq!(tx_header.tx_id, 0);
1070        match tx_header.ordinal {
1071            _ => Err(fidl::Error::UnknownOrdinal {
1072                ordinal: tx_header.ordinal,
1073                protocol_name: <CallManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1074            }),
1075        }
1076    }
1077}
1078
1079/// A Stream of incoming requests for fuchsia.bluetooth.hfp/CallManager.
1080pub struct CallManagerRequestStream {
1081    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1082    is_terminated: bool,
1083}
1084
1085impl std::marker::Unpin for CallManagerRequestStream {}
1086
1087impl futures::stream::FusedStream for CallManagerRequestStream {
1088    fn is_terminated(&self) -> bool {
1089        self.is_terminated
1090    }
1091}
1092
1093impl fidl::endpoints::RequestStream for CallManagerRequestStream {
1094    type Protocol = CallManagerMarker;
1095    type ControlHandle = CallManagerControlHandle;
1096
1097    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1098        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1099    }
1100
1101    fn control_handle(&self) -> Self::ControlHandle {
1102        CallManagerControlHandle { inner: self.inner.clone() }
1103    }
1104
1105    fn into_inner(
1106        self,
1107    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1108    {
1109        (self.inner, self.is_terminated)
1110    }
1111
1112    fn from_inner(
1113        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1114        is_terminated: bool,
1115    ) -> Self {
1116        Self { inner, is_terminated }
1117    }
1118}
1119
1120impl futures::Stream for CallManagerRequestStream {
1121    type Item = Result<CallManagerRequest, fidl::Error>;
1122
1123    fn poll_next(
1124        mut self: std::pin::Pin<&mut Self>,
1125        cx: &mut std::task::Context<'_>,
1126    ) -> std::task::Poll<Option<Self::Item>> {
1127        let this = &mut *self;
1128        if this.inner.check_shutdown(cx) {
1129            this.is_terminated = true;
1130            return std::task::Poll::Ready(None);
1131        }
1132        if this.is_terminated {
1133            panic!("polled CallManagerRequestStream after completion");
1134        }
1135        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1136            |bytes, handles| {
1137                match this.inner.channel().read_etc(cx, bytes, handles) {
1138                    std::task::Poll::Ready(Ok(())) => {}
1139                    std::task::Poll::Pending => return std::task::Poll::Pending,
1140                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1141                        this.is_terminated = true;
1142                        return std::task::Poll::Ready(None);
1143                    }
1144                    std::task::Poll::Ready(Err(e)) => {
1145                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1146                            e.into(),
1147                        ))))
1148                    }
1149                }
1150
1151                // A message has been received from the channel
1152                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1153
1154                std::task::Poll::Ready(Some(match header.ordinal {
1155                    0x1431cc24b2980086 => {
1156                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1157                        let mut req = fidl::new_empty!(
1158                            CallManagerPeerConnectedRequest,
1159                            fidl::encoding::DefaultFuchsiaResourceDialect
1160                        );
1161                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CallManagerPeerConnectedRequest>(&header, _body_bytes, handles, &mut req)?;
1162                        let control_handle = CallManagerControlHandle { inner: this.inner.clone() };
1163                        Ok(CallManagerRequest::PeerConnected {
1164                            id: req.id,
1165                            handle: req.handle,
1166
1167                            responder: CallManagerPeerConnectedResponder {
1168                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1169                                tx_id: header.tx_id,
1170                            },
1171                        })
1172                    }
1173                    _ => Err(fidl::Error::UnknownOrdinal {
1174                        ordinal: header.ordinal,
1175                        protocol_name:
1176                            <CallManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1177                    }),
1178                }))
1179            },
1180        )
1181    }
1182}
1183
1184#[derive(Debug)]
1185pub enum CallManagerRequest {
1186    /// Signal that a peer that supports the HFP Hands-Free role is connected.
1187    ///
1188    /// `id` is the unique identifier associated with the peer.
1189    /// `handle` is the channel that the call manager should use to manage
1190    /// a the peer. If the call manager does not intend to handle a given peer,
1191    /// it must close the handle with a `ZX_ERR_UNAVAILABLE` epitaph.
1192    ///
1193    /// Multiple concurrent PeerConnected requests can be made by the client.
1194    /// The empty response is used as a flow control mechanism to allow the
1195    /// client to limit the number of pending PeerConnected requests.
1196    PeerConnected {
1197        id: fidl_fuchsia_bluetooth::PeerId,
1198        handle: fidl::endpoints::ServerEnd<PeerHandlerMarker>,
1199        responder: CallManagerPeerConnectedResponder,
1200    },
1201}
1202
1203impl CallManagerRequest {
1204    #[allow(irrefutable_let_patterns)]
1205    pub fn into_peer_connected(
1206        self,
1207    ) -> Option<(
1208        fidl_fuchsia_bluetooth::PeerId,
1209        fidl::endpoints::ServerEnd<PeerHandlerMarker>,
1210        CallManagerPeerConnectedResponder,
1211    )> {
1212        if let CallManagerRequest::PeerConnected { id, handle, responder } = self {
1213            Some((id, handle, responder))
1214        } else {
1215            None
1216        }
1217    }
1218
1219    /// Name of the method defined in FIDL
1220    pub fn method_name(&self) -> &'static str {
1221        match *self {
1222            CallManagerRequest::PeerConnected { .. } => "peer_connected",
1223        }
1224    }
1225}
1226
1227#[derive(Debug, Clone)]
1228pub struct CallManagerControlHandle {
1229    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1230}
1231
1232impl fidl::endpoints::ControlHandle for CallManagerControlHandle {
1233    fn shutdown(&self) {
1234        self.inner.shutdown()
1235    }
1236    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1237        self.inner.shutdown_with_epitaph(status)
1238    }
1239
1240    fn is_closed(&self) -> bool {
1241        self.inner.channel().is_closed()
1242    }
1243    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1244        self.inner.channel().on_closed()
1245    }
1246
1247    #[cfg(target_os = "fuchsia")]
1248    fn signal_peer(
1249        &self,
1250        clear_mask: zx::Signals,
1251        set_mask: zx::Signals,
1252    ) -> Result<(), zx_status::Status> {
1253        use fidl::Peered;
1254        self.inner.channel().signal_peer(clear_mask, set_mask)
1255    }
1256}
1257
1258impl CallManagerControlHandle {}
1259
1260#[must_use = "FIDL methods require a response to be sent"]
1261#[derive(Debug)]
1262pub struct CallManagerPeerConnectedResponder {
1263    control_handle: std::mem::ManuallyDrop<CallManagerControlHandle>,
1264    tx_id: u32,
1265}
1266
1267/// Set the the channel to be shutdown (see [`CallManagerControlHandle::shutdown`])
1268/// if the responder is dropped without sending a response, so that the client
1269/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1270impl std::ops::Drop for CallManagerPeerConnectedResponder {
1271    fn drop(&mut self) {
1272        self.control_handle.shutdown();
1273        // Safety: drops once, never accessed again
1274        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1275    }
1276}
1277
1278impl fidl::endpoints::Responder for CallManagerPeerConnectedResponder {
1279    type ControlHandle = CallManagerControlHandle;
1280
1281    fn control_handle(&self) -> &CallManagerControlHandle {
1282        &self.control_handle
1283    }
1284
1285    fn drop_without_shutdown(mut self) {
1286        // Safety: drops once, never accessed again due to mem::forget
1287        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1288        // Prevent Drop from running (which would shut down the channel)
1289        std::mem::forget(self);
1290    }
1291}
1292
1293impl CallManagerPeerConnectedResponder {
1294    /// Sends a response to the FIDL transaction.
1295    ///
1296    /// Sets the channel to shutdown if an error occurs.
1297    pub fn send(self) -> Result<(), fidl::Error> {
1298        let _result = self.send_raw();
1299        if _result.is_err() {
1300            self.control_handle.shutdown();
1301        }
1302        self.drop_without_shutdown();
1303        _result
1304    }
1305
1306    /// Similar to "send" but does not shutdown the channel if an error occurs.
1307    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1308        let _result = self.send_raw();
1309        self.drop_without_shutdown();
1310        _result
1311    }
1312
1313    fn send_raw(&self) -> Result<(), fidl::Error> {
1314        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1315            (),
1316            self.tx_id,
1317            0x1431cc24b2980086,
1318            fidl::encoding::DynamicFlags::empty(),
1319        )
1320    }
1321}
1322
1323#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1324pub struct HandsFreeMarker;
1325
1326impl fidl::endpoints::ProtocolMarker for HandsFreeMarker {
1327    type Proxy = HandsFreeProxy;
1328    type RequestStream = HandsFreeRequestStream;
1329    #[cfg(target_os = "fuchsia")]
1330    type SynchronousProxy = HandsFreeSynchronousProxy;
1331
1332    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.hfp.HandsFree";
1333}
1334impl fidl::endpoints::DiscoverableProtocolMarker for HandsFreeMarker {}
1335pub type HandsFreeWatchPeerConnectedResult =
1336    Result<(fidl_fuchsia_bluetooth::PeerId, fidl::endpoints::ClientEnd<PeerHandlerMarker>), i32>;
1337
1338pub trait HandsFreeProxyInterface: Send + Sync {
1339    type WatchPeerConnectedResponseFut: std::future::Future<Output = Result<HandsFreeWatchPeerConnectedResult, fidl::Error>>
1340        + Send;
1341    fn r#watch_peer_connected(&self) -> Self::WatchPeerConnectedResponseFut;
1342}
1343#[derive(Debug)]
1344#[cfg(target_os = "fuchsia")]
1345pub struct HandsFreeSynchronousProxy {
1346    client: fidl::client::sync::Client,
1347}
1348
1349#[cfg(target_os = "fuchsia")]
1350impl fidl::endpoints::SynchronousProxy for HandsFreeSynchronousProxy {
1351    type Proxy = HandsFreeProxy;
1352    type Protocol = HandsFreeMarker;
1353
1354    fn from_channel(inner: fidl::Channel) -> Self {
1355        Self::new(inner)
1356    }
1357
1358    fn into_channel(self) -> fidl::Channel {
1359        self.client.into_channel()
1360    }
1361
1362    fn as_channel(&self) -> &fidl::Channel {
1363        self.client.as_channel()
1364    }
1365}
1366
1367#[cfg(target_os = "fuchsia")]
1368impl HandsFreeSynchronousProxy {
1369    pub fn new(channel: fidl::Channel) -> Self {
1370        let protocol_name = <HandsFreeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1371        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1372    }
1373
1374    pub fn into_channel(self) -> fidl::Channel {
1375        self.client.into_channel()
1376    }
1377
1378    /// Waits until an event arrives and returns it. It is safe for other
1379    /// threads to make concurrent requests while waiting for an event.
1380    pub fn wait_for_event(
1381        &self,
1382        deadline: zx::MonotonicInstant,
1383    ) -> Result<HandsFreeEvent, fidl::Error> {
1384        HandsFreeEvent::decode(self.client.wait_for_event(deadline)?)
1385    }
1386
1387    /// Hanging get that waits for a a peer that supports the HFP Audio Gateway
1388    /// role to connect.
1389    ///
1390    /// `id` is the unique identifier associated with the peer.
1391    ///
1392    /// `handle` is the channel that the client should use to manage the peer.
1393    /// If the call manager does not intend to handle a given peer. it must
1394    /// close the handle,
1395    pub fn r#watch_peer_connected(
1396        &self,
1397        ___deadline: zx::MonotonicInstant,
1398    ) -> Result<HandsFreeWatchPeerConnectedResult, fidl::Error> {
1399        let _response = self.client.send_query::<
1400            fidl::encoding::EmptyPayload,
1401            fidl::encoding::ResultType<HandsFreeWatchPeerConnectedResponse, i32>,
1402        >(
1403            (),
1404            0x1cc503325a8bbc3f,
1405            fidl::encoding::DynamicFlags::empty(),
1406            ___deadline,
1407        )?;
1408        Ok(_response.map(|x| (x.id, x.handle)))
1409    }
1410}
1411
1412#[derive(Debug, Clone)]
1413pub struct HandsFreeProxy {
1414    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1415}
1416
1417impl fidl::endpoints::Proxy for HandsFreeProxy {
1418    type Protocol = HandsFreeMarker;
1419
1420    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1421        Self::new(inner)
1422    }
1423
1424    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1425        self.client.into_channel().map_err(|client| Self { client })
1426    }
1427
1428    fn as_channel(&self) -> &::fidl::AsyncChannel {
1429        self.client.as_channel()
1430    }
1431}
1432
1433impl HandsFreeProxy {
1434    /// Create a new Proxy for fuchsia.bluetooth.hfp/HandsFree.
1435    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1436        let protocol_name = <HandsFreeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1437        Self { client: fidl::client::Client::new(channel, protocol_name) }
1438    }
1439
1440    /// Get a Stream of events from the remote end of the protocol.
1441    ///
1442    /// # Panics
1443    ///
1444    /// Panics if the event stream was already taken.
1445    pub fn take_event_stream(&self) -> HandsFreeEventStream {
1446        HandsFreeEventStream { event_receiver: self.client.take_event_receiver() }
1447    }
1448
1449    /// Hanging get that waits for a a peer that supports the HFP Audio Gateway
1450    /// role to connect.
1451    ///
1452    /// `id` is the unique identifier associated with the peer.
1453    ///
1454    /// `handle` is the channel that the client should use to manage the peer.
1455    /// If the call manager does not intend to handle a given peer. it must
1456    /// close the handle,
1457    pub fn r#watch_peer_connected(
1458        &self,
1459    ) -> fidl::client::QueryResponseFut<
1460        HandsFreeWatchPeerConnectedResult,
1461        fidl::encoding::DefaultFuchsiaResourceDialect,
1462    > {
1463        HandsFreeProxyInterface::r#watch_peer_connected(self)
1464    }
1465}
1466
1467impl HandsFreeProxyInterface for HandsFreeProxy {
1468    type WatchPeerConnectedResponseFut = fidl::client::QueryResponseFut<
1469        HandsFreeWatchPeerConnectedResult,
1470        fidl::encoding::DefaultFuchsiaResourceDialect,
1471    >;
1472    fn r#watch_peer_connected(&self) -> Self::WatchPeerConnectedResponseFut {
1473        fn _decode(
1474            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1475        ) -> Result<HandsFreeWatchPeerConnectedResult, fidl::Error> {
1476            let _response = fidl::client::decode_transaction_body::<
1477                fidl::encoding::ResultType<HandsFreeWatchPeerConnectedResponse, i32>,
1478                fidl::encoding::DefaultFuchsiaResourceDialect,
1479                0x1cc503325a8bbc3f,
1480            >(_buf?)?;
1481            Ok(_response.map(|x| (x.id, x.handle)))
1482        }
1483        self.client.send_query_and_decode::<
1484            fidl::encoding::EmptyPayload,
1485            HandsFreeWatchPeerConnectedResult,
1486        >(
1487            (),
1488            0x1cc503325a8bbc3f,
1489            fidl::encoding::DynamicFlags::empty(),
1490            _decode,
1491        )
1492    }
1493}
1494
1495pub struct HandsFreeEventStream {
1496    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1497}
1498
1499impl std::marker::Unpin for HandsFreeEventStream {}
1500
1501impl futures::stream::FusedStream for HandsFreeEventStream {
1502    fn is_terminated(&self) -> bool {
1503        self.event_receiver.is_terminated()
1504    }
1505}
1506
1507impl futures::Stream for HandsFreeEventStream {
1508    type Item = Result<HandsFreeEvent, fidl::Error>;
1509
1510    fn poll_next(
1511        mut self: std::pin::Pin<&mut Self>,
1512        cx: &mut std::task::Context<'_>,
1513    ) -> std::task::Poll<Option<Self::Item>> {
1514        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1515            &mut self.event_receiver,
1516            cx
1517        )?) {
1518            Some(buf) => std::task::Poll::Ready(Some(HandsFreeEvent::decode(buf))),
1519            None => std::task::Poll::Ready(None),
1520        }
1521    }
1522}
1523
1524#[derive(Debug)]
1525pub enum HandsFreeEvent {}
1526
1527impl HandsFreeEvent {
1528    /// Decodes a message buffer as a [`HandsFreeEvent`].
1529    fn decode(
1530        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1531    ) -> Result<HandsFreeEvent, fidl::Error> {
1532        let (bytes, _handles) = buf.split_mut();
1533        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1534        debug_assert_eq!(tx_header.tx_id, 0);
1535        match tx_header.ordinal {
1536            _ => Err(fidl::Error::UnknownOrdinal {
1537                ordinal: tx_header.ordinal,
1538                protocol_name: <HandsFreeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1539            }),
1540        }
1541    }
1542}
1543
1544/// A Stream of incoming requests for fuchsia.bluetooth.hfp/HandsFree.
1545pub struct HandsFreeRequestStream {
1546    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1547    is_terminated: bool,
1548}
1549
1550impl std::marker::Unpin for HandsFreeRequestStream {}
1551
1552impl futures::stream::FusedStream for HandsFreeRequestStream {
1553    fn is_terminated(&self) -> bool {
1554        self.is_terminated
1555    }
1556}
1557
1558impl fidl::endpoints::RequestStream for HandsFreeRequestStream {
1559    type Protocol = HandsFreeMarker;
1560    type ControlHandle = HandsFreeControlHandle;
1561
1562    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1563        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1564    }
1565
1566    fn control_handle(&self) -> Self::ControlHandle {
1567        HandsFreeControlHandle { inner: self.inner.clone() }
1568    }
1569
1570    fn into_inner(
1571        self,
1572    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1573    {
1574        (self.inner, self.is_terminated)
1575    }
1576
1577    fn from_inner(
1578        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1579        is_terminated: bool,
1580    ) -> Self {
1581        Self { inner, is_terminated }
1582    }
1583}
1584
1585impl futures::Stream for HandsFreeRequestStream {
1586    type Item = Result<HandsFreeRequest, fidl::Error>;
1587
1588    fn poll_next(
1589        mut self: std::pin::Pin<&mut Self>,
1590        cx: &mut std::task::Context<'_>,
1591    ) -> std::task::Poll<Option<Self::Item>> {
1592        let this = &mut *self;
1593        if this.inner.check_shutdown(cx) {
1594            this.is_terminated = true;
1595            return std::task::Poll::Ready(None);
1596        }
1597        if this.is_terminated {
1598            panic!("polled HandsFreeRequestStream after completion");
1599        }
1600        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1601            |bytes, handles| {
1602                match this.inner.channel().read_etc(cx, bytes, handles) {
1603                    std::task::Poll::Ready(Ok(())) => {}
1604                    std::task::Poll::Pending => return std::task::Poll::Pending,
1605                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1606                        this.is_terminated = true;
1607                        return std::task::Poll::Ready(None);
1608                    }
1609                    std::task::Poll::Ready(Err(e)) => {
1610                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1611                            e.into(),
1612                        ))))
1613                    }
1614                }
1615
1616                // A message has been received from the channel
1617                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1618
1619                std::task::Poll::Ready(Some(match header.ordinal {
1620                    0x1cc503325a8bbc3f => {
1621                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1622                        let mut req = fidl::new_empty!(
1623                            fidl::encoding::EmptyPayload,
1624                            fidl::encoding::DefaultFuchsiaResourceDialect
1625                        );
1626                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1627                        let control_handle = HandsFreeControlHandle { inner: this.inner.clone() };
1628                        Ok(HandsFreeRequest::WatchPeerConnected {
1629                            responder: HandsFreeWatchPeerConnectedResponder {
1630                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1631                                tx_id: header.tx_id,
1632                            },
1633                        })
1634                    }
1635                    _ => Err(fidl::Error::UnknownOrdinal {
1636                        ordinal: header.ordinal,
1637                        protocol_name:
1638                            <HandsFreeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1639                    }),
1640                }))
1641            },
1642        )
1643    }
1644}
1645
1646#[derive(Debug)]
1647pub enum HandsFreeRequest {
1648    /// Hanging get that waits for a a peer that supports the HFP Audio Gateway
1649    /// role to connect.
1650    ///
1651    /// `id` is the unique identifier associated with the peer.
1652    ///
1653    /// `handle` is the channel that the client should use to manage the peer.
1654    /// If the call manager does not intend to handle a given peer. it must
1655    /// close the handle,
1656    WatchPeerConnected { responder: HandsFreeWatchPeerConnectedResponder },
1657}
1658
1659impl HandsFreeRequest {
1660    #[allow(irrefutable_let_patterns)]
1661    pub fn into_watch_peer_connected(self) -> Option<(HandsFreeWatchPeerConnectedResponder)> {
1662        if let HandsFreeRequest::WatchPeerConnected { responder } = self {
1663            Some((responder))
1664        } else {
1665            None
1666        }
1667    }
1668
1669    /// Name of the method defined in FIDL
1670    pub fn method_name(&self) -> &'static str {
1671        match *self {
1672            HandsFreeRequest::WatchPeerConnected { .. } => "watch_peer_connected",
1673        }
1674    }
1675}
1676
1677#[derive(Debug, Clone)]
1678pub struct HandsFreeControlHandle {
1679    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1680}
1681
1682impl fidl::endpoints::ControlHandle for HandsFreeControlHandle {
1683    fn shutdown(&self) {
1684        self.inner.shutdown()
1685    }
1686    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1687        self.inner.shutdown_with_epitaph(status)
1688    }
1689
1690    fn is_closed(&self) -> bool {
1691        self.inner.channel().is_closed()
1692    }
1693    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1694        self.inner.channel().on_closed()
1695    }
1696
1697    #[cfg(target_os = "fuchsia")]
1698    fn signal_peer(
1699        &self,
1700        clear_mask: zx::Signals,
1701        set_mask: zx::Signals,
1702    ) -> Result<(), zx_status::Status> {
1703        use fidl::Peered;
1704        self.inner.channel().signal_peer(clear_mask, set_mask)
1705    }
1706}
1707
1708impl HandsFreeControlHandle {}
1709
1710#[must_use = "FIDL methods require a response to be sent"]
1711#[derive(Debug)]
1712pub struct HandsFreeWatchPeerConnectedResponder {
1713    control_handle: std::mem::ManuallyDrop<HandsFreeControlHandle>,
1714    tx_id: u32,
1715}
1716
1717/// Set the the channel to be shutdown (see [`HandsFreeControlHandle::shutdown`])
1718/// if the responder is dropped without sending a response, so that the client
1719/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1720impl std::ops::Drop for HandsFreeWatchPeerConnectedResponder {
1721    fn drop(&mut self) {
1722        self.control_handle.shutdown();
1723        // Safety: drops once, never accessed again
1724        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1725    }
1726}
1727
1728impl fidl::endpoints::Responder for HandsFreeWatchPeerConnectedResponder {
1729    type ControlHandle = HandsFreeControlHandle;
1730
1731    fn control_handle(&self) -> &HandsFreeControlHandle {
1732        &self.control_handle
1733    }
1734
1735    fn drop_without_shutdown(mut self) {
1736        // Safety: drops once, never accessed again due to mem::forget
1737        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1738        // Prevent Drop from running (which would shut down the channel)
1739        std::mem::forget(self);
1740    }
1741}
1742
1743impl HandsFreeWatchPeerConnectedResponder {
1744    /// Sends a response to the FIDL transaction.
1745    ///
1746    /// Sets the channel to shutdown if an error occurs.
1747    pub fn send(
1748        self,
1749        mut result: Result<
1750            (&fidl_fuchsia_bluetooth::PeerId, fidl::endpoints::ClientEnd<PeerHandlerMarker>),
1751            i32,
1752        >,
1753    ) -> Result<(), fidl::Error> {
1754        let _result = self.send_raw(result);
1755        if _result.is_err() {
1756            self.control_handle.shutdown();
1757        }
1758        self.drop_without_shutdown();
1759        _result
1760    }
1761
1762    /// Similar to "send" but does not shutdown the channel if an error occurs.
1763    pub fn send_no_shutdown_on_err(
1764        self,
1765        mut result: Result<
1766            (&fidl_fuchsia_bluetooth::PeerId, fidl::endpoints::ClientEnd<PeerHandlerMarker>),
1767            i32,
1768        >,
1769    ) -> Result<(), fidl::Error> {
1770        let _result = self.send_raw(result);
1771        self.drop_without_shutdown();
1772        _result
1773    }
1774
1775    fn send_raw(
1776        &self,
1777        mut result: Result<
1778            (&fidl_fuchsia_bluetooth::PeerId, fidl::endpoints::ClientEnd<PeerHandlerMarker>),
1779            i32,
1780        >,
1781    ) -> Result<(), fidl::Error> {
1782        self.control_handle.inner.send::<fidl::encoding::ResultType<
1783            HandsFreeWatchPeerConnectedResponse,
1784            i32,
1785        >>(
1786            result,
1787            self.tx_id,
1788            0x1cc503325a8bbc3f,
1789            fidl::encoding::DynamicFlags::empty(),
1790        )
1791    }
1792}
1793
1794#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1795pub struct HeadsetGainMarker;
1796
1797impl fidl::endpoints::ProtocolMarker for HeadsetGainMarker {
1798    type Proxy = HeadsetGainProxy;
1799    type RequestStream = HeadsetGainRequestStream;
1800    #[cfg(target_os = "fuchsia")]
1801    type SynchronousProxy = HeadsetGainSynchronousProxy;
1802
1803    const DEBUG_NAME: &'static str = "(anonymous) HeadsetGain";
1804}
1805
1806pub trait HeadsetGainProxyInterface: Send + Sync {
1807    fn r#set_speaker_gain(&self, requested: u8) -> Result<(), fidl::Error>;
1808    type WatchSpeakerGainResponseFut: std::future::Future<Output = Result<u8, fidl::Error>> + Send;
1809    fn r#watch_speaker_gain(&self) -> Self::WatchSpeakerGainResponseFut;
1810    fn r#set_microphone_gain(&self, requested: u8) -> Result<(), fidl::Error>;
1811    type WatchMicrophoneGainResponseFut: std::future::Future<Output = Result<u8, fidl::Error>>
1812        + Send;
1813    fn r#watch_microphone_gain(&self) -> Self::WatchMicrophoneGainResponseFut;
1814}
1815#[derive(Debug)]
1816#[cfg(target_os = "fuchsia")]
1817pub struct HeadsetGainSynchronousProxy {
1818    client: fidl::client::sync::Client,
1819}
1820
1821#[cfg(target_os = "fuchsia")]
1822impl fidl::endpoints::SynchronousProxy for HeadsetGainSynchronousProxy {
1823    type Proxy = HeadsetGainProxy;
1824    type Protocol = HeadsetGainMarker;
1825
1826    fn from_channel(inner: fidl::Channel) -> Self {
1827        Self::new(inner)
1828    }
1829
1830    fn into_channel(self) -> fidl::Channel {
1831        self.client.into_channel()
1832    }
1833
1834    fn as_channel(&self) -> &fidl::Channel {
1835        self.client.as_channel()
1836    }
1837}
1838
1839#[cfg(target_os = "fuchsia")]
1840impl HeadsetGainSynchronousProxy {
1841    pub fn new(channel: fidl::Channel) -> Self {
1842        let protocol_name = <HeadsetGainMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1843        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1844    }
1845
1846    pub fn into_channel(self) -> fidl::Channel {
1847        self.client.into_channel()
1848    }
1849
1850    /// Waits until an event arrives and returns it. It is safe for other
1851    /// threads to make concurrent requests while waiting for an event.
1852    pub fn wait_for_event(
1853        &self,
1854        deadline: zx::MonotonicInstant,
1855    ) -> Result<HeadsetGainEvent, fidl::Error> {
1856        HeadsetGainEvent::decode(self.client.wait_for_event(deadline)?)
1857    }
1858
1859    /// Make a request to the headset to set the speaker gain to `requested`.
1860    ///
1861    /// `requested` must be in the range [0-15] inclusive. Any values outside of
1862    /// this range will result in the channel closing with a
1863    /// `ZX_ERR_INVALID_ARGUMENT` epitaph.
1864    pub fn r#set_speaker_gain(&self, mut requested: u8) -> Result<(), fidl::Error> {
1865        self.client.send::<HeadsetGainSetSpeakerGainRequest>(
1866            (requested,),
1867            0x3462191b2a6ae5ce,
1868            fidl::encoding::DynamicFlags::empty(),
1869        )
1870    }
1871
1872    /// Hanging get to watch for updates to the headset speaker gain. Responses
1873    /// represent the current gain value that is set.
1874    ///
1875    /// The returned `gain` value will always be in the range [0-15] inclusive.
1876    pub fn r#watch_speaker_gain(
1877        &self,
1878        ___deadline: zx::MonotonicInstant,
1879    ) -> Result<u8, fidl::Error> {
1880        let _response = self
1881            .client
1882            .send_query::<fidl::encoding::EmptyPayload, HeadsetGainWatchSpeakerGainResponse>(
1883                (),
1884                0x2007abdf2695c747,
1885                fidl::encoding::DynamicFlags::empty(),
1886                ___deadline,
1887            )?;
1888        Ok(_response.gain)
1889    }
1890
1891    /// Make a request to the Headset to set the microphone gain to `requested`.
1892    ///
1893    /// `requested` must be in the range [0-15] inclusive. Any values outside of
1894    /// this range will result in the channel closing with a
1895    /// `ZX_ERR_INVALID_ARGUMENT` epitaph.
1896    pub fn r#set_microphone_gain(&self, mut requested: u8) -> Result<(), fidl::Error> {
1897        self.client.send::<HeadsetGainSetMicrophoneGainRequest>(
1898            (requested,),
1899            0x7ddbb4e63caeef8e,
1900            fidl::encoding::DynamicFlags::empty(),
1901        )
1902    }
1903
1904    /// Hanging get to watch for updates to the headset microphone gain. Responses
1905    /// represent the current gain value that is set.
1906    ///
1907    /// The returned `gain` value will always be in the range [0-15] inclusive.
1908    pub fn r#watch_microphone_gain(
1909        &self,
1910        ___deadline: zx::MonotonicInstant,
1911    ) -> Result<u8, fidl::Error> {
1912        let _response = self
1913            .client
1914            .send_query::<fidl::encoding::EmptyPayload, HeadsetGainWatchMicrophoneGainResponse>(
1915                (),
1916                0x1d171fb432fa55ad,
1917                fidl::encoding::DynamicFlags::empty(),
1918                ___deadline,
1919            )?;
1920        Ok(_response.gain)
1921    }
1922}
1923
1924#[derive(Debug, Clone)]
1925pub struct HeadsetGainProxy {
1926    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1927}
1928
1929impl fidl::endpoints::Proxy for HeadsetGainProxy {
1930    type Protocol = HeadsetGainMarker;
1931
1932    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1933        Self::new(inner)
1934    }
1935
1936    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1937        self.client.into_channel().map_err(|client| Self { client })
1938    }
1939
1940    fn as_channel(&self) -> &::fidl::AsyncChannel {
1941        self.client.as_channel()
1942    }
1943}
1944
1945impl HeadsetGainProxy {
1946    /// Create a new Proxy for fuchsia.bluetooth.hfp/HeadsetGain.
1947    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1948        let protocol_name = <HeadsetGainMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1949        Self { client: fidl::client::Client::new(channel, protocol_name) }
1950    }
1951
1952    /// Get a Stream of events from the remote end of the protocol.
1953    ///
1954    /// # Panics
1955    ///
1956    /// Panics if the event stream was already taken.
1957    pub fn take_event_stream(&self) -> HeadsetGainEventStream {
1958        HeadsetGainEventStream { event_receiver: self.client.take_event_receiver() }
1959    }
1960
1961    /// Make a request to the headset to set the speaker gain to `requested`.
1962    ///
1963    /// `requested` must be in the range [0-15] inclusive. Any values outside of
1964    /// this range will result in the channel closing with a
1965    /// `ZX_ERR_INVALID_ARGUMENT` epitaph.
1966    pub fn r#set_speaker_gain(&self, mut requested: u8) -> Result<(), fidl::Error> {
1967        HeadsetGainProxyInterface::r#set_speaker_gain(self, requested)
1968    }
1969
1970    /// Hanging get to watch for updates to the headset speaker gain. Responses
1971    /// represent the current gain value that is set.
1972    ///
1973    /// The returned `gain` value will always be in the range [0-15] inclusive.
1974    pub fn r#watch_speaker_gain(
1975        &self,
1976    ) -> fidl::client::QueryResponseFut<u8, fidl::encoding::DefaultFuchsiaResourceDialect> {
1977        HeadsetGainProxyInterface::r#watch_speaker_gain(self)
1978    }
1979
1980    /// Make a request to the Headset to set the microphone gain to `requested`.
1981    ///
1982    /// `requested` must be in the range [0-15] inclusive. Any values outside of
1983    /// this range will result in the channel closing with a
1984    /// `ZX_ERR_INVALID_ARGUMENT` epitaph.
1985    pub fn r#set_microphone_gain(&self, mut requested: u8) -> Result<(), fidl::Error> {
1986        HeadsetGainProxyInterface::r#set_microphone_gain(self, requested)
1987    }
1988
1989    /// Hanging get to watch for updates to the headset microphone gain. Responses
1990    /// represent the current gain value that is set.
1991    ///
1992    /// The returned `gain` value will always be in the range [0-15] inclusive.
1993    pub fn r#watch_microphone_gain(
1994        &self,
1995    ) -> fidl::client::QueryResponseFut<u8, fidl::encoding::DefaultFuchsiaResourceDialect> {
1996        HeadsetGainProxyInterface::r#watch_microphone_gain(self)
1997    }
1998}
1999
2000impl HeadsetGainProxyInterface for HeadsetGainProxy {
2001    fn r#set_speaker_gain(&self, mut requested: u8) -> Result<(), fidl::Error> {
2002        self.client.send::<HeadsetGainSetSpeakerGainRequest>(
2003            (requested,),
2004            0x3462191b2a6ae5ce,
2005            fidl::encoding::DynamicFlags::empty(),
2006        )
2007    }
2008
2009    type WatchSpeakerGainResponseFut =
2010        fidl::client::QueryResponseFut<u8, fidl::encoding::DefaultFuchsiaResourceDialect>;
2011    fn r#watch_speaker_gain(&self) -> Self::WatchSpeakerGainResponseFut {
2012        fn _decode(
2013            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2014        ) -> Result<u8, fidl::Error> {
2015            let _response = fidl::client::decode_transaction_body::<
2016                HeadsetGainWatchSpeakerGainResponse,
2017                fidl::encoding::DefaultFuchsiaResourceDialect,
2018                0x2007abdf2695c747,
2019            >(_buf?)?;
2020            Ok(_response.gain)
2021        }
2022        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u8>(
2023            (),
2024            0x2007abdf2695c747,
2025            fidl::encoding::DynamicFlags::empty(),
2026            _decode,
2027        )
2028    }
2029
2030    fn r#set_microphone_gain(&self, mut requested: u8) -> Result<(), fidl::Error> {
2031        self.client.send::<HeadsetGainSetMicrophoneGainRequest>(
2032            (requested,),
2033            0x7ddbb4e63caeef8e,
2034            fidl::encoding::DynamicFlags::empty(),
2035        )
2036    }
2037
2038    type WatchMicrophoneGainResponseFut =
2039        fidl::client::QueryResponseFut<u8, fidl::encoding::DefaultFuchsiaResourceDialect>;
2040    fn r#watch_microphone_gain(&self) -> Self::WatchMicrophoneGainResponseFut {
2041        fn _decode(
2042            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2043        ) -> Result<u8, fidl::Error> {
2044            let _response = fidl::client::decode_transaction_body::<
2045                HeadsetGainWatchMicrophoneGainResponse,
2046                fidl::encoding::DefaultFuchsiaResourceDialect,
2047                0x1d171fb432fa55ad,
2048            >(_buf?)?;
2049            Ok(_response.gain)
2050        }
2051        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u8>(
2052            (),
2053            0x1d171fb432fa55ad,
2054            fidl::encoding::DynamicFlags::empty(),
2055            _decode,
2056        )
2057    }
2058}
2059
2060pub struct HeadsetGainEventStream {
2061    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2062}
2063
2064impl std::marker::Unpin for HeadsetGainEventStream {}
2065
2066impl futures::stream::FusedStream for HeadsetGainEventStream {
2067    fn is_terminated(&self) -> bool {
2068        self.event_receiver.is_terminated()
2069    }
2070}
2071
2072impl futures::Stream for HeadsetGainEventStream {
2073    type Item = Result<HeadsetGainEvent, fidl::Error>;
2074
2075    fn poll_next(
2076        mut self: std::pin::Pin<&mut Self>,
2077        cx: &mut std::task::Context<'_>,
2078    ) -> std::task::Poll<Option<Self::Item>> {
2079        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2080            &mut self.event_receiver,
2081            cx
2082        )?) {
2083            Some(buf) => std::task::Poll::Ready(Some(HeadsetGainEvent::decode(buf))),
2084            None => std::task::Poll::Ready(None),
2085        }
2086    }
2087}
2088
2089#[derive(Debug)]
2090pub enum HeadsetGainEvent {}
2091
2092impl HeadsetGainEvent {
2093    /// Decodes a message buffer as a [`HeadsetGainEvent`].
2094    fn decode(
2095        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2096    ) -> Result<HeadsetGainEvent, fidl::Error> {
2097        let (bytes, _handles) = buf.split_mut();
2098        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2099        debug_assert_eq!(tx_header.tx_id, 0);
2100        match tx_header.ordinal {
2101            _ => Err(fidl::Error::UnknownOrdinal {
2102                ordinal: tx_header.ordinal,
2103                protocol_name: <HeadsetGainMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2104            }),
2105        }
2106    }
2107}
2108
2109/// A Stream of incoming requests for fuchsia.bluetooth.hfp/HeadsetGain.
2110pub struct HeadsetGainRequestStream {
2111    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2112    is_terminated: bool,
2113}
2114
2115impl std::marker::Unpin for HeadsetGainRequestStream {}
2116
2117impl futures::stream::FusedStream for HeadsetGainRequestStream {
2118    fn is_terminated(&self) -> bool {
2119        self.is_terminated
2120    }
2121}
2122
2123impl fidl::endpoints::RequestStream for HeadsetGainRequestStream {
2124    type Protocol = HeadsetGainMarker;
2125    type ControlHandle = HeadsetGainControlHandle;
2126
2127    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2128        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2129    }
2130
2131    fn control_handle(&self) -> Self::ControlHandle {
2132        HeadsetGainControlHandle { inner: self.inner.clone() }
2133    }
2134
2135    fn into_inner(
2136        self,
2137    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2138    {
2139        (self.inner, self.is_terminated)
2140    }
2141
2142    fn from_inner(
2143        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2144        is_terminated: bool,
2145    ) -> Self {
2146        Self { inner, is_terminated }
2147    }
2148}
2149
2150impl futures::Stream for HeadsetGainRequestStream {
2151    type Item = Result<HeadsetGainRequest, fidl::Error>;
2152
2153    fn poll_next(
2154        mut self: std::pin::Pin<&mut Self>,
2155        cx: &mut std::task::Context<'_>,
2156    ) -> std::task::Poll<Option<Self::Item>> {
2157        let this = &mut *self;
2158        if this.inner.check_shutdown(cx) {
2159            this.is_terminated = true;
2160            return std::task::Poll::Ready(None);
2161        }
2162        if this.is_terminated {
2163            panic!("polled HeadsetGainRequestStream after completion");
2164        }
2165        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2166            |bytes, handles| {
2167                match this.inner.channel().read_etc(cx, bytes, handles) {
2168                    std::task::Poll::Ready(Ok(())) => {}
2169                    std::task::Poll::Pending => return std::task::Poll::Pending,
2170                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2171                        this.is_terminated = true;
2172                        return std::task::Poll::Ready(None);
2173                    }
2174                    std::task::Poll::Ready(Err(e)) => {
2175                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2176                            e.into(),
2177                        ))))
2178                    }
2179                }
2180
2181                // A message has been received from the channel
2182                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2183
2184                std::task::Poll::Ready(Some(match header.ordinal {
2185                    0x3462191b2a6ae5ce => {
2186                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2187                        let mut req = fidl::new_empty!(
2188                            HeadsetGainSetSpeakerGainRequest,
2189                            fidl::encoding::DefaultFuchsiaResourceDialect
2190                        );
2191                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HeadsetGainSetSpeakerGainRequest>(&header, _body_bytes, handles, &mut req)?;
2192                        let control_handle = HeadsetGainControlHandle { inner: this.inner.clone() };
2193                        Ok(HeadsetGainRequest::SetSpeakerGain {
2194                            requested: req.requested,
2195
2196                            control_handle,
2197                        })
2198                    }
2199                    0x2007abdf2695c747 => {
2200                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2201                        let mut req = fidl::new_empty!(
2202                            fidl::encoding::EmptyPayload,
2203                            fidl::encoding::DefaultFuchsiaResourceDialect
2204                        );
2205                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2206                        let control_handle = HeadsetGainControlHandle { inner: this.inner.clone() };
2207                        Ok(HeadsetGainRequest::WatchSpeakerGain {
2208                            responder: HeadsetGainWatchSpeakerGainResponder {
2209                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2210                                tx_id: header.tx_id,
2211                            },
2212                        })
2213                    }
2214                    0x7ddbb4e63caeef8e => {
2215                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2216                        let mut req = fidl::new_empty!(
2217                            HeadsetGainSetMicrophoneGainRequest,
2218                            fidl::encoding::DefaultFuchsiaResourceDialect
2219                        );
2220                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HeadsetGainSetMicrophoneGainRequest>(&header, _body_bytes, handles, &mut req)?;
2221                        let control_handle = HeadsetGainControlHandle { inner: this.inner.clone() };
2222                        Ok(HeadsetGainRequest::SetMicrophoneGain {
2223                            requested: req.requested,
2224
2225                            control_handle,
2226                        })
2227                    }
2228                    0x1d171fb432fa55ad => {
2229                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2230                        let mut req = fidl::new_empty!(
2231                            fidl::encoding::EmptyPayload,
2232                            fidl::encoding::DefaultFuchsiaResourceDialect
2233                        );
2234                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2235                        let control_handle = HeadsetGainControlHandle { inner: this.inner.clone() };
2236                        Ok(HeadsetGainRequest::WatchMicrophoneGain {
2237                            responder: HeadsetGainWatchMicrophoneGainResponder {
2238                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2239                                tx_id: header.tx_id,
2240                            },
2241                        })
2242                    }
2243                    _ => Err(fidl::Error::UnknownOrdinal {
2244                        ordinal: header.ordinal,
2245                        protocol_name:
2246                            <HeadsetGainMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2247                    }),
2248                }))
2249            },
2250        )
2251    }
2252}
2253
2254/// Control Headset Speaker and Microphone gain and receive reports of current
2255/// values as specified in HFP v1.8, Section 4.29. This protocol is served by the
2256/// Hfp service.
2257///
2258/// Gain is represented as an absolute value on a scale from 0 to 15. 0 is the
2259/// minimum gain and 15 is the maximum gain. It is related to a particular
2260/// (implementation dependent) volume level controlled by the Headset.
2261///
2262///
2263/// Epitaphs:
2264///
2265/// This channel will be closed with a `ZX_ERR_ALREADY_BOUND` epitaph if there
2266/// is already an active `HeadsetGain` channel.
2267///
2268/// This channel will be closed with a `ZX_ERR_NOT_SUPPORTED` epitaph if the Hfp
2269/// service is not configured to support remote volume control or the peer
2270/// headset does not support remote volume control. If the channel is closed
2271/// with this error, the client should not attempt to reopen it using the
2272/// `PeerHandler::GainControl` request on the same PeerHandler connection.
2273///
2274/// This channel will be closed with a `ZX_ERR_INVALID_ARGUMENT` epitaph if
2275/// invalid arguments are passed to requests. See documentation on specific
2276/// requests for more details.
2277#[derive(Debug)]
2278pub enum HeadsetGainRequest {
2279    /// Make a request to the headset to set the speaker gain to `requested`.
2280    ///
2281    /// `requested` must be in the range [0-15] inclusive. Any values outside of
2282    /// this range will result in the channel closing with a
2283    /// `ZX_ERR_INVALID_ARGUMENT` epitaph.
2284    SetSpeakerGain { requested: u8, control_handle: HeadsetGainControlHandle },
2285    /// Hanging get to watch for updates to the headset speaker gain. Responses
2286    /// represent the current gain value that is set.
2287    ///
2288    /// The returned `gain` value will always be in the range [0-15] inclusive.
2289    WatchSpeakerGain { responder: HeadsetGainWatchSpeakerGainResponder },
2290    /// Make a request to the Headset to set the microphone gain to `requested`.
2291    ///
2292    /// `requested` must be in the range [0-15] inclusive. Any values outside of
2293    /// this range will result in the channel closing with a
2294    /// `ZX_ERR_INVALID_ARGUMENT` epitaph.
2295    SetMicrophoneGain { requested: u8, control_handle: HeadsetGainControlHandle },
2296    /// Hanging get to watch for updates to the headset microphone gain. Responses
2297    /// represent the current gain value that is set.
2298    ///
2299    /// The returned `gain` value will always be in the range [0-15] inclusive.
2300    WatchMicrophoneGain { responder: HeadsetGainWatchMicrophoneGainResponder },
2301}
2302
2303impl HeadsetGainRequest {
2304    #[allow(irrefutable_let_patterns)]
2305    pub fn into_set_speaker_gain(self) -> Option<(u8, HeadsetGainControlHandle)> {
2306        if let HeadsetGainRequest::SetSpeakerGain { requested, control_handle } = self {
2307            Some((requested, control_handle))
2308        } else {
2309            None
2310        }
2311    }
2312
2313    #[allow(irrefutable_let_patterns)]
2314    pub fn into_watch_speaker_gain(self) -> Option<(HeadsetGainWatchSpeakerGainResponder)> {
2315        if let HeadsetGainRequest::WatchSpeakerGain { responder } = self {
2316            Some((responder))
2317        } else {
2318            None
2319        }
2320    }
2321
2322    #[allow(irrefutable_let_patterns)]
2323    pub fn into_set_microphone_gain(self) -> Option<(u8, HeadsetGainControlHandle)> {
2324        if let HeadsetGainRequest::SetMicrophoneGain { requested, control_handle } = self {
2325            Some((requested, control_handle))
2326        } else {
2327            None
2328        }
2329    }
2330
2331    #[allow(irrefutable_let_patterns)]
2332    pub fn into_watch_microphone_gain(self) -> Option<(HeadsetGainWatchMicrophoneGainResponder)> {
2333        if let HeadsetGainRequest::WatchMicrophoneGain { responder } = self {
2334            Some((responder))
2335        } else {
2336            None
2337        }
2338    }
2339
2340    /// Name of the method defined in FIDL
2341    pub fn method_name(&self) -> &'static str {
2342        match *self {
2343            HeadsetGainRequest::SetSpeakerGain { .. } => "set_speaker_gain",
2344            HeadsetGainRequest::WatchSpeakerGain { .. } => "watch_speaker_gain",
2345            HeadsetGainRequest::SetMicrophoneGain { .. } => "set_microphone_gain",
2346            HeadsetGainRequest::WatchMicrophoneGain { .. } => "watch_microphone_gain",
2347        }
2348    }
2349}
2350
2351#[derive(Debug, Clone)]
2352pub struct HeadsetGainControlHandle {
2353    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2354}
2355
2356impl fidl::endpoints::ControlHandle for HeadsetGainControlHandle {
2357    fn shutdown(&self) {
2358        self.inner.shutdown()
2359    }
2360    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2361        self.inner.shutdown_with_epitaph(status)
2362    }
2363
2364    fn is_closed(&self) -> bool {
2365        self.inner.channel().is_closed()
2366    }
2367    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2368        self.inner.channel().on_closed()
2369    }
2370
2371    #[cfg(target_os = "fuchsia")]
2372    fn signal_peer(
2373        &self,
2374        clear_mask: zx::Signals,
2375        set_mask: zx::Signals,
2376    ) -> Result<(), zx_status::Status> {
2377        use fidl::Peered;
2378        self.inner.channel().signal_peer(clear_mask, set_mask)
2379    }
2380}
2381
2382impl HeadsetGainControlHandle {}
2383
2384#[must_use = "FIDL methods require a response to be sent"]
2385#[derive(Debug)]
2386pub struct HeadsetGainWatchSpeakerGainResponder {
2387    control_handle: std::mem::ManuallyDrop<HeadsetGainControlHandle>,
2388    tx_id: u32,
2389}
2390
2391/// Set the the channel to be shutdown (see [`HeadsetGainControlHandle::shutdown`])
2392/// if the responder is dropped without sending a response, so that the client
2393/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2394impl std::ops::Drop for HeadsetGainWatchSpeakerGainResponder {
2395    fn drop(&mut self) {
2396        self.control_handle.shutdown();
2397        // Safety: drops once, never accessed again
2398        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2399    }
2400}
2401
2402impl fidl::endpoints::Responder for HeadsetGainWatchSpeakerGainResponder {
2403    type ControlHandle = HeadsetGainControlHandle;
2404
2405    fn control_handle(&self) -> &HeadsetGainControlHandle {
2406        &self.control_handle
2407    }
2408
2409    fn drop_without_shutdown(mut self) {
2410        // Safety: drops once, never accessed again due to mem::forget
2411        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2412        // Prevent Drop from running (which would shut down the channel)
2413        std::mem::forget(self);
2414    }
2415}
2416
2417impl HeadsetGainWatchSpeakerGainResponder {
2418    /// Sends a response to the FIDL transaction.
2419    ///
2420    /// Sets the channel to shutdown if an error occurs.
2421    pub fn send(self, mut gain: u8) -> Result<(), fidl::Error> {
2422        let _result = self.send_raw(gain);
2423        if _result.is_err() {
2424            self.control_handle.shutdown();
2425        }
2426        self.drop_without_shutdown();
2427        _result
2428    }
2429
2430    /// Similar to "send" but does not shutdown the channel if an error occurs.
2431    pub fn send_no_shutdown_on_err(self, mut gain: u8) -> Result<(), fidl::Error> {
2432        let _result = self.send_raw(gain);
2433        self.drop_without_shutdown();
2434        _result
2435    }
2436
2437    fn send_raw(&self, mut gain: u8) -> Result<(), fidl::Error> {
2438        self.control_handle.inner.send::<HeadsetGainWatchSpeakerGainResponse>(
2439            (gain,),
2440            self.tx_id,
2441            0x2007abdf2695c747,
2442            fidl::encoding::DynamicFlags::empty(),
2443        )
2444    }
2445}
2446
2447#[must_use = "FIDL methods require a response to be sent"]
2448#[derive(Debug)]
2449pub struct HeadsetGainWatchMicrophoneGainResponder {
2450    control_handle: std::mem::ManuallyDrop<HeadsetGainControlHandle>,
2451    tx_id: u32,
2452}
2453
2454/// Set the the channel to be shutdown (see [`HeadsetGainControlHandle::shutdown`])
2455/// if the responder is dropped without sending a response, so that the client
2456/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2457impl std::ops::Drop for HeadsetGainWatchMicrophoneGainResponder {
2458    fn drop(&mut self) {
2459        self.control_handle.shutdown();
2460        // Safety: drops once, never accessed again
2461        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2462    }
2463}
2464
2465impl fidl::endpoints::Responder for HeadsetGainWatchMicrophoneGainResponder {
2466    type ControlHandle = HeadsetGainControlHandle;
2467
2468    fn control_handle(&self) -> &HeadsetGainControlHandle {
2469        &self.control_handle
2470    }
2471
2472    fn drop_without_shutdown(mut self) {
2473        // Safety: drops once, never accessed again due to mem::forget
2474        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2475        // Prevent Drop from running (which would shut down the channel)
2476        std::mem::forget(self);
2477    }
2478}
2479
2480impl HeadsetGainWatchMicrophoneGainResponder {
2481    /// Sends a response to the FIDL transaction.
2482    ///
2483    /// Sets the channel to shutdown if an error occurs.
2484    pub fn send(self, mut gain: u8) -> Result<(), fidl::Error> {
2485        let _result = self.send_raw(gain);
2486        if _result.is_err() {
2487            self.control_handle.shutdown();
2488        }
2489        self.drop_without_shutdown();
2490        _result
2491    }
2492
2493    /// Similar to "send" but does not shutdown the channel if an error occurs.
2494    pub fn send_no_shutdown_on_err(self, mut gain: u8) -> Result<(), fidl::Error> {
2495        let _result = self.send_raw(gain);
2496        self.drop_without_shutdown();
2497        _result
2498    }
2499
2500    fn send_raw(&self, mut gain: u8) -> Result<(), fidl::Error> {
2501        self.control_handle.inner.send::<HeadsetGainWatchMicrophoneGainResponse>(
2502            (gain,),
2503            self.tx_id,
2504            0x1d171fb432fa55ad,
2505            fidl::encoding::DynamicFlags::empty(),
2506        )
2507    }
2508}
2509
2510#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2511pub struct HfpMarker;
2512
2513impl fidl::endpoints::ProtocolMarker for HfpMarker {
2514    type Proxy = HfpProxy;
2515    type RequestStream = HfpRequestStream;
2516    #[cfg(target_os = "fuchsia")]
2517    type SynchronousProxy = HfpSynchronousProxy;
2518
2519    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.hfp.Hfp";
2520}
2521impl fidl::endpoints::DiscoverableProtocolMarker for HfpMarker {}
2522
2523pub trait HfpProxyInterface: Send + Sync {
2524    fn r#register(
2525        &self,
2526        manager: fidl::endpoints::ClientEnd<CallManagerMarker>,
2527    ) -> Result<(), fidl::Error>;
2528}
2529#[derive(Debug)]
2530#[cfg(target_os = "fuchsia")]
2531pub struct HfpSynchronousProxy {
2532    client: fidl::client::sync::Client,
2533}
2534
2535#[cfg(target_os = "fuchsia")]
2536impl fidl::endpoints::SynchronousProxy for HfpSynchronousProxy {
2537    type Proxy = HfpProxy;
2538    type Protocol = HfpMarker;
2539
2540    fn from_channel(inner: fidl::Channel) -> Self {
2541        Self::new(inner)
2542    }
2543
2544    fn into_channel(self) -> fidl::Channel {
2545        self.client.into_channel()
2546    }
2547
2548    fn as_channel(&self) -> &fidl::Channel {
2549        self.client.as_channel()
2550    }
2551}
2552
2553#[cfg(target_os = "fuchsia")]
2554impl HfpSynchronousProxy {
2555    pub fn new(channel: fidl::Channel) -> Self {
2556        let protocol_name = <HfpMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2557        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2558    }
2559
2560    pub fn into_channel(self) -> fidl::Channel {
2561        self.client.into_channel()
2562    }
2563
2564    /// Waits until an event arrives and returns it. It is safe for other
2565    /// threads to make concurrent requests while waiting for an event.
2566    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<HfpEvent, fidl::Error> {
2567        HfpEvent::decode(self.client.wait_for_event(deadline)?)
2568    }
2569
2570    /// Register as the call manager for this device.
2571    ///
2572    /// There can only be one call manager registered at a time. If one is
2573    /// registered at the time a call to `Register` is made, the newer
2574    /// CallManager channel will be closed.
2575    ///
2576    /// A call manager can be unregistered by closing either end of the channel.
2577    pub fn r#register(
2578        &self,
2579        mut manager: fidl::endpoints::ClientEnd<CallManagerMarker>,
2580    ) -> Result<(), fidl::Error> {
2581        self.client.send::<HfpRegisterRequest>(
2582            (manager,),
2583            0x1b2ea4f6069181ad,
2584            fidl::encoding::DynamicFlags::empty(),
2585        )
2586    }
2587}
2588
2589#[derive(Debug, Clone)]
2590pub struct HfpProxy {
2591    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2592}
2593
2594impl fidl::endpoints::Proxy for HfpProxy {
2595    type Protocol = HfpMarker;
2596
2597    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2598        Self::new(inner)
2599    }
2600
2601    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2602        self.client.into_channel().map_err(|client| Self { client })
2603    }
2604
2605    fn as_channel(&self) -> &::fidl::AsyncChannel {
2606        self.client.as_channel()
2607    }
2608}
2609
2610impl HfpProxy {
2611    /// Create a new Proxy for fuchsia.bluetooth.hfp/Hfp.
2612    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2613        let protocol_name = <HfpMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2614        Self { client: fidl::client::Client::new(channel, protocol_name) }
2615    }
2616
2617    /// Get a Stream of events from the remote end of the protocol.
2618    ///
2619    /// # Panics
2620    ///
2621    /// Panics if the event stream was already taken.
2622    pub fn take_event_stream(&self) -> HfpEventStream {
2623        HfpEventStream { event_receiver: self.client.take_event_receiver() }
2624    }
2625
2626    /// Register as the call manager for this device.
2627    ///
2628    /// There can only be one call manager registered at a time. If one is
2629    /// registered at the time a call to `Register` is made, the newer
2630    /// CallManager channel will be closed.
2631    ///
2632    /// A call manager can be unregistered by closing either end of the channel.
2633    pub fn r#register(
2634        &self,
2635        mut manager: fidl::endpoints::ClientEnd<CallManagerMarker>,
2636    ) -> Result<(), fidl::Error> {
2637        HfpProxyInterface::r#register(self, manager)
2638    }
2639}
2640
2641impl HfpProxyInterface for HfpProxy {
2642    fn r#register(
2643        &self,
2644        mut manager: fidl::endpoints::ClientEnd<CallManagerMarker>,
2645    ) -> Result<(), fidl::Error> {
2646        self.client.send::<HfpRegisterRequest>(
2647            (manager,),
2648            0x1b2ea4f6069181ad,
2649            fidl::encoding::DynamicFlags::empty(),
2650        )
2651    }
2652}
2653
2654pub struct HfpEventStream {
2655    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2656}
2657
2658impl std::marker::Unpin for HfpEventStream {}
2659
2660impl futures::stream::FusedStream for HfpEventStream {
2661    fn is_terminated(&self) -> bool {
2662        self.event_receiver.is_terminated()
2663    }
2664}
2665
2666impl futures::Stream for HfpEventStream {
2667    type Item = Result<HfpEvent, fidl::Error>;
2668
2669    fn poll_next(
2670        mut self: std::pin::Pin<&mut Self>,
2671        cx: &mut std::task::Context<'_>,
2672    ) -> std::task::Poll<Option<Self::Item>> {
2673        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2674            &mut self.event_receiver,
2675            cx
2676        )?) {
2677            Some(buf) => std::task::Poll::Ready(Some(HfpEvent::decode(buf))),
2678            None => std::task::Poll::Ready(None),
2679        }
2680    }
2681}
2682
2683#[derive(Debug)]
2684pub enum HfpEvent {}
2685
2686impl HfpEvent {
2687    /// Decodes a message buffer as a [`HfpEvent`].
2688    fn decode(
2689        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2690    ) -> Result<HfpEvent, fidl::Error> {
2691        let (bytes, _handles) = buf.split_mut();
2692        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2693        debug_assert_eq!(tx_header.tx_id, 0);
2694        match tx_header.ordinal {
2695            _ => Err(fidl::Error::UnknownOrdinal {
2696                ordinal: tx_header.ordinal,
2697                protocol_name: <HfpMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2698            }),
2699        }
2700    }
2701}
2702
2703/// A Stream of incoming requests for fuchsia.bluetooth.hfp/Hfp.
2704pub struct HfpRequestStream {
2705    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2706    is_terminated: bool,
2707}
2708
2709impl std::marker::Unpin for HfpRequestStream {}
2710
2711impl futures::stream::FusedStream for HfpRequestStream {
2712    fn is_terminated(&self) -> bool {
2713        self.is_terminated
2714    }
2715}
2716
2717impl fidl::endpoints::RequestStream for HfpRequestStream {
2718    type Protocol = HfpMarker;
2719    type ControlHandle = HfpControlHandle;
2720
2721    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2722        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2723    }
2724
2725    fn control_handle(&self) -> Self::ControlHandle {
2726        HfpControlHandle { inner: self.inner.clone() }
2727    }
2728
2729    fn into_inner(
2730        self,
2731    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2732    {
2733        (self.inner, self.is_terminated)
2734    }
2735
2736    fn from_inner(
2737        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2738        is_terminated: bool,
2739    ) -> Self {
2740        Self { inner, is_terminated }
2741    }
2742}
2743
2744impl futures::Stream for HfpRequestStream {
2745    type Item = Result<HfpRequest, fidl::Error>;
2746
2747    fn poll_next(
2748        mut self: std::pin::Pin<&mut Self>,
2749        cx: &mut std::task::Context<'_>,
2750    ) -> std::task::Poll<Option<Self::Item>> {
2751        let this = &mut *self;
2752        if this.inner.check_shutdown(cx) {
2753            this.is_terminated = true;
2754            return std::task::Poll::Ready(None);
2755        }
2756        if this.is_terminated {
2757            panic!("polled HfpRequestStream after completion");
2758        }
2759        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2760            |bytes, handles| {
2761                match this.inner.channel().read_etc(cx, bytes, handles) {
2762                    std::task::Poll::Ready(Ok(())) => {}
2763                    std::task::Poll::Pending => return std::task::Poll::Pending,
2764                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2765                        this.is_terminated = true;
2766                        return std::task::Poll::Ready(None);
2767                    }
2768                    std::task::Poll::Ready(Err(e)) => {
2769                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2770                            e.into(),
2771                        ))))
2772                    }
2773                }
2774
2775                // A message has been received from the channel
2776                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2777
2778                std::task::Poll::Ready(Some(match header.ordinal {
2779                    0x1b2ea4f6069181ad => {
2780                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2781                        let mut req = fidl::new_empty!(
2782                            HfpRegisterRequest,
2783                            fidl::encoding::DefaultFuchsiaResourceDialect
2784                        );
2785                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HfpRegisterRequest>(&header, _body_bytes, handles, &mut req)?;
2786                        let control_handle = HfpControlHandle { inner: this.inner.clone() };
2787                        Ok(HfpRequest::Register { manager: req.manager, control_handle })
2788                    }
2789                    _ => Err(fidl::Error::UnknownOrdinal {
2790                        ordinal: header.ordinal,
2791                        protocol_name: <HfpMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2792                    }),
2793                }))
2794            },
2795        )
2796    }
2797}
2798
2799#[derive(Debug)]
2800pub enum HfpRequest {
2801    /// Register as the call manager for this device.
2802    ///
2803    /// There can only be one call manager registered at a time. If one is
2804    /// registered at the time a call to `Register` is made, the newer
2805    /// CallManager channel will be closed.
2806    ///
2807    /// A call manager can be unregistered by closing either end of the channel.
2808    Register {
2809        manager: fidl::endpoints::ClientEnd<CallManagerMarker>,
2810        control_handle: HfpControlHandle,
2811    },
2812}
2813
2814impl HfpRequest {
2815    #[allow(irrefutable_let_patterns)]
2816    pub fn into_register(
2817        self,
2818    ) -> Option<(fidl::endpoints::ClientEnd<CallManagerMarker>, HfpControlHandle)> {
2819        if let HfpRequest::Register { manager, control_handle } = self {
2820            Some((manager, control_handle))
2821        } else {
2822            None
2823        }
2824    }
2825
2826    /// Name of the method defined in FIDL
2827    pub fn method_name(&self) -> &'static str {
2828        match *self {
2829            HfpRequest::Register { .. } => "register",
2830        }
2831    }
2832}
2833
2834#[derive(Debug, Clone)]
2835pub struct HfpControlHandle {
2836    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2837}
2838
2839impl fidl::endpoints::ControlHandle for HfpControlHandle {
2840    fn shutdown(&self) {
2841        self.inner.shutdown()
2842    }
2843    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2844        self.inner.shutdown_with_epitaph(status)
2845    }
2846
2847    fn is_closed(&self) -> bool {
2848        self.inner.channel().is_closed()
2849    }
2850    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2851        self.inner.channel().on_closed()
2852    }
2853
2854    #[cfg(target_os = "fuchsia")]
2855    fn signal_peer(
2856        &self,
2857        clear_mask: zx::Signals,
2858        set_mask: zx::Signals,
2859    ) -> Result<(), zx_status::Status> {
2860        use fidl::Peered;
2861        self.inner.channel().signal_peer(clear_mask, set_mask)
2862    }
2863}
2864
2865impl HfpControlHandle {}
2866
2867#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2868pub struct PeerHandlerMarker;
2869
2870impl fidl::endpoints::ProtocolMarker for PeerHandlerMarker {
2871    type Proxy = PeerHandlerProxy;
2872    type RequestStream = PeerHandlerRequestStream;
2873    #[cfg(target_os = "fuchsia")]
2874    type SynchronousProxy = PeerHandlerSynchronousProxy;
2875
2876    const DEBUG_NAME: &'static str = "(anonymous) PeerHandler";
2877}
2878pub type PeerHandlerRequestOutgoingCallResult = Result<(), i32>;
2879pub type PeerHandlerSetNrecModeResult = Result<(), i32>;
2880
2881pub trait PeerHandlerProxyInterface: Send + Sync {
2882    type WatchNetworkInformationResponseFut: std::future::Future<Output = Result<NetworkInformation, fidl::Error>>
2883        + Send;
2884    fn r#watch_network_information(&self) -> Self::WatchNetworkInformationResponseFut;
2885    type WatchNextCallResponseFut: std::future::Future<Output = Result<NextCall, fidl::Error>>
2886        + Send;
2887    fn r#watch_next_call(&self) -> Self::WatchNextCallResponseFut;
2888    type RequestOutgoingCallResponseFut: std::future::Future<Output = Result<PeerHandlerRequestOutgoingCallResult, fidl::Error>>
2889        + Send;
2890    fn r#request_outgoing_call(&self, action: &CallAction) -> Self::RequestOutgoingCallResponseFut;
2891    type QueryOperatorResponseFut: std::future::Future<Output = Result<Option<String>, fidl::Error>>
2892        + Send;
2893    fn r#query_operator(&self) -> Self::QueryOperatorResponseFut;
2894    type SubscriberNumberInformationResponseFut: std::future::Future<Output = Result<Vec<String>, fidl::Error>>
2895        + Send;
2896    fn r#subscriber_number_information(&self) -> Self::SubscriberNumberInformationResponseFut;
2897    type SetNrecModeResponseFut: std::future::Future<Output = Result<PeerHandlerSetNrecModeResult, fidl::Error>>
2898        + Send;
2899    fn r#set_nrec_mode(&self, enabled: bool) -> Self::SetNrecModeResponseFut;
2900    fn r#report_headset_battery_level(&self, level: u8) -> Result<(), fidl::Error>;
2901    fn r#gain_control(
2902        &self,
2903        control: fidl::endpoints::ClientEnd<HeadsetGainMarker>,
2904    ) -> Result<(), fidl::Error>;
2905}
2906#[derive(Debug)]
2907#[cfg(target_os = "fuchsia")]
2908pub struct PeerHandlerSynchronousProxy {
2909    client: fidl::client::sync::Client,
2910}
2911
2912#[cfg(target_os = "fuchsia")]
2913impl fidl::endpoints::SynchronousProxy for PeerHandlerSynchronousProxy {
2914    type Proxy = PeerHandlerProxy;
2915    type Protocol = PeerHandlerMarker;
2916
2917    fn from_channel(inner: fidl::Channel) -> Self {
2918        Self::new(inner)
2919    }
2920
2921    fn into_channel(self) -> fidl::Channel {
2922        self.client.into_channel()
2923    }
2924
2925    fn as_channel(&self) -> &fidl::Channel {
2926        self.client.as_channel()
2927    }
2928}
2929
2930#[cfg(target_os = "fuchsia")]
2931impl PeerHandlerSynchronousProxy {
2932    pub fn new(channel: fidl::Channel) -> Self {
2933        let protocol_name = <PeerHandlerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2934        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2935    }
2936
2937    pub fn into_channel(self) -> fidl::Channel {
2938        self.client.into_channel()
2939    }
2940
2941    /// Waits until an event arrives and returns it. It is safe for other
2942    /// threads to make concurrent requests while waiting for an event.
2943    pub fn wait_for_event(
2944        &self,
2945        deadline: zx::MonotonicInstant,
2946    ) -> Result<PeerHandlerEvent, fidl::Error> {
2947        PeerHandlerEvent::decode(self.client.wait_for_event(deadline)?)
2948    }
2949
2950    /// Hanging get to provide the Hfp service with an `update` on the
2951    /// `NetworkInformation`. Any fields in `update` that are not present will
2952    /// be treated as unmodified by the update.
2953    ///
2954    /// The call manager or audio gateway peer _should_ provide a fully
2955    /// populated `update` when it is called for the first time.
2956    ///
2957    /// The most up-to-date `NetworkInformation` is used during the connection
2958    /// initialization process of the peer, and updates are propagated to the
2959    /// peer if it supports AG Indicators.
2960    pub fn r#watch_network_information(
2961        &self,
2962        ___deadline: zx::MonotonicInstant,
2963    ) -> Result<NetworkInformation, fidl::Error> {
2964        let _response = self
2965            .client
2966            .send_query::<fidl::encoding::EmptyPayload, PeerHandlerWatchNetworkInformationResponse>(
2967                (),
2968                0x1c9eba597076b7cb,
2969                fidl::encoding::DynamicFlags::empty(),
2970                ___deadline,
2971            )?;
2972        Ok(_response.update)
2973    }
2974
2975    /// Hanging get which returns when a new call is initiated by the call
2976    /// manager or audio gateway peer, or an ongoing call is transferred to the
2977    /// headset.  `RequestOutgoingCall` can be called before or after
2978    /// `WatchNextCall`.
2979    pub fn r#watch_next_call(
2980        &self,
2981        ___deadline: zx::MonotonicInstant,
2982    ) -> Result<NextCall, fidl::Error> {
2983        let _response = self
2984            .client
2985            .send_query::<fidl::encoding::EmptyPayload, PeerHandlerWatchNextCallResponse>(
2986                (),
2987                0x5e3b7b4e7c3d359,
2988                fidl::encoding::DynamicFlags::empty(),
2989                ___deadline,
2990            )?;
2991        Ok(_response.call)
2992    }
2993
2994    /// Used to request an outgoing call be initiated by the call manager or
2995    /// audio gateway peer.  `RequestOutgoingCall` shall complete after the
2996    /// outgoing call has been initiated and the corresponding `Call` protocol
2997    /// has been returned via a `WatchNextCall` result.
2998    ///
2999    /// An error is returned if the call could not be placed as requested.
3000    ///
3001    /// - ZX_ERR_NOT_SUPPORTED can be used if the system does not support the
3002    ///   requested action.
3003    ///
3004    /// - ZX_ERR_ALREADY_EXISTS can be used if there is alreadya call in
3005    ///   progress and the system does not support additional calls.
3006    pub fn r#request_outgoing_call(
3007        &self,
3008        mut action: &CallAction,
3009        ___deadline: zx::MonotonicInstant,
3010    ) -> Result<PeerHandlerRequestOutgoingCallResult, fidl::Error> {
3011        let _response = self.client.send_query::<
3012            PeerHandlerRequestOutgoingCallRequest,
3013            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3014        >(
3015            (action,),
3016            0x1a2637c743c89ad,
3017            fidl::encoding::DynamicFlags::empty(),
3018            ___deadline,
3019        )?;
3020        Ok(_response.map(|x| x))
3021    }
3022
3023    /// Request the name of the network operator for the call manager or audio
3024    /// gateway peer. A null value is returned if there is no operator name
3025    /// available.
3026    pub fn r#query_operator(
3027        &self,
3028        ___deadline: zx::MonotonicInstant,
3029    ) -> Result<Option<String>, fidl::Error> {
3030        let _response = self
3031            .client
3032            .send_query::<fidl::encoding::EmptyPayload, PeerHandlerQueryOperatorResponse>(
3033                (),
3034                0x1217eaf5db4c3300,
3035                fidl::encoding::DynamicFlags::empty(),
3036                ___deadline,
3037            )?;
3038        Ok(_response.operator)
3039    }
3040
3041    /// Request subscriber numbers from the call manager or audio gateway peer.
3042    /// There can be zero or more numbers returned. Sending more than 128
3043    /// numbers is not supported at this time.
3044    pub fn r#subscriber_number_information(
3045        &self,
3046        ___deadline: zx::MonotonicInstant,
3047    ) -> Result<Vec<String>, fidl::Error> {
3048        let _response = self.client.send_query::<
3049            fidl::encoding::EmptyPayload,
3050            PeerHandlerSubscriberNumberInformationResponse,
3051        >(
3052            (),
3053            0x15f5235855b02a3a,
3054            fidl::encoding::DynamicFlags::empty(),
3055            ___deadline,
3056        )?;
3057        Ok(_response.numbers)
3058    }
3059
3060    /// Request by the HF to enable or disable the Noise Reduction/Echo Cancellation
3061    /// functionality on the AG based on the `enabled` boolean.
3062    /// A `ZX_ERR_NOT_SUPPORTED` error is returned if Noice Reduction/Echo
3063    /// Cancellation is not supported by the device.
3064    pub fn r#set_nrec_mode(
3065        &self,
3066        mut enabled: bool,
3067        ___deadline: zx::MonotonicInstant,
3068    ) -> Result<PeerHandlerSetNrecModeResult, fidl::Error> {
3069        let _response = self.client.send_query::<
3070            PeerHandlerSetNrecModeRequest,
3071            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3072        >(
3073            (enabled,),
3074            0x2f8890d0f866672f,
3075            fidl::encoding::DynamicFlags::empty(),
3076            ___deadline,
3077        )?;
3078        Ok(_response.map(|x| x))
3079    }
3080
3081    /// Headset battery level from 0 ~ 100
3082    /// See https://www.bluetooth.com/specifications/assigned-numbers/hands-free-profile/
3083    pub fn r#report_headset_battery_level(&self, mut level: u8) -> Result<(), fidl::Error> {
3084        self.client.send::<PeerHandlerReportHeadsetBatteryLevelRequest>(
3085            (level,),
3086            0x4e3e8be4680d85b,
3087            fidl::encoding::DynamicFlags::empty(),
3088        )
3089    }
3090
3091    /// Tear off protocol for Headset Gain.
3092    ///
3093    /// Only one HeadsetGain protocol can be active for a PeerHandler protocol
3094    /// at any given time. Older HeadsetGain protocols are given preference. If
3095    /// a HeadsetGain protocol is active when a new GainControl request is made,
3096    /// the new HeadsetGain protocol will be closed immediately.
3097    pub fn r#gain_control(
3098        &self,
3099        mut control: fidl::endpoints::ClientEnd<HeadsetGainMarker>,
3100    ) -> Result<(), fidl::Error> {
3101        self.client.send::<PeerHandlerGainControlRequest>(
3102            (control,),
3103            0x6e043b6d2e0fb917,
3104            fidl::encoding::DynamicFlags::empty(),
3105        )
3106    }
3107}
3108
3109#[derive(Debug, Clone)]
3110pub struct PeerHandlerProxy {
3111    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3112}
3113
3114impl fidl::endpoints::Proxy for PeerHandlerProxy {
3115    type Protocol = PeerHandlerMarker;
3116
3117    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3118        Self::new(inner)
3119    }
3120
3121    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3122        self.client.into_channel().map_err(|client| Self { client })
3123    }
3124
3125    fn as_channel(&self) -> &::fidl::AsyncChannel {
3126        self.client.as_channel()
3127    }
3128}
3129
3130impl PeerHandlerProxy {
3131    /// Create a new Proxy for fuchsia.bluetooth.hfp/PeerHandler.
3132    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3133        let protocol_name = <PeerHandlerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3134        Self { client: fidl::client::Client::new(channel, protocol_name) }
3135    }
3136
3137    /// Get a Stream of events from the remote end of the protocol.
3138    ///
3139    /// # Panics
3140    ///
3141    /// Panics if the event stream was already taken.
3142    pub fn take_event_stream(&self) -> PeerHandlerEventStream {
3143        PeerHandlerEventStream { event_receiver: self.client.take_event_receiver() }
3144    }
3145
3146    /// Hanging get to provide the Hfp service with an `update` on the
3147    /// `NetworkInformation`. Any fields in `update` that are not present will
3148    /// be treated as unmodified by the update.
3149    ///
3150    /// The call manager or audio gateway peer _should_ provide a fully
3151    /// populated `update` when it is called for the first time.
3152    ///
3153    /// The most up-to-date `NetworkInformation` is used during the connection
3154    /// initialization process of the peer, and updates are propagated to the
3155    /// peer if it supports AG Indicators.
3156    pub fn r#watch_network_information(
3157        &self,
3158    ) -> fidl::client::QueryResponseFut<
3159        NetworkInformation,
3160        fidl::encoding::DefaultFuchsiaResourceDialect,
3161    > {
3162        PeerHandlerProxyInterface::r#watch_network_information(self)
3163    }
3164
3165    /// Hanging get which returns when a new call is initiated by the call
3166    /// manager or audio gateway peer, or an ongoing call is transferred to the
3167    /// headset.  `RequestOutgoingCall` can be called before or after
3168    /// `WatchNextCall`.
3169    pub fn r#watch_next_call(
3170        &self,
3171    ) -> fidl::client::QueryResponseFut<NextCall, fidl::encoding::DefaultFuchsiaResourceDialect>
3172    {
3173        PeerHandlerProxyInterface::r#watch_next_call(self)
3174    }
3175
3176    /// Used to request an outgoing call be initiated by the call manager or
3177    /// audio gateway peer.  `RequestOutgoingCall` shall complete after the
3178    /// outgoing call has been initiated and the corresponding `Call` protocol
3179    /// has been returned via a `WatchNextCall` result.
3180    ///
3181    /// An error is returned if the call could not be placed as requested.
3182    ///
3183    /// - ZX_ERR_NOT_SUPPORTED can be used if the system does not support the
3184    ///   requested action.
3185    ///
3186    /// - ZX_ERR_ALREADY_EXISTS can be used if there is alreadya call in
3187    ///   progress and the system does not support additional calls.
3188    pub fn r#request_outgoing_call(
3189        &self,
3190        mut action: &CallAction,
3191    ) -> fidl::client::QueryResponseFut<
3192        PeerHandlerRequestOutgoingCallResult,
3193        fidl::encoding::DefaultFuchsiaResourceDialect,
3194    > {
3195        PeerHandlerProxyInterface::r#request_outgoing_call(self, action)
3196    }
3197
3198    /// Request the name of the network operator for the call manager or audio
3199    /// gateway peer. A null value is returned if there is no operator name
3200    /// available.
3201    pub fn r#query_operator(
3202        &self,
3203    ) -> fidl::client::QueryResponseFut<Option<String>, fidl::encoding::DefaultFuchsiaResourceDialect>
3204    {
3205        PeerHandlerProxyInterface::r#query_operator(self)
3206    }
3207
3208    /// Request subscriber numbers from the call manager or audio gateway peer.
3209    /// There can be zero or more numbers returned. Sending more than 128
3210    /// numbers is not supported at this time.
3211    pub fn r#subscriber_number_information(
3212        &self,
3213    ) -> fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>
3214    {
3215        PeerHandlerProxyInterface::r#subscriber_number_information(self)
3216    }
3217
3218    /// Request by the HF to enable or disable the Noise Reduction/Echo Cancellation
3219    /// functionality on the AG based on the `enabled` boolean.
3220    /// A `ZX_ERR_NOT_SUPPORTED` error is returned if Noice Reduction/Echo
3221    /// Cancellation is not supported by the device.
3222    pub fn r#set_nrec_mode(
3223        &self,
3224        mut enabled: bool,
3225    ) -> fidl::client::QueryResponseFut<
3226        PeerHandlerSetNrecModeResult,
3227        fidl::encoding::DefaultFuchsiaResourceDialect,
3228    > {
3229        PeerHandlerProxyInterface::r#set_nrec_mode(self, enabled)
3230    }
3231
3232    /// Headset battery level from 0 ~ 100
3233    /// See https://www.bluetooth.com/specifications/assigned-numbers/hands-free-profile/
3234    pub fn r#report_headset_battery_level(&self, mut level: u8) -> Result<(), fidl::Error> {
3235        PeerHandlerProxyInterface::r#report_headset_battery_level(self, level)
3236    }
3237
3238    /// Tear off protocol for Headset Gain.
3239    ///
3240    /// Only one HeadsetGain protocol can be active for a PeerHandler protocol
3241    /// at any given time. Older HeadsetGain protocols are given preference. If
3242    /// a HeadsetGain protocol is active when a new GainControl request is made,
3243    /// the new HeadsetGain protocol will be closed immediately.
3244    pub fn r#gain_control(
3245        &self,
3246        mut control: fidl::endpoints::ClientEnd<HeadsetGainMarker>,
3247    ) -> Result<(), fidl::Error> {
3248        PeerHandlerProxyInterface::r#gain_control(self, control)
3249    }
3250}
3251
3252impl PeerHandlerProxyInterface for PeerHandlerProxy {
3253    type WatchNetworkInformationResponseFut = fidl::client::QueryResponseFut<
3254        NetworkInformation,
3255        fidl::encoding::DefaultFuchsiaResourceDialect,
3256    >;
3257    fn r#watch_network_information(&self) -> Self::WatchNetworkInformationResponseFut {
3258        fn _decode(
3259            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3260        ) -> Result<NetworkInformation, fidl::Error> {
3261            let _response = fidl::client::decode_transaction_body::<
3262                PeerHandlerWatchNetworkInformationResponse,
3263                fidl::encoding::DefaultFuchsiaResourceDialect,
3264                0x1c9eba597076b7cb,
3265            >(_buf?)?;
3266            Ok(_response.update)
3267        }
3268        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NetworkInformation>(
3269            (),
3270            0x1c9eba597076b7cb,
3271            fidl::encoding::DynamicFlags::empty(),
3272            _decode,
3273        )
3274    }
3275
3276    type WatchNextCallResponseFut =
3277        fidl::client::QueryResponseFut<NextCall, fidl::encoding::DefaultFuchsiaResourceDialect>;
3278    fn r#watch_next_call(&self) -> Self::WatchNextCallResponseFut {
3279        fn _decode(
3280            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3281        ) -> Result<NextCall, fidl::Error> {
3282            let _response = fidl::client::decode_transaction_body::<
3283                PeerHandlerWatchNextCallResponse,
3284                fidl::encoding::DefaultFuchsiaResourceDialect,
3285                0x5e3b7b4e7c3d359,
3286            >(_buf?)?;
3287            Ok(_response.call)
3288        }
3289        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NextCall>(
3290            (),
3291            0x5e3b7b4e7c3d359,
3292            fidl::encoding::DynamicFlags::empty(),
3293            _decode,
3294        )
3295    }
3296
3297    type RequestOutgoingCallResponseFut = fidl::client::QueryResponseFut<
3298        PeerHandlerRequestOutgoingCallResult,
3299        fidl::encoding::DefaultFuchsiaResourceDialect,
3300    >;
3301    fn r#request_outgoing_call(
3302        &self,
3303        mut action: &CallAction,
3304    ) -> Self::RequestOutgoingCallResponseFut {
3305        fn _decode(
3306            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3307        ) -> Result<PeerHandlerRequestOutgoingCallResult, fidl::Error> {
3308            let _response = fidl::client::decode_transaction_body::<
3309                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3310                fidl::encoding::DefaultFuchsiaResourceDialect,
3311                0x1a2637c743c89ad,
3312            >(_buf?)?;
3313            Ok(_response.map(|x| x))
3314        }
3315        self.client.send_query_and_decode::<
3316            PeerHandlerRequestOutgoingCallRequest,
3317            PeerHandlerRequestOutgoingCallResult,
3318        >(
3319            (action,),
3320            0x1a2637c743c89ad,
3321            fidl::encoding::DynamicFlags::empty(),
3322            _decode,
3323        )
3324    }
3325
3326    type QueryOperatorResponseFut = fidl::client::QueryResponseFut<
3327        Option<String>,
3328        fidl::encoding::DefaultFuchsiaResourceDialect,
3329    >;
3330    fn r#query_operator(&self) -> Self::QueryOperatorResponseFut {
3331        fn _decode(
3332            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3333        ) -> Result<Option<String>, fidl::Error> {
3334            let _response = fidl::client::decode_transaction_body::<
3335                PeerHandlerQueryOperatorResponse,
3336                fidl::encoding::DefaultFuchsiaResourceDialect,
3337                0x1217eaf5db4c3300,
3338            >(_buf?)?;
3339            Ok(_response.operator)
3340        }
3341        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Option<String>>(
3342            (),
3343            0x1217eaf5db4c3300,
3344            fidl::encoding::DynamicFlags::empty(),
3345            _decode,
3346        )
3347    }
3348
3349    type SubscriberNumberInformationResponseFut =
3350        fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>;
3351    fn r#subscriber_number_information(&self) -> Self::SubscriberNumberInformationResponseFut {
3352        fn _decode(
3353            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3354        ) -> Result<Vec<String>, fidl::Error> {
3355            let _response = fidl::client::decode_transaction_body::<
3356                PeerHandlerSubscriberNumberInformationResponse,
3357                fidl::encoding::DefaultFuchsiaResourceDialect,
3358                0x15f5235855b02a3a,
3359            >(_buf?)?;
3360            Ok(_response.numbers)
3361        }
3362        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<String>>(
3363            (),
3364            0x15f5235855b02a3a,
3365            fidl::encoding::DynamicFlags::empty(),
3366            _decode,
3367        )
3368    }
3369
3370    type SetNrecModeResponseFut = fidl::client::QueryResponseFut<
3371        PeerHandlerSetNrecModeResult,
3372        fidl::encoding::DefaultFuchsiaResourceDialect,
3373    >;
3374    fn r#set_nrec_mode(&self, mut enabled: bool) -> Self::SetNrecModeResponseFut {
3375        fn _decode(
3376            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3377        ) -> Result<PeerHandlerSetNrecModeResult, fidl::Error> {
3378            let _response = fidl::client::decode_transaction_body::<
3379                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3380                fidl::encoding::DefaultFuchsiaResourceDialect,
3381                0x2f8890d0f866672f,
3382            >(_buf?)?;
3383            Ok(_response.map(|x| x))
3384        }
3385        self.client
3386            .send_query_and_decode::<PeerHandlerSetNrecModeRequest, PeerHandlerSetNrecModeResult>(
3387                (enabled,),
3388                0x2f8890d0f866672f,
3389                fidl::encoding::DynamicFlags::empty(),
3390                _decode,
3391            )
3392    }
3393
3394    fn r#report_headset_battery_level(&self, mut level: u8) -> Result<(), fidl::Error> {
3395        self.client.send::<PeerHandlerReportHeadsetBatteryLevelRequest>(
3396            (level,),
3397            0x4e3e8be4680d85b,
3398            fidl::encoding::DynamicFlags::empty(),
3399        )
3400    }
3401
3402    fn r#gain_control(
3403        &self,
3404        mut control: fidl::endpoints::ClientEnd<HeadsetGainMarker>,
3405    ) -> Result<(), fidl::Error> {
3406        self.client.send::<PeerHandlerGainControlRequest>(
3407            (control,),
3408            0x6e043b6d2e0fb917,
3409            fidl::encoding::DynamicFlags::empty(),
3410        )
3411    }
3412}
3413
3414pub struct PeerHandlerEventStream {
3415    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3416}
3417
3418impl std::marker::Unpin for PeerHandlerEventStream {}
3419
3420impl futures::stream::FusedStream for PeerHandlerEventStream {
3421    fn is_terminated(&self) -> bool {
3422        self.event_receiver.is_terminated()
3423    }
3424}
3425
3426impl futures::Stream for PeerHandlerEventStream {
3427    type Item = Result<PeerHandlerEvent, fidl::Error>;
3428
3429    fn poll_next(
3430        mut self: std::pin::Pin<&mut Self>,
3431        cx: &mut std::task::Context<'_>,
3432    ) -> std::task::Poll<Option<Self::Item>> {
3433        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3434            &mut self.event_receiver,
3435            cx
3436        )?) {
3437            Some(buf) => std::task::Poll::Ready(Some(PeerHandlerEvent::decode(buf))),
3438            None => std::task::Poll::Ready(None),
3439        }
3440    }
3441}
3442
3443#[derive(Debug)]
3444pub enum PeerHandlerEvent {}
3445
3446impl PeerHandlerEvent {
3447    /// Decodes a message buffer as a [`PeerHandlerEvent`].
3448    fn decode(
3449        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3450    ) -> Result<PeerHandlerEvent, fidl::Error> {
3451        let (bytes, _handles) = buf.split_mut();
3452        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3453        debug_assert_eq!(tx_header.tx_id, 0);
3454        match tx_header.ordinal {
3455            _ => Err(fidl::Error::UnknownOrdinal {
3456                ordinal: tx_header.ordinal,
3457                protocol_name: <PeerHandlerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3458            }),
3459        }
3460    }
3461}
3462
3463/// A Stream of incoming requests for fuchsia.bluetooth.hfp/PeerHandler.
3464pub struct PeerHandlerRequestStream {
3465    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3466    is_terminated: bool,
3467}
3468
3469impl std::marker::Unpin for PeerHandlerRequestStream {}
3470
3471impl futures::stream::FusedStream for PeerHandlerRequestStream {
3472    fn is_terminated(&self) -> bool {
3473        self.is_terminated
3474    }
3475}
3476
3477impl fidl::endpoints::RequestStream for PeerHandlerRequestStream {
3478    type Protocol = PeerHandlerMarker;
3479    type ControlHandle = PeerHandlerControlHandle;
3480
3481    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3482        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3483    }
3484
3485    fn control_handle(&self) -> Self::ControlHandle {
3486        PeerHandlerControlHandle { inner: self.inner.clone() }
3487    }
3488
3489    fn into_inner(
3490        self,
3491    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3492    {
3493        (self.inner, self.is_terminated)
3494    }
3495
3496    fn from_inner(
3497        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3498        is_terminated: bool,
3499    ) -> Self {
3500        Self { inner, is_terminated }
3501    }
3502}
3503
3504impl futures::Stream for PeerHandlerRequestStream {
3505    type Item = Result<PeerHandlerRequest, fidl::Error>;
3506
3507    fn poll_next(
3508        mut self: std::pin::Pin<&mut Self>,
3509        cx: &mut std::task::Context<'_>,
3510    ) -> std::task::Poll<Option<Self::Item>> {
3511        let this = &mut *self;
3512        if this.inner.check_shutdown(cx) {
3513            this.is_terminated = true;
3514            return std::task::Poll::Ready(None);
3515        }
3516        if this.is_terminated {
3517            panic!("polled PeerHandlerRequestStream after completion");
3518        }
3519        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3520            |bytes, handles| {
3521                match this.inner.channel().read_etc(cx, bytes, handles) {
3522                    std::task::Poll::Ready(Ok(())) => {}
3523                    std::task::Poll::Pending => return std::task::Poll::Pending,
3524                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3525                        this.is_terminated = true;
3526                        return std::task::Poll::Ready(None);
3527                    }
3528                    std::task::Poll::Ready(Err(e)) => {
3529                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3530                            e.into(),
3531                        ))))
3532                    }
3533                }
3534
3535                // A message has been received from the channel
3536                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3537
3538                std::task::Poll::Ready(Some(match header.ordinal {
3539                    0x1c9eba597076b7cb => {
3540                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3541                        let mut req = fidl::new_empty!(
3542                            fidl::encoding::EmptyPayload,
3543                            fidl::encoding::DefaultFuchsiaResourceDialect
3544                        );
3545                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3546                        let control_handle = PeerHandlerControlHandle { inner: this.inner.clone() };
3547                        Ok(PeerHandlerRequest::WatchNetworkInformation {
3548                            responder: PeerHandlerWatchNetworkInformationResponder {
3549                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3550                                tx_id: header.tx_id,
3551                            },
3552                        })
3553                    }
3554                    0x5e3b7b4e7c3d359 => {
3555                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3556                        let mut req = fidl::new_empty!(
3557                            fidl::encoding::EmptyPayload,
3558                            fidl::encoding::DefaultFuchsiaResourceDialect
3559                        );
3560                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3561                        let control_handle = PeerHandlerControlHandle { inner: this.inner.clone() };
3562                        Ok(PeerHandlerRequest::WatchNextCall {
3563                            responder: PeerHandlerWatchNextCallResponder {
3564                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3565                                tx_id: header.tx_id,
3566                            },
3567                        })
3568                    }
3569                    0x1a2637c743c89ad => {
3570                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3571                        let mut req = fidl::new_empty!(
3572                            PeerHandlerRequestOutgoingCallRequest,
3573                            fidl::encoding::DefaultFuchsiaResourceDialect
3574                        );
3575                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerHandlerRequestOutgoingCallRequest>(&header, _body_bytes, handles, &mut req)?;
3576                        let control_handle = PeerHandlerControlHandle { inner: this.inner.clone() };
3577                        Ok(PeerHandlerRequest::RequestOutgoingCall {
3578                            action: req.action,
3579
3580                            responder: PeerHandlerRequestOutgoingCallResponder {
3581                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3582                                tx_id: header.tx_id,
3583                            },
3584                        })
3585                    }
3586                    0x1217eaf5db4c3300 => {
3587                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3588                        let mut req = fidl::new_empty!(
3589                            fidl::encoding::EmptyPayload,
3590                            fidl::encoding::DefaultFuchsiaResourceDialect
3591                        );
3592                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3593                        let control_handle = PeerHandlerControlHandle { inner: this.inner.clone() };
3594                        Ok(PeerHandlerRequest::QueryOperator {
3595                            responder: PeerHandlerQueryOperatorResponder {
3596                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3597                                tx_id: header.tx_id,
3598                            },
3599                        })
3600                    }
3601                    0x15f5235855b02a3a => {
3602                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3603                        let mut req = fidl::new_empty!(
3604                            fidl::encoding::EmptyPayload,
3605                            fidl::encoding::DefaultFuchsiaResourceDialect
3606                        );
3607                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3608                        let control_handle = PeerHandlerControlHandle { inner: this.inner.clone() };
3609                        Ok(PeerHandlerRequest::SubscriberNumberInformation {
3610                            responder: PeerHandlerSubscriberNumberInformationResponder {
3611                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3612                                tx_id: header.tx_id,
3613                            },
3614                        })
3615                    }
3616                    0x2f8890d0f866672f => {
3617                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3618                        let mut req = fidl::new_empty!(
3619                            PeerHandlerSetNrecModeRequest,
3620                            fidl::encoding::DefaultFuchsiaResourceDialect
3621                        );
3622                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerHandlerSetNrecModeRequest>(&header, _body_bytes, handles, &mut req)?;
3623                        let control_handle = PeerHandlerControlHandle { inner: this.inner.clone() };
3624                        Ok(PeerHandlerRequest::SetNrecMode {
3625                            enabled: req.enabled,
3626
3627                            responder: PeerHandlerSetNrecModeResponder {
3628                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3629                                tx_id: header.tx_id,
3630                            },
3631                        })
3632                    }
3633                    0x4e3e8be4680d85b => {
3634                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3635                        let mut req = fidl::new_empty!(
3636                            PeerHandlerReportHeadsetBatteryLevelRequest,
3637                            fidl::encoding::DefaultFuchsiaResourceDialect
3638                        );
3639                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerHandlerReportHeadsetBatteryLevelRequest>(&header, _body_bytes, handles, &mut req)?;
3640                        let control_handle = PeerHandlerControlHandle { inner: this.inner.clone() };
3641                        Ok(PeerHandlerRequest::ReportHeadsetBatteryLevel {
3642                            level: req.level,
3643
3644                            control_handle,
3645                        })
3646                    }
3647                    0x6e043b6d2e0fb917 => {
3648                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3649                        let mut req = fidl::new_empty!(
3650                            PeerHandlerGainControlRequest,
3651                            fidl::encoding::DefaultFuchsiaResourceDialect
3652                        );
3653                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerHandlerGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
3654                        let control_handle = PeerHandlerControlHandle { inner: this.inner.clone() };
3655                        Ok(PeerHandlerRequest::GainControl { control: req.control, control_handle })
3656                    }
3657                    _ => Err(fidl::Error::UnknownOrdinal {
3658                        ordinal: header.ordinal,
3659                        protocol_name:
3660                            <PeerHandlerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3661                    }),
3662                }))
3663            },
3664        )
3665    }
3666}
3667
3668/// The call manager or the hands-free server component will serve a call
3669/// handler protocol for each connected headset that it chooses to manage calls
3670/// through.
3671///
3672/// If the peer handler is closed by either channel endpoint, all protocols
3673/// associated with this peer handler are closed. This includes any Call, and
3674/// HeadsetGain protocols. Channels closed by a server end will include an
3675/// epitaph `ZX_ERR_HANDLE_CLOSED` in this situation.
3676#[derive(Debug)]
3677pub enum PeerHandlerRequest {
3678    /// Hanging get to provide the Hfp service with an `update` on the
3679    /// `NetworkInformation`. Any fields in `update` that are not present will
3680    /// be treated as unmodified by the update.
3681    ///
3682    /// The call manager or audio gateway peer _should_ provide a fully
3683    /// populated `update` when it is called for the first time.
3684    ///
3685    /// The most up-to-date `NetworkInformation` is used during the connection
3686    /// initialization process of the peer, and updates are propagated to the
3687    /// peer if it supports AG Indicators.
3688    WatchNetworkInformation { responder: PeerHandlerWatchNetworkInformationResponder },
3689    /// Hanging get which returns when a new call is initiated by the call
3690    /// manager or audio gateway peer, or an ongoing call is transferred to the
3691    /// headset.  `RequestOutgoingCall` can be called before or after
3692    /// `WatchNextCall`.
3693    WatchNextCall { responder: PeerHandlerWatchNextCallResponder },
3694    /// Used to request an outgoing call be initiated by the call manager or
3695    /// audio gateway peer.  `RequestOutgoingCall` shall complete after the
3696    /// outgoing call has been initiated and the corresponding `Call` protocol
3697    /// has been returned via a `WatchNextCall` result.
3698    ///
3699    /// An error is returned if the call could not be placed as requested.
3700    ///
3701    /// - ZX_ERR_NOT_SUPPORTED can be used if the system does not support the
3702    ///   requested action.
3703    ///
3704    /// - ZX_ERR_ALREADY_EXISTS can be used if there is alreadya call in
3705    ///   progress and the system does not support additional calls.
3706    RequestOutgoingCall { action: CallAction, responder: PeerHandlerRequestOutgoingCallResponder },
3707    /// Request the name of the network operator for the call manager or audio
3708    /// gateway peer. A null value is returned if there is no operator name
3709    /// available.
3710    QueryOperator { responder: PeerHandlerQueryOperatorResponder },
3711    /// Request subscriber numbers from the call manager or audio gateway peer.
3712    /// There can be zero or more numbers returned. Sending more than 128
3713    /// numbers is not supported at this time.
3714    SubscriberNumberInformation { responder: PeerHandlerSubscriberNumberInformationResponder },
3715    /// Request by the HF to enable or disable the Noise Reduction/Echo Cancellation
3716    /// functionality on the AG based on the `enabled` boolean.
3717    /// A `ZX_ERR_NOT_SUPPORTED` error is returned if Noice Reduction/Echo
3718    /// Cancellation is not supported by the device.
3719    SetNrecMode { enabled: bool, responder: PeerHandlerSetNrecModeResponder },
3720    /// Headset battery level from 0 ~ 100
3721    /// See https://www.bluetooth.com/specifications/assigned-numbers/hands-free-profile/
3722    ReportHeadsetBatteryLevel { level: u8, control_handle: PeerHandlerControlHandle },
3723    /// Tear off protocol for Headset Gain.
3724    ///
3725    /// Only one HeadsetGain protocol can be active for a PeerHandler protocol
3726    /// at any given time. Older HeadsetGain protocols are given preference. If
3727    /// a HeadsetGain protocol is active when a new GainControl request is made,
3728    /// the new HeadsetGain protocol will be closed immediately.
3729    GainControl {
3730        control: fidl::endpoints::ClientEnd<HeadsetGainMarker>,
3731        control_handle: PeerHandlerControlHandle,
3732    },
3733}
3734
3735impl PeerHandlerRequest {
3736    #[allow(irrefutable_let_patterns)]
3737    pub fn into_watch_network_information(
3738        self,
3739    ) -> Option<(PeerHandlerWatchNetworkInformationResponder)> {
3740        if let PeerHandlerRequest::WatchNetworkInformation { responder } = self {
3741            Some((responder))
3742        } else {
3743            None
3744        }
3745    }
3746
3747    #[allow(irrefutable_let_patterns)]
3748    pub fn into_watch_next_call(self) -> Option<(PeerHandlerWatchNextCallResponder)> {
3749        if let PeerHandlerRequest::WatchNextCall { responder } = self {
3750            Some((responder))
3751        } else {
3752            None
3753        }
3754    }
3755
3756    #[allow(irrefutable_let_patterns)]
3757    pub fn into_request_outgoing_call(
3758        self,
3759    ) -> Option<(CallAction, PeerHandlerRequestOutgoingCallResponder)> {
3760        if let PeerHandlerRequest::RequestOutgoingCall { action, responder } = self {
3761            Some((action, responder))
3762        } else {
3763            None
3764        }
3765    }
3766
3767    #[allow(irrefutable_let_patterns)]
3768    pub fn into_query_operator(self) -> Option<(PeerHandlerQueryOperatorResponder)> {
3769        if let PeerHandlerRequest::QueryOperator { responder } = self {
3770            Some((responder))
3771        } else {
3772            None
3773        }
3774    }
3775
3776    #[allow(irrefutable_let_patterns)]
3777    pub fn into_subscriber_number_information(
3778        self,
3779    ) -> Option<(PeerHandlerSubscriberNumberInformationResponder)> {
3780        if let PeerHandlerRequest::SubscriberNumberInformation { responder } = self {
3781            Some((responder))
3782        } else {
3783            None
3784        }
3785    }
3786
3787    #[allow(irrefutable_let_patterns)]
3788    pub fn into_set_nrec_mode(self) -> Option<(bool, PeerHandlerSetNrecModeResponder)> {
3789        if let PeerHandlerRequest::SetNrecMode { enabled, responder } = self {
3790            Some((enabled, responder))
3791        } else {
3792            None
3793        }
3794    }
3795
3796    #[allow(irrefutable_let_patterns)]
3797    pub fn into_report_headset_battery_level(self) -> Option<(u8, PeerHandlerControlHandle)> {
3798        if let PeerHandlerRequest::ReportHeadsetBatteryLevel { level, control_handle } = self {
3799            Some((level, control_handle))
3800        } else {
3801            None
3802        }
3803    }
3804
3805    #[allow(irrefutable_let_patterns)]
3806    pub fn into_gain_control(
3807        self,
3808    ) -> Option<(fidl::endpoints::ClientEnd<HeadsetGainMarker>, PeerHandlerControlHandle)> {
3809        if let PeerHandlerRequest::GainControl { control, control_handle } = self {
3810            Some((control, control_handle))
3811        } else {
3812            None
3813        }
3814    }
3815
3816    /// Name of the method defined in FIDL
3817    pub fn method_name(&self) -> &'static str {
3818        match *self {
3819            PeerHandlerRequest::WatchNetworkInformation { .. } => "watch_network_information",
3820            PeerHandlerRequest::WatchNextCall { .. } => "watch_next_call",
3821            PeerHandlerRequest::RequestOutgoingCall { .. } => "request_outgoing_call",
3822            PeerHandlerRequest::QueryOperator { .. } => "query_operator",
3823            PeerHandlerRequest::SubscriberNumberInformation { .. } => {
3824                "subscriber_number_information"
3825            }
3826            PeerHandlerRequest::SetNrecMode { .. } => "set_nrec_mode",
3827            PeerHandlerRequest::ReportHeadsetBatteryLevel { .. } => "report_headset_battery_level",
3828            PeerHandlerRequest::GainControl { .. } => "gain_control",
3829        }
3830    }
3831}
3832
3833#[derive(Debug, Clone)]
3834pub struct PeerHandlerControlHandle {
3835    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3836}
3837
3838impl fidl::endpoints::ControlHandle for PeerHandlerControlHandle {
3839    fn shutdown(&self) {
3840        self.inner.shutdown()
3841    }
3842    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3843        self.inner.shutdown_with_epitaph(status)
3844    }
3845
3846    fn is_closed(&self) -> bool {
3847        self.inner.channel().is_closed()
3848    }
3849    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3850        self.inner.channel().on_closed()
3851    }
3852
3853    #[cfg(target_os = "fuchsia")]
3854    fn signal_peer(
3855        &self,
3856        clear_mask: zx::Signals,
3857        set_mask: zx::Signals,
3858    ) -> Result<(), zx_status::Status> {
3859        use fidl::Peered;
3860        self.inner.channel().signal_peer(clear_mask, set_mask)
3861    }
3862}
3863
3864impl PeerHandlerControlHandle {}
3865
3866#[must_use = "FIDL methods require a response to be sent"]
3867#[derive(Debug)]
3868pub struct PeerHandlerWatchNetworkInformationResponder {
3869    control_handle: std::mem::ManuallyDrop<PeerHandlerControlHandle>,
3870    tx_id: u32,
3871}
3872
3873/// Set the the channel to be shutdown (see [`PeerHandlerControlHandle::shutdown`])
3874/// if the responder is dropped without sending a response, so that the client
3875/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3876impl std::ops::Drop for PeerHandlerWatchNetworkInformationResponder {
3877    fn drop(&mut self) {
3878        self.control_handle.shutdown();
3879        // Safety: drops once, never accessed again
3880        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3881    }
3882}
3883
3884impl fidl::endpoints::Responder for PeerHandlerWatchNetworkInformationResponder {
3885    type ControlHandle = PeerHandlerControlHandle;
3886
3887    fn control_handle(&self) -> &PeerHandlerControlHandle {
3888        &self.control_handle
3889    }
3890
3891    fn drop_without_shutdown(mut self) {
3892        // Safety: drops once, never accessed again due to mem::forget
3893        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3894        // Prevent Drop from running (which would shut down the channel)
3895        std::mem::forget(self);
3896    }
3897}
3898
3899impl PeerHandlerWatchNetworkInformationResponder {
3900    /// Sends a response to the FIDL transaction.
3901    ///
3902    /// Sets the channel to shutdown if an error occurs.
3903    pub fn send(self, mut update: &NetworkInformation) -> Result<(), fidl::Error> {
3904        let _result = self.send_raw(update);
3905        if _result.is_err() {
3906            self.control_handle.shutdown();
3907        }
3908        self.drop_without_shutdown();
3909        _result
3910    }
3911
3912    /// Similar to "send" but does not shutdown the channel if an error occurs.
3913    pub fn send_no_shutdown_on_err(
3914        self,
3915        mut update: &NetworkInformation,
3916    ) -> Result<(), fidl::Error> {
3917        let _result = self.send_raw(update);
3918        self.drop_without_shutdown();
3919        _result
3920    }
3921
3922    fn send_raw(&self, mut update: &NetworkInformation) -> Result<(), fidl::Error> {
3923        self.control_handle.inner.send::<PeerHandlerWatchNetworkInformationResponse>(
3924            (update,),
3925            self.tx_id,
3926            0x1c9eba597076b7cb,
3927            fidl::encoding::DynamicFlags::empty(),
3928        )
3929    }
3930}
3931
3932#[must_use = "FIDL methods require a response to be sent"]
3933#[derive(Debug)]
3934pub struct PeerHandlerWatchNextCallResponder {
3935    control_handle: std::mem::ManuallyDrop<PeerHandlerControlHandle>,
3936    tx_id: u32,
3937}
3938
3939/// Set the the channel to be shutdown (see [`PeerHandlerControlHandle::shutdown`])
3940/// if the responder is dropped without sending a response, so that the client
3941/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3942impl std::ops::Drop for PeerHandlerWatchNextCallResponder {
3943    fn drop(&mut self) {
3944        self.control_handle.shutdown();
3945        // Safety: drops once, never accessed again
3946        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3947    }
3948}
3949
3950impl fidl::endpoints::Responder for PeerHandlerWatchNextCallResponder {
3951    type ControlHandle = PeerHandlerControlHandle;
3952
3953    fn control_handle(&self) -> &PeerHandlerControlHandle {
3954        &self.control_handle
3955    }
3956
3957    fn drop_without_shutdown(mut self) {
3958        // Safety: drops once, never accessed again due to mem::forget
3959        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3960        // Prevent Drop from running (which would shut down the channel)
3961        std::mem::forget(self);
3962    }
3963}
3964
3965impl PeerHandlerWatchNextCallResponder {
3966    /// Sends a response to the FIDL transaction.
3967    ///
3968    /// Sets the channel to shutdown if an error occurs.
3969    pub fn send(self, mut call: NextCall) -> Result<(), fidl::Error> {
3970        let _result = self.send_raw(call);
3971        if _result.is_err() {
3972            self.control_handle.shutdown();
3973        }
3974        self.drop_without_shutdown();
3975        _result
3976    }
3977
3978    /// Similar to "send" but does not shutdown the channel if an error occurs.
3979    pub fn send_no_shutdown_on_err(self, mut call: NextCall) -> Result<(), fidl::Error> {
3980        let _result = self.send_raw(call);
3981        self.drop_without_shutdown();
3982        _result
3983    }
3984
3985    fn send_raw(&self, mut call: NextCall) -> Result<(), fidl::Error> {
3986        self.control_handle.inner.send::<PeerHandlerWatchNextCallResponse>(
3987            (&mut call,),
3988            self.tx_id,
3989            0x5e3b7b4e7c3d359,
3990            fidl::encoding::DynamicFlags::empty(),
3991        )
3992    }
3993}
3994
3995#[must_use = "FIDL methods require a response to be sent"]
3996#[derive(Debug)]
3997pub struct PeerHandlerRequestOutgoingCallResponder {
3998    control_handle: std::mem::ManuallyDrop<PeerHandlerControlHandle>,
3999    tx_id: u32,
4000}
4001
4002/// Set the the channel to be shutdown (see [`PeerHandlerControlHandle::shutdown`])
4003/// if the responder is dropped without sending a response, so that the client
4004/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4005impl std::ops::Drop for PeerHandlerRequestOutgoingCallResponder {
4006    fn drop(&mut self) {
4007        self.control_handle.shutdown();
4008        // Safety: drops once, never accessed again
4009        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4010    }
4011}
4012
4013impl fidl::endpoints::Responder for PeerHandlerRequestOutgoingCallResponder {
4014    type ControlHandle = PeerHandlerControlHandle;
4015
4016    fn control_handle(&self) -> &PeerHandlerControlHandle {
4017        &self.control_handle
4018    }
4019
4020    fn drop_without_shutdown(mut self) {
4021        // Safety: drops once, never accessed again due to mem::forget
4022        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4023        // Prevent Drop from running (which would shut down the channel)
4024        std::mem::forget(self);
4025    }
4026}
4027
4028impl PeerHandlerRequestOutgoingCallResponder {
4029    /// Sends a response to the FIDL transaction.
4030    ///
4031    /// Sets the channel to shutdown if an error occurs.
4032    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4033        let _result = self.send_raw(result);
4034        if _result.is_err() {
4035            self.control_handle.shutdown();
4036        }
4037        self.drop_without_shutdown();
4038        _result
4039    }
4040
4041    /// Similar to "send" but does not shutdown the channel if an error occurs.
4042    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4043        let _result = self.send_raw(result);
4044        self.drop_without_shutdown();
4045        _result
4046    }
4047
4048    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4049        self.control_handle
4050            .inner
4051            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4052                result,
4053                self.tx_id,
4054                0x1a2637c743c89ad,
4055                fidl::encoding::DynamicFlags::empty(),
4056            )
4057    }
4058}
4059
4060#[must_use = "FIDL methods require a response to be sent"]
4061#[derive(Debug)]
4062pub struct PeerHandlerQueryOperatorResponder {
4063    control_handle: std::mem::ManuallyDrop<PeerHandlerControlHandle>,
4064    tx_id: u32,
4065}
4066
4067/// Set the the channel to be shutdown (see [`PeerHandlerControlHandle::shutdown`])
4068/// if the responder is dropped without sending a response, so that the client
4069/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4070impl std::ops::Drop for PeerHandlerQueryOperatorResponder {
4071    fn drop(&mut self) {
4072        self.control_handle.shutdown();
4073        // Safety: drops once, never accessed again
4074        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4075    }
4076}
4077
4078impl fidl::endpoints::Responder for PeerHandlerQueryOperatorResponder {
4079    type ControlHandle = PeerHandlerControlHandle;
4080
4081    fn control_handle(&self) -> &PeerHandlerControlHandle {
4082        &self.control_handle
4083    }
4084
4085    fn drop_without_shutdown(mut self) {
4086        // Safety: drops once, never accessed again due to mem::forget
4087        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4088        // Prevent Drop from running (which would shut down the channel)
4089        std::mem::forget(self);
4090    }
4091}
4092
4093impl PeerHandlerQueryOperatorResponder {
4094    /// Sends a response to the FIDL transaction.
4095    ///
4096    /// Sets the channel to shutdown if an error occurs.
4097    pub fn send(self, mut operator: Option<&str>) -> Result<(), fidl::Error> {
4098        let _result = self.send_raw(operator);
4099        if _result.is_err() {
4100            self.control_handle.shutdown();
4101        }
4102        self.drop_without_shutdown();
4103        _result
4104    }
4105
4106    /// Similar to "send" but does not shutdown the channel if an error occurs.
4107    pub fn send_no_shutdown_on_err(self, mut operator: Option<&str>) -> Result<(), fidl::Error> {
4108        let _result = self.send_raw(operator);
4109        self.drop_without_shutdown();
4110        _result
4111    }
4112
4113    fn send_raw(&self, mut operator: Option<&str>) -> Result<(), fidl::Error> {
4114        self.control_handle.inner.send::<PeerHandlerQueryOperatorResponse>(
4115            (operator,),
4116            self.tx_id,
4117            0x1217eaf5db4c3300,
4118            fidl::encoding::DynamicFlags::empty(),
4119        )
4120    }
4121}
4122
4123#[must_use = "FIDL methods require a response to be sent"]
4124#[derive(Debug)]
4125pub struct PeerHandlerSubscriberNumberInformationResponder {
4126    control_handle: std::mem::ManuallyDrop<PeerHandlerControlHandle>,
4127    tx_id: u32,
4128}
4129
4130/// Set the the channel to be shutdown (see [`PeerHandlerControlHandle::shutdown`])
4131/// if the responder is dropped without sending a response, so that the client
4132/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4133impl std::ops::Drop for PeerHandlerSubscriberNumberInformationResponder {
4134    fn drop(&mut self) {
4135        self.control_handle.shutdown();
4136        // Safety: drops once, never accessed again
4137        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4138    }
4139}
4140
4141impl fidl::endpoints::Responder for PeerHandlerSubscriberNumberInformationResponder {
4142    type ControlHandle = PeerHandlerControlHandle;
4143
4144    fn control_handle(&self) -> &PeerHandlerControlHandle {
4145        &self.control_handle
4146    }
4147
4148    fn drop_without_shutdown(mut self) {
4149        // Safety: drops once, never accessed again due to mem::forget
4150        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4151        // Prevent Drop from running (which would shut down the channel)
4152        std::mem::forget(self);
4153    }
4154}
4155
4156impl PeerHandlerSubscriberNumberInformationResponder {
4157    /// Sends a response to the FIDL transaction.
4158    ///
4159    /// Sets the channel to shutdown if an error occurs.
4160    pub fn send(self, mut numbers: &[String]) -> Result<(), fidl::Error> {
4161        let _result = self.send_raw(numbers);
4162        if _result.is_err() {
4163            self.control_handle.shutdown();
4164        }
4165        self.drop_without_shutdown();
4166        _result
4167    }
4168
4169    /// Similar to "send" but does not shutdown the channel if an error occurs.
4170    pub fn send_no_shutdown_on_err(self, mut numbers: &[String]) -> Result<(), fidl::Error> {
4171        let _result = self.send_raw(numbers);
4172        self.drop_without_shutdown();
4173        _result
4174    }
4175
4176    fn send_raw(&self, mut numbers: &[String]) -> Result<(), fidl::Error> {
4177        self.control_handle.inner.send::<PeerHandlerSubscriberNumberInformationResponse>(
4178            (numbers,),
4179            self.tx_id,
4180            0x15f5235855b02a3a,
4181            fidl::encoding::DynamicFlags::empty(),
4182        )
4183    }
4184}
4185
4186#[must_use = "FIDL methods require a response to be sent"]
4187#[derive(Debug)]
4188pub struct PeerHandlerSetNrecModeResponder {
4189    control_handle: std::mem::ManuallyDrop<PeerHandlerControlHandle>,
4190    tx_id: u32,
4191}
4192
4193/// Set the the channel to be shutdown (see [`PeerHandlerControlHandle::shutdown`])
4194/// if the responder is dropped without sending a response, so that the client
4195/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4196impl std::ops::Drop for PeerHandlerSetNrecModeResponder {
4197    fn drop(&mut self) {
4198        self.control_handle.shutdown();
4199        // Safety: drops once, never accessed again
4200        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4201    }
4202}
4203
4204impl fidl::endpoints::Responder for PeerHandlerSetNrecModeResponder {
4205    type ControlHandle = PeerHandlerControlHandle;
4206
4207    fn control_handle(&self) -> &PeerHandlerControlHandle {
4208        &self.control_handle
4209    }
4210
4211    fn drop_without_shutdown(mut self) {
4212        // Safety: drops once, never accessed again due to mem::forget
4213        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4214        // Prevent Drop from running (which would shut down the channel)
4215        std::mem::forget(self);
4216    }
4217}
4218
4219impl PeerHandlerSetNrecModeResponder {
4220    /// Sends a response to the FIDL transaction.
4221    ///
4222    /// Sets the channel to shutdown if an error occurs.
4223    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4224        let _result = self.send_raw(result);
4225        if _result.is_err() {
4226            self.control_handle.shutdown();
4227        }
4228        self.drop_without_shutdown();
4229        _result
4230    }
4231
4232    /// Similar to "send" but does not shutdown the channel if an error occurs.
4233    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4234        let _result = self.send_raw(result);
4235        self.drop_without_shutdown();
4236        _result
4237    }
4238
4239    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4240        self.control_handle
4241            .inner
4242            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4243                result,
4244                self.tx_id,
4245                0x2f8890d0f866672f,
4246                fidl::encoding::DynamicFlags::empty(),
4247            )
4248    }
4249}
4250
4251mod internal {
4252    use super::*;
4253
4254    impl fidl::encoding::ResourceTypeMarker for CallManagerPeerConnectedRequest {
4255        type Borrowed<'a> = &'a mut Self;
4256        fn take_or_borrow<'a>(
4257            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4258        ) -> Self::Borrowed<'a> {
4259            value
4260        }
4261    }
4262
4263    unsafe impl fidl::encoding::TypeMarker for CallManagerPeerConnectedRequest {
4264        type Owned = Self;
4265
4266        #[inline(always)]
4267        fn inline_align(_context: fidl::encoding::Context) -> usize {
4268            8
4269        }
4270
4271        #[inline(always)]
4272        fn inline_size(_context: fidl::encoding::Context) -> usize {
4273            16
4274        }
4275    }
4276
4277    unsafe impl
4278        fidl::encoding::Encode<
4279            CallManagerPeerConnectedRequest,
4280            fidl::encoding::DefaultFuchsiaResourceDialect,
4281        > for &mut CallManagerPeerConnectedRequest
4282    {
4283        #[inline]
4284        unsafe fn encode(
4285            self,
4286            encoder: &mut fidl::encoding::Encoder<
4287                '_,
4288                fidl::encoding::DefaultFuchsiaResourceDialect,
4289            >,
4290            offset: usize,
4291            _depth: fidl::encoding::Depth,
4292        ) -> fidl::Result<()> {
4293            encoder.debug_check_bounds::<CallManagerPeerConnectedRequest>(offset);
4294            // Delegate to tuple encoding.
4295            fidl::encoding::Encode::<CallManagerPeerConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4296                (
4297                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
4298                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerHandlerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handle),
4299                ),
4300                encoder, offset, _depth
4301            )
4302        }
4303    }
4304    unsafe impl<
4305            T0: fidl::encoding::Encode<
4306                fidl_fuchsia_bluetooth::PeerId,
4307                fidl::encoding::DefaultFuchsiaResourceDialect,
4308            >,
4309            T1: fidl::encoding::Encode<
4310                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerHandlerMarker>>,
4311                fidl::encoding::DefaultFuchsiaResourceDialect,
4312            >,
4313        >
4314        fidl::encoding::Encode<
4315            CallManagerPeerConnectedRequest,
4316            fidl::encoding::DefaultFuchsiaResourceDialect,
4317        > for (T0, T1)
4318    {
4319        #[inline]
4320        unsafe fn encode(
4321            self,
4322            encoder: &mut fidl::encoding::Encoder<
4323                '_,
4324                fidl::encoding::DefaultFuchsiaResourceDialect,
4325            >,
4326            offset: usize,
4327            depth: fidl::encoding::Depth,
4328        ) -> fidl::Result<()> {
4329            encoder.debug_check_bounds::<CallManagerPeerConnectedRequest>(offset);
4330            // Zero out padding regions. There's no need to apply masks
4331            // because the unmasked parts will be overwritten by fields.
4332            unsafe {
4333                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
4334                (ptr as *mut u64).write_unaligned(0);
4335            }
4336            // Write the fields.
4337            self.0.encode(encoder, offset + 0, depth)?;
4338            self.1.encode(encoder, offset + 8, depth)?;
4339            Ok(())
4340        }
4341    }
4342
4343    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4344        for CallManagerPeerConnectedRequest
4345    {
4346        #[inline(always)]
4347        fn new_empty() -> Self {
4348            Self {
4349                id: fidl::new_empty!(
4350                    fidl_fuchsia_bluetooth::PeerId,
4351                    fidl::encoding::DefaultFuchsiaResourceDialect
4352                ),
4353                handle: fidl::new_empty!(
4354                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerHandlerMarker>>,
4355                    fidl::encoding::DefaultFuchsiaResourceDialect
4356                ),
4357            }
4358        }
4359
4360        #[inline]
4361        unsafe fn decode(
4362            &mut self,
4363            decoder: &mut fidl::encoding::Decoder<
4364                '_,
4365                fidl::encoding::DefaultFuchsiaResourceDialect,
4366            >,
4367            offset: usize,
4368            _depth: fidl::encoding::Depth,
4369        ) -> fidl::Result<()> {
4370            decoder.debug_check_bounds::<Self>(offset);
4371            // Verify that padding bytes are zero.
4372            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
4373            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4374            let mask = 0xffffffff00000000u64;
4375            let maskedval = padval & mask;
4376            if maskedval != 0 {
4377                return Err(fidl::Error::NonZeroPadding {
4378                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
4379                });
4380            }
4381            fidl::decode!(
4382                fidl_fuchsia_bluetooth::PeerId,
4383                fidl::encoding::DefaultFuchsiaResourceDialect,
4384                &mut self.id,
4385                decoder,
4386                offset + 0,
4387                _depth
4388            )?;
4389            fidl::decode!(
4390                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerHandlerMarker>>,
4391                fidl::encoding::DefaultFuchsiaResourceDialect,
4392                &mut self.handle,
4393                decoder,
4394                offset + 8,
4395                _depth
4396            )?;
4397            Ok(())
4398        }
4399    }
4400
4401    impl fidl::encoding::ResourceTypeMarker for HandsFreeWatchPeerConnectedResponse {
4402        type Borrowed<'a> = &'a mut Self;
4403        fn take_or_borrow<'a>(
4404            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4405        ) -> Self::Borrowed<'a> {
4406            value
4407        }
4408    }
4409
4410    unsafe impl fidl::encoding::TypeMarker for HandsFreeWatchPeerConnectedResponse {
4411        type Owned = Self;
4412
4413        #[inline(always)]
4414        fn inline_align(_context: fidl::encoding::Context) -> usize {
4415            8
4416        }
4417
4418        #[inline(always)]
4419        fn inline_size(_context: fidl::encoding::Context) -> usize {
4420            16
4421        }
4422    }
4423
4424    unsafe impl
4425        fidl::encoding::Encode<
4426            HandsFreeWatchPeerConnectedResponse,
4427            fidl::encoding::DefaultFuchsiaResourceDialect,
4428        > for &mut HandsFreeWatchPeerConnectedResponse
4429    {
4430        #[inline]
4431        unsafe fn encode(
4432            self,
4433            encoder: &mut fidl::encoding::Encoder<
4434                '_,
4435                fidl::encoding::DefaultFuchsiaResourceDialect,
4436            >,
4437            offset: usize,
4438            _depth: fidl::encoding::Depth,
4439        ) -> fidl::Result<()> {
4440            encoder.debug_check_bounds::<HandsFreeWatchPeerConnectedResponse>(offset);
4441            // Delegate to tuple encoding.
4442            fidl::encoding::Encode::<HandsFreeWatchPeerConnectedResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4443                (
4444                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
4445                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PeerHandlerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handle),
4446                ),
4447                encoder, offset, _depth
4448            )
4449        }
4450    }
4451    unsafe impl<
4452            T0: fidl::encoding::Encode<
4453                fidl_fuchsia_bluetooth::PeerId,
4454                fidl::encoding::DefaultFuchsiaResourceDialect,
4455            >,
4456            T1: fidl::encoding::Encode<
4457                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PeerHandlerMarker>>,
4458                fidl::encoding::DefaultFuchsiaResourceDialect,
4459            >,
4460        >
4461        fidl::encoding::Encode<
4462            HandsFreeWatchPeerConnectedResponse,
4463            fidl::encoding::DefaultFuchsiaResourceDialect,
4464        > for (T0, T1)
4465    {
4466        #[inline]
4467        unsafe fn encode(
4468            self,
4469            encoder: &mut fidl::encoding::Encoder<
4470                '_,
4471                fidl::encoding::DefaultFuchsiaResourceDialect,
4472            >,
4473            offset: usize,
4474            depth: fidl::encoding::Depth,
4475        ) -> fidl::Result<()> {
4476            encoder.debug_check_bounds::<HandsFreeWatchPeerConnectedResponse>(offset);
4477            // Zero out padding regions. There's no need to apply masks
4478            // because the unmasked parts will be overwritten by fields.
4479            unsafe {
4480                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
4481                (ptr as *mut u64).write_unaligned(0);
4482            }
4483            // Write the fields.
4484            self.0.encode(encoder, offset + 0, depth)?;
4485            self.1.encode(encoder, offset + 8, depth)?;
4486            Ok(())
4487        }
4488    }
4489
4490    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4491        for HandsFreeWatchPeerConnectedResponse
4492    {
4493        #[inline(always)]
4494        fn new_empty() -> Self {
4495            Self {
4496                id: fidl::new_empty!(
4497                    fidl_fuchsia_bluetooth::PeerId,
4498                    fidl::encoding::DefaultFuchsiaResourceDialect
4499                ),
4500                handle: fidl::new_empty!(
4501                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PeerHandlerMarker>>,
4502                    fidl::encoding::DefaultFuchsiaResourceDialect
4503                ),
4504            }
4505        }
4506
4507        #[inline]
4508        unsafe fn decode(
4509            &mut self,
4510            decoder: &mut fidl::encoding::Decoder<
4511                '_,
4512                fidl::encoding::DefaultFuchsiaResourceDialect,
4513            >,
4514            offset: usize,
4515            _depth: fidl::encoding::Depth,
4516        ) -> fidl::Result<()> {
4517            decoder.debug_check_bounds::<Self>(offset);
4518            // Verify that padding bytes are zero.
4519            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
4520            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4521            let mask = 0xffffffff00000000u64;
4522            let maskedval = padval & mask;
4523            if maskedval != 0 {
4524                return Err(fidl::Error::NonZeroPadding {
4525                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
4526                });
4527            }
4528            fidl::decode!(
4529                fidl_fuchsia_bluetooth::PeerId,
4530                fidl::encoding::DefaultFuchsiaResourceDialect,
4531                &mut self.id,
4532                decoder,
4533                offset + 0,
4534                _depth
4535            )?;
4536            fidl::decode!(
4537                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PeerHandlerMarker>>,
4538                fidl::encoding::DefaultFuchsiaResourceDialect,
4539                &mut self.handle,
4540                decoder,
4541                offset + 8,
4542                _depth
4543            )?;
4544            Ok(())
4545        }
4546    }
4547
4548    impl fidl::encoding::ResourceTypeMarker for HfpRegisterRequest {
4549        type Borrowed<'a> = &'a mut Self;
4550        fn take_or_borrow<'a>(
4551            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4552        ) -> Self::Borrowed<'a> {
4553            value
4554        }
4555    }
4556
4557    unsafe impl fidl::encoding::TypeMarker for HfpRegisterRequest {
4558        type Owned = Self;
4559
4560        #[inline(always)]
4561        fn inline_align(_context: fidl::encoding::Context) -> usize {
4562            4
4563        }
4564
4565        #[inline(always)]
4566        fn inline_size(_context: fidl::encoding::Context) -> usize {
4567            4
4568        }
4569    }
4570
4571    unsafe impl
4572        fidl::encoding::Encode<HfpRegisterRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4573        for &mut HfpRegisterRequest
4574    {
4575        #[inline]
4576        unsafe fn encode(
4577            self,
4578            encoder: &mut fidl::encoding::Encoder<
4579                '_,
4580                fidl::encoding::DefaultFuchsiaResourceDialect,
4581            >,
4582            offset: usize,
4583            _depth: fidl::encoding::Depth,
4584        ) -> fidl::Result<()> {
4585            encoder.debug_check_bounds::<HfpRegisterRequest>(offset);
4586            // Delegate to tuple encoding.
4587            fidl::encoding::Encode::<HfpRegisterRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4588                (
4589                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallManagerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.manager),
4590                ),
4591                encoder, offset, _depth
4592            )
4593        }
4594    }
4595    unsafe impl<
4596            T0: fidl::encoding::Encode<
4597                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallManagerMarker>>,
4598                fidl::encoding::DefaultFuchsiaResourceDialect,
4599            >,
4600        >
4601        fidl::encoding::Encode<HfpRegisterRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4602        for (T0,)
4603    {
4604        #[inline]
4605        unsafe fn encode(
4606            self,
4607            encoder: &mut fidl::encoding::Encoder<
4608                '_,
4609                fidl::encoding::DefaultFuchsiaResourceDialect,
4610            >,
4611            offset: usize,
4612            depth: fidl::encoding::Depth,
4613        ) -> fidl::Result<()> {
4614            encoder.debug_check_bounds::<HfpRegisterRequest>(offset);
4615            // Zero out padding regions. There's no need to apply masks
4616            // because the unmasked parts will be overwritten by fields.
4617            // Write the fields.
4618            self.0.encode(encoder, offset + 0, depth)?;
4619            Ok(())
4620        }
4621    }
4622
4623    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4624        for HfpRegisterRequest
4625    {
4626        #[inline(always)]
4627        fn new_empty() -> Self {
4628            Self {
4629                manager: fidl::new_empty!(
4630                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallManagerMarker>>,
4631                    fidl::encoding::DefaultFuchsiaResourceDialect
4632                ),
4633            }
4634        }
4635
4636        #[inline]
4637        unsafe fn decode(
4638            &mut self,
4639            decoder: &mut fidl::encoding::Decoder<
4640                '_,
4641                fidl::encoding::DefaultFuchsiaResourceDialect,
4642            >,
4643            offset: usize,
4644            _depth: fidl::encoding::Depth,
4645        ) -> fidl::Result<()> {
4646            decoder.debug_check_bounds::<Self>(offset);
4647            // Verify that padding bytes are zero.
4648            fidl::decode!(
4649                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallManagerMarker>>,
4650                fidl::encoding::DefaultFuchsiaResourceDialect,
4651                &mut self.manager,
4652                decoder,
4653                offset + 0,
4654                _depth
4655            )?;
4656            Ok(())
4657        }
4658    }
4659
4660    impl fidl::encoding::ResourceTypeMarker for PeerHandlerGainControlRequest {
4661        type Borrowed<'a> = &'a mut Self;
4662        fn take_or_borrow<'a>(
4663            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4664        ) -> Self::Borrowed<'a> {
4665            value
4666        }
4667    }
4668
4669    unsafe impl fidl::encoding::TypeMarker for PeerHandlerGainControlRequest {
4670        type Owned = Self;
4671
4672        #[inline(always)]
4673        fn inline_align(_context: fidl::encoding::Context) -> usize {
4674            4
4675        }
4676
4677        #[inline(always)]
4678        fn inline_size(_context: fidl::encoding::Context) -> usize {
4679            4
4680        }
4681    }
4682
4683    unsafe impl
4684        fidl::encoding::Encode<
4685            PeerHandlerGainControlRequest,
4686            fidl::encoding::DefaultFuchsiaResourceDialect,
4687        > for &mut PeerHandlerGainControlRequest
4688    {
4689        #[inline]
4690        unsafe fn encode(
4691            self,
4692            encoder: &mut fidl::encoding::Encoder<
4693                '_,
4694                fidl::encoding::DefaultFuchsiaResourceDialect,
4695            >,
4696            offset: usize,
4697            _depth: fidl::encoding::Depth,
4698        ) -> fidl::Result<()> {
4699            encoder.debug_check_bounds::<PeerHandlerGainControlRequest>(offset);
4700            // Delegate to tuple encoding.
4701            fidl::encoding::Encode::<PeerHandlerGainControlRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4702                (
4703                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HeadsetGainMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.control),
4704                ),
4705                encoder, offset, _depth
4706            )
4707        }
4708    }
4709    unsafe impl<
4710            T0: fidl::encoding::Encode<
4711                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HeadsetGainMarker>>,
4712                fidl::encoding::DefaultFuchsiaResourceDialect,
4713            >,
4714        >
4715        fidl::encoding::Encode<
4716            PeerHandlerGainControlRequest,
4717            fidl::encoding::DefaultFuchsiaResourceDialect,
4718        > for (T0,)
4719    {
4720        #[inline]
4721        unsafe fn encode(
4722            self,
4723            encoder: &mut fidl::encoding::Encoder<
4724                '_,
4725                fidl::encoding::DefaultFuchsiaResourceDialect,
4726            >,
4727            offset: usize,
4728            depth: fidl::encoding::Depth,
4729        ) -> fidl::Result<()> {
4730            encoder.debug_check_bounds::<PeerHandlerGainControlRequest>(offset);
4731            // Zero out padding regions. There's no need to apply masks
4732            // because the unmasked parts will be overwritten by fields.
4733            // Write the fields.
4734            self.0.encode(encoder, offset + 0, depth)?;
4735            Ok(())
4736        }
4737    }
4738
4739    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4740        for PeerHandlerGainControlRequest
4741    {
4742        #[inline(always)]
4743        fn new_empty() -> Self {
4744            Self {
4745                control: fidl::new_empty!(
4746                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HeadsetGainMarker>>,
4747                    fidl::encoding::DefaultFuchsiaResourceDialect
4748                ),
4749            }
4750        }
4751
4752        #[inline]
4753        unsafe fn decode(
4754            &mut self,
4755            decoder: &mut fidl::encoding::Decoder<
4756                '_,
4757                fidl::encoding::DefaultFuchsiaResourceDialect,
4758            >,
4759            offset: usize,
4760            _depth: fidl::encoding::Depth,
4761        ) -> fidl::Result<()> {
4762            decoder.debug_check_bounds::<Self>(offset);
4763            // Verify that padding bytes are zero.
4764            fidl::decode!(
4765                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HeadsetGainMarker>>,
4766                fidl::encoding::DefaultFuchsiaResourceDialect,
4767                &mut self.control,
4768                decoder,
4769                offset + 0,
4770                _depth
4771            )?;
4772            Ok(())
4773        }
4774    }
4775
4776    impl fidl::encoding::ResourceTypeMarker for PeerHandlerWatchNextCallResponse {
4777        type Borrowed<'a> = &'a mut Self;
4778        fn take_or_borrow<'a>(
4779            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4780        ) -> Self::Borrowed<'a> {
4781            value
4782        }
4783    }
4784
4785    unsafe impl fidl::encoding::TypeMarker for PeerHandlerWatchNextCallResponse {
4786        type Owned = Self;
4787
4788        #[inline(always)]
4789        fn inline_align(_context: fidl::encoding::Context) -> usize {
4790            8
4791        }
4792
4793        #[inline(always)]
4794        fn inline_size(_context: fidl::encoding::Context) -> usize {
4795            16
4796        }
4797    }
4798
4799    unsafe impl
4800        fidl::encoding::Encode<
4801            PeerHandlerWatchNextCallResponse,
4802            fidl::encoding::DefaultFuchsiaResourceDialect,
4803        > for &mut PeerHandlerWatchNextCallResponse
4804    {
4805        #[inline]
4806        unsafe fn encode(
4807            self,
4808            encoder: &mut fidl::encoding::Encoder<
4809                '_,
4810                fidl::encoding::DefaultFuchsiaResourceDialect,
4811            >,
4812            offset: usize,
4813            _depth: fidl::encoding::Depth,
4814        ) -> fidl::Result<()> {
4815            encoder.debug_check_bounds::<PeerHandlerWatchNextCallResponse>(offset);
4816            // Delegate to tuple encoding.
4817            fidl::encoding::Encode::<
4818                PeerHandlerWatchNextCallResponse,
4819                fidl::encoding::DefaultFuchsiaResourceDialect,
4820            >::encode(
4821                (<NextCall as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.call),),
4822                encoder,
4823                offset,
4824                _depth,
4825            )
4826        }
4827    }
4828    unsafe impl<T0: fidl::encoding::Encode<NextCall, fidl::encoding::DefaultFuchsiaResourceDialect>>
4829        fidl::encoding::Encode<
4830            PeerHandlerWatchNextCallResponse,
4831            fidl::encoding::DefaultFuchsiaResourceDialect,
4832        > for (T0,)
4833    {
4834        #[inline]
4835        unsafe fn encode(
4836            self,
4837            encoder: &mut fidl::encoding::Encoder<
4838                '_,
4839                fidl::encoding::DefaultFuchsiaResourceDialect,
4840            >,
4841            offset: usize,
4842            depth: fidl::encoding::Depth,
4843        ) -> fidl::Result<()> {
4844            encoder.debug_check_bounds::<PeerHandlerWatchNextCallResponse>(offset);
4845            // Zero out padding regions. There's no need to apply masks
4846            // because the unmasked parts will be overwritten by fields.
4847            // Write the fields.
4848            self.0.encode(encoder, offset + 0, depth)?;
4849            Ok(())
4850        }
4851    }
4852
4853    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4854        for PeerHandlerWatchNextCallResponse
4855    {
4856        #[inline(always)]
4857        fn new_empty() -> Self {
4858            Self { call: fidl::new_empty!(NextCall, fidl::encoding::DefaultFuchsiaResourceDialect) }
4859        }
4860
4861        #[inline]
4862        unsafe fn decode(
4863            &mut self,
4864            decoder: &mut fidl::encoding::Decoder<
4865                '_,
4866                fidl::encoding::DefaultFuchsiaResourceDialect,
4867            >,
4868            offset: usize,
4869            _depth: fidl::encoding::Depth,
4870        ) -> fidl::Result<()> {
4871            decoder.debug_check_bounds::<Self>(offset);
4872            // Verify that padding bytes are zero.
4873            fidl::decode!(
4874                NextCall,
4875                fidl::encoding::DefaultFuchsiaResourceDialect,
4876                &mut self.call,
4877                decoder,
4878                offset + 0,
4879                _depth
4880            )?;
4881            Ok(())
4882        }
4883    }
4884
4885    impl NextCall {
4886        #[inline(always)]
4887        fn max_ordinal_present(&self) -> u64 {
4888            if let Some(_) = self.direction {
4889                return 4;
4890            }
4891            if let Some(_) = self.state {
4892                return 3;
4893            }
4894            if let Some(_) = self.remote {
4895                return 2;
4896            }
4897            if let Some(_) = self.call {
4898                return 1;
4899            }
4900            0
4901        }
4902    }
4903
4904    impl fidl::encoding::ResourceTypeMarker for NextCall {
4905        type Borrowed<'a> = &'a mut Self;
4906        fn take_or_borrow<'a>(
4907            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4908        ) -> Self::Borrowed<'a> {
4909            value
4910        }
4911    }
4912
4913    unsafe impl fidl::encoding::TypeMarker for NextCall {
4914        type Owned = Self;
4915
4916        #[inline(always)]
4917        fn inline_align(_context: fidl::encoding::Context) -> usize {
4918            8
4919        }
4920
4921        #[inline(always)]
4922        fn inline_size(_context: fidl::encoding::Context) -> usize {
4923            16
4924        }
4925    }
4926
4927    unsafe impl fidl::encoding::Encode<NextCall, fidl::encoding::DefaultFuchsiaResourceDialect>
4928        for &mut NextCall
4929    {
4930        unsafe fn encode(
4931            self,
4932            encoder: &mut fidl::encoding::Encoder<
4933                '_,
4934                fidl::encoding::DefaultFuchsiaResourceDialect,
4935            >,
4936            offset: usize,
4937            mut depth: fidl::encoding::Depth,
4938        ) -> fidl::Result<()> {
4939            encoder.debug_check_bounds::<NextCall>(offset);
4940            // Vector header
4941            let max_ordinal: u64 = self.max_ordinal_present();
4942            encoder.write_num(max_ordinal, offset);
4943            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4944            // Calling encoder.out_of_line_offset(0) is not allowed.
4945            if max_ordinal == 0 {
4946                return Ok(());
4947            }
4948            depth.increment()?;
4949            let envelope_size = 8;
4950            let bytes_len = max_ordinal as usize * envelope_size;
4951            #[allow(unused_variables)]
4952            let offset = encoder.out_of_line_offset(bytes_len);
4953            let mut _prev_end_offset: usize = 0;
4954            if 1 > max_ordinal {
4955                return Ok(());
4956            }
4957
4958            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4959            // are envelope_size bytes.
4960            let cur_offset: usize = (1 - 1) * envelope_size;
4961
4962            // Zero reserved fields.
4963            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4964
4965            // Safety:
4966            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4967            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4968            //   envelope_size bytes, there is always sufficient room.
4969            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
4970            self.call.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4971            encoder, offset + cur_offset, depth
4972        )?;
4973
4974            _prev_end_offset = cur_offset + envelope_size;
4975            if 2 > max_ordinal {
4976                return Ok(());
4977            }
4978
4979            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4980            // are envelope_size bytes.
4981            let cur_offset: usize = (2 - 1) * envelope_size;
4982
4983            // Zero reserved fields.
4984            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4985
4986            // Safety:
4987            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4988            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4989            //   envelope_size bytes, there is always sufficient room.
4990            fidl::encoding::encode_in_envelope_optional::<
4991                fidl::encoding::BoundedString<256>,
4992                fidl::encoding::DefaultFuchsiaResourceDialect,
4993            >(
4994                self.remote.as_ref().map(
4995                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
4996                ),
4997                encoder,
4998                offset + cur_offset,
4999                depth,
5000            )?;
5001
5002            _prev_end_offset = cur_offset + envelope_size;
5003            if 3 > max_ordinal {
5004                return Ok(());
5005            }
5006
5007            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5008            // are envelope_size bytes.
5009            let cur_offset: usize = (3 - 1) * envelope_size;
5010
5011            // Zero reserved fields.
5012            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5013
5014            // Safety:
5015            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5016            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5017            //   envelope_size bytes, there is always sufficient room.
5018            fidl::encoding::encode_in_envelope_optional::<
5019                CallState,
5020                fidl::encoding::DefaultFuchsiaResourceDialect,
5021            >(
5022                self.state.as_ref().map(<CallState as fidl::encoding::ValueTypeMarker>::borrow),
5023                encoder,
5024                offset + cur_offset,
5025                depth,
5026            )?;
5027
5028            _prev_end_offset = cur_offset + envelope_size;
5029            if 4 > max_ordinal {
5030                return Ok(());
5031            }
5032
5033            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5034            // are envelope_size bytes.
5035            let cur_offset: usize = (4 - 1) * envelope_size;
5036
5037            // Zero reserved fields.
5038            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5039
5040            // Safety:
5041            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5042            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5043            //   envelope_size bytes, there is always sufficient room.
5044            fidl::encoding::encode_in_envelope_optional::<
5045                CallDirection,
5046                fidl::encoding::DefaultFuchsiaResourceDialect,
5047            >(
5048                self.direction
5049                    .as_ref()
5050                    .map(<CallDirection as fidl::encoding::ValueTypeMarker>::borrow),
5051                encoder,
5052                offset + cur_offset,
5053                depth,
5054            )?;
5055
5056            _prev_end_offset = cur_offset + envelope_size;
5057
5058            Ok(())
5059        }
5060    }
5061
5062    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for NextCall {
5063        #[inline(always)]
5064        fn new_empty() -> Self {
5065            Self::default()
5066        }
5067
5068        unsafe fn decode(
5069            &mut self,
5070            decoder: &mut fidl::encoding::Decoder<
5071                '_,
5072                fidl::encoding::DefaultFuchsiaResourceDialect,
5073            >,
5074            offset: usize,
5075            mut depth: fidl::encoding::Depth,
5076        ) -> fidl::Result<()> {
5077            decoder.debug_check_bounds::<Self>(offset);
5078            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5079                None => return Err(fidl::Error::NotNullable),
5080                Some(len) => len,
5081            };
5082            // Calling decoder.out_of_line_offset(0) is not allowed.
5083            if len == 0 {
5084                return Ok(());
5085            };
5086            depth.increment()?;
5087            let envelope_size = 8;
5088            let bytes_len = len * envelope_size;
5089            let offset = decoder.out_of_line_offset(bytes_len)?;
5090            // Decode the envelope for each type.
5091            let mut _next_ordinal_to_read = 0;
5092            let mut next_offset = offset;
5093            let end_offset = offset + bytes_len;
5094            _next_ordinal_to_read += 1;
5095            if next_offset >= end_offset {
5096                return Ok(());
5097            }
5098
5099            // Decode unknown envelopes for gaps in ordinals.
5100            while _next_ordinal_to_read < 1 {
5101                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5102                _next_ordinal_to_read += 1;
5103                next_offset += envelope_size;
5104            }
5105
5106            let next_out_of_line = decoder.next_out_of_line();
5107            let handles_before = decoder.remaining_handles();
5108            if let Some((inlined, num_bytes, num_handles)) =
5109                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5110            {
5111                let member_inline_size = <fidl::encoding::Endpoint<
5112                    fidl::endpoints::ClientEnd<CallMarker>,
5113                > as fidl::encoding::TypeMarker>::inline_size(
5114                    decoder.context
5115                );
5116                if inlined != (member_inline_size <= 4) {
5117                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5118                }
5119                let inner_offset;
5120                let mut inner_depth = depth.clone();
5121                if inlined {
5122                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5123                    inner_offset = next_offset;
5124                } else {
5125                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5126                    inner_depth.increment()?;
5127                }
5128                let val_ref = self.call.get_or_insert_with(|| {
5129                    fidl::new_empty!(
5130                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallMarker>>,
5131                        fidl::encoding::DefaultFuchsiaResourceDialect
5132                    )
5133                });
5134                fidl::decode!(
5135                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallMarker>>,
5136                    fidl::encoding::DefaultFuchsiaResourceDialect,
5137                    val_ref,
5138                    decoder,
5139                    inner_offset,
5140                    inner_depth
5141                )?;
5142                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5143                {
5144                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5145                }
5146                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5147                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5148                }
5149            }
5150
5151            next_offset += envelope_size;
5152            _next_ordinal_to_read += 1;
5153            if next_offset >= end_offset {
5154                return Ok(());
5155            }
5156
5157            // Decode unknown envelopes for gaps in ordinals.
5158            while _next_ordinal_to_read < 2 {
5159                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5160                _next_ordinal_to_read += 1;
5161                next_offset += envelope_size;
5162            }
5163
5164            let next_out_of_line = decoder.next_out_of_line();
5165            let handles_before = decoder.remaining_handles();
5166            if let Some((inlined, num_bytes, num_handles)) =
5167                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5168            {
5169                let member_inline_size =
5170                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
5171                        decoder.context,
5172                    );
5173                if inlined != (member_inline_size <= 4) {
5174                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5175                }
5176                let inner_offset;
5177                let mut inner_depth = depth.clone();
5178                if inlined {
5179                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5180                    inner_offset = next_offset;
5181                } else {
5182                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5183                    inner_depth.increment()?;
5184                }
5185                let val_ref = self.remote.get_or_insert_with(|| {
5186                    fidl::new_empty!(
5187                        fidl::encoding::BoundedString<256>,
5188                        fidl::encoding::DefaultFuchsiaResourceDialect
5189                    )
5190                });
5191                fidl::decode!(
5192                    fidl::encoding::BoundedString<256>,
5193                    fidl::encoding::DefaultFuchsiaResourceDialect,
5194                    val_ref,
5195                    decoder,
5196                    inner_offset,
5197                    inner_depth
5198                )?;
5199                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5200                {
5201                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5202                }
5203                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5204                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5205                }
5206            }
5207
5208            next_offset += envelope_size;
5209            _next_ordinal_to_read += 1;
5210            if next_offset >= end_offset {
5211                return Ok(());
5212            }
5213
5214            // Decode unknown envelopes for gaps in ordinals.
5215            while _next_ordinal_to_read < 3 {
5216                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5217                _next_ordinal_to_read += 1;
5218                next_offset += envelope_size;
5219            }
5220
5221            let next_out_of_line = decoder.next_out_of_line();
5222            let handles_before = decoder.remaining_handles();
5223            if let Some((inlined, num_bytes, num_handles)) =
5224                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5225            {
5226                let member_inline_size =
5227                    <CallState as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5228                if inlined != (member_inline_size <= 4) {
5229                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5230                }
5231                let inner_offset;
5232                let mut inner_depth = depth.clone();
5233                if inlined {
5234                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5235                    inner_offset = next_offset;
5236                } else {
5237                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5238                    inner_depth.increment()?;
5239                }
5240                let val_ref = self.state.get_or_insert_with(|| {
5241                    fidl::new_empty!(CallState, fidl::encoding::DefaultFuchsiaResourceDialect)
5242                });
5243                fidl::decode!(
5244                    CallState,
5245                    fidl::encoding::DefaultFuchsiaResourceDialect,
5246                    val_ref,
5247                    decoder,
5248                    inner_offset,
5249                    inner_depth
5250                )?;
5251                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5252                {
5253                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5254                }
5255                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5256                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5257                }
5258            }
5259
5260            next_offset += envelope_size;
5261            _next_ordinal_to_read += 1;
5262            if next_offset >= end_offset {
5263                return Ok(());
5264            }
5265
5266            // Decode unknown envelopes for gaps in ordinals.
5267            while _next_ordinal_to_read < 4 {
5268                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5269                _next_ordinal_to_read += 1;
5270                next_offset += envelope_size;
5271            }
5272
5273            let next_out_of_line = decoder.next_out_of_line();
5274            let handles_before = decoder.remaining_handles();
5275            if let Some((inlined, num_bytes, num_handles)) =
5276                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5277            {
5278                let member_inline_size =
5279                    <CallDirection as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5280                if inlined != (member_inline_size <= 4) {
5281                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5282                }
5283                let inner_offset;
5284                let mut inner_depth = depth.clone();
5285                if inlined {
5286                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5287                    inner_offset = next_offset;
5288                } else {
5289                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5290                    inner_depth.increment()?;
5291                }
5292                let val_ref = self.direction.get_or_insert_with(|| {
5293                    fidl::new_empty!(CallDirection, fidl::encoding::DefaultFuchsiaResourceDialect)
5294                });
5295                fidl::decode!(
5296                    CallDirection,
5297                    fidl::encoding::DefaultFuchsiaResourceDialect,
5298                    val_ref,
5299                    decoder,
5300                    inner_offset,
5301                    inner_depth
5302                )?;
5303                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5304                {
5305                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5306                }
5307                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5308                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5309                }
5310            }
5311
5312            next_offset += envelope_size;
5313
5314            // Decode the remaining unknown envelopes.
5315            while next_offset < end_offset {
5316                _next_ordinal_to_read += 1;
5317                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5318                next_offset += envelope_size;
5319            }
5320
5321            Ok(())
5322        }
5323    }
5324}