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