Skip to main content

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