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