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 _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13/// Represents a specific phone book memory location.
14pub type Memory = String;
15
16/// Represents a text string of V.250 dialing digits.
17/// See TS 127.007v06.08.00, Section 6.2 for more information.
18pub type Number = String;
19
20pub const MAX_PICONET_SIZE: u64 = 8;
21
22/// The direction of call initiation.
23#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
24#[repr(u32)]
25pub enum CallDirection {
26    /// Call originated on this device. This is also known as an Outgoing call.
27    MobileOriginated = 1,
28    /// Call is terminated on this device. This is also known as an Incoming call.
29    MobileTerminated = 2,
30}
31
32impl CallDirection {
33    #[inline]
34    pub fn from_primitive(prim: u32) -> Option<Self> {
35        match prim {
36            1 => Some(Self::MobileOriginated),
37            2 => Some(Self::MobileTerminated),
38            _ => None,
39        }
40    }
41
42    #[inline]
43    pub const fn into_primitive(self) -> u32 {
44        self as u32
45    }
46
47    #[deprecated = "Strict enums should not use `is_unknown`"]
48    #[inline]
49    pub fn is_unknown(&self) -> bool {
50        false
51    }
52}
53
54/// Represents the valid states of a call.
55#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
56pub enum CallState {
57    /// There is a callsetup procedure in progress for an outgoing call.
58    /// This state should not be set by the Call protocol client.
59    /// It is the initial state of an unanswered outgoing call.
60    OutgoingDialing,
61    /// There is a callsetup procedure in progress for an outgoing call and the
62    /// remote party has been alerted to the callsetup. This state is an
63    /// optional transition from OUTGOING_DIALING.
64    OutgoingAlerting,
65    /// There is a callsetup procedure in progress for an incoming call.
66    IncomingRinging,
67    /// There is a callsetup procedure in progress for an incoming call.
68    IncomingWaiting,
69    /// A call is in progress but another call is active.
70    OngoingHeld,
71    /// A call is active.
72    OngoingActive,
73    /// The call has been termianted.
74    Terminated,
75    /// The call has been transferred to the AG, after which the HF is no longer
76    /// tracking its state.
77    TransferredToAg,
78    #[doc(hidden)]
79    __SourceBreaking { unknown_ordinal: u32 },
80}
81
82/// Pattern that matches an unknown `CallState` member.
83#[macro_export]
84macro_rules! CallStateUnknown {
85    () => {
86        _
87    };
88}
89
90impl CallState {
91    #[inline]
92    pub fn from_primitive(prim: u32) -> Option<Self> {
93        match prim {
94            1 => Some(Self::OutgoingDialing),
95            2 => Some(Self::OutgoingAlerting),
96            3 => Some(Self::IncomingRinging),
97            4 => Some(Self::IncomingWaiting),
98            5 => Some(Self::OngoingHeld),
99            6 => Some(Self::OngoingActive),
100            7 => Some(Self::Terminated),
101            8 => Some(Self::TransferredToAg),
102            _ => None,
103        }
104    }
105
106    #[inline]
107    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
108        match prim {
109            1 => Self::OutgoingDialing,
110            2 => Self::OutgoingAlerting,
111            3 => Self::IncomingRinging,
112            4 => Self::IncomingWaiting,
113            5 => Self::OngoingHeld,
114            6 => Self::OngoingActive,
115            7 => Self::Terminated,
116            8 => Self::TransferredToAg,
117            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
118        }
119    }
120
121    #[inline]
122    pub fn unknown() -> Self {
123        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
124    }
125
126    #[inline]
127    pub const fn into_primitive(self) -> u32 {
128        match self {
129            Self::OutgoingDialing => 1,
130            Self::OutgoingAlerting => 2,
131            Self::IncomingRinging => 3,
132            Self::IncomingWaiting => 4,
133            Self::OngoingHeld => 5,
134            Self::OngoingActive => 6,
135            Self::Terminated => 7,
136            Self::TransferredToAg => 8,
137            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
138        }
139    }
140
141    #[inline]
142    pub fn is_unknown(&self) -> bool {
143        match self {
144            Self::__SourceBreaking { unknown_ordinal: _ } => true,
145            _ => false,
146        }
147    }
148}
149
150/// Dual-tone multi-frequency signaling codes.
151#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
152#[repr(u8)]
153pub enum DtmfCode {
154    /// Represented by ASCII "1" in AT commands.
155    One = 49,
156    /// Represented by ASCII "2" in AT commands.
157    Two = 50,
158    /// Represented by ASCII "3" in AT commands.
159    Three = 51,
160    /// Represented by ASCII "4" in AT commands.
161    Four = 52,
162    /// Represented by ASCII "5" in AT commands.
163    Five = 53,
164    /// Represented by ASCII "6" in AT commands.
165    Six = 54,
166    /// Represented by ASCII "7" in AT commands.
167    Seven = 55,
168    /// Represented by ASCII "8" in AT commands.
169    Eight = 56,
170    /// Represented by ASCII "9" in AT commands.
171    Nine = 57,
172    /// Represented by ASCII "#" in AT commands.
173    NumberSign = 35,
174    /// Represented by ASCII "0" in AT commands.
175    Zero = 48,
176    /// Represented by ASCII "*" in AT commands.
177    Asterisk = 42,
178    /// Represented by ASCII "A" in AT commands.
179    A = 65,
180    /// Represented by ASCII "B" in AT commands.
181    B = 66,
182    /// Represented by ASCII "C" in AT commands.
183    C = 67,
184    /// Represented by ASCII "D" in AT commands.
185    D = 68,
186}
187
188impl DtmfCode {
189    #[inline]
190    pub fn from_primitive(prim: u8) -> Option<Self> {
191        match prim {
192            49 => Some(Self::One),
193            50 => Some(Self::Two),
194            51 => Some(Self::Three),
195            52 => Some(Self::Four),
196            53 => Some(Self::Five),
197            54 => Some(Self::Six),
198            55 => Some(Self::Seven),
199            56 => Some(Self::Eight),
200            57 => Some(Self::Nine),
201            35 => Some(Self::NumberSign),
202            48 => Some(Self::Zero),
203            42 => Some(Self::Asterisk),
204            65 => Some(Self::A),
205            66 => Some(Self::B),
206            67 => Some(Self::C),
207            68 => Some(Self::D),
208            _ => None,
209        }
210    }
211
212    #[inline]
213    pub const fn into_primitive(self) -> u8 {
214        self as u8
215    }
216
217    #[deprecated = "Strict enums should not use `is_unknown`"]
218    #[inline]
219    pub fn is_unknown(&self) -> bool {
220        false
221    }
222}
223
224/// Represents the signal strength of a connection between the Audio Gateway and
225/// a network.
226#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
227#[repr(i8)]
228pub enum SignalStrength {
229    None = 1,
230    VeryLow = 2,
231    Low = 3,
232    Medium = 4,
233    High = 5,
234    VeryHigh = 6,
235}
236
237impl SignalStrength {
238    #[inline]
239    pub fn from_primitive(prim: i8) -> Option<Self> {
240        match prim {
241            1 => Some(Self::None),
242            2 => Some(Self::VeryLow),
243            3 => Some(Self::Low),
244            4 => Some(Self::Medium),
245            5 => Some(Self::High),
246            6 => Some(Self::VeryHigh),
247            _ => None,
248        }
249    }
250
251    #[inline]
252    pub const fn into_primitive(self) -> i8 {
253        self as i8
254    }
255
256    #[deprecated = "Strict enums should not use `is_unknown`"]
257    #[inline]
258    pub fn is_unknown(&self) -> bool {
259        false
260    }
261}
262
263#[derive(Debug, PartialEq)]
264pub struct CallManagerPeerConnectedRequest {
265    pub id: fidl_fuchsia_bluetooth::PeerId,
266    pub handle: fidl::endpoints::ServerEnd<PeerHandlerMarker>,
267}
268
269impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
270    for CallManagerPeerConnectedRequest
271{
272}
273
274#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
275pub struct CallSendDtmfCodeRequest {
276    pub code: DtmfCode,
277}
278
279impl fidl::Persistable for CallSendDtmfCodeRequest {}
280
281#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
282pub struct CallWatchStateResponse {
283    pub state: CallState,
284}
285
286impl fidl::Persistable for CallWatchStateResponse {}
287
288#[derive(Debug, PartialEq)]
289pub struct HandsFreeWatchPeerConnectedResponse {
290    pub id: fidl_fuchsia_bluetooth::PeerId,
291    pub handle: fidl::endpoints::ClientEnd<PeerHandlerMarker>,
292}
293
294impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
295    for HandsFreeWatchPeerConnectedResponse
296{
297}
298
299#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
300#[repr(C)]
301pub struct HeadsetGainSetMicrophoneGainRequest {
302    pub requested: u8,
303}
304
305impl fidl::Persistable for HeadsetGainSetMicrophoneGainRequest {}
306
307#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
308#[repr(C)]
309pub struct HeadsetGainSetSpeakerGainRequest {
310    pub requested: u8,
311}
312
313impl fidl::Persistable for HeadsetGainSetSpeakerGainRequest {}
314
315#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
316#[repr(C)]
317pub struct HeadsetGainWatchMicrophoneGainResponse {
318    pub gain: u8,
319}
320
321impl fidl::Persistable for HeadsetGainWatchMicrophoneGainResponse {}
322
323#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
324#[repr(C)]
325pub struct HeadsetGainWatchSpeakerGainResponse {
326    pub gain: u8,
327}
328
329impl fidl::Persistable for HeadsetGainWatchSpeakerGainResponse {}
330
331#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
332pub struct HfpRegisterRequest {
333    pub manager: fidl::endpoints::ClientEnd<CallManagerMarker>,
334}
335
336impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for HfpRegisterRequest {}
337
338#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
339pub struct PeerHandlerGainControlRequest {
340    pub control: fidl::endpoints::ClientEnd<HeadsetGainMarker>,
341}
342
343impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
344    for PeerHandlerGainControlRequest
345{
346}
347
348#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
349pub struct PeerHandlerQueryOperatorResponse {
350    pub operator: Option<String>,
351}
352
353impl fidl::Persistable for PeerHandlerQueryOperatorResponse {}
354
355#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
356#[repr(C)]
357pub struct PeerHandlerReportHeadsetBatteryLevelRequest {
358    pub level: u8,
359}
360
361impl fidl::Persistable for PeerHandlerReportHeadsetBatteryLevelRequest {}
362
363#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
364pub struct PeerHandlerRequestOutgoingCallRequest {
365    pub action: CallAction,
366}
367
368impl fidl::Persistable for PeerHandlerRequestOutgoingCallRequest {}
369
370#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
371pub struct PeerHandlerSetNrecModeRequest {
372    pub enabled: bool,
373}
374
375impl fidl::Persistable for PeerHandlerSetNrecModeRequest {}
376
377#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
378pub struct PeerHandlerSubscriberNumberInformationResponse {
379    pub numbers: Vec<String>,
380}
381
382impl fidl::Persistable for PeerHandlerSubscriberNumberInformationResponse {}
383
384#[derive(Clone, Debug, PartialEq)]
385pub struct PeerHandlerWatchNetworkInformationResponse {
386    pub update: NetworkInformation,
387}
388
389impl fidl::Persistable for PeerHandlerWatchNetworkInformationResponse {}
390
391#[derive(Debug, PartialEq)]
392pub struct PeerHandlerWatchNextCallResponse {
393    pub call: NextCall,
394}
395
396impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
397    for PeerHandlerWatchNextCallResponse
398{
399}
400
401/// Represents the action of redialing the last dialed number.
402#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
403pub struct RedialLast;
404
405impl fidl::Persistable for RedialLast {}
406
407/// Represents the action of transferring an active call to the Headset.
408#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
409pub struct TransferActive;
410
411impl fidl::Persistable for TransferActive {}
412
413/// Network information for the Audio Gateway. Typically this represents
414/// information regarding the state of connectivity to a telephony network.
415#[derive(Clone, Debug, Default, PartialEq)]
416pub struct NetworkInformation {
417    /// Report the status of registration with the network. See HFP v1.8,
418    /// Section 4.4
419    pub service_available: Option<bool>,
420    /// Report the signal strength of the connection to the network. See
421    /// the HFP v1.8, Section 4.5.
422    pub signal_strength: Option<SignalStrength>,
423    /// Report the roaming status of the connection to the network. See
424    /// HFP v1.8, Section 4.6
425    pub roaming: Option<bool>,
426    #[doc(hidden)]
427    pub __source_breaking: fidl::marker::SourceBreaking,
428}
429
430impl fidl::Persistable for NetworkInformation {}
431
432/// Information for the next call reported by a Peer Handler.
433#[derive(Debug, Default, PartialEq)]
434pub struct NextCall {
435    /// Channel for this call.
436    /// This field is required.
437    pub call: Option<fidl::endpoints::ClientEnd<CallMarker>>,
438    /// The Number of the remote party on the call.
439    /// This field is required.
440    pub remote: Option<String>,
441    /// State of the call when it is reported by the Peer Handler.
442    /// This field is required.
443    pub state: Option<CallState>,
444    /// Direction of the call's initiation. See `CallDirection` documentation
445    /// for more information.
446    /// This field is required.
447    pub direction: Option<CallDirection>,
448    #[doc(hidden)]
449    pub __source_breaking: fidl::marker::SourceBreaking,
450}
451
452impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NextCall {}
453
454/// A command from the HF with a value representing what number to dial.
455#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
456pub enum CallAction {
457    /// A complete number to be dialed by the call handler service. See HFP v1.8
458    /// Section 4.18.
459    DialFromNumber(String),
460    /// A phone book memory location from which a number to be dialed should be
461    /// looked up. See HFP v1.8 Section 4.19.
462    DialFromLocation(String),
463    /// The call handler service should dial the last used number. See HFP v1.8
464    /// Section 4.20.
465    RedialLast(RedialLast),
466    /// Request to transfer an active call to the headset rather than initiating
467    /// a new outgoing call. A call must already be in progress on the Audio
468    /// Gateway in order for a transfer of audio to the Hands-Free device to take
469    /// place. See HFP v1.8 Section 4.16.
470    TransferActive(TransferActive),
471}
472
473impl CallAction {
474    #[inline]
475    pub fn ordinal(&self) -> u64 {
476        match *self {
477            Self::DialFromNumber(_) => 1,
478            Self::DialFromLocation(_) => 2,
479            Self::RedialLast(_) => 3,
480            Self::TransferActive(_) => 4,
481        }
482    }
483
484    #[deprecated = "Strict unions should not use `is_unknown`"]
485    #[inline]
486    pub fn is_unknown(&self) -> bool {
487        false
488    }
489}
490
491impl fidl::Persistable for CallAction {}
492
493#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
494pub struct CallMarker;
495
496impl fidl::endpoints::ProtocolMarker for CallMarker {
497    type Proxy = CallProxy;
498    type RequestStream = CallRequestStream;
499    #[cfg(target_os = "fuchsia")]
500    type SynchronousProxy = CallSynchronousProxy;
501
502    const DEBUG_NAME: &'static str = "(anonymous) Call";
503}
504pub type CallSendDtmfCodeResult = Result<(), i32>;
505
506pub trait CallProxyInterface: Send + Sync {
507    type WatchStateResponseFut: std::future::Future<Output = Result<CallState, fidl::Error>> + Send;
508    fn r#watch_state(&self) -> Self::WatchStateResponseFut;
509    fn r#request_hold(&self) -> Result<(), fidl::Error>;
510    fn r#request_active(&self) -> Result<(), fidl::Error>;
511    fn r#request_terminate(&self) -> Result<(), fidl::Error>;
512    fn r#request_transfer_audio(&self) -> Result<(), fidl::Error>;
513    type SendDtmfCodeResponseFut: std::future::Future<Output = Result<CallSendDtmfCodeResult, fidl::Error>>
514        + Send;
515    fn r#send_dtmf_code(&self, code: DtmfCode) -> Self::SendDtmfCodeResponseFut;
516}
517#[derive(Debug)]
518#[cfg(target_os = "fuchsia")]
519pub struct CallSynchronousProxy {
520    client: fidl::client::sync::Client,
521}
522
523#[cfg(target_os = "fuchsia")]
524impl fidl::endpoints::SynchronousProxy for CallSynchronousProxy {
525    type Proxy = CallProxy;
526    type Protocol = CallMarker;
527
528    fn from_channel(inner: fidl::Channel) -> Self {
529        Self::new(inner)
530    }
531
532    fn into_channel(self) -> fidl::Channel {
533        self.client.into_channel()
534    }
535
536    fn as_channel(&self) -> &fidl::Channel {
537        self.client.as_channel()
538    }
539}
540
541#[cfg(target_os = "fuchsia")]
542impl CallSynchronousProxy {
543    pub fn new(channel: fidl::Channel) -> Self {
544        let protocol_name = <CallMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
545        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
546    }
547
548    pub fn into_channel(self) -> fidl::Channel {
549        self.client.into_channel()
550    }
551
552    /// Waits until an event arrives and returns it. It is safe for other
553    /// threads to make concurrent requests while waiting for an event.
554    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<CallEvent, fidl::Error> {
555        CallEvent::decode(self.client.wait_for_event(deadline)?)
556    }
557
558    /// A hanging get method for call state. See the `CallState` documentation
559    /// for information on possible states.
560    pub fn r#watch_state(
561        &self,
562        ___deadline: zx::MonotonicInstant,
563    ) -> Result<CallState, fidl::Error> {
564        let _response =
565            self.client.send_query::<fidl::encoding::EmptyPayload, CallWatchStateResponse>(
566                (),
567                0x5262bcc909bdaeb5,
568                fidl::encoding::DynamicFlags::empty(),
569                ___deadline,
570            )?;
571        Ok(_response.state)
572    }
573
574    /// Request that the Call be set to the ONGOING_HELD CallState
575    pub fn r#request_hold(&self) -> Result<(), fidl::Error> {
576        self.client.send::<fidl::encoding::EmptyPayload>(
577            (),
578            0x35ade403017d20eb,
579            fidl::encoding::DynamicFlags::empty(),
580        )
581    }
582
583    /// Request that the Call be set to the ONGOING_ACTIVE CallState.
584    /// This has the side effect of placing all other Calls that are routed to
585    /// this peer in the ONGOING_HELD call state if it succeeds.
586    pub fn r#request_active(&self) -> Result<(), fidl::Error> {
587        self.client.send::<fidl::encoding::EmptyPayload>(
588            (),
589            0x248518f967f1fe6e,
590            fidl::encoding::DynamicFlags::empty(),
591        )
592    }
593
594    /// Request that the Call be TERMINATED.
595    pub fn r#request_terminate(&self) -> Result<(), fidl::Error> {
596        self.client.send::<fidl::encoding::EmptyPayload>(
597            (),
598            0x4940915197ee4916,
599            fidl::encoding::DynamicFlags::empty(),
600        )
601    }
602
603    /// Request that the Call's audio be transfered to the Audio Gateway and
604    /// the call state set to TRANSFERRED_TO_AG.
605    pub fn r#request_transfer_audio(&self) -> Result<(), fidl::Error> {
606        self.client.send::<fidl::encoding::EmptyPayload>(
607            (),
608            0xb0ca6649f2e104c,
609            fidl::encoding::DynamicFlags::empty(),
610        )
611    }
612
613    /// Send a code that the call manager or remote audio gateway peer should
614    /// transmit to its network connection. The request returns after the code
615    /// has been transmitted to the network.
616    ///
617    /// Can return an error if the call manager or peer failed to transmit the
618    /// code to the network.
619    pub fn r#send_dtmf_code(
620        &self,
621        mut code: DtmfCode,
622        ___deadline: zx::MonotonicInstant,
623    ) -> Result<CallSendDtmfCodeResult, fidl::Error> {
624        let _response = self.client.send_query::<
625            CallSendDtmfCodeRequest,
626            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
627        >(
628            (code,),
629            0x50768933ca33fcd6,
630            fidl::encoding::DynamicFlags::empty(),
631            ___deadline,
632        )?;
633        Ok(_response.map(|x| x))
634    }
635}
636
637#[derive(Debug, Clone)]
638pub struct CallProxy {
639    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
640}
641
642impl fidl::endpoints::Proxy for CallProxy {
643    type Protocol = CallMarker;
644
645    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
646        Self::new(inner)
647    }
648
649    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
650        self.client.into_channel().map_err(|client| Self { client })
651    }
652
653    fn as_channel(&self) -> &::fidl::AsyncChannel {
654        self.client.as_channel()
655    }
656}
657
658impl CallProxy {
659    /// Create a new Proxy for fuchsia.bluetooth.hfp/Call.
660    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
661        let protocol_name = <CallMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
662        Self { client: fidl::client::Client::new(channel, protocol_name) }
663    }
664
665    /// Get a Stream of events from the remote end of the protocol.
666    ///
667    /// # Panics
668    ///
669    /// Panics if the event stream was already taken.
670    pub fn take_event_stream(&self) -> CallEventStream {
671        CallEventStream { event_receiver: self.client.take_event_receiver() }
672    }
673
674    /// A hanging get method for call state. See the `CallState` documentation
675    /// for information on possible states.
676    pub fn r#watch_state(
677        &self,
678    ) -> fidl::client::QueryResponseFut<CallState, fidl::encoding::DefaultFuchsiaResourceDialect>
679    {
680        CallProxyInterface::r#watch_state(self)
681    }
682
683    /// Request that the Call be set to the ONGOING_HELD CallState
684    pub fn r#request_hold(&self) -> Result<(), fidl::Error> {
685        CallProxyInterface::r#request_hold(self)
686    }
687
688    /// Request that the Call be set to the ONGOING_ACTIVE CallState.
689    /// This has the side effect of placing all other Calls that are routed to
690    /// this peer in the ONGOING_HELD call state if it succeeds.
691    pub fn r#request_active(&self) -> Result<(), fidl::Error> {
692        CallProxyInterface::r#request_active(self)
693    }
694
695    /// Request that the Call be TERMINATED.
696    pub fn r#request_terminate(&self) -> Result<(), fidl::Error> {
697        CallProxyInterface::r#request_terminate(self)
698    }
699
700    /// Request that the Call's audio be transfered to the Audio Gateway and
701    /// the call state set to TRANSFERRED_TO_AG.
702    pub fn r#request_transfer_audio(&self) -> Result<(), fidl::Error> {
703        CallProxyInterface::r#request_transfer_audio(self)
704    }
705
706    /// Send a code that the call manager or remote audio gateway peer should
707    /// transmit to its network connection. The request returns after the code
708    /// has been transmitted to the network.
709    ///
710    /// Can return an error if the call manager or peer failed to transmit the
711    /// code to the network.
712    pub fn r#send_dtmf_code(
713        &self,
714        mut code: DtmfCode,
715    ) -> fidl::client::QueryResponseFut<
716        CallSendDtmfCodeResult,
717        fidl::encoding::DefaultFuchsiaResourceDialect,
718    > {
719        CallProxyInterface::r#send_dtmf_code(self, code)
720    }
721}
722
723impl CallProxyInterface for CallProxy {
724    type WatchStateResponseFut =
725        fidl::client::QueryResponseFut<CallState, fidl::encoding::DefaultFuchsiaResourceDialect>;
726    fn r#watch_state(&self) -> Self::WatchStateResponseFut {
727        fn _decode(
728            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
729        ) -> Result<CallState, fidl::Error> {
730            let _response = fidl::client::decode_transaction_body::<
731                CallWatchStateResponse,
732                fidl::encoding::DefaultFuchsiaResourceDialect,
733                0x5262bcc909bdaeb5,
734            >(_buf?)?;
735            Ok(_response.state)
736        }
737        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, CallState>(
738            (),
739            0x5262bcc909bdaeb5,
740            fidl::encoding::DynamicFlags::empty(),
741            _decode,
742        )
743    }
744
745    fn r#request_hold(&self) -> Result<(), fidl::Error> {
746        self.client.send::<fidl::encoding::EmptyPayload>(
747            (),
748            0x35ade403017d20eb,
749            fidl::encoding::DynamicFlags::empty(),
750        )
751    }
752
753    fn r#request_active(&self) -> Result<(), fidl::Error> {
754        self.client.send::<fidl::encoding::EmptyPayload>(
755            (),
756            0x248518f967f1fe6e,
757            fidl::encoding::DynamicFlags::empty(),
758        )
759    }
760
761    fn r#request_terminate(&self) -> Result<(), fidl::Error> {
762        self.client.send::<fidl::encoding::EmptyPayload>(
763            (),
764            0x4940915197ee4916,
765            fidl::encoding::DynamicFlags::empty(),
766        )
767    }
768
769    fn r#request_transfer_audio(&self) -> Result<(), fidl::Error> {
770        self.client.send::<fidl::encoding::EmptyPayload>(
771            (),
772            0xb0ca6649f2e104c,
773            fidl::encoding::DynamicFlags::empty(),
774        )
775    }
776
777    type SendDtmfCodeResponseFut = fidl::client::QueryResponseFut<
778        CallSendDtmfCodeResult,
779        fidl::encoding::DefaultFuchsiaResourceDialect,
780    >;
781    fn r#send_dtmf_code(&self, mut code: DtmfCode) -> Self::SendDtmfCodeResponseFut {
782        fn _decode(
783            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
784        ) -> Result<CallSendDtmfCodeResult, fidl::Error> {
785            let _response = fidl::client::decode_transaction_body::<
786                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
787                fidl::encoding::DefaultFuchsiaResourceDialect,
788                0x50768933ca33fcd6,
789            >(_buf?)?;
790            Ok(_response.map(|x| x))
791        }
792        self.client.send_query_and_decode::<CallSendDtmfCodeRequest, CallSendDtmfCodeResult>(
793            (code,),
794            0x50768933ca33fcd6,
795            fidl::encoding::DynamicFlags::empty(),
796            _decode,
797        )
798    }
799}
800
801pub struct CallEventStream {
802    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
803}
804
805impl std::marker::Unpin for CallEventStream {}
806
807impl futures::stream::FusedStream for CallEventStream {
808    fn is_terminated(&self) -> bool {
809        self.event_receiver.is_terminated()
810    }
811}
812
813impl futures::Stream for CallEventStream {
814    type Item = Result<CallEvent, fidl::Error>;
815
816    fn poll_next(
817        mut self: std::pin::Pin<&mut Self>,
818        cx: &mut std::task::Context<'_>,
819    ) -> std::task::Poll<Option<Self::Item>> {
820        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
821            &mut self.event_receiver,
822            cx
823        )?) {
824            Some(buf) => std::task::Poll::Ready(Some(CallEvent::decode(buf))),
825            None => std::task::Poll::Ready(None),
826        }
827    }
828}
829
830#[derive(Debug)]
831pub enum CallEvent {}
832
833impl CallEvent {
834    /// Decodes a message buffer as a [`CallEvent`].
835    fn decode(
836        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
837    ) -> Result<CallEvent, fidl::Error> {
838        let (bytes, _handles) = buf.split_mut();
839        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
840        debug_assert_eq!(tx_header.tx_id, 0);
841        match tx_header.ordinal {
842            _ => Err(fidl::Error::UnknownOrdinal {
843                ordinal: tx_header.ordinal,
844                protocol_name: <CallMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
845            }),
846        }
847    }
848}
849
850/// A Stream of incoming requests for fuchsia.bluetooth.hfp/Call.
851pub struct CallRequestStream {
852    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
853    is_terminated: bool,
854}
855
856impl std::marker::Unpin for CallRequestStream {}
857
858impl futures::stream::FusedStream for CallRequestStream {
859    fn is_terminated(&self) -> bool {
860        self.is_terminated
861    }
862}
863
864impl fidl::endpoints::RequestStream for CallRequestStream {
865    type Protocol = CallMarker;
866    type ControlHandle = CallControlHandle;
867
868    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
869        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
870    }
871
872    fn control_handle(&self) -> Self::ControlHandle {
873        CallControlHandle { inner: self.inner.clone() }
874    }
875
876    fn into_inner(
877        self,
878    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
879    {
880        (self.inner, self.is_terminated)
881    }
882
883    fn from_inner(
884        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
885        is_terminated: bool,
886    ) -> Self {
887        Self { inner, is_terminated }
888    }
889}
890
891impl futures::Stream for CallRequestStream {
892    type Item = Result<CallRequest, fidl::Error>;
893
894    fn poll_next(
895        mut self: std::pin::Pin<&mut Self>,
896        cx: &mut std::task::Context<'_>,
897    ) -> std::task::Poll<Option<Self::Item>> {
898        let this = &mut *self;
899        if this.inner.check_shutdown(cx) {
900            this.is_terminated = true;
901            return std::task::Poll::Ready(None);
902        }
903        if this.is_terminated {
904            panic!("polled CallRequestStream after completion");
905        }
906        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
907            |bytes, handles| {
908                match this.inner.channel().read_etc(cx, bytes, handles) {
909                    std::task::Poll::Ready(Ok(())) => {}
910                    std::task::Poll::Pending => return std::task::Poll::Pending,
911                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
912                        this.is_terminated = true;
913                        return std::task::Poll::Ready(None);
914                    }
915                    std::task::Poll::Ready(Err(e)) => {
916                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
917                            e.into(),
918                        ))))
919                    }
920                }
921
922                // A message has been received from the channel
923                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
924
925                std::task::Poll::Ready(Some(match header.ordinal {
926                    0x5262bcc909bdaeb5 => {
927                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
928                        let mut req = fidl::new_empty!(
929                            fidl::encoding::EmptyPayload,
930                            fidl::encoding::DefaultFuchsiaResourceDialect
931                        );
932                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
933                        let control_handle = CallControlHandle { inner: this.inner.clone() };
934                        Ok(CallRequest::WatchState {
935                            responder: CallWatchStateResponder {
936                                control_handle: std::mem::ManuallyDrop::new(control_handle),
937                                tx_id: header.tx_id,
938                            },
939                        })
940                    }
941                    0x35ade403017d20eb => {
942                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
943                        let mut req = fidl::new_empty!(
944                            fidl::encoding::EmptyPayload,
945                            fidl::encoding::DefaultFuchsiaResourceDialect
946                        );
947                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
948                        let control_handle = CallControlHandle { inner: this.inner.clone() };
949                        Ok(CallRequest::RequestHold { control_handle })
950                    }
951                    0x248518f967f1fe6e => {
952                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
953                        let mut req = fidl::new_empty!(
954                            fidl::encoding::EmptyPayload,
955                            fidl::encoding::DefaultFuchsiaResourceDialect
956                        );
957                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
958                        let control_handle = CallControlHandle { inner: this.inner.clone() };
959                        Ok(CallRequest::RequestActive { control_handle })
960                    }
961                    0x4940915197ee4916 => {
962                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
963                        let mut req = fidl::new_empty!(
964                            fidl::encoding::EmptyPayload,
965                            fidl::encoding::DefaultFuchsiaResourceDialect
966                        );
967                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
968                        let control_handle = CallControlHandle { inner: this.inner.clone() };
969                        Ok(CallRequest::RequestTerminate { control_handle })
970                    }
971                    0xb0ca6649f2e104c => {
972                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
973                        let mut req = fidl::new_empty!(
974                            fidl::encoding::EmptyPayload,
975                            fidl::encoding::DefaultFuchsiaResourceDialect
976                        );
977                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
978                        let control_handle = CallControlHandle { inner: this.inner.clone() };
979                        Ok(CallRequest::RequestTransferAudio { control_handle })
980                    }
981                    0x50768933ca33fcd6 => {
982                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
983                        let mut req = fidl::new_empty!(
984                            CallSendDtmfCodeRequest,
985                            fidl::encoding::DefaultFuchsiaResourceDialect
986                        );
987                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CallSendDtmfCodeRequest>(&header, _body_bytes, handles, &mut req)?;
988                        let control_handle = CallControlHandle { inner: this.inner.clone() };
989                        Ok(CallRequest::SendDtmfCode {
990                            code: req.code,
991
992                            responder: CallSendDtmfCodeResponder {
993                                control_handle: std::mem::ManuallyDrop::new(control_handle),
994                                tx_id: header.tx_id,
995                            },
996                        })
997                    }
998                    _ => Err(fidl::Error::UnknownOrdinal {
999                        ordinal: header.ordinal,
1000                        protocol_name: <CallMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1001                    }),
1002                }))
1003            },
1004        )
1005    }
1006}
1007
1008/// Controls the lifecycle of a call that has been routed through a headset.
1009#[derive(Debug)]
1010pub enum CallRequest {
1011    /// A hanging get method for call state. See the `CallState` documentation
1012    /// for information on possible states.
1013    WatchState { responder: CallWatchStateResponder },
1014    /// Request that the Call be set to the ONGOING_HELD CallState
1015    RequestHold { control_handle: CallControlHandle },
1016    /// Request that the Call be set to the ONGOING_ACTIVE CallState.
1017    /// This has the side effect of placing all other Calls that are routed to
1018    /// this peer in the ONGOING_HELD call state if it succeeds.
1019    RequestActive { control_handle: CallControlHandle },
1020    /// Request that the Call be TERMINATED.
1021    RequestTerminate { control_handle: CallControlHandle },
1022    /// Request that the Call's audio be transfered to the Audio Gateway and
1023    /// the call state set to TRANSFERRED_TO_AG.
1024    RequestTransferAudio { control_handle: CallControlHandle },
1025    /// Send a code that the call manager or remote audio gateway peer should
1026    /// transmit to its network connection. The request returns after the code
1027    /// has been transmitted to the network.
1028    ///
1029    /// Can return an error if the call manager or peer failed to transmit the
1030    /// code to the network.
1031    SendDtmfCode { code: DtmfCode, responder: CallSendDtmfCodeResponder },
1032}
1033
1034impl CallRequest {
1035    #[allow(irrefutable_let_patterns)]
1036    pub fn into_watch_state(self) -> Option<(CallWatchStateResponder)> {
1037        if let CallRequest::WatchState { responder } = self {
1038            Some((responder))
1039        } else {
1040            None
1041        }
1042    }
1043
1044    #[allow(irrefutable_let_patterns)]
1045    pub fn into_request_hold(self) -> Option<(CallControlHandle)> {
1046        if let CallRequest::RequestHold { control_handle } = self {
1047            Some((control_handle))
1048        } else {
1049            None
1050        }
1051    }
1052
1053    #[allow(irrefutable_let_patterns)]
1054    pub fn into_request_active(self) -> Option<(CallControlHandle)> {
1055        if let CallRequest::RequestActive { control_handle } = self {
1056            Some((control_handle))
1057        } else {
1058            None
1059        }
1060    }
1061
1062    #[allow(irrefutable_let_patterns)]
1063    pub fn into_request_terminate(self) -> Option<(CallControlHandle)> {
1064        if let CallRequest::RequestTerminate { control_handle } = self {
1065            Some((control_handle))
1066        } else {
1067            None
1068        }
1069    }
1070
1071    #[allow(irrefutable_let_patterns)]
1072    pub fn into_request_transfer_audio(self) -> Option<(CallControlHandle)> {
1073        if let CallRequest::RequestTransferAudio { control_handle } = self {
1074            Some((control_handle))
1075        } else {
1076            None
1077        }
1078    }
1079
1080    #[allow(irrefutable_let_patterns)]
1081    pub fn into_send_dtmf_code(self) -> Option<(DtmfCode, CallSendDtmfCodeResponder)> {
1082        if let CallRequest::SendDtmfCode { code, responder } = self {
1083            Some((code, responder))
1084        } else {
1085            None
1086        }
1087    }
1088
1089    /// Name of the method defined in FIDL
1090    pub fn method_name(&self) -> &'static str {
1091        match *self {
1092            CallRequest::WatchState { .. } => "watch_state",
1093            CallRequest::RequestHold { .. } => "request_hold",
1094            CallRequest::RequestActive { .. } => "request_active",
1095            CallRequest::RequestTerminate { .. } => "request_terminate",
1096            CallRequest::RequestTransferAudio { .. } => "request_transfer_audio",
1097            CallRequest::SendDtmfCode { .. } => "send_dtmf_code",
1098        }
1099    }
1100}
1101
1102#[derive(Debug, Clone)]
1103pub struct CallControlHandle {
1104    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1105}
1106
1107impl fidl::endpoints::ControlHandle for CallControlHandle {
1108    fn shutdown(&self) {
1109        self.inner.shutdown()
1110    }
1111    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1112        self.inner.shutdown_with_epitaph(status)
1113    }
1114
1115    fn is_closed(&self) -> bool {
1116        self.inner.channel().is_closed()
1117    }
1118    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1119        self.inner.channel().on_closed()
1120    }
1121
1122    #[cfg(target_os = "fuchsia")]
1123    fn signal_peer(
1124        &self,
1125        clear_mask: zx::Signals,
1126        set_mask: zx::Signals,
1127    ) -> Result<(), zx_status::Status> {
1128        use fidl::Peered;
1129        self.inner.channel().signal_peer(clear_mask, set_mask)
1130    }
1131}
1132
1133impl CallControlHandle {}
1134
1135#[must_use = "FIDL methods require a response to be sent"]
1136#[derive(Debug)]
1137pub struct CallWatchStateResponder {
1138    control_handle: std::mem::ManuallyDrop<CallControlHandle>,
1139    tx_id: u32,
1140}
1141
1142/// Set the the channel to be shutdown (see [`CallControlHandle::shutdown`])
1143/// if the responder is dropped without sending a response, so that the client
1144/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1145impl std::ops::Drop for CallWatchStateResponder {
1146    fn drop(&mut self) {
1147        self.control_handle.shutdown();
1148        // Safety: drops once, never accessed again
1149        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1150    }
1151}
1152
1153impl fidl::endpoints::Responder for CallWatchStateResponder {
1154    type ControlHandle = CallControlHandle;
1155
1156    fn control_handle(&self) -> &CallControlHandle {
1157        &self.control_handle
1158    }
1159
1160    fn drop_without_shutdown(mut self) {
1161        // Safety: drops once, never accessed again due to mem::forget
1162        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1163        // Prevent Drop from running (which would shut down the channel)
1164        std::mem::forget(self);
1165    }
1166}
1167
1168impl CallWatchStateResponder {
1169    /// Sends a response to the FIDL transaction.
1170    ///
1171    /// Sets the channel to shutdown if an error occurs.
1172    pub fn send(self, mut state: CallState) -> Result<(), fidl::Error> {
1173        let _result = self.send_raw(state);
1174        if _result.is_err() {
1175            self.control_handle.shutdown();
1176        }
1177        self.drop_without_shutdown();
1178        _result
1179    }
1180
1181    /// Similar to "send" but does not shutdown the channel if an error occurs.
1182    pub fn send_no_shutdown_on_err(self, mut state: CallState) -> Result<(), fidl::Error> {
1183        let _result = self.send_raw(state);
1184        self.drop_without_shutdown();
1185        _result
1186    }
1187
1188    fn send_raw(&self, mut state: CallState) -> Result<(), fidl::Error> {
1189        self.control_handle.inner.send::<CallWatchStateResponse>(
1190            (state,),
1191            self.tx_id,
1192            0x5262bcc909bdaeb5,
1193            fidl::encoding::DynamicFlags::empty(),
1194        )
1195    }
1196}
1197
1198#[must_use = "FIDL methods require a response to be sent"]
1199#[derive(Debug)]
1200pub struct CallSendDtmfCodeResponder {
1201    control_handle: std::mem::ManuallyDrop<CallControlHandle>,
1202    tx_id: u32,
1203}
1204
1205/// Set the the channel to be shutdown (see [`CallControlHandle::shutdown`])
1206/// if the responder is dropped without sending a response, so that the client
1207/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1208impl std::ops::Drop for CallSendDtmfCodeResponder {
1209    fn drop(&mut self) {
1210        self.control_handle.shutdown();
1211        // Safety: drops once, never accessed again
1212        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1213    }
1214}
1215
1216impl fidl::endpoints::Responder for CallSendDtmfCodeResponder {
1217    type ControlHandle = CallControlHandle;
1218
1219    fn control_handle(&self) -> &CallControlHandle {
1220        &self.control_handle
1221    }
1222
1223    fn drop_without_shutdown(mut self) {
1224        // Safety: drops once, never accessed again due to mem::forget
1225        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1226        // Prevent Drop from running (which would shut down the channel)
1227        std::mem::forget(self);
1228    }
1229}
1230
1231impl CallSendDtmfCodeResponder {
1232    /// Sends a response to the FIDL transaction.
1233    ///
1234    /// Sets the channel to shutdown if an error occurs.
1235    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1236        let _result = self.send_raw(result);
1237        if _result.is_err() {
1238            self.control_handle.shutdown();
1239        }
1240        self.drop_without_shutdown();
1241        _result
1242    }
1243
1244    /// Similar to "send" but does not shutdown the channel if an error occurs.
1245    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1246        let _result = self.send_raw(result);
1247        self.drop_without_shutdown();
1248        _result
1249    }
1250
1251    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1252        self.control_handle
1253            .inner
1254            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1255                result,
1256                self.tx_id,
1257                0x50768933ca33fcd6,
1258                fidl::encoding::DynamicFlags::empty(),
1259            )
1260    }
1261}
1262
1263#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1264pub struct CallManagerMarker;
1265
1266impl fidl::endpoints::ProtocolMarker for CallManagerMarker {
1267    type Proxy = CallManagerProxy;
1268    type RequestStream = CallManagerRequestStream;
1269    #[cfg(target_os = "fuchsia")]
1270    type SynchronousProxy = CallManagerSynchronousProxy;
1271
1272    const DEBUG_NAME: &'static str = "(anonymous) CallManager";
1273}
1274
1275pub trait CallManagerProxyInterface: Send + Sync {
1276    type PeerConnectedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1277    fn r#peer_connected(
1278        &self,
1279        id: &fidl_fuchsia_bluetooth::PeerId,
1280        handle: fidl::endpoints::ServerEnd<PeerHandlerMarker>,
1281    ) -> Self::PeerConnectedResponseFut;
1282}
1283#[derive(Debug)]
1284#[cfg(target_os = "fuchsia")]
1285pub struct CallManagerSynchronousProxy {
1286    client: fidl::client::sync::Client,
1287}
1288
1289#[cfg(target_os = "fuchsia")]
1290impl fidl::endpoints::SynchronousProxy for CallManagerSynchronousProxy {
1291    type Proxy = CallManagerProxy;
1292    type Protocol = CallManagerMarker;
1293
1294    fn from_channel(inner: fidl::Channel) -> Self {
1295        Self::new(inner)
1296    }
1297
1298    fn into_channel(self) -> fidl::Channel {
1299        self.client.into_channel()
1300    }
1301
1302    fn as_channel(&self) -> &fidl::Channel {
1303        self.client.as_channel()
1304    }
1305}
1306
1307#[cfg(target_os = "fuchsia")]
1308impl CallManagerSynchronousProxy {
1309    pub fn new(channel: fidl::Channel) -> Self {
1310        let protocol_name = <CallManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1311        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1312    }
1313
1314    pub fn into_channel(self) -> fidl::Channel {
1315        self.client.into_channel()
1316    }
1317
1318    /// Waits until an event arrives and returns it. It is safe for other
1319    /// threads to make concurrent requests while waiting for an event.
1320    pub fn wait_for_event(
1321        &self,
1322        deadline: zx::MonotonicInstant,
1323    ) -> Result<CallManagerEvent, fidl::Error> {
1324        CallManagerEvent::decode(self.client.wait_for_event(deadline)?)
1325    }
1326
1327    /// Signal that a peer that supports the HFP Hands-Free role is connected.
1328    ///
1329    /// `id` is the unique identifier associated with the peer.
1330    /// `handle` is the channel that the call manager should use to manage
1331    /// a the peer. If the call manager does not intend to handle a given peer,
1332    /// it must close the handle with a `ZX_ERR_UNAVAILABLE` epitaph.
1333    ///
1334    /// Multiple concurrent PeerConnected requests can be made by the client.
1335    /// The empty response is used as a flow control mechanism to allow the
1336    /// client to limit the number of pending PeerConnected requests.
1337    pub fn r#peer_connected(
1338        &self,
1339        mut id: &fidl_fuchsia_bluetooth::PeerId,
1340        mut handle: fidl::endpoints::ServerEnd<PeerHandlerMarker>,
1341        ___deadline: zx::MonotonicInstant,
1342    ) -> Result<(), fidl::Error> {
1343        let _response = self
1344            .client
1345            .send_query::<CallManagerPeerConnectedRequest, fidl::encoding::EmptyPayload>(
1346                (id, handle),
1347                0x1431cc24b2980086,
1348                fidl::encoding::DynamicFlags::empty(),
1349                ___deadline,
1350            )?;
1351        Ok(_response)
1352    }
1353}
1354
1355#[derive(Debug, Clone)]
1356pub struct CallManagerProxy {
1357    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1358}
1359
1360impl fidl::endpoints::Proxy for CallManagerProxy {
1361    type Protocol = CallManagerMarker;
1362
1363    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1364        Self::new(inner)
1365    }
1366
1367    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1368        self.client.into_channel().map_err(|client| Self { client })
1369    }
1370
1371    fn as_channel(&self) -> &::fidl::AsyncChannel {
1372        self.client.as_channel()
1373    }
1374}
1375
1376impl CallManagerProxy {
1377    /// Create a new Proxy for fuchsia.bluetooth.hfp/CallManager.
1378    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1379        let protocol_name = <CallManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1380        Self { client: fidl::client::Client::new(channel, protocol_name) }
1381    }
1382
1383    /// Get a Stream of events from the remote end of the protocol.
1384    ///
1385    /// # Panics
1386    ///
1387    /// Panics if the event stream was already taken.
1388    pub fn take_event_stream(&self) -> CallManagerEventStream {
1389        CallManagerEventStream { event_receiver: self.client.take_event_receiver() }
1390    }
1391
1392    /// Signal that a peer that supports the HFP Hands-Free role is connected.
1393    ///
1394    /// `id` is the unique identifier associated with the peer.
1395    /// `handle` is the channel that the call manager should use to manage
1396    /// a the peer. If the call manager does not intend to handle a given peer,
1397    /// it must close the handle with a `ZX_ERR_UNAVAILABLE` epitaph.
1398    ///
1399    /// Multiple concurrent PeerConnected requests can be made by the client.
1400    /// The empty response is used as a flow control mechanism to allow the
1401    /// client to limit the number of pending PeerConnected requests.
1402    pub fn r#peer_connected(
1403        &self,
1404        mut id: &fidl_fuchsia_bluetooth::PeerId,
1405        mut handle: fidl::endpoints::ServerEnd<PeerHandlerMarker>,
1406    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1407        CallManagerProxyInterface::r#peer_connected(self, id, handle)
1408    }
1409}
1410
1411impl CallManagerProxyInterface for CallManagerProxy {
1412    type PeerConnectedResponseFut =
1413        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1414    fn r#peer_connected(
1415        &self,
1416        mut id: &fidl_fuchsia_bluetooth::PeerId,
1417        mut handle: fidl::endpoints::ServerEnd<PeerHandlerMarker>,
1418    ) -> Self::PeerConnectedResponseFut {
1419        fn _decode(
1420            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1421        ) -> Result<(), fidl::Error> {
1422            let _response = fidl::client::decode_transaction_body::<
1423                fidl::encoding::EmptyPayload,
1424                fidl::encoding::DefaultFuchsiaResourceDialect,
1425                0x1431cc24b2980086,
1426            >(_buf?)?;
1427            Ok(_response)
1428        }
1429        self.client.send_query_and_decode::<CallManagerPeerConnectedRequest, ()>(
1430            (id, handle),
1431            0x1431cc24b2980086,
1432            fidl::encoding::DynamicFlags::empty(),
1433            _decode,
1434        )
1435    }
1436}
1437
1438pub struct CallManagerEventStream {
1439    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1440}
1441
1442impl std::marker::Unpin for CallManagerEventStream {}
1443
1444impl futures::stream::FusedStream for CallManagerEventStream {
1445    fn is_terminated(&self) -> bool {
1446        self.event_receiver.is_terminated()
1447    }
1448}
1449
1450impl futures::Stream for CallManagerEventStream {
1451    type Item = Result<CallManagerEvent, fidl::Error>;
1452
1453    fn poll_next(
1454        mut self: std::pin::Pin<&mut Self>,
1455        cx: &mut std::task::Context<'_>,
1456    ) -> std::task::Poll<Option<Self::Item>> {
1457        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1458            &mut self.event_receiver,
1459            cx
1460        )?) {
1461            Some(buf) => std::task::Poll::Ready(Some(CallManagerEvent::decode(buf))),
1462            None => std::task::Poll::Ready(None),
1463        }
1464    }
1465}
1466
1467#[derive(Debug)]
1468pub enum CallManagerEvent {}
1469
1470impl CallManagerEvent {
1471    /// Decodes a message buffer as a [`CallManagerEvent`].
1472    fn decode(
1473        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1474    ) -> Result<CallManagerEvent, fidl::Error> {
1475        let (bytes, _handles) = buf.split_mut();
1476        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1477        debug_assert_eq!(tx_header.tx_id, 0);
1478        match tx_header.ordinal {
1479            _ => Err(fidl::Error::UnknownOrdinal {
1480                ordinal: tx_header.ordinal,
1481                protocol_name: <CallManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1482            }),
1483        }
1484    }
1485}
1486
1487/// A Stream of incoming requests for fuchsia.bluetooth.hfp/CallManager.
1488pub struct CallManagerRequestStream {
1489    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1490    is_terminated: bool,
1491}
1492
1493impl std::marker::Unpin for CallManagerRequestStream {}
1494
1495impl futures::stream::FusedStream for CallManagerRequestStream {
1496    fn is_terminated(&self) -> bool {
1497        self.is_terminated
1498    }
1499}
1500
1501impl fidl::endpoints::RequestStream for CallManagerRequestStream {
1502    type Protocol = CallManagerMarker;
1503    type ControlHandle = CallManagerControlHandle;
1504
1505    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1506        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1507    }
1508
1509    fn control_handle(&self) -> Self::ControlHandle {
1510        CallManagerControlHandle { inner: self.inner.clone() }
1511    }
1512
1513    fn into_inner(
1514        self,
1515    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1516    {
1517        (self.inner, self.is_terminated)
1518    }
1519
1520    fn from_inner(
1521        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1522        is_terminated: bool,
1523    ) -> Self {
1524        Self { inner, is_terminated }
1525    }
1526}
1527
1528impl futures::Stream for CallManagerRequestStream {
1529    type Item = Result<CallManagerRequest, fidl::Error>;
1530
1531    fn poll_next(
1532        mut self: std::pin::Pin<&mut Self>,
1533        cx: &mut std::task::Context<'_>,
1534    ) -> std::task::Poll<Option<Self::Item>> {
1535        let this = &mut *self;
1536        if this.inner.check_shutdown(cx) {
1537            this.is_terminated = true;
1538            return std::task::Poll::Ready(None);
1539        }
1540        if this.is_terminated {
1541            panic!("polled CallManagerRequestStream after completion");
1542        }
1543        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1544            |bytes, handles| {
1545                match this.inner.channel().read_etc(cx, bytes, handles) {
1546                    std::task::Poll::Ready(Ok(())) => {}
1547                    std::task::Poll::Pending => return std::task::Poll::Pending,
1548                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1549                        this.is_terminated = true;
1550                        return std::task::Poll::Ready(None);
1551                    }
1552                    std::task::Poll::Ready(Err(e)) => {
1553                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1554                            e.into(),
1555                        ))))
1556                    }
1557                }
1558
1559                // A message has been received from the channel
1560                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1561
1562                std::task::Poll::Ready(Some(match header.ordinal {
1563                    0x1431cc24b2980086 => {
1564                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1565                        let mut req = fidl::new_empty!(
1566                            CallManagerPeerConnectedRequest,
1567                            fidl::encoding::DefaultFuchsiaResourceDialect
1568                        );
1569                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CallManagerPeerConnectedRequest>(&header, _body_bytes, handles, &mut req)?;
1570                        let control_handle = CallManagerControlHandle { inner: this.inner.clone() };
1571                        Ok(CallManagerRequest::PeerConnected {
1572                            id: req.id,
1573                            handle: req.handle,
1574
1575                            responder: CallManagerPeerConnectedResponder {
1576                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1577                                tx_id: header.tx_id,
1578                            },
1579                        })
1580                    }
1581                    _ => Err(fidl::Error::UnknownOrdinal {
1582                        ordinal: header.ordinal,
1583                        protocol_name:
1584                            <CallManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1585                    }),
1586                }))
1587            },
1588        )
1589    }
1590}
1591
1592#[derive(Debug)]
1593pub enum CallManagerRequest {
1594    /// Signal that a peer that supports the HFP Hands-Free role is connected.
1595    ///
1596    /// `id` is the unique identifier associated with the peer.
1597    /// `handle` is the channel that the call manager should use to manage
1598    /// a the peer. If the call manager does not intend to handle a given peer,
1599    /// it must close the handle with a `ZX_ERR_UNAVAILABLE` epitaph.
1600    ///
1601    /// Multiple concurrent PeerConnected requests can be made by the client.
1602    /// The empty response is used as a flow control mechanism to allow the
1603    /// client to limit the number of pending PeerConnected requests.
1604    PeerConnected {
1605        id: fidl_fuchsia_bluetooth::PeerId,
1606        handle: fidl::endpoints::ServerEnd<PeerHandlerMarker>,
1607        responder: CallManagerPeerConnectedResponder,
1608    },
1609}
1610
1611impl CallManagerRequest {
1612    #[allow(irrefutable_let_patterns)]
1613    pub fn into_peer_connected(
1614        self,
1615    ) -> Option<(
1616        fidl_fuchsia_bluetooth::PeerId,
1617        fidl::endpoints::ServerEnd<PeerHandlerMarker>,
1618        CallManagerPeerConnectedResponder,
1619    )> {
1620        if let CallManagerRequest::PeerConnected { id, handle, responder } = self {
1621            Some((id, handle, responder))
1622        } else {
1623            None
1624        }
1625    }
1626
1627    /// Name of the method defined in FIDL
1628    pub fn method_name(&self) -> &'static str {
1629        match *self {
1630            CallManagerRequest::PeerConnected { .. } => "peer_connected",
1631        }
1632    }
1633}
1634
1635#[derive(Debug, Clone)]
1636pub struct CallManagerControlHandle {
1637    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1638}
1639
1640impl fidl::endpoints::ControlHandle for CallManagerControlHandle {
1641    fn shutdown(&self) {
1642        self.inner.shutdown()
1643    }
1644    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1645        self.inner.shutdown_with_epitaph(status)
1646    }
1647
1648    fn is_closed(&self) -> bool {
1649        self.inner.channel().is_closed()
1650    }
1651    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1652        self.inner.channel().on_closed()
1653    }
1654
1655    #[cfg(target_os = "fuchsia")]
1656    fn signal_peer(
1657        &self,
1658        clear_mask: zx::Signals,
1659        set_mask: zx::Signals,
1660    ) -> Result<(), zx_status::Status> {
1661        use fidl::Peered;
1662        self.inner.channel().signal_peer(clear_mask, set_mask)
1663    }
1664}
1665
1666impl CallManagerControlHandle {}
1667
1668#[must_use = "FIDL methods require a response to be sent"]
1669#[derive(Debug)]
1670pub struct CallManagerPeerConnectedResponder {
1671    control_handle: std::mem::ManuallyDrop<CallManagerControlHandle>,
1672    tx_id: u32,
1673}
1674
1675/// Set the the channel to be shutdown (see [`CallManagerControlHandle::shutdown`])
1676/// if the responder is dropped without sending a response, so that the client
1677/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1678impl std::ops::Drop for CallManagerPeerConnectedResponder {
1679    fn drop(&mut self) {
1680        self.control_handle.shutdown();
1681        // Safety: drops once, never accessed again
1682        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1683    }
1684}
1685
1686impl fidl::endpoints::Responder for CallManagerPeerConnectedResponder {
1687    type ControlHandle = CallManagerControlHandle;
1688
1689    fn control_handle(&self) -> &CallManagerControlHandle {
1690        &self.control_handle
1691    }
1692
1693    fn drop_without_shutdown(mut self) {
1694        // Safety: drops once, never accessed again due to mem::forget
1695        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1696        // Prevent Drop from running (which would shut down the channel)
1697        std::mem::forget(self);
1698    }
1699}
1700
1701impl CallManagerPeerConnectedResponder {
1702    /// Sends a response to the FIDL transaction.
1703    ///
1704    /// Sets the channel to shutdown if an error occurs.
1705    pub fn send(self) -> Result<(), fidl::Error> {
1706        let _result = self.send_raw();
1707        if _result.is_err() {
1708            self.control_handle.shutdown();
1709        }
1710        self.drop_without_shutdown();
1711        _result
1712    }
1713
1714    /// Similar to "send" but does not shutdown the channel if an error occurs.
1715    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1716        let _result = self.send_raw();
1717        self.drop_without_shutdown();
1718        _result
1719    }
1720
1721    fn send_raw(&self) -> Result<(), fidl::Error> {
1722        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1723            (),
1724            self.tx_id,
1725            0x1431cc24b2980086,
1726            fidl::encoding::DynamicFlags::empty(),
1727        )
1728    }
1729}
1730
1731#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1732pub struct HandsFreeMarker;
1733
1734impl fidl::endpoints::ProtocolMarker for HandsFreeMarker {
1735    type Proxy = HandsFreeProxy;
1736    type RequestStream = HandsFreeRequestStream;
1737    #[cfg(target_os = "fuchsia")]
1738    type SynchronousProxy = HandsFreeSynchronousProxy;
1739
1740    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.hfp.HandsFree";
1741}
1742impl fidl::endpoints::DiscoverableProtocolMarker for HandsFreeMarker {}
1743pub type HandsFreeWatchPeerConnectedResult =
1744    Result<(fidl_fuchsia_bluetooth::PeerId, fidl::endpoints::ClientEnd<PeerHandlerMarker>), i32>;
1745
1746pub trait HandsFreeProxyInterface: Send + Sync {
1747    type WatchPeerConnectedResponseFut: std::future::Future<Output = Result<HandsFreeWatchPeerConnectedResult, fidl::Error>>
1748        + Send;
1749    fn r#watch_peer_connected(&self) -> Self::WatchPeerConnectedResponseFut;
1750}
1751#[derive(Debug)]
1752#[cfg(target_os = "fuchsia")]
1753pub struct HandsFreeSynchronousProxy {
1754    client: fidl::client::sync::Client,
1755}
1756
1757#[cfg(target_os = "fuchsia")]
1758impl fidl::endpoints::SynchronousProxy for HandsFreeSynchronousProxy {
1759    type Proxy = HandsFreeProxy;
1760    type Protocol = HandsFreeMarker;
1761
1762    fn from_channel(inner: fidl::Channel) -> Self {
1763        Self::new(inner)
1764    }
1765
1766    fn into_channel(self) -> fidl::Channel {
1767        self.client.into_channel()
1768    }
1769
1770    fn as_channel(&self) -> &fidl::Channel {
1771        self.client.as_channel()
1772    }
1773}
1774
1775#[cfg(target_os = "fuchsia")]
1776impl HandsFreeSynchronousProxy {
1777    pub fn new(channel: fidl::Channel) -> Self {
1778        let protocol_name = <HandsFreeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1779        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1780    }
1781
1782    pub fn into_channel(self) -> fidl::Channel {
1783        self.client.into_channel()
1784    }
1785
1786    /// Waits until an event arrives and returns it. It is safe for other
1787    /// threads to make concurrent requests while waiting for an event.
1788    pub fn wait_for_event(
1789        &self,
1790        deadline: zx::MonotonicInstant,
1791    ) -> Result<HandsFreeEvent, fidl::Error> {
1792        HandsFreeEvent::decode(self.client.wait_for_event(deadline)?)
1793    }
1794
1795    /// Hanging get that waits for a a peer that supports the HFP Audio Gateway
1796    /// role to connect.
1797    ///
1798    /// `id` is the unique identifier associated with the peer.
1799    ///
1800    /// `handle` is the channel that the client should use to manage the peer.
1801    /// If the call manager does not intend to handle a given peer. it must
1802    /// close the handle,
1803    pub fn r#watch_peer_connected(
1804        &self,
1805        ___deadline: zx::MonotonicInstant,
1806    ) -> Result<HandsFreeWatchPeerConnectedResult, fidl::Error> {
1807        let _response = self.client.send_query::<
1808            fidl::encoding::EmptyPayload,
1809            fidl::encoding::ResultType<HandsFreeWatchPeerConnectedResponse, i32>,
1810        >(
1811            (),
1812            0x1cc503325a8bbc3f,
1813            fidl::encoding::DynamicFlags::empty(),
1814            ___deadline,
1815        )?;
1816        Ok(_response.map(|x| (x.id, x.handle)))
1817    }
1818}
1819
1820#[derive(Debug, Clone)]
1821pub struct HandsFreeProxy {
1822    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1823}
1824
1825impl fidl::endpoints::Proxy for HandsFreeProxy {
1826    type Protocol = HandsFreeMarker;
1827
1828    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1829        Self::new(inner)
1830    }
1831
1832    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1833        self.client.into_channel().map_err(|client| Self { client })
1834    }
1835
1836    fn as_channel(&self) -> &::fidl::AsyncChannel {
1837        self.client.as_channel()
1838    }
1839}
1840
1841impl HandsFreeProxy {
1842    /// Create a new Proxy for fuchsia.bluetooth.hfp/HandsFree.
1843    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1844        let protocol_name = <HandsFreeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1845        Self { client: fidl::client::Client::new(channel, protocol_name) }
1846    }
1847
1848    /// Get a Stream of events from the remote end of the protocol.
1849    ///
1850    /// # Panics
1851    ///
1852    /// Panics if the event stream was already taken.
1853    pub fn take_event_stream(&self) -> HandsFreeEventStream {
1854        HandsFreeEventStream { event_receiver: self.client.take_event_receiver() }
1855    }
1856
1857    /// Hanging get that waits for a a peer that supports the HFP Audio Gateway
1858    /// role to connect.
1859    ///
1860    /// `id` is the unique identifier associated with the peer.
1861    ///
1862    /// `handle` is the channel that the client should use to manage the peer.
1863    /// If the call manager does not intend to handle a given peer. it must
1864    /// close the handle,
1865    pub fn r#watch_peer_connected(
1866        &self,
1867    ) -> fidl::client::QueryResponseFut<
1868        HandsFreeWatchPeerConnectedResult,
1869        fidl::encoding::DefaultFuchsiaResourceDialect,
1870    > {
1871        HandsFreeProxyInterface::r#watch_peer_connected(self)
1872    }
1873}
1874
1875impl HandsFreeProxyInterface for HandsFreeProxy {
1876    type WatchPeerConnectedResponseFut = fidl::client::QueryResponseFut<
1877        HandsFreeWatchPeerConnectedResult,
1878        fidl::encoding::DefaultFuchsiaResourceDialect,
1879    >;
1880    fn r#watch_peer_connected(&self) -> Self::WatchPeerConnectedResponseFut {
1881        fn _decode(
1882            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1883        ) -> Result<HandsFreeWatchPeerConnectedResult, fidl::Error> {
1884            let _response = fidl::client::decode_transaction_body::<
1885                fidl::encoding::ResultType<HandsFreeWatchPeerConnectedResponse, i32>,
1886                fidl::encoding::DefaultFuchsiaResourceDialect,
1887                0x1cc503325a8bbc3f,
1888            >(_buf?)?;
1889            Ok(_response.map(|x| (x.id, x.handle)))
1890        }
1891        self.client.send_query_and_decode::<
1892            fidl::encoding::EmptyPayload,
1893            HandsFreeWatchPeerConnectedResult,
1894        >(
1895            (),
1896            0x1cc503325a8bbc3f,
1897            fidl::encoding::DynamicFlags::empty(),
1898            _decode,
1899        )
1900    }
1901}
1902
1903pub struct HandsFreeEventStream {
1904    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1905}
1906
1907impl std::marker::Unpin for HandsFreeEventStream {}
1908
1909impl futures::stream::FusedStream for HandsFreeEventStream {
1910    fn is_terminated(&self) -> bool {
1911        self.event_receiver.is_terminated()
1912    }
1913}
1914
1915impl futures::Stream for HandsFreeEventStream {
1916    type Item = Result<HandsFreeEvent, fidl::Error>;
1917
1918    fn poll_next(
1919        mut self: std::pin::Pin<&mut Self>,
1920        cx: &mut std::task::Context<'_>,
1921    ) -> std::task::Poll<Option<Self::Item>> {
1922        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1923            &mut self.event_receiver,
1924            cx
1925        )?) {
1926            Some(buf) => std::task::Poll::Ready(Some(HandsFreeEvent::decode(buf))),
1927            None => std::task::Poll::Ready(None),
1928        }
1929    }
1930}
1931
1932#[derive(Debug)]
1933pub enum HandsFreeEvent {}
1934
1935impl HandsFreeEvent {
1936    /// Decodes a message buffer as a [`HandsFreeEvent`].
1937    fn decode(
1938        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1939    ) -> Result<HandsFreeEvent, fidl::Error> {
1940        let (bytes, _handles) = buf.split_mut();
1941        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1942        debug_assert_eq!(tx_header.tx_id, 0);
1943        match tx_header.ordinal {
1944            _ => Err(fidl::Error::UnknownOrdinal {
1945                ordinal: tx_header.ordinal,
1946                protocol_name: <HandsFreeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1947            }),
1948        }
1949    }
1950}
1951
1952/// A Stream of incoming requests for fuchsia.bluetooth.hfp/HandsFree.
1953pub struct HandsFreeRequestStream {
1954    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1955    is_terminated: bool,
1956}
1957
1958impl std::marker::Unpin for HandsFreeRequestStream {}
1959
1960impl futures::stream::FusedStream for HandsFreeRequestStream {
1961    fn is_terminated(&self) -> bool {
1962        self.is_terminated
1963    }
1964}
1965
1966impl fidl::endpoints::RequestStream for HandsFreeRequestStream {
1967    type Protocol = HandsFreeMarker;
1968    type ControlHandle = HandsFreeControlHandle;
1969
1970    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1971        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1972    }
1973
1974    fn control_handle(&self) -> Self::ControlHandle {
1975        HandsFreeControlHandle { inner: self.inner.clone() }
1976    }
1977
1978    fn into_inner(
1979        self,
1980    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1981    {
1982        (self.inner, self.is_terminated)
1983    }
1984
1985    fn from_inner(
1986        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1987        is_terminated: bool,
1988    ) -> Self {
1989        Self { inner, is_terminated }
1990    }
1991}
1992
1993impl futures::Stream for HandsFreeRequestStream {
1994    type Item = Result<HandsFreeRequest, fidl::Error>;
1995
1996    fn poll_next(
1997        mut self: std::pin::Pin<&mut Self>,
1998        cx: &mut std::task::Context<'_>,
1999    ) -> std::task::Poll<Option<Self::Item>> {
2000        let this = &mut *self;
2001        if this.inner.check_shutdown(cx) {
2002            this.is_terminated = true;
2003            return std::task::Poll::Ready(None);
2004        }
2005        if this.is_terminated {
2006            panic!("polled HandsFreeRequestStream after completion");
2007        }
2008        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2009            |bytes, handles| {
2010                match this.inner.channel().read_etc(cx, bytes, handles) {
2011                    std::task::Poll::Ready(Ok(())) => {}
2012                    std::task::Poll::Pending => return std::task::Poll::Pending,
2013                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2014                        this.is_terminated = true;
2015                        return std::task::Poll::Ready(None);
2016                    }
2017                    std::task::Poll::Ready(Err(e)) => {
2018                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2019                            e.into(),
2020                        ))))
2021                    }
2022                }
2023
2024                // A message has been received from the channel
2025                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2026
2027                std::task::Poll::Ready(Some(match header.ordinal {
2028                    0x1cc503325a8bbc3f => {
2029                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2030                        let mut req = fidl::new_empty!(
2031                            fidl::encoding::EmptyPayload,
2032                            fidl::encoding::DefaultFuchsiaResourceDialect
2033                        );
2034                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2035                        let control_handle = HandsFreeControlHandle { inner: this.inner.clone() };
2036                        Ok(HandsFreeRequest::WatchPeerConnected {
2037                            responder: HandsFreeWatchPeerConnectedResponder {
2038                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2039                                tx_id: header.tx_id,
2040                            },
2041                        })
2042                    }
2043                    _ => Err(fidl::Error::UnknownOrdinal {
2044                        ordinal: header.ordinal,
2045                        protocol_name:
2046                            <HandsFreeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2047                    }),
2048                }))
2049            },
2050        )
2051    }
2052}
2053
2054#[derive(Debug)]
2055pub enum HandsFreeRequest {
2056    /// Hanging get that waits for a a peer that supports the HFP Audio Gateway
2057    /// role to connect.
2058    ///
2059    /// `id` is the unique identifier associated with the peer.
2060    ///
2061    /// `handle` is the channel that the client should use to manage the peer.
2062    /// If the call manager does not intend to handle a given peer. it must
2063    /// close the handle,
2064    WatchPeerConnected { responder: HandsFreeWatchPeerConnectedResponder },
2065}
2066
2067impl HandsFreeRequest {
2068    #[allow(irrefutable_let_patterns)]
2069    pub fn into_watch_peer_connected(self) -> Option<(HandsFreeWatchPeerConnectedResponder)> {
2070        if let HandsFreeRequest::WatchPeerConnected { responder } = self {
2071            Some((responder))
2072        } else {
2073            None
2074        }
2075    }
2076
2077    /// Name of the method defined in FIDL
2078    pub fn method_name(&self) -> &'static str {
2079        match *self {
2080            HandsFreeRequest::WatchPeerConnected { .. } => "watch_peer_connected",
2081        }
2082    }
2083}
2084
2085#[derive(Debug, Clone)]
2086pub struct HandsFreeControlHandle {
2087    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2088}
2089
2090impl fidl::endpoints::ControlHandle for HandsFreeControlHandle {
2091    fn shutdown(&self) {
2092        self.inner.shutdown()
2093    }
2094    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2095        self.inner.shutdown_with_epitaph(status)
2096    }
2097
2098    fn is_closed(&self) -> bool {
2099        self.inner.channel().is_closed()
2100    }
2101    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2102        self.inner.channel().on_closed()
2103    }
2104
2105    #[cfg(target_os = "fuchsia")]
2106    fn signal_peer(
2107        &self,
2108        clear_mask: zx::Signals,
2109        set_mask: zx::Signals,
2110    ) -> Result<(), zx_status::Status> {
2111        use fidl::Peered;
2112        self.inner.channel().signal_peer(clear_mask, set_mask)
2113    }
2114}
2115
2116impl HandsFreeControlHandle {}
2117
2118#[must_use = "FIDL methods require a response to be sent"]
2119#[derive(Debug)]
2120pub struct HandsFreeWatchPeerConnectedResponder {
2121    control_handle: std::mem::ManuallyDrop<HandsFreeControlHandle>,
2122    tx_id: u32,
2123}
2124
2125/// Set the the channel to be shutdown (see [`HandsFreeControlHandle::shutdown`])
2126/// if the responder is dropped without sending a response, so that the client
2127/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2128impl std::ops::Drop for HandsFreeWatchPeerConnectedResponder {
2129    fn drop(&mut self) {
2130        self.control_handle.shutdown();
2131        // Safety: drops once, never accessed again
2132        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2133    }
2134}
2135
2136impl fidl::endpoints::Responder for HandsFreeWatchPeerConnectedResponder {
2137    type ControlHandle = HandsFreeControlHandle;
2138
2139    fn control_handle(&self) -> &HandsFreeControlHandle {
2140        &self.control_handle
2141    }
2142
2143    fn drop_without_shutdown(mut self) {
2144        // Safety: drops once, never accessed again due to mem::forget
2145        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2146        // Prevent Drop from running (which would shut down the channel)
2147        std::mem::forget(self);
2148    }
2149}
2150
2151impl HandsFreeWatchPeerConnectedResponder {
2152    /// Sends a response to the FIDL transaction.
2153    ///
2154    /// Sets the channel to shutdown if an error occurs.
2155    pub fn send(
2156        self,
2157        mut result: Result<
2158            (&fidl_fuchsia_bluetooth::PeerId, fidl::endpoints::ClientEnd<PeerHandlerMarker>),
2159            i32,
2160        >,
2161    ) -> Result<(), fidl::Error> {
2162        let _result = self.send_raw(result);
2163        if _result.is_err() {
2164            self.control_handle.shutdown();
2165        }
2166        self.drop_without_shutdown();
2167        _result
2168    }
2169
2170    /// Similar to "send" but does not shutdown the channel if an error occurs.
2171    pub fn send_no_shutdown_on_err(
2172        self,
2173        mut result: Result<
2174            (&fidl_fuchsia_bluetooth::PeerId, fidl::endpoints::ClientEnd<PeerHandlerMarker>),
2175            i32,
2176        >,
2177    ) -> Result<(), fidl::Error> {
2178        let _result = self.send_raw(result);
2179        self.drop_without_shutdown();
2180        _result
2181    }
2182
2183    fn send_raw(
2184        &self,
2185        mut result: Result<
2186            (&fidl_fuchsia_bluetooth::PeerId, fidl::endpoints::ClientEnd<PeerHandlerMarker>),
2187            i32,
2188        >,
2189    ) -> Result<(), fidl::Error> {
2190        self.control_handle.inner.send::<fidl::encoding::ResultType<
2191            HandsFreeWatchPeerConnectedResponse,
2192            i32,
2193        >>(
2194            result,
2195            self.tx_id,
2196            0x1cc503325a8bbc3f,
2197            fidl::encoding::DynamicFlags::empty(),
2198        )
2199    }
2200}
2201
2202#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2203pub struct HeadsetGainMarker;
2204
2205impl fidl::endpoints::ProtocolMarker for HeadsetGainMarker {
2206    type Proxy = HeadsetGainProxy;
2207    type RequestStream = HeadsetGainRequestStream;
2208    #[cfg(target_os = "fuchsia")]
2209    type SynchronousProxy = HeadsetGainSynchronousProxy;
2210
2211    const DEBUG_NAME: &'static str = "(anonymous) HeadsetGain";
2212}
2213
2214pub trait HeadsetGainProxyInterface: Send + Sync {
2215    fn r#set_speaker_gain(&self, requested: u8) -> Result<(), fidl::Error>;
2216    type WatchSpeakerGainResponseFut: std::future::Future<Output = Result<u8, fidl::Error>> + Send;
2217    fn r#watch_speaker_gain(&self) -> Self::WatchSpeakerGainResponseFut;
2218    fn r#set_microphone_gain(&self, requested: u8) -> Result<(), fidl::Error>;
2219    type WatchMicrophoneGainResponseFut: std::future::Future<Output = Result<u8, fidl::Error>>
2220        + Send;
2221    fn r#watch_microphone_gain(&self) -> Self::WatchMicrophoneGainResponseFut;
2222}
2223#[derive(Debug)]
2224#[cfg(target_os = "fuchsia")]
2225pub struct HeadsetGainSynchronousProxy {
2226    client: fidl::client::sync::Client,
2227}
2228
2229#[cfg(target_os = "fuchsia")]
2230impl fidl::endpoints::SynchronousProxy for HeadsetGainSynchronousProxy {
2231    type Proxy = HeadsetGainProxy;
2232    type Protocol = HeadsetGainMarker;
2233
2234    fn from_channel(inner: fidl::Channel) -> Self {
2235        Self::new(inner)
2236    }
2237
2238    fn into_channel(self) -> fidl::Channel {
2239        self.client.into_channel()
2240    }
2241
2242    fn as_channel(&self) -> &fidl::Channel {
2243        self.client.as_channel()
2244    }
2245}
2246
2247#[cfg(target_os = "fuchsia")]
2248impl HeadsetGainSynchronousProxy {
2249    pub fn new(channel: fidl::Channel) -> Self {
2250        let protocol_name = <HeadsetGainMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2251        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2252    }
2253
2254    pub fn into_channel(self) -> fidl::Channel {
2255        self.client.into_channel()
2256    }
2257
2258    /// Waits until an event arrives and returns it. It is safe for other
2259    /// threads to make concurrent requests while waiting for an event.
2260    pub fn wait_for_event(
2261        &self,
2262        deadline: zx::MonotonicInstant,
2263    ) -> Result<HeadsetGainEvent, fidl::Error> {
2264        HeadsetGainEvent::decode(self.client.wait_for_event(deadline)?)
2265    }
2266
2267    /// Make a request to the headset to set the speaker gain to `requested`.
2268    ///
2269    /// `requested` must be in the range [0-15] inclusive. Any values outside of
2270    /// this range will result in the channel closing with a
2271    /// `ZX_ERR_INVALID_ARGUMENT` epitaph.
2272    pub fn r#set_speaker_gain(&self, mut requested: u8) -> Result<(), fidl::Error> {
2273        self.client.send::<HeadsetGainSetSpeakerGainRequest>(
2274            (requested,),
2275            0x3462191b2a6ae5ce,
2276            fidl::encoding::DynamicFlags::empty(),
2277        )
2278    }
2279
2280    /// Hanging get to watch for updates to the headset speaker gain. Responses
2281    /// represent the current gain value that is set.
2282    ///
2283    /// The returned `gain` value will always be in the range [0-15] inclusive.
2284    pub fn r#watch_speaker_gain(
2285        &self,
2286        ___deadline: zx::MonotonicInstant,
2287    ) -> Result<u8, fidl::Error> {
2288        let _response = self
2289            .client
2290            .send_query::<fidl::encoding::EmptyPayload, HeadsetGainWatchSpeakerGainResponse>(
2291                (),
2292                0x2007abdf2695c747,
2293                fidl::encoding::DynamicFlags::empty(),
2294                ___deadline,
2295            )?;
2296        Ok(_response.gain)
2297    }
2298
2299    /// Make a request to the Headset to set the microphone gain to `requested`.
2300    ///
2301    /// `requested` must be in the range [0-15] inclusive. Any values outside of
2302    /// this range will result in the channel closing with a
2303    /// `ZX_ERR_INVALID_ARGUMENT` epitaph.
2304    pub fn r#set_microphone_gain(&self, mut requested: u8) -> Result<(), fidl::Error> {
2305        self.client.send::<HeadsetGainSetMicrophoneGainRequest>(
2306            (requested,),
2307            0x7ddbb4e63caeef8e,
2308            fidl::encoding::DynamicFlags::empty(),
2309        )
2310    }
2311
2312    /// Hanging get to watch for updates to the headset microphone gain. Responses
2313    /// represent the current gain value that is set.
2314    ///
2315    /// The returned `gain` value will always be in the range [0-15] inclusive.
2316    pub fn r#watch_microphone_gain(
2317        &self,
2318        ___deadline: zx::MonotonicInstant,
2319    ) -> Result<u8, fidl::Error> {
2320        let _response = self
2321            .client
2322            .send_query::<fidl::encoding::EmptyPayload, HeadsetGainWatchMicrophoneGainResponse>(
2323                (),
2324                0x1d171fb432fa55ad,
2325                fidl::encoding::DynamicFlags::empty(),
2326                ___deadline,
2327            )?;
2328        Ok(_response.gain)
2329    }
2330}
2331
2332#[derive(Debug, Clone)]
2333pub struct HeadsetGainProxy {
2334    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2335}
2336
2337impl fidl::endpoints::Proxy for HeadsetGainProxy {
2338    type Protocol = HeadsetGainMarker;
2339
2340    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2341        Self::new(inner)
2342    }
2343
2344    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2345        self.client.into_channel().map_err(|client| Self { client })
2346    }
2347
2348    fn as_channel(&self) -> &::fidl::AsyncChannel {
2349        self.client.as_channel()
2350    }
2351}
2352
2353impl HeadsetGainProxy {
2354    /// Create a new Proxy for fuchsia.bluetooth.hfp/HeadsetGain.
2355    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2356        let protocol_name = <HeadsetGainMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2357        Self { client: fidl::client::Client::new(channel, protocol_name) }
2358    }
2359
2360    /// Get a Stream of events from the remote end of the protocol.
2361    ///
2362    /// # Panics
2363    ///
2364    /// Panics if the event stream was already taken.
2365    pub fn take_event_stream(&self) -> HeadsetGainEventStream {
2366        HeadsetGainEventStream { event_receiver: self.client.take_event_receiver() }
2367    }
2368
2369    /// Make a request to the headset to set the speaker gain to `requested`.
2370    ///
2371    /// `requested` must be in the range [0-15] inclusive. Any values outside of
2372    /// this range will result in the channel closing with a
2373    /// `ZX_ERR_INVALID_ARGUMENT` epitaph.
2374    pub fn r#set_speaker_gain(&self, mut requested: u8) -> Result<(), fidl::Error> {
2375        HeadsetGainProxyInterface::r#set_speaker_gain(self, requested)
2376    }
2377
2378    /// Hanging get to watch for updates to the headset speaker gain. Responses
2379    /// represent the current gain value that is set.
2380    ///
2381    /// The returned `gain` value will always be in the range [0-15] inclusive.
2382    pub fn r#watch_speaker_gain(
2383        &self,
2384    ) -> fidl::client::QueryResponseFut<u8, fidl::encoding::DefaultFuchsiaResourceDialect> {
2385        HeadsetGainProxyInterface::r#watch_speaker_gain(self)
2386    }
2387
2388    /// Make a request to the Headset to set the microphone gain to `requested`.
2389    ///
2390    /// `requested` must be in the range [0-15] inclusive. Any values outside of
2391    /// this range will result in the channel closing with a
2392    /// `ZX_ERR_INVALID_ARGUMENT` epitaph.
2393    pub fn r#set_microphone_gain(&self, mut requested: u8) -> Result<(), fidl::Error> {
2394        HeadsetGainProxyInterface::r#set_microphone_gain(self, requested)
2395    }
2396
2397    /// Hanging get to watch for updates to the headset microphone gain. Responses
2398    /// represent the current gain value that is set.
2399    ///
2400    /// The returned `gain` value will always be in the range [0-15] inclusive.
2401    pub fn r#watch_microphone_gain(
2402        &self,
2403    ) -> fidl::client::QueryResponseFut<u8, fidl::encoding::DefaultFuchsiaResourceDialect> {
2404        HeadsetGainProxyInterface::r#watch_microphone_gain(self)
2405    }
2406}
2407
2408impl HeadsetGainProxyInterface for HeadsetGainProxy {
2409    fn r#set_speaker_gain(&self, mut requested: u8) -> Result<(), fidl::Error> {
2410        self.client.send::<HeadsetGainSetSpeakerGainRequest>(
2411            (requested,),
2412            0x3462191b2a6ae5ce,
2413            fidl::encoding::DynamicFlags::empty(),
2414        )
2415    }
2416
2417    type WatchSpeakerGainResponseFut =
2418        fidl::client::QueryResponseFut<u8, fidl::encoding::DefaultFuchsiaResourceDialect>;
2419    fn r#watch_speaker_gain(&self) -> Self::WatchSpeakerGainResponseFut {
2420        fn _decode(
2421            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2422        ) -> Result<u8, fidl::Error> {
2423            let _response = fidl::client::decode_transaction_body::<
2424                HeadsetGainWatchSpeakerGainResponse,
2425                fidl::encoding::DefaultFuchsiaResourceDialect,
2426                0x2007abdf2695c747,
2427            >(_buf?)?;
2428            Ok(_response.gain)
2429        }
2430        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u8>(
2431            (),
2432            0x2007abdf2695c747,
2433            fidl::encoding::DynamicFlags::empty(),
2434            _decode,
2435        )
2436    }
2437
2438    fn r#set_microphone_gain(&self, mut requested: u8) -> Result<(), fidl::Error> {
2439        self.client.send::<HeadsetGainSetMicrophoneGainRequest>(
2440            (requested,),
2441            0x7ddbb4e63caeef8e,
2442            fidl::encoding::DynamicFlags::empty(),
2443        )
2444    }
2445
2446    type WatchMicrophoneGainResponseFut =
2447        fidl::client::QueryResponseFut<u8, fidl::encoding::DefaultFuchsiaResourceDialect>;
2448    fn r#watch_microphone_gain(&self) -> Self::WatchMicrophoneGainResponseFut {
2449        fn _decode(
2450            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2451        ) -> Result<u8, fidl::Error> {
2452            let _response = fidl::client::decode_transaction_body::<
2453                HeadsetGainWatchMicrophoneGainResponse,
2454                fidl::encoding::DefaultFuchsiaResourceDialect,
2455                0x1d171fb432fa55ad,
2456            >(_buf?)?;
2457            Ok(_response.gain)
2458        }
2459        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u8>(
2460            (),
2461            0x1d171fb432fa55ad,
2462            fidl::encoding::DynamicFlags::empty(),
2463            _decode,
2464        )
2465    }
2466}
2467
2468pub struct HeadsetGainEventStream {
2469    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2470}
2471
2472impl std::marker::Unpin for HeadsetGainEventStream {}
2473
2474impl futures::stream::FusedStream for HeadsetGainEventStream {
2475    fn is_terminated(&self) -> bool {
2476        self.event_receiver.is_terminated()
2477    }
2478}
2479
2480impl futures::Stream for HeadsetGainEventStream {
2481    type Item = Result<HeadsetGainEvent, fidl::Error>;
2482
2483    fn poll_next(
2484        mut self: std::pin::Pin<&mut Self>,
2485        cx: &mut std::task::Context<'_>,
2486    ) -> std::task::Poll<Option<Self::Item>> {
2487        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2488            &mut self.event_receiver,
2489            cx
2490        )?) {
2491            Some(buf) => std::task::Poll::Ready(Some(HeadsetGainEvent::decode(buf))),
2492            None => std::task::Poll::Ready(None),
2493        }
2494    }
2495}
2496
2497#[derive(Debug)]
2498pub enum HeadsetGainEvent {}
2499
2500impl HeadsetGainEvent {
2501    /// Decodes a message buffer as a [`HeadsetGainEvent`].
2502    fn decode(
2503        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2504    ) -> Result<HeadsetGainEvent, fidl::Error> {
2505        let (bytes, _handles) = buf.split_mut();
2506        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2507        debug_assert_eq!(tx_header.tx_id, 0);
2508        match tx_header.ordinal {
2509            _ => Err(fidl::Error::UnknownOrdinal {
2510                ordinal: tx_header.ordinal,
2511                protocol_name: <HeadsetGainMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2512            }),
2513        }
2514    }
2515}
2516
2517/// A Stream of incoming requests for fuchsia.bluetooth.hfp/HeadsetGain.
2518pub struct HeadsetGainRequestStream {
2519    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2520    is_terminated: bool,
2521}
2522
2523impl std::marker::Unpin for HeadsetGainRequestStream {}
2524
2525impl futures::stream::FusedStream for HeadsetGainRequestStream {
2526    fn is_terminated(&self) -> bool {
2527        self.is_terminated
2528    }
2529}
2530
2531impl fidl::endpoints::RequestStream for HeadsetGainRequestStream {
2532    type Protocol = HeadsetGainMarker;
2533    type ControlHandle = HeadsetGainControlHandle;
2534
2535    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2536        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2537    }
2538
2539    fn control_handle(&self) -> Self::ControlHandle {
2540        HeadsetGainControlHandle { inner: self.inner.clone() }
2541    }
2542
2543    fn into_inner(
2544        self,
2545    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2546    {
2547        (self.inner, self.is_terminated)
2548    }
2549
2550    fn from_inner(
2551        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2552        is_terminated: bool,
2553    ) -> Self {
2554        Self { inner, is_terminated }
2555    }
2556}
2557
2558impl futures::Stream for HeadsetGainRequestStream {
2559    type Item = Result<HeadsetGainRequest, fidl::Error>;
2560
2561    fn poll_next(
2562        mut self: std::pin::Pin<&mut Self>,
2563        cx: &mut std::task::Context<'_>,
2564    ) -> std::task::Poll<Option<Self::Item>> {
2565        let this = &mut *self;
2566        if this.inner.check_shutdown(cx) {
2567            this.is_terminated = true;
2568            return std::task::Poll::Ready(None);
2569        }
2570        if this.is_terminated {
2571            panic!("polled HeadsetGainRequestStream after completion");
2572        }
2573        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2574            |bytes, handles| {
2575                match this.inner.channel().read_etc(cx, bytes, handles) {
2576                    std::task::Poll::Ready(Ok(())) => {}
2577                    std::task::Poll::Pending => return std::task::Poll::Pending,
2578                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2579                        this.is_terminated = true;
2580                        return std::task::Poll::Ready(None);
2581                    }
2582                    std::task::Poll::Ready(Err(e)) => {
2583                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2584                            e.into(),
2585                        ))))
2586                    }
2587                }
2588
2589                // A message has been received from the channel
2590                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2591
2592                std::task::Poll::Ready(Some(match header.ordinal {
2593                    0x3462191b2a6ae5ce => {
2594                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2595                        let mut req = fidl::new_empty!(
2596                            HeadsetGainSetSpeakerGainRequest,
2597                            fidl::encoding::DefaultFuchsiaResourceDialect
2598                        );
2599                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HeadsetGainSetSpeakerGainRequest>(&header, _body_bytes, handles, &mut req)?;
2600                        let control_handle = HeadsetGainControlHandle { inner: this.inner.clone() };
2601                        Ok(HeadsetGainRequest::SetSpeakerGain {
2602                            requested: req.requested,
2603
2604                            control_handle,
2605                        })
2606                    }
2607                    0x2007abdf2695c747 => {
2608                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2609                        let mut req = fidl::new_empty!(
2610                            fidl::encoding::EmptyPayload,
2611                            fidl::encoding::DefaultFuchsiaResourceDialect
2612                        );
2613                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2614                        let control_handle = HeadsetGainControlHandle { inner: this.inner.clone() };
2615                        Ok(HeadsetGainRequest::WatchSpeakerGain {
2616                            responder: HeadsetGainWatchSpeakerGainResponder {
2617                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2618                                tx_id: header.tx_id,
2619                            },
2620                        })
2621                    }
2622                    0x7ddbb4e63caeef8e => {
2623                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2624                        let mut req = fidl::new_empty!(
2625                            HeadsetGainSetMicrophoneGainRequest,
2626                            fidl::encoding::DefaultFuchsiaResourceDialect
2627                        );
2628                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HeadsetGainSetMicrophoneGainRequest>(&header, _body_bytes, handles, &mut req)?;
2629                        let control_handle = HeadsetGainControlHandle { inner: this.inner.clone() };
2630                        Ok(HeadsetGainRequest::SetMicrophoneGain {
2631                            requested: req.requested,
2632
2633                            control_handle,
2634                        })
2635                    }
2636                    0x1d171fb432fa55ad => {
2637                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2638                        let mut req = fidl::new_empty!(
2639                            fidl::encoding::EmptyPayload,
2640                            fidl::encoding::DefaultFuchsiaResourceDialect
2641                        );
2642                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2643                        let control_handle = HeadsetGainControlHandle { inner: this.inner.clone() };
2644                        Ok(HeadsetGainRequest::WatchMicrophoneGain {
2645                            responder: HeadsetGainWatchMicrophoneGainResponder {
2646                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2647                                tx_id: header.tx_id,
2648                            },
2649                        })
2650                    }
2651                    _ => Err(fidl::Error::UnknownOrdinal {
2652                        ordinal: header.ordinal,
2653                        protocol_name:
2654                            <HeadsetGainMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2655                    }),
2656                }))
2657            },
2658        )
2659    }
2660}
2661
2662/// Control Headset Speaker and Microphone gain and receive reports of current
2663/// values as specified in HFP v1.8, Section 4.29. This protocol is served by the
2664/// Hfp service.
2665///
2666/// Gain is represented as an absolute value on a scale from 0 to 15. 0 is the
2667/// minimum gain and 15 is the maximum gain. It is related to a particular
2668/// (implementation dependent) volume level controlled by the Headset.
2669///
2670///
2671/// Epitaphs:
2672///
2673/// This channel will be closed with a `ZX_ERR_ALREADY_BOUND` epitaph if there
2674/// is already an active `HeadsetGain` channel.
2675///
2676/// This channel will be closed with a `ZX_ERR_NOT_SUPPORTED` epitaph if the Hfp
2677/// service is not configured to support remote volume control or the peer
2678/// headset does not support remote volume control. If the channel is closed
2679/// with this error, the client should not attempt to reopen it using the
2680/// `PeerHandler::GainControl` request on the same PeerHandler connection.
2681///
2682/// This channel will be closed with a `ZX_ERR_INVALID_ARGUMENT` epitaph if
2683/// invalid arguments are passed to requests. See documentation on specific
2684/// requests for more details.
2685#[derive(Debug)]
2686pub enum HeadsetGainRequest {
2687    /// Make a request to the headset to set the speaker gain to `requested`.
2688    ///
2689    /// `requested` must be in the range [0-15] inclusive. Any values outside of
2690    /// this range will result in the channel closing with a
2691    /// `ZX_ERR_INVALID_ARGUMENT` epitaph.
2692    SetSpeakerGain { requested: u8, control_handle: HeadsetGainControlHandle },
2693    /// Hanging get to watch for updates to the headset speaker gain. Responses
2694    /// represent the current gain value that is set.
2695    ///
2696    /// The returned `gain` value will always be in the range [0-15] inclusive.
2697    WatchSpeakerGain { responder: HeadsetGainWatchSpeakerGainResponder },
2698    /// Make a request to the Headset to set the microphone gain to `requested`.
2699    ///
2700    /// `requested` must be in the range [0-15] inclusive. Any values outside of
2701    /// this range will result in the channel closing with a
2702    /// `ZX_ERR_INVALID_ARGUMENT` epitaph.
2703    SetMicrophoneGain { requested: u8, control_handle: HeadsetGainControlHandle },
2704    /// Hanging get to watch for updates to the headset microphone gain. Responses
2705    /// represent the current gain value that is set.
2706    ///
2707    /// The returned `gain` value will always be in the range [0-15] inclusive.
2708    WatchMicrophoneGain { responder: HeadsetGainWatchMicrophoneGainResponder },
2709}
2710
2711impl HeadsetGainRequest {
2712    #[allow(irrefutable_let_patterns)]
2713    pub fn into_set_speaker_gain(self) -> Option<(u8, HeadsetGainControlHandle)> {
2714        if let HeadsetGainRequest::SetSpeakerGain { requested, control_handle } = self {
2715            Some((requested, control_handle))
2716        } else {
2717            None
2718        }
2719    }
2720
2721    #[allow(irrefutable_let_patterns)]
2722    pub fn into_watch_speaker_gain(self) -> Option<(HeadsetGainWatchSpeakerGainResponder)> {
2723        if let HeadsetGainRequest::WatchSpeakerGain { responder } = self {
2724            Some((responder))
2725        } else {
2726            None
2727        }
2728    }
2729
2730    #[allow(irrefutable_let_patterns)]
2731    pub fn into_set_microphone_gain(self) -> Option<(u8, HeadsetGainControlHandle)> {
2732        if let HeadsetGainRequest::SetMicrophoneGain { requested, control_handle } = self {
2733            Some((requested, control_handle))
2734        } else {
2735            None
2736        }
2737    }
2738
2739    #[allow(irrefutable_let_patterns)]
2740    pub fn into_watch_microphone_gain(self) -> Option<(HeadsetGainWatchMicrophoneGainResponder)> {
2741        if let HeadsetGainRequest::WatchMicrophoneGain { responder } = self {
2742            Some((responder))
2743        } else {
2744            None
2745        }
2746    }
2747
2748    /// Name of the method defined in FIDL
2749    pub fn method_name(&self) -> &'static str {
2750        match *self {
2751            HeadsetGainRequest::SetSpeakerGain { .. } => "set_speaker_gain",
2752            HeadsetGainRequest::WatchSpeakerGain { .. } => "watch_speaker_gain",
2753            HeadsetGainRequest::SetMicrophoneGain { .. } => "set_microphone_gain",
2754            HeadsetGainRequest::WatchMicrophoneGain { .. } => "watch_microphone_gain",
2755        }
2756    }
2757}
2758
2759#[derive(Debug, Clone)]
2760pub struct HeadsetGainControlHandle {
2761    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2762}
2763
2764impl fidl::endpoints::ControlHandle for HeadsetGainControlHandle {
2765    fn shutdown(&self) {
2766        self.inner.shutdown()
2767    }
2768    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2769        self.inner.shutdown_with_epitaph(status)
2770    }
2771
2772    fn is_closed(&self) -> bool {
2773        self.inner.channel().is_closed()
2774    }
2775    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2776        self.inner.channel().on_closed()
2777    }
2778
2779    #[cfg(target_os = "fuchsia")]
2780    fn signal_peer(
2781        &self,
2782        clear_mask: zx::Signals,
2783        set_mask: zx::Signals,
2784    ) -> Result<(), zx_status::Status> {
2785        use fidl::Peered;
2786        self.inner.channel().signal_peer(clear_mask, set_mask)
2787    }
2788}
2789
2790impl HeadsetGainControlHandle {}
2791
2792#[must_use = "FIDL methods require a response to be sent"]
2793#[derive(Debug)]
2794pub struct HeadsetGainWatchSpeakerGainResponder {
2795    control_handle: std::mem::ManuallyDrop<HeadsetGainControlHandle>,
2796    tx_id: u32,
2797}
2798
2799/// Set the the channel to be shutdown (see [`HeadsetGainControlHandle::shutdown`])
2800/// if the responder is dropped without sending a response, so that the client
2801/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2802impl std::ops::Drop for HeadsetGainWatchSpeakerGainResponder {
2803    fn drop(&mut self) {
2804        self.control_handle.shutdown();
2805        // Safety: drops once, never accessed again
2806        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2807    }
2808}
2809
2810impl fidl::endpoints::Responder for HeadsetGainWatchSpeakerGainResponder {
2811    type ControlHandle = HeadsetGainControlHandle;
2812
2813    fn control_handle(&self) -> &HeadsetGainControlHandle {
2814        &self.control_handle
2815    }
2816
2817    fn drop_without_shutdown(mut self) {
2818        // Safety: drops once, never accessed again due to mem::forget
2819        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2820        // Prevent Drop from running (which would shut down the channel)
2821        std::mem::forget(self);
2822    }
2823}
2824
2825impl HeadsetGainWatchSpeakerGainResponder {
2826    /// Sends a response to the FIDL transaction.
2827    ///
2828    /// Sets the channel to shutdown if an error occurs.
2829    pub fn send(self, mut gain: u8) -> Result<(), fidl::Error> {
2830        let _result = self.send_raw(gain);
2831        if _result.is_err() {
2832            self.control_handle.shutdown();
2833        }
2834        self.drop_without_shutdown();
2835        _result
2836    }
2837
2838    /// Similar to "send" but does not shutdown the channel if an error occurs.
2839    pub fn send_no_shutdown_on_err(self, mut gain: u8) -> Result<(), fidl::Error> {
2840        let _result = self.send_raw(gain);
2841        self.drop_without_shutdown();
2842        _result
2843    }
2844
2845    fn send_raw(&self, mut gain: u8) -> Result<(), fidl::Error> {
2846        self.control_handle.inner.send::<HeadsetGainWatchSpeakerGainResponse>(
2847            (gain,),
2848            self.tx_id,
2849            0x2007abdf2695c747,
2850            fidl::encoding::DynamicFlags::empty(),
2851        )
2852    }
2853}
2854
2855#[must_use = "FIDL methods require a response to be sent"]
2856#[derive(Debug)]
2857pub struct HeadsetGainWatchMicrophoneGainResponder {
2858    control_handle: std::mem::ManuallyDrop<HeadsetGainControlHandle>,
2859    tx_id: u32,
2860}
2861
2862/// Set the the channel to be shutdown (see [`HeadsetGainControlHandle::shutdown`])
2863/// if the responder is dropped without sending a response, so that the client
2864/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2865impl std::ops::Drop for HeadsetGainWatchMicrophoneGainResponder {
2866    fn drop(&mut self) {
2867        self.control_handle.shutdown();
2868        // Safety: drops once, never accessed again
2869        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2870    }
2871}
2872
2873impl fidl::endpoints::Responder for HeadsetGainWatchMicrophoneGainResponder {
2874    type ControlHandle = HeadsetGainControlHandle;
2875
2876    fn control_handle(&self) -> &HeadsetGainControlHandle {
2877        &self.control_handle
2878    }
2879
2880    fn drop_without_shutdown(mut self) {
2881        // Safety: drops once, never accessed again due to mem::forget
2882        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2883        // Prevent Drop from running (which would shut down the channel)
2884        std::mem::forget(self);
2885    }
2886}
2887
2888impl HeadsetGainWatchMicrophoneGainResponder {
2889    /// Sends a response to the FIDL transaction.
2890    ///
2891    /// Sets the channel to shutdown if an error occurs.
2892    pub fn send(self, mut gain: u8) -> Result<(), fidl::Error> {
2893        let _result = self.send_raw(gain);
2894        if _result.is_err() {
2895            self.control_handle.shutdown();
2896        }
2897        self.drop_without_shutdown();
2898        _result
2899    }
2900
2901    /// Similar to "send" but does not shutdown the channel if an error occurs.
2902    pub fn send_no_shutdown_on_err(self, mut gain: u8) -> Result<(), fidl::Error> {
2903        let _result = self.send_raw(gain);
2904        self.drop_without_shutdown();
2905        _result
2906    }
2907
2908    fn send_raw(&self, mut gain: u8) -> Result<(), fidl::Error> {
2909        self.control_handle.inner.send::<HeadsetGainWatchMicrophoneGainResponse>(
2910            (gain,),
2911            self.tx_id,
2912            0x1d171fb432fa55ad,
2913            fidl::encoding::DynamicFlags::empty(),
2914        )
2915    }
2916}
2917
2918#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2919pub struct HfpMarker;
2920
2921impl fidl::endpoints::ProtocolMarker for HfpMarker {
2922    type Proxy = HfpProxy;
2923    type RequestStream = HfpRequestStream;
2924    #[cfg(target_os = "fuchsia")]
2925    type SynchronousProxy = HfpSynchronousProxy;
2926
2927    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.hfp.Hfp";
2928}
2929impl fidl::endpoints::DiscoverableProtocolMarker for HfpMarker {}
2930
2931pub trait HfpProxyInterface: Send + Sync {
2932    fn r#register(
2933        &self,
2934        manager: fidl::endpoints::ClientEnd<CallManagerMarker>,
2935    ) -> Result<(), fidl::Error>;
2936}
2937#[derive(Debug)]
2938#[cfg(target_os = "fuchsia")]
2939pub struct HfpSynchronousProxy {
2940    client: fidl::client::sync::Client,
2941}
2942
2943#[cfg(target_os = "fuchsia")]
2944impl fidl::endpoints::SynchronousProxy for HfpSynchronousProxy {
2945    type Proxy = HfpProxy;
2946    type Protocol = HfpMarker;
2947
2948    fn from_channel(inner: fidl::Channel) -> Self {
2949        Self::new(inner)
2950    }
2951
2952    fn into_channel(self) -> fidl::Channel {
2953        self.client.into_channel()
2954    }
2955
2956    fn as_channel(&self) -> &fidl::Channel {
2957        self.client.as_channel()
2958    }
2959}
2960
2961#[cfg(target_os = "fuchsia")]
2962impl HfpSynchronousProxy {
2963    pub fn new(channel: fidl::Channel) -> Self {
2964        let protocol_name = <HfpMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2965        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2966    }
2967
2968    pub fn into_channel(self) -> fidl::Channel {
2969        self.client.into_channel()
2970    }
2971
2972    /// Waits until an event arrives and returns it. It is safe for other
2973    /// threads to make concurrent requests while waiting for an event.
2974    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<HfpEvent, fidl::Error> {
2975        HfpEvent::decode(self.client.wait_for_event(deadline)?)
2976    }
2977
2978    /// Register as the call manager for this device.
2979    ///
2980    /// There can only be one call manager registered at a time. If one is
2981    /// registered at the time a call to `Register` is made, the newer
2982    /// CallManager channel will be closed.
2983    ///
2984    /// A call manager can be unregistered by closing either end of the channel.
2985    pub fn r#register(
2986        &self,
2987        mut manager: fidl::endpoints::ClientEnd<CallManagerMarker>,
2988    ) -> Result<(), fidl::Error> {
2989        self.client.send::<HfpRegisterRequest>(
2990            (manager,),
2991            0x1b2ea4f6069181ad,
2992            fidl::encoding::DynamicFlags::empty(),
2993        )
2994    }
2995}
2996
2997#[derive(Debug, Clone)]
2998pub struct HfpProxy {
2999    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3000}
3001
3002impl fidl::endpoints::Proxy for HfpProxy {
3003    type Protocol = HfpMarker;
3004
3005    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3006        Self::new(inner)
3007    }
3008
3009    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3010        self.client.into_channel().map_err(|client| Self { client })
3011    }
3012
3013    fn as_channel(&self) -> &::fidl::AsyncChannel {
3014        self.client.as_channel()
3015    }
3016}
3017
3018impl HfpProxy {
3019    /// Create a new Proxy for fuchsia.bluetooth.hfp/Hfp.
3020    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3021        let protocol_name = <HfpMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3022        Self { client: fidl::client::Client::new(channel, protocol_name) }
3023    }
3024
3025    /// Get a Stream of events from the remote end of the protocol.
3026    ///
3027    /// # Panics
3028    ///
3029    /// Panics if the event stream was already taken.
3030    pub fn take_event_stream(&self) -> HfpEventStream {
3031        HfpEventStream { event_receiver: self.client.take_event_receiver() }
3032    }
3033
3034    /// Register as the call manager for this device.
3035    ///
3036    /// There can only be one call manager registered at a time. If one is
3037    /// registered at the time a call to `Register` is made, the newer
3038    /// CallManager channel will be closed.
3039    ///
3040    /// A call manager can be unregistered by closing either end of the channel.
3041    pub fn r#register(
3042        &self,
3043        mut manager: fidl::endpoints::ClientEnd<CallManagerMarker>,
3044    ) -> Result<(), fidl::Error> {
3045        HfpProxyInterface::r#register(self, manager)
3046    }
3047}
3048
3049impl HfpProxyInterface for HfpProxy {
3050    fn r#register(
3051        &self,
3052        mut manager: fidl::endpoints::ClientEnd<CallManagerMarker>,
3053    ) -> Result<(), fidl::Error> {
3054        self.client.send::<HfpRegisterRequest>(
3055            (manager,),
3056            0x1b2ea4f6069181ad,
3057            fidl::encoding::DynamicFlags::empty(),
3058        )
3059    }
3060}
3061
3062pub struct HfpEventStream {
3063    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3064}
3065
3066impl std::marker::Unpin for HfpEventStream {}
3067
3068impl futures::stream::FusedStream for HfpEventStream {
3069    fn is_terminated(&self) -> bool {
3070        self.event_receiver.is_terminated()
3071    }
3072}
3073
3074impl futures::Stream for HfpEventStream {
3075    type Item = Result<HfpEvent, fidl::Error>;
3076
3077    fn poll_next(
3078        mut self: std::pin::Pin<&mut Self>,
3079        cx: &mut std::task::Context<'_>,
3080    ) -> std::task::Poll<Option<Self::Item>> {
3081        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3082            &mut self.event_receiver,
3083            cx
3084        )?) {
3085            Some(buf) => std::task::Poll::Ready(Some(HfpEvent::decode(buf))),
3086            None => std::task::Poll::Ready(None),
3087        }
3088    }
3089}
3090
3091#[derive(Debug)]
3092pub enum HfpEvent {}
3093
3094impl HfpEvent {
3095    /// Decodes a message buffer as a [`HfpEvent`].
3096    fn decode(
3097        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3098    ) -> Result<HfpEvent, fidl::Error> {
3099        let (bytes, _handles) = buf.split_mut();
3100        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3101        debug_assert_eq!(tx_header.tx_id, 0);
3102        match tx_header.ordinal {
3103            _ => Err(fidl::Error::UnknownOrdinal {
3104                ordinal: tx_header.ordinal,
3105                protocol_name: <HfpMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3106            }),
3107        }
3108    }
3109}
3110
3111/// A Stream of incoming requests for fuchsia.bluetooth.hfp/Hfp.
3112pub struct HfpRequestStream {
3113    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3114    is_terminated: bool,
3115}
3116
3117impl std::marker::Unpin for HfpRequestStream {}
3118
3119impl futures::stream::FusedStream for HfpRequestStream {
3120    fn is_terminated(&self) -> bool {
3121        self.is_terminated
3122    }
3123}
3124
3125impl fidl::endpoints::RequestStream for HfpRequestStream {
3126    type Protocol = HfpMarker;
3127    type ControlHandle = HfpControlHandle;
3128
3129    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3130        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3131    }
3132
3133    fn control_handle(&self) -> Self::ControlHandle {
3134        HfpControlHandle { inner: self.inner.clone() }
3135    }
3136
3137    fn into_inner(
3138        self,
3139    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3140    {
3141        (self.inner, self.is_terminated)
3142    }
3143
3144    fn from_inner(
3145        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3146        is_terminated: bool,
3147    ) -> Self {
3148        Self { inner, is_terminated }
3149    }
3150}
3151
3152impl futures::Stream for HfpRequestStream {
3153    type Item = Result<HfpRequest, fidl::Error>;
3154
3155    fn poll_next(
3156        mut self: std::pin::Pin<&mut Self>,
3157        cx: &mut std::task::Context<'_>,
3158    ) -> std::task::Poll<Option<Self::Item>> {
3159        let this = &mut *self;
3160        if this.inner.check_shutdown(cx) {
3161            this.is_terminated = true;
3162            return std::task::Poll::Ready(None);
3163        }
3164        if this.is_terminated {
3165            panic!("polled HfpRequestStream after completion");
3166        }
3167        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3168            |bytes, handles| {
3169                match this.inner.channel().read_etc(cx, bytes, handles) {
3170                    std::task::Poll::Ready(Ok(())) => {}
3171                    std::task::Poll::Pending => return std::task::Poll::Pending,
3172                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3173                        this.is_terminated = true;
3174                        return std::task::Poll::Ready(None);
3175                    }
3176                    std::task::Poll::Ready(Err(e)) => {
3177                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3178                            e.into(),
3179                        ))))
3180                    }
3181                }
3182
3183                // A message has been received from the channel
3184                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3185
3186                std::task::Poll::Ready(Some(match header.ordinal {
3187                    0x1b2ea4f6069181ad => {
3188                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3189                        let mut req = fidl::new_empty!(
3190                            HfpRegisterRequest,
3191                            fidl::encoding::DefaultFuchsiaResourceDialect
3192                        );
3193                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HfpRegisterRequest>(&header, _body_bytes, handles, &mut req)?;
3194                        let control_handle = HfpControlHandle { inner: this.inner.clone() };
3195                        Ok(HfpRequest::Register { manager: req.manager, control_handle })
3196                    }
3197                    _ => Err(fidl::Error::UnknownOrdinal {
3198                        ordinal: header.ordinal,
3199                        protocol_name: <HfpMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3200                    }),
3201                }))
3202            },
3203        )
3204    }
3205}
3206
3207#[derive(Debug)]
3208pub enum HfpRequest {
3209    /// Register as the call manager for this device.
3210    ///
3211    /// There can only be one call manager registered at a time. If one is
3212    /// registered at the time a call to `Register` is made, the newer
3213    /// CallManager channel will be closed.
3214    ///
3215    /// A call manager can be unregistered by closing either end of the channel.
3216    Register {
3217        manager: fidl::endpoints::ClientEnd<CallManagerMarker>,
3218        control_handle: HfpControlHandle,
3219    },
3220}
3221
3222impl HfpRequest {
3223    #[allow(irrefutable_let_patterns)]
3224    pub fn into_register(
3225        self,
3226    ) -> Option<(fidl::endpoints::ClientEnd<CallManagerMarker>, HfpControlHandle)> {
3227        if let HfpRequest::Register { manager, control_handle } = self {
3228            Some((manager, control_handle))
3229        } else {
3230            None
3231        }
3232    }
3233
3234    /// Name of the method defined in FIDL
3235    pub fn method_name(&self) -> &'static str {
3236        match *self {
3237            HfpRequest::Register { .. } => "register",
3238        }
3239    }
3240}
3241
3242#[derive(Debug, Clone)]
3243pub struct HfpControlHandle {
3244    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3245}
3246
3247impl fidl::endpoints::ControlHandle for HfpControlHandle {
3248    fn shutdown(&self) {
3249        self.inner.shutdown()
3250    }
3251    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3252        self.inner.shutdown_with_epitaph(status)
3253    }
3254
3255    fn is_closed(&self) -> bool {
3256        self.inner.channel().is_closed()
3257    }
3258    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3259        self.inner.channel().on_closed()
3260    }
3261
3262    #[cfg(target_os = "fuchsia")]
3263    fn signal_peer(
3264        &self,
3265        clear_mask: zx::Signals,
3266        set_mask: zx::Signals,
3267    ) -> Result<(), zx_status::Status> {
3268        use fidl::Peered;
3269        self.inner.channel().signal_peer(clear_mask, set_mask)
3270    }
3271}
3272
3273impl HfpControlHandle {}
3274
3275#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3276pub struct PeerHandlerMarker;
3277
3278impl fidl::endpoints::ProtocolMarker for PeerHandlerMarker {
3279    type Proxy = PeerHandlerProxy;
3280    type RequestStream = PeerHandlerRequestStream;
3281    #[cfg(target_os = "fuchsia")]
3282    type SynchronousProxy = PeerHandlerSynchronousProxy;
3283
3284    const DEBUG_NAME: &'static str = "(anonymous) PeerHandler";
3285}
3286pub type PeerHandlerRequestOutgoingCallResult = Result<(), i32>;
3287pub type PeerHandlerSetNrecModeResult = Result<(), i32>;
3288
3289pub trait PeerHandlerProxyInterface: Send + Sync {
3290    type WatchNetworkInformationResponseFut: std::future::Future<Output = Result<NetworkInformation, fidl::Error>>
3291        + Send;
3292    fn r#watch_network_information(&self) -> Self::WatchNetworkInformationResponseFut;
3293    type WatchNextCallResponseFut: std::future::Future<Output = Result<NextCall, fidl::Error>>
3294        + Send;
3295    fn r#watch_next_call(&self) -> Self::WatchNextCallResponseFut;
3296    type RequestOutgoingCallResponseFut: std::future::Future<Output = Result<PeerHandlerRequestOutgoingCallResult, fidl::Error>>
3297        + Send;
3298    fn r#request_outgoing_call(&self, action: &CallAction) -> Self::RequestOutgoingCallResponseFut;
3299    type QueryOperatorResponseFut: std::future::Future<Output = Result<Option<String>, fidl::Error>>
3300        + Send;
3301    fn r#query_operator(&self) -> Self::QueryOperatorResponseFut;
3302    type SubscriberNumberInformationResponseFut: std::future::Future<Output = Result<Vec<String>, fidl::Error>>
3303        + Send;
3304    fn r#subscriber_number_information(&self) -> Self::SubscriberNumberInformationResponseFut;
3305    type SetNrecModeResponseFut: std::future::Future<Output = Result<PeerHandlerSetNrecModeResult, fidl::Error>>
3306        + Send;
3307    fn r#set_nrec_mode(&self, enabled: bool) -> Self::SetNrecModeResponseFut;
3308    fn r#report_headset_battery_level(&self, level: u8) -> Result<(), fidl::Error>;
3309    fn r#gain_control(
3310        &self,
3311        control: fidl::endpoints::ClientEnd<HeadsetGainMarker>,
3312    ) -> Result<(), fidl::Error>;
3313}
3314#[derive(Debug)]
3315#[cfg(target_os = "fuchsia")]
3316pub struct PeerHandlerSynchronousProxy {
3317    client: fidl::client::sync::Client,
3318}
3319
3320#[cfg(target_os = "fuchsia")]
3321impl fidl::endpoints::SynchronousProxy for PeerHandlerSynchronousProxy {
3322    type Proxy = PeerHandlerProxy;
3323    type Protocol = PeerHandlerMarker;
3324
3325    fn from_channel(inner: fidl::Channel) -> Self {
3326        Self::new(inner)
3327    }
3328
3329    fn into_channel(self) -> fidl::Channel {
3330        self.client.into_channel()
3331    }
3332
3333    fn as_channel(&self) -> &fidl::Channel {
3334        self.client.as_channel()
3335    }
3336}
3337
3338#[cfg(target_os = "fuchsia")]
3339impl PeerHandlerSynchronousProxy {
3340    pub fn new(channel: fidl::Channel) -> Self {
3341        let protocol_name = <PeerHandlerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3342        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3343    }
3344
3345    pub fn into_channel(self) -> fidl::Channel {
3346        self.client.into_channel()
3347    }
3348
3349    /// Waits until an event arrives and returns it. It is safe for other
3350    /// threads to make concurrent requests while waiting for an event.
3351    pub fn wait_for_event(
3352        &self,
3353        deadline: zx::MonotonicInstant,
3354    ) -> Result<PeerHandlerEvent, fidl::Error> {
3355        PeerHandlerEvent::decode(self.client.wait_for_event(deadline)?)
3356    }
3357
3358    /// Hanging get to provide the Hfp service with an `update` on the
3359    /// `NetworkInformation`. Any fields in `update` that are not present will
3360    /// be treated as unmodified by the update.
3361    ///
3362    /// The call manager or audio gateway peer _should_ provide a fully
3363    /// populated `update` when it is called for the first time.
3364    ///
3365    /// The most up-to-date `NetworkInformation` is used during the connection
3366    /// initialization process of the peer, and updates are propagated to the
3367    /// peer if it supports AG Indicators.
3368    pub fn r#watch_network_information(
3369        &self,
3370        ___deadline: zx::MonotonicInstant,
3371    ) -> Result<NetworkInformation, fidl::Error> {
3372        let _response = self
3373            .client
3374            .send_query::<fidl::encoding::EmptyPayload, PeerHandlerWatchNetworkInformationResponse>(
3375                (),
3376                0x1c9eba597076b7cb,
3377                fidl::encoding::DynamicFlags::empty(),
3378                ___deadline,
3379            )?;
3380        Ok(_response.update)
3381    }
3382
3383    /// Hanging get which returns when a new call is initiated by the call
3384    /// manager or audio gateway peer, or an ongoing call is transferred to the
3385    /// headset.  `RequestOutgoingCall` can be called before or after
3386    /// `WatchNextCall`.
3387    pub fn r#watch_next_call(
3388        &self,
3389        ___deadline: zx::MonotonicInstant,
3390    ) -> Result<NextCall, fidl::Error> {
3391        let _response = self
3392            .client
3393            .send_query::<fidl::encoding::EmptyPayload, PeerHandlerWatchNextCallResponse>(
3394                (),
3395                0x5e3b7b4e7c3d359,
3396                fidl::encoding::DynamicFlags::empty(),
3397                ___deadline,
3398            )?;
3399        Ok(_response.call)
3400    }
3401
3402    /// Used to request an outgoing call be initiated by the call manager or
3403    /// audio gateway peer.  `RequestOutgoingCall` shall complete after the
3404    /// outgoing call has been initiated and the corresponding `Call` protocol
3405    /// has been returned via a `WatchNextCall` result.
3406    ///
3407    /// An error is returned if the call could not be placed as requested.
3408    ///
3409    /// - ZX_ERR_NOT_SUPPORTED can be used if the system does not support the
3410    ///   requested action.
3411    ///
3412    /// - ZX_ERR_ALREADY_EXISTS can be used if there is alreadya call in
3413    ///   progress and the system does not support additional calls.
3414    pub fn r#request_outgoing_call(
3415        &self,
3416        mut action: &CallAction,
3417        ___deadline: zx::MonotonicInstant,
3418    ) -> Result<PeerHandlerRequestOutgoingCallResult, fidl::Error> {
3419        let _response = self.client.send_query::<
3420            PeerHandlerRequestOutgoingCallRequest,
3421            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3422        >(
3423            (action,),
3424            0x1a2637c743c89ad,
3425            fidl::encoding::DynamicFlags::empty(),
3426            ___deadline,
3427        )?;
3428        Ok(_response.map(|x| x))
3429    }
3430
3431    /// Request the name of the network operator for the call manager or audio
3432    /// gateway peer. A null value is returned if there is no operator name
3433    /// available.
3434    pub fn r#query_operator(
3435        &self,
3436        ___deadline: zx::MonotonicInstant,
3437    ) -> Result<Option<String>, fidl::Error> {
3438        let _response = self
3439            .client
3440            .send_query::<fidl::encoding::EmptyPayload, PeerHandlerQueryOperatorResponse>(
3441                (),
3442                0x1217eaf5db4c3300,
3443                fidl::encoding::DynamicFlags::empty(),
3444                ___deadline,
3445            )?;
3446        Ok(_response.operator)
3447    }
3448
3449    /// Request subscriber numbers from the call manager or audio gateway peer.
3450    /// There can be zero or more numbers returned. Sending more than 128
3451    /// numbers is not supported at this time.
3452    pub fn r#subscriber_number_information(
3453        &self,
3454        ___deadline: zx::MonotonicInstant,
3455    ) -> Result<Vec<String>, fidl::Error> {
3456        let _response = self.client.send_query::<
3457            fidl::encoding::EmptyPayload,
3458            PeerHandlerSubscriberNumberInformationResponse,
3459        >(
3460            (),
3461            0x15f5235855b02a3a,
3462            fidl::encoding::DynamicFlags::empty(),
3463            ___deadline,
3464        )?;
3465        Ok(_response.numbers)
3466    }
3467
3468    /// Request by the HF to enable or disable the Noise Reduction/Echo Cancellation
3469    /// functionality on the AG based on the `enabled` boolean.
3470    /// A `ZX_ERR_NOT_SUPPORTED` error is returned if Noice Reduction/Echo
3471    /// Cancellation is not supported by the device.
3472    pub fn r#set_nrec_mode(
3473        &self,
3474        mut enabled: bool,
3475        ___deadline: zx::MonotonicInstant,
3476    ) -> Result<PeerHandlerSetNrecModeResult, fidl::Error> {
3477        let _response = self.client.send_query::<
3478            PeerHandlerSetNrecModeRequest,
3479            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3480        >(
3481            (enabled,),
3482            0x2f8890d0f866672f,
3483            fidl::encoding::DynamicFlags::empty(),
3484            ___deadline,
3485        )?;
3486        Ok(_response.map(|x| x))
3487    }
3488
3489    /// Headset battery level from 0 ~ 100
3490    /// See https://www.bluetooth.com/specifications/assigned-numbers/hands-free-profile/
3491    pub fn r#report_headset_battery_level(&self, mut level: u8) -> Result<(), fidl::Error> {
3492        self.client.send::<PeerHandlerReportHeadsetBatteryLevelRequest>(
3493            (level,),
3494            0x4e3e8be4680d85b,
3495            fidl::encoding::DynamicFlags::empty(),
3496        )
3497    }
3498
3499    /// Tear off protocol for Headset Gain.
3500    ///
3501    /// Only one HeadsetGain protocol can be active for a PeerHandler protocol
3502    /// at any given time. Older HeadsetGain protocols are given preference. If
3503    /// a HeadsetGain protocol is active when a new GainControl request is made,
3504    /// the new HeadsetGain protocol will be closed immediately.
3505    pub fn r#gain_control(
3506        &self,
3507        mut control: fidl::endpoints::ClientEnd<HeadsetGainMarker>,
3508    ) -> Result<(), fidl::Error> {
3509        self.client.send::<PeerHandlerGainControlRequest>(
3510            (control,),
3511            0x6e043b6d2e0fb917,
3512            fidl::encoding::DynamicFlags::empty(),
3513        )
3514    }
3515}
3516
3517#[derive(Debug, Clone)]
3518pub struct PeerHandlerProxy {
3519    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3520}
3521
3522impl fidl::endpoints::Proxy for PeerHandlerProxy {
3523    type Protocol = PeerHandlerMarker;
3524
3525    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3526        Self::new(inner)
3527    }
3528
3529    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3530        self.client.into_channel().map_err(|client| Self { client })
3531    }
3532
3533    fn as_channel(&self) -> &::fidl::AsyncChannel {
3534        self.client.as_channel()
3535    }
3536}
3537
3538impl PeerHandlerProxy {
3539    /// Create a new Proxy for fuchsia.bluetooth.hfp/PeerHandler.
3540    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3541        let protocol_name = <PeerHandlerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3542        Self { client: fidl::client::Client::new(channel, protocol_name) }
3543    }
3544
3545    /// Get a Stream of events from the remote end of the protocol.
3546    ///
3547    /// # Panics
3548    ///
3549    /// Panics if the event stream was already taken.
3550    pub fn take_event_stream(&self) -> PeerHandlerEventStream {
3551        PeerHandlerEventStream { event_receiver: self.client.take_event_receiver() }
3552    }
3553
3554    /// Hanging get to provide the Hfp service with an `update` on the
3555    /// `NetworkInformation`. Any fields in `update` that are not present will
3556    /// be treated as unmodified by the update.
3557    ///
3558    /// The call manager or audio gateway peer _should_ provide a fully
3559    /// populated `update` when it is called for the first time.
3560    ///
3561    /// The most up-to-date `NetworkInformation` is used during the connection
3562    /// initialization process of the peer, and updates are propagated to the
3563    /// peer if it supports AG Indicators.
3564    pub fn r#watch_network_information(
3565        &self,
3566    ) -> fidl::client::QueryResponseFut<
3567        NetworkInformation,
3568        fidl::encoding::DefaultFuchsiaResourceDialect,
3569    > {
3570        PeerHandlerProxyInterface::r#watch_network_information(self)
3571    }
3572
3573    /// Hanging get which returns when a new call is initiated by the call
3574    /// manager or audio gateway peer, or an ongoing call is transferred to the
3575    /// headset.  `RequestOutgoingCall` can be called before or after
3576    /// `WatchNextCall`.
3577    pub fn r#watch_next_call(
3578        &self,
3579    ) -> fidl::client::QueryResponseFut<NextCall, fidl::encoding::DefaultFuchsiaResourceDialect>
3580    {
3581        PeerHandlerProxyInterface::r#watch_next_call(self)
3582    }
3583
3584    /// Used to request an outgoing call be initiated by the call manager or
3585    /// audio gateway peer.  `RequestOutgoingCall` shall complete after the
3586    /// outgoing call has been initiated and the corresponding `Call` protocol
3587    /// has been returned via a `WatchNextCall` result.
3588    ///
3589    /// An error is returned if the call could not be placed as requested.
3590    ///
3591    /// - ZX_ERR_NOT_SUPPORTED can be used if the system does not support the
3592    ///   requested action.
3593    ///
3594    /// - ZX_ERR_ALREADY_EXISTS can be used if there is alreadya call in
3595    ///   progress and the system does not support additional calls.
3596    pub fn r#request_outgoing_call(
3597        &self,
3598        mut action: &CallAction,
3599    ) -> fidl::client::QueryResponseFut<
3600        PeerHandlerRequestOutgoingCallResult,
3601        fidl::encoding::DefaultFuchsiaResourceDialect,
3602    > {
3603        PeerHandlerProxyInterface::r#request_outgoing_call(self, action)
3604    }
3605
3606    /// Request the name of the network operator for the call manager or audio
3607    /// gateway peer. A null value is returned if there is no operator name
3608    /// available.
3609    pub fn r#query_operator(
3610        &self,
3611    ) -> fidl::client::QueryResponseFut<Option<String>, fidl::encoding::DefaultFuchsiaResourceDialect>
3612    {
3613        PeerHandlerProxyInterface::r#query_operator(self)
3614    }
3615
3616    /// Request subscriber numbers from the call manager or audio gateway peer.
3617    /// There can be zero or more numbers returned. Sending more than 128
3618    /// numbers is not supported at this time.
3619    pub fn r#subscriber_number_information(
3620        &self,
3621    ) -> fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>
3622    {
3623        PeerHandlerProxyInterface::r#subscriber_number_information(self)
3624    }
3625
3626    /// Request by the HF to enable or disable the Noise Reduction/Echo Cancellation
3627    /// functionality on the AG based on the `enabled` boolean.
3628    /// A `ZX_ERR_NOT_SUPPORTED` error is returned if Noice Reduction/Echo
3629    /// Cancellation is not supported by the device.
3630    pub fn r#set_nrec_mode(
3631        &self,
3632        mut enabled: bool,
3633    ) -> fidl::client::QueryResponseFut<
3634        PeerHandlerSetNrecModeResult,
3635        fidl::encoding::DefaultFuchsiaResourceDialect,
3636    > {
3637        PeerHandlerProxyInterface::r#set_nrec_mode(self, enabled)
3638    }
3639
3640    /// Headset battery level from 0 ~ 100
3641    /// See https://www.bluetooth.com/specifications/assigned-numbers/hands-free-profile/
3642    pub fn r#report_headset_battery_level(&self, mut level: u8) -> Result<(), fidl::Error> {
3643        PeerHandlerProxyInterface::r#report_headset_battery_level(self, level)
3644    }
3645
3646    /// Tear off protocol for Headset Gain.
3647    ///
3648    /// Only one HeadsetGain protocol can be active for a PeerHandler protocol
3649    /// at any given time. Older HeadsetGain protocols are given preference. If
3650    /// a HeadsetGain protocol is active when a new GainControl request is made,
3651    /// the new HeadsetGain protocol will be closed immediately.
3652    pub fn r#gain_control(
3653        &self,
3654        mut control: fidl::endpoints::ClientEnd<HeadsetGainMarker>,
3655    ) -> Result<(), fidl::Error> {
3656        PeerHandlerProxyInterface::r#gain_control(self, control)
3657    }
3658}
3659
3660impl PeerHandlerProxyInterface for PeerHandlerProxy {
3661    type WatchNetworkInformationResponseFut = fidl::client::QueryResponseFut<
3662        NetworkInformation,
3663        fidl::encoding::DefaultFuchsiaResourceDialect,
3664    >;
3665    fn r#watch_network_information(&self) -> Self::WatchNetworkInformationResponseFut {
3666        fn _decode(
3667            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3668        ) -> Result<NetworkInformation, fidl::Error> {
3669            let _response = fidl::client::decode_transaction_body::<
3670                PeerHandlerWatchNetworkInformationResponse,
3671                fidl::encoding::DefaultFuchsiaResourceDialect,
3672                0x1c9eba597076b7cb,
3673            >(_buf?)?;
3674            Ok(_response.update)
3675        }
3676        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NetworkInformation>(
3677            (),
3678            0x1c9eba597076b7cb,
3679            fidl::encoding::DynamicFlags::empty(),
3680            _decode,
3681        )
3682    }
3683
3684    type WatchNextCallResponseFut =
3685        fidl::client::QueryResponseFut<NextCall, fidl::encoding::DefaultFuchsiaResourceDialect>;
3686    fn r#watch_next_call(&self) -> Self::WatchNextCallResponseFut {
3687        fn _decode(
3688            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3689        ) -> Result<NextCall, fidl::Error> {
3690            let _response = fidl::client::decode_transaction_body::<
3691                PeerHandlerWatchNextCallResponse,
3692                fidl::encoding::DefaultFuchsiaResourceDialect,
3693                0x5e3b7b4e7c3d359,
3694            >(_buf?)?;
3695            Ok(_response.call)
3696        }
3697        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NextCall>(
3698            (),
3699            0x5e3b7b4e7c3d359,
3700            fidl::encoding::DynamicFlags::empty(),
3701            _decode,
3702        )
3703    }
3704
3705    type RequestOutgoingCallResponseFut = fidl::client::QueryResponseFut<
3706        PeerHandlerRequestOutgoingCallResult,
3707        fidl::encoding::DefaultFuchsiaResourceDialect,
3708    >;
3709    fn r#request_outgoing_call(
3710        &self,
3711        mut action: &CallAction,
3712    ) -> Self::RequestOutgoingCallResponseFut {
3713        fn _decode(
3714            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3715        ) -> Result<PeerHandlerRequestOutgoingCallResult, fidl::Error> {
3716            let _response = fidl::client::decode_transaction_body::<
3717                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3718                fidl::encoding::DefaultFuchsiaResourceDialect,
3719                0x1a2637c743c89ad,
3720            >(_buf?)?;
3721            Ok(_response.map(|x| x))
3722        }
3723        self.client.send_query_and_decode::<
3724            PeerHandlerRequestOutgoingCallRequest,
3725            PeerHandlerRequestOutgoingCallResult,
3726        >(
3727            (action,),
3728            0x1a2637c743c89ad,
3729            fidl::encoding::DynamicFlags::empty(),
3730            _decode,
3731        )
3732    }
3733
3734    type QueryOperatorResponseFut = fidl::client::QueryResponseFut<
3735        Option<String>,
3736        fidl::encoding::DefaultFuchsiaResourceDialect,
3737    >;
3738    fn r#query_operator(&self) -> Self::QueryOperatorResponseFut {
3739        fn _decode(
3740            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3741        ) -> Result<Option<String>, fidl::Error> {
3742            let _response = fidl::client::decode_transaction_body::<
3743                PeerHandlerQueryOperatorResponse,
3744                fidl::encoding::DefaultFuchsiaResourceDialect,
3745                0x1217eaf5db4c3300,
3746            >(_buf?)?;
3747            Ok(_response.operator)
3748        }
3749        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Option<String>>(
3750            (),
3751            0x1217eaf5db4c3300,
3752            fidl::encoding::DynamicFlags::empty(),
3753            _decode,
3754        )
3755    }
3756
3757    type SubscriberNumberInformationResponseFut =
3758        fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>;
3759    fn r#subscriber_number_information(&self) -> Self::SubscriberNumberInformationResponseFut {
3760        fn _decode(
3761            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3762        ) -> Result<Vec<String>, fidl::Error> {
3763            let _response = fidl::client::decode_transaction_body::<
3764                PeerHandlerSubscriberNumberInformationResponse,
3765                fidl::encoding::DefaultFuchsiaResourceDialect,
3766                0x15f5235855b02a3a,
3767            >(_buf?)?;
3768            Ok(_response.numbers)
3769        }
3770        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<String>>(
3771            (),
3772            0x15f5235855b02a3a,
3773            fidl::encoding::DynamicFlags::empty(),
3774            _decode,
3775        )
3776    }
3777
3778    type SetNrecModeResponseFut = fidl::client::QueryResponseFut<
3779        PeerHandlerSetNrecModeResult,
3780        fidl::encoding::DefaultFuchsiaResourceDialect,
3781    >;
3782    fn r#set_nrec_mode(&self, mut enabled: bool) -> Self::SetNrecModeResponseFut {
3783        fn _decode(
3784            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3785        ) -> Result<PeerHandlerSetNrecModeResult, fidl::Error> {
3786            let _response = fidl::client::decode_transaction_body::<
3787                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3788                fidl::encoding::DefaultFuchsiaResourceDialect,
3789                0x2f8890d0f866672f,
3790            >(_buf?)?;
3791            Ok(_response.map(|x| x))
3792        }
3793        self.client
3794            .send_query_and_decode::<PeerHandlerSetNrecModeRequest, PeerHandlerSetNrecModeResult>(
3795                (enabled,),
3796                0x2f8890d0f866672f,
3797                fidl::encoding::DynamicFlags::empty(),
3798                _decode,
3799            )
3800    }
3801
3802    fn r#report_headset_battery_level(&self, mut level: u8) -> Result<(), fidl::Error> {
3803        self.client.send::<PeerHandlerReportHeadsetBatteryLevelRequest>(
3804            (level,),
3805            0x4e3e8be4680d85b,
3806            fidl::encoding::DynamicFlags::empty(),
3807        )
3808    }
3809
3810    fn r#gain_control(
3811        &self,
3812        mut control: fidl::endpoints::ClientEnd<HeadsetGainMarker>,
3813    ) -> Result<(), fidl::Error> {
3814        self.client.send::<PeerHandlerGainControlRequest>(
3815            (control,),
3816            0x6e043b6d2e0fb917,
3817            fidl::encoding::DynamicFlags::empty(),
3818        )
3819    }
3820}
3821
3822pub struct PeerHandlerEventStream {
3823    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3824}
3825
3826impl std::marker::Unpin for PeerHandlerEventStream {}
3827
3828impl futures::stream::FusedStream for PeerHandlerEventStream {
3829    fn is_terminated(&self) -> bool {
3830        self.event_receiver.is_terminated()
3831    }
3832}
3833
3834impl futures::Stream for PeerHandlerEventStream {
3835    type Item = Result<PeerHandlerEvent, fidl::Error>;
3836
3837    fn poll_next(
3838        mut self: std::pin::Pin<&mut Self>,
3839        cx: &mut std::task::Context<'_>,
3840    ) -> std::task::Poll<Option<Self::Item>> {
3841        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3842            &mut self.event_receiver,
3843            cx
3844        )?) {
3845            Some(buf) => std::task::Poll::Ready(Some(PeerHandlerEvent::decode(buf))),
3846            None => std::task::Poll::Ready(None),
3847        }
3848    }
3849}
3850
3851#[derive(Debug)]
3852pub enum PeerHandlerEvent {}
3853
3854impl PeerHandlerEvent {
3855    /// Decodes a message buffer as a [`PeerHandlerEvent`].
3856    fn decode(
3857        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3858    ) -> Result<PeerHandlerEvent, fidl::Error> {
3859        let (bytes, _handles) = buf.split_mut();
3860        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3861        debug_assert_eq!(tx_header.tx_id, 0);
3862        match tx_header.ordinal {
3863            _ => Err(fidl::Error::UnknownOrdinal {
3864                ordinal: tx_header.ordinal,
3865                protocol_name: <PeerHandlerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3866            }),
3867        }
3868    }
3869}
3870
3871/// A Stream of incoming requests for fuchsia.bluetooth.hfp/PeerHandler.
3872pub struct PeerHandlerRequestStream {
3873    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3874    is_terminated: bool,
3875}
3876
3877impl std::marker::Unpin for PeerHandlerRequestStream {}
3878
3879impl futures::stream::FusedStream for PeerHandlerRequestStream {
3880    fn is_terminated(&self) -> bool {
3881        self.is_terminated
3882    }
3883}
3884
3885impl fidl::endpoints::RequestStream for PeerHandlerRequestStream {
3886    type Protocol = PeerHandlerMarker;
3887    type ControlHandle = PeerHandlerControlHandle;
3888
3889    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3890        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3891    }
3892
3893    fn control_handle(&self) -> Self::ControlHandle {
3894        PeerHandlerControlHandle { inner: self.inner.clone() }
3895    }
3896
3897    fn into_inner(
3898        self,
3899    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3900    {
3901        (self.inner, self.is_terminated)
3902    }
3903
3904    fn from_inner(
3905        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3906        is_terminated: bool,
3907    ) -> Self {
3908        Self { inner, is_terminated }
3909    }
3910}
3911
3912impl futures::Stream for PeerHandlerRequestStream {
3913    type Item = Result<PeerHandlerRequest, fidl::Error>;
3914
3915    fn poll_next(
3916        mut self: std::pin::Pin<&mut Self>,
3917        cx: &mut std::task::Context<'_>,
3918    ) -> std::task::Poll<Option<Self::Item>> {
3919        let this = &mut *self;
3920        if this.inner.check_shutdown(cx) {
3921            this.is_terminated = true;
3922            return std::task::Poll::Ready(None);
3923        }
3924        if this.is_terminated {
3925            panic!("polled PeerHandlerRequestStream after completion");
3926        }
3927        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3928            |bytes, handles| {
3929                match this.inner.channel().read_etc(cx, bytes, handles) {
3930                    std::task::Poll::Ready(Ok(())) => {}
3931                    std::task::Poll::Pending => return std::task::Poll::Pending,
3932                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3933                        this.is_terminated = true;
3934                        return std::task::Poll::Ready(None);
3935                    }
3936                    std::task::Poll::Ready(Err(e)) => {
3937                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3938                            e.into(),
3939                        ))))
3940                    }
3941                }
3942
3943                // A message has been received from the channel
3944                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3945
3946                std::task::Poll::Ready(Some(match header.ordinal {
3947                    0x1c9eba597076b7cb => {
3948                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3949                        let mut req = fidl::new_empty!(
3950                            fidl::encoding::EmptyPayload,
3951                            fidl::encoding::DefaultFuchsiaResourceDialect
3952                        );
3953                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3954                        let control_handle = PeerHandlerControlHandle { inner: this.inner.clone() };
3955                        Ok(PeerHandlerRequest::WatchNetworkInformation {
3956                            responder: PeerHandlerWatchNetworkInformationResponder {
3957                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3958                                tx_id: header.tx_id,
3959                            },
3960                        })
3961                    }
3962                    0x5e3b7b4e7c3d359 => {
3963                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3964                        let mut req = fidl::new_empty!(
3965                            fidl::encoding::EmptyPayload,
3966                            fidl::encoding::DefaultFuchsiaResourceDialect
3967                        );
3968                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3969                        let control_handle = PeerHandlerControlHandle { inner: this.inner.clone() };
3970                        Ok(PeerHandlerRequest::WatchNextCall {
3971                            responder: PeerHandlerWatchNextCallResponder {
3972                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3973                                tx_id: header.tx_id,
3974                            },
3975                        })
3976                    }
3977                    0x1a2637c743c89ad => {
3978                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3979                        let mut req = fidl::new_empty!(
3980                            PeerHandlerRequestOutgoingCallRequest,
3981                            fidl::encoding::DefaultFuchsiaResourceDialect
3982                        );
3983                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerHandlerRequestOutgoingCallRequest>(&header, _body_bytes, handles, &mut req)?;
3984                        let control_handle = PeerHandlerControlHandle { inner: this.inner.clone() };
3985                        Ok(PeerHandlerRequest::RequestOutgoingCall {
3986                            action: req.action,
3987
3988                            responder: PeerHandlerRequestOutgoingCallResponder {
3989                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3990                                tx_id: header.tx_id,
3991                            },
3992                        })
3993                    }
3994                    0x1217eaf5db4c3300 => {
3995                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3996                        let mut req = fidl::new_empty!(
3997                            fidl::encoding::EmptyPayload,
3998                            fidl::encoding::DefaultFuchsiaResourceDialect
3999                        );
4000                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4001                        let control_handle = PeerHandlerControlHandle { inner: this.inner.clone() };
4002                        Ok(PeerHandlerRequest::QueryOperator {
4003                            responder: PeerHandlerQueryOperatorResponder {
4004                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4005                                tx_id: header.tx_id,
4006                            },
4007                        })
4008                    }
4009                    0x15f5235855b02a3a => {
4010                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4011                        let mut req = fidl::new_empty!(
4012                            fidl::encoding::EmptyPayload,
4013                            fidl::encoding::DefaultFuchsiaResourceDialect
4014                        );
4015                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4016                        let control_handle = PeerHandlerControlHandle { inner: this.inner.clone() };
4017                        Ok(PeerHandlerRequest::SubscriberNumberInformation {
4018                            responder: PeerHandlerSubscriberNumberInformationResponder {
4019                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4020                                tx_id: header.tx_id,
4021                            },
4022                        })
4023                    }
4024                    0x2f8890d0f866672f => {
4025                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4026                        let mut req = fidl::new_empty!(
4027                            PeerHandlerSetNrecModeRequest,
4028                            fidl::encoding::DefaultFuchsiaResourceDialect
4029                        );
4030                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerHandlerSetNrecModeRequest>(&header, _body_bytes, handles, &mut req)?;
4031                        let control_handle = PeerHandlerControlHandle { inner: this.inner.clone() };
4032                        Ok(PeerHandlerRequest::SetNrecMode {
4033                            enabled: req.enabled,
4034
4035                            responder: PeerHandlerSetNrecModeResponder {
4036                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4037                                tx_id: header.tx_id,
4038                            },
4039                        })
4040                    }
4041                    0x4e3e8be4680d85b => {
4042                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4043                        let mut req = fidl::new_empty!(
4044                            PeerHandlerReportHeadsetBatteryLevelRequest,
4045                            fidl::encoding::DefaultFuchsiaResourceDialect
4046                        );
4047                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerHandlerReportHeadsetBatteryLevelRequest>(&header, _body_bytes, handles, &mut req)?;
4048                        let control_handle = PeerHandlerControlHandle { inner: this.inner.clone() };
4049                        Ok(PeerHandlerRequest::ReportHeadsetBatteryLevel {
4050                            level: req.level,
4051
4052                            control_handle,
4053                        })
4054                    }
4055                    0x6e043b6d2e0fb917 => {
4056                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4057                        let mut req = fidl::new_empty!(
4058                            PeerHandlerGainControlRequest,
4059                            fidl::encoding::DefaultFuchsiaResourceDialect
4060                        );
4061                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerHandlerGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
4062                        let control_handle = PeerHandlerControlHandle { inner: this.inner.clone() };
4063                        Ok(PeerHandlerRequest::GainControl { control: req.control, control_handle })
4064                    }
4065                    _ => Err(fidl::Error::UnknownOrdinal {
4066                        ordinal: header.ordinal,
4067                        protocol_name:
4068                            <PeerHandlerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4069                    }),
4070                }))
4071            },
4072        )
4073    }
4074}
4075
4076/// The call manager or the hands-free server component will serve a call
4077/// handler protocol for each connected headset that it chooses to manage calls
4078/// through.
4079///
4080/// If the peer handler is closed by either channel endpoint, all protocols
4081/// associated with this peer handler are closed. This includes any Call, and
4082/// HeadsetGain protocols. Channels closed by a server end will include an
4083/// epitaph `ZX_ERR_HANDLE_CLOSED` in this situation.
4084#[derive(Debug)]
4085pub enum PeerHandlerRequest {
4086    /// Hanging get to provide the Hfp service with an `update` on the
4087    /// `NetworkInformation`. Any fields in `update` that are not present will
4088    /// be treated as unmodified by the update.
4089    ///
4090    /// The call manager or audio gateway peer _should_ provide a fully
4091    /// populated `update` when it is called for the first time.
4092    ///
4093    /// The most up-to-date `NetworkInformation` is used during the connection
4094    /// initialization process of the peer, and updates are propagated to the
4095    /// peer if it supports AG Indicators.
4096    WatchNetworkInformation { responder: PeerHandlerWatchNetworkInformationResponder },
4097    /// Hanging get which returns when a new call is initiated by the call
4098    /// manager or audio gateway peer, or an ongoing call is transferred to the
4099    /// headset.  `RequestOutgoingCall` can be called before or after
4100    /// `WatchNextCall`.
4101    WatchNextCall { responder: PeerHandlerWatchNextCallResponder },
4102    /// Used to request an outgoing call be initiated by the call manager or
4103    /// audio gateway peer.  `RequestOutgoingCall` shall complete after the
4104    /// outgoing call has been initiated and the corresponding `Call` protocol
4105    /// has been returned via a `WatchNextCall` result.
4106    ///
4107    /// An error is returned if the call could not be placed as requested.
4108    ///
4109    /// - ZX_ERR_NOT_SUPPORTED can be used if the system does not support the
4110    ///   requested action.
4111    ///
4112    /// - ZX_ERR_ALREADY_EXISTS can be used if there is alreadya call in
4113    ///   progress and the system does not support additional calls.
4114    RequestOutgoingCall { action: CallAction, responder: PeerHandlerRequestOutgoingCallResponder },
4115    /// Request the name of the network operator for the call manager or audio
4116    /// gateway peer. A null value is returned if there is no operator name
4117    /// available.
4118    QueryOperator { responder: PeerHandlerQueryOperatorResponder },
4119    /// Request subscriber numbers from the call manager or audio gateway peer.
4120    /// There can be zero or more numbers returned. Sending more than 128
4121    /// numbers is not supported at this time.
4122    SubscriberNumberInformation { responder: PeerHandlerSubscriberNumberInformationResponder },
4123    /// Request by the HF to enable or disable the Noise Reduction/Echo Cancellation
4124    /// functionality on the AG based on the `enabled` boolean.
4125    /// A `ZX_ERR_NOT_SUPPORTED` error is returned if Noice Reduction/Echo
4126    /// Cancellation is not supported by the device.
4127    SetNrecMode { enabled: bool, responder: PeerHandlerSetNrecModeResponder },
4128    /// Headset battery level from 0 ~ 100
4129    /// See https://www.bluetooth.com/specifications/assigned-numbers/hands-free-profile/
4130    ReportHeadsetBatteryLevel { level: u8, control_handle: PeerHandlerControlHandle },
4131    /// Tear off protocol for Headset Gain.
4132    ///
4133    /// Only one HeadsetGain protocol can be active for a PeerHandler protocol
4134    /// at any given time. Older HeadsetGain protocols are given preference. If
4135    /// a HeadsetGain protocol is active when a new GainControl request is made,
4136    /// the new HeadsetGain protocol will be closed immediately.
4137    GainControl {
4138        control: fidl::endpoints::ClientEnd<HeadsetGainMarker>,
4139        control_handle: PeerHandlerControlHandle,
4140    },
4141}
4142
4143impl PeerHandlerRequest {
4144    #[allow(irrefutable_let_patterns)]
4145    pub fn into_watch_network_information(
4146        self,
4147    ) -> Option<(PeerHandlerWatchNetworkInformationResponder)> {
4148        if let PeerHandlerRequest::WatchNetworkInformation { responder } = self {
4149            Some((responder))
4150        } else {
4151            None
4152        }
4153    }
4154
4155    #[allow(irrefutable_let_patterns)]
4156    pub fn into_watch_next_call(self) -> Option<(PeerHandlerWatchNextCallResponder)> {
4157        if let PeerHandlerRequest::WatchNextCall { responder } = self {
4158            Some((responder))
4159        } else {
4160            None
4161        }
4162    }
4163
4164    #[allow(irrefutable_let_patterns)]
4165    pub fn into_request_outgoing_call(
4166        self,
4167    ) -> Option<(CallAction, PeerHandlerRequestOutgoingCallResponder)> {
4168        if let PeerHandlerRequest::RequestOutgoingCall { action, responder } = self {
4169            Some((action, responder))
4170        } else {
4171            None
4172        }
4173    }
4174
4175    #[allow(irrefutable_let_patterns)]
4176    pub fn into_query_operator(self) -> Option<(PeerHandlerQueryOperatorResponder)> {
4177        if let PeerHandlerRequest::QueryOperator { responder } = self {
4178            Some((responder))
4179        } else {
4180            None
4181        }
4182    }
4183
4184    #[allow(irrefutable_let_patterns)]
4185    pub fn into_subscriber_number_information(
4186        self,
4187    ) -> Option<(PeerHandlerSubscriberNumberInformationResponder)> {
4188        if let PeerHandlerRequest::SubscriberNumberInformation { responder } = self {
4189            Some((responder))
4190        } else {
4191            None
4192        }
4193    }
4194
4195    #[allow(irrefutable_let_patterns)]
4196    pub fn into_set_nrec_mode(self) -> Option<(bool, PeerHandlerSetNrecModeResponder)> {
4197        if let PeerHandlerRequest::SetNrecMode { enabled, responder } = self {
4198            Some((enabled, responder))
4199        } else {
4200            None
4201        }
4202    }
4203
4204    #[allow(irrefutable_let_patterns)]
4205    pub fn into_report_headset_battery_level(self) -> Option<(u8, PeerHandlerControlHandle)> {
4206        if let PeerHandlerRequest::ReportHeadsetBatteryLevel { level, control_handle } = self {
4207            Some((level, control_handle))
4208        } else {
4209            None
4210        }
4211    }
4212
4213    #[allow(irrefutable_let_patterns)]
4214    pub fn into_gain_control(
4215        self,
4216    ) -> Option<(fidl::endpoints::ClientEnd<HeadsetGainMarker>, PeerHandlerControlHandle)> {
4217        if let PeerHandlerRequest::GainControl { control, control_handle } = self {
4218            Some((control, control_handle))
4219        } else {
4220            None
4221        }
4222    }
4223
4224    /// Name of the method defined in FIDL
4225    pub fn method_name(&self) -> &'static str {
4226        match *self {
4227            PeerHandlerRequest::WatchNetworkInformation { .. } => "watch_network_information",
4228            PeerHandlerRequest::WatchNextCall { .. } => "watch_next_call",
4229            PeerHandlerRequest::RequestOutgoingCall { .. } => "request_outgoing_call",
4230            PeerHandlerRequest::QueryOperator { .. } => "query_operator",
4231            PeerHandlerRequest::SubscriberNumberInformation { .. } => {
4232                "subscriber_number_information"
4233            }
4234            PeerHandlerRequest::SetNrecMode { .. } => "set_nrec_mode",
4235            PeerHandlerRequest::ReportHeadsetBatteryLevel { .. } => "report_headset_battery_level",
4236            PeerHandlerRequest::GainControl { .. } => "gain_control",
4237        }
4238    }
4239}
4240
4241#[derive(Debug, Clone)]
4242pub struct PeerHandlerControlHandle {
4243    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4244}
4245
4246impl fidl::endpoints::ControlHandle for PeerHandlerControlHandle {
4247    fn shutdown(&self) {
4248        self.inner.shutdown()
4249    }
4250    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4251        self.inner.shutdown_with_epitaph(status)
4252    }
4253
4254    fn is_closed(&self) -> bool {
4255        self.inner.channel().is_closed()
4256    }
4257    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4258        self.inner.channel().on_closed()
4259    }
4260
4261    #[cfg(target_os = "fuchsia")]
4262    fn signal_peer(
4263        &self,
4264        clear_mask: zx::Signals,
4265        set_mask: zx::Signals,
4266    ) -> Result<(), zx_status::Status> {
4267        use fidl::Peered;
4268        self.inner.channel().signal_peer(clear_mask, set_mask)
4269    }
4270}
4271
4272impl PeerHandlerControlHandle {}
4273
4274#[must_use = "FIDL methods require a response to be sent"]
4275#[derive(Debug)]
4276pub struct PeerHandlerWatchNetworkInformationResponder {
4277    control_handle: std::mem::ManuallyDrop<PeerHandlerControlHandle>,
4278    tx_id: u32,
4279}
4280
4281/// Set the the channel to be shutdown (see [`PeerHandlerControlHandle::shutdown`])
4282/// if the responder is dropped without sending a response, so that the client
4283/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4284impl std::ops::Drop for PeerHandlerWatchNetworkInformationResponder {
4285    fn drop(&mut self) {
4286        self.control_handle.shutdown();
4287        // Safety: drops once, never accessed again
4288        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4289    }
4290}
4291
4292impl fidl::endpoints::Responder for PeerHandlerWatchNetworkInformationResponder {
4293    type ControlHandle = PeerHandlerControlHandle;
4294
4295    fn control_handle(&self) -> &PeerHandlerControlHandle {
4296        &self.control_handle
4297    }
4298
4299    fn drop_without_shutdown(mut self) {
4300        // Safety: drops once, never accessed again due to mem::forget
4301        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4302        // Prevent Drop from running (which would shut down the channel)
4303        std::mem::forget(self);
4304    }
4305}
4306
4307impl PeerHandlerWatchNetworkInformationResponder {
4308    /// Sends a response to the FIDL transaction.
4309    ///
4310    /// Sets the channel to shutdown if an error occurs.
4311    pub fn send(self, mut update: &NetworkInformation) -> Result<(), fidl::Error> {
4312        let _result = self.send_raw(update);
4313        if _result.is_err() {
4314            self.control_handle.shutdown();
4315        }
4316        self.drop_without_shutdown();
4317        _result
4318    }
4319
4320    /// Similar to "send" but does not shutdown the channel if an error occurs.
4321    pub fn send_no_shutdown_on_err(
4322        self,
4323        mut update: &NetworkInformation,
4324    ) -> Result<(), fidl::Error> {
4325        let _result = self.send_raw(update);
4326        self.drop_without_shutdown();
4327        _result
4328    }
4329
4330    fn send_raw(&self, mut update: &NetworkInformation) -> Result<(), fidl::Error> {
4331        self.control_handle.inner.send::<PeerHandlerWatchNetworkInformationResponse>(
4332            (update,),
4333            self.tx_id,
4334            0x1c9eba597076b7cb,
4335            fidl::encoding::DynamicFlags::empty(),
4336        )
4337    }
4338}
4339
4340#[must_use = "FIDL methods require a response to be sent"]
4341#[derive(Debug)]
4342pub struct PeerHandlerWatchNextCallResponder {
4343    control_handle: std::mem::ManuallyDrop<PeerHandlerControlHandle>,
4344    tx_id: u32,
4345}
4346
4347/// Set the the channel to be shutdown (see [`PeerHandlerControlHandle::shutdown`])
4348/// if the responder is dropped without sending a response, so that the client
4349/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4350impl std::ops::Drop for PeerHandlerWatchNextCallResponder {
4351    fn drop(&mut self) {
4352        self.control_handle.shutdown();
4353        // Safety: drops once, never accessed again
4354        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4355    }
4356}
4357
4358impl fidl::endpoints::Responder for PeerHandlerWatchNextCallResponder {
4359    type ControlHandle = PeerHandlerControlHandle;
4360
4361    fn control_handle(&self) -> &PeerHandlerControlHandle {
4362        &self.control_handle
4363    }
4364
4365    fn drop_without_shutdown(mut self) {
4366        // Safety: drops once, never accessed again due to mem::forget
4367        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4368        // Prevent Drop from running (which would shut down the channel)
4369        std::mem::forget(self);
4370    }
4371}
4372
4373impl PeerHandlerWatchNextCallResponder {
4374    /// Sends a response to the FIDL transaction.
4375    ///
4376    /// Sets the channel to shutdown if an error occurs.
4377    pub fn send(self, mut call: NextCall) -> Result<(), fidl::Error> {
4378        let _result = self.send_raw(call);
4379        if _result.is_err() {
4380            self.control_handle.shutdown();
4381        }
4382        self.drop_without_shutdown();
4383        _result
4384    }
4385
4386    /// Similar to "send" but does not shutdown the channel if an error occurs.
4387    pub fn send_no_shutdown_on_err(self, mut call: NextCall) -> Result<(), fidl::Error> {
4388        let _result = self.send_raw(call);
4389        self.drop_without_shutdown();
4390        _result
4391    }
4392
4393    fn send_raw(&self, mut call: NextCall) -> Result<(), fidl::Error> {
4394        self.control_handle.inner.send::<PeerHandlerWatchNextCallResponse>(
4395            (&mut call,),
4396            self.tx_id,
4397            0x5e3b7b4e7c3d359,
4398            fidl::encoding::DynamicFlags::empty(),
4399        )
4400    }
4401}
4402
4403#[must_use = "FIDL methods require a response to be sent"]
4404#[derive(Debug)]
4405pub struct PeerHandlerRequestOutgoingCallResponder {
4406    control_handle: std::mem::ManuallyDrop<PeerHandlerControlHandle>,
4407    tx_id: u32,
4408}
4409
4410/// Set the the channel to be shutdown (see [`PeerHandlerControlHandle::shutdown`])
4411/// if the responder is dropped without sending a response, so that the client
4412/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4413impl std::ops::Drop for PeerHandlerRequestOutgoingCallResponder {
4414    fn drop(&mut self) {
4415        self.control_handle.shutdown();
4416        // Safety: drops once, never accessed again
4417        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4418    }
4419}
4420
4421impl fidl::endpoints::Responder for PeerHandlerRequestOutgoingCallResponder {
4422    type ControlHandle = PeerHandlerControlHandle;
4423
4424    fn control_handle(&self) -> &PeerHandlerControlHandle {
4425        &self.control_handle
4426    }
4427
4428    fn drop_without_shutdown(mut self) {
4429        // Safety: drops once, never accessed again due to mem::forget
4430        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4431        // Prevent Drop from running (which would shut down the channel)
4432        std::mem::forget(self);
4433    }
4434}
4435
4436impl PeerHandlerRequestOutgoingCallResponder {
4437    /// Sends a response to the FIDL transaction.
4438    ///
4439    /// Sets the channel to shutdown if an error occurs.
4440    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4441        let _result = self.send_raw(result);
4442        if _result.is_err() {
4443            self.control_handle.shutdown();
4444        }
4445        self.drop_without_shutdown();
4446        _result
4447    }
4448
4449    /// Similar to "send" but does not shutdown the channel if an error occurs.
4450    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4451        let _result = self.send_raw(result);
4452        self.drop_without_shutdown();
4453        _result
4454    }
4455
4456    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4457        self.control_handle
4458            .inner
4459            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4460                result,
4461                self.tx_id,
4462                0x1a2637c743c89ad,
4463                fidl::encoding::DynamicFlags::empty(),
4464            )
4465    }
4466}
4467
4468#[must_use = "FIDL methods require a response to be sent"]
4469#[derive(Debug)]
4470pub struct PeerHandlerQueryOperatorResponder {
4471    control_handle: std::mem::ManuallyDrop<PeerHandlerControlHandle>,
4472    tx_id: u32,
4473}
4474
4475/// Set the the channel to be shutdown (see [`PeerHandlerControlHandle::shutdown`])
4476/// if the responder is dropped without sending a response, so that the client
4477/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4478impl std::ops::Drop for PeerHandlerQueryOperatorResponder {
4479    fn drop(&mut self) {
4480        self.control_handle.shutdown();
4481        // Safety: drops once, never accessed again
4482        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4483    }
4484}
4485
4486impl fidl::endpoints::Responder for PeerHandlerQueryOperatorResponder {
4487    type ControlHandle = PeerHandlerControlHandle;
4488
4489    fn control_handle(&self) -> &PeerHandlerControlHandle {
4490        &self.control_handle
4491    }
4492
4493    fn drop_without_shutdown(mut self) {
4494        // Safety: drops once, never accessed again due to mem::forget
4495        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4496        // Prevent Drop from running (which would shut down the channel)
4497        std::mem::forget(self);
4498    }
4499}
4500
4501impl PeerHandlerQueryOperatorResponder {
4502    /// Sends a response to the FIDL transaction.
4503    ///
4504    /// Sets the channel to shutdown if an error occurs.
4505    pub fn send(self, mut operator: Option<&str>) -> Result<(), fidl::Error> {
4506        let _result = self.send_raw(operator);
4507        if _result.is_err() {
4508            self.control_handle.shutdown();
4509        }
4510        self.drop_without_shutdown();
4511        _result
4512    }
4513
4514    /// Similar to "send" but does not shutdown the channel if an error occurs.
4515    pub fn send_no_shutdown_on_err(self, mut operator: Option<&str>) -> Result<(), fidl::Error> {
4516        let _result = self.send_raw(operator);
4517        self.drop_without_shutdown();
4518        _result
4519    }
4520
4521    fn send_raw(&self, mut operator: Option<&str>) -> Result<(), fidl::Error> {
4522        self.control_handle.inner.send::<PeerHandlerQueryOperatorResponse>(
4523            (operator,),
4524            self.tx_id,
4525            0x1217eaf5db4c3300,
4526            fidl::encoding::DynamicFlags::empty(),
4527        )
4528    }
4529}
4530
4531#[must_use = "FIDL methods require a response to be sent"]
4532#[derive(Debug)]
4533pub struct PeerHandlerSubscriberNumberInformationResponder {
4534    control_handle: std::mem::ManuallyDrop<PeerHandlerControlHandle>,
4535    tx_id: u32,
4536}
4537
4538/// Set the the channel to be shutdown (see [`PeerHandlerControlHandle::shutdown`])
4539/// if the responder is dropped without sending a response, so that the client
4540/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4541impl std::ops::Drop for PeerHandlerSubscriberNumberInformationResponder {
4542    fn drop(&mut self) {
4543        self.control_handle.shutdown();
4544        // Safety: drops once, never accessed again
4545        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4546    }
4547}
4548
4549impl fidl::endpoints::Responder for PeerHandlerSubscriberNumberInformationResponder {
4550    type ControlHandle = PeerHandlerControlHandle;
4551
4552    fn control_handle(&self) -> &PeerHandlerControlHandle {
4553        &self.control_handle
4554    }
4555
4556    fn drop_without_shutdown(mut self) {
4557        // Safety: drops once, never accessed again due to mem::forget
4558        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4559        // Prevent Drop from running (which would shut down the channel)
4560        std::mem::forget(self);
4561    }
4562}
4563
4564impl PeerHandlerSubscriberNumberInformationResponder {
4565    /// Sends a response to the FIDL transaction.
4566    ///
4567    /// Sets the channel to shutdown if an error occurs.
4568    pub fn send(self, mut numbers: &[String]) -> Result<(), fidl::Error> {
4569        let _result = self.send_raw(numbers);
4570        if _result.is_err() {
4571            self.control_handle.shutdown();
4572        }
4573        self.drop_without_shutdown();
4574        _result
4575    }
4576
4577    /// Similar to "send" but does not shutdown the channel if an error occurs.
4578    pub fn send_no_shutdown_on_err(self, mut numbers: &[String]) -> Result<(), fidl::Error> {
4579        let _result = self.send_raw(numbers);
4580        self.drop_without_shutdown();
4581        _result
4582    }
4583
4584    fn send_raw(&self, mut numbers: &[String]) -> Result<(), fidl::Error> {
4585        self.control_handle.inner.send::<PeerHandlerSubscriberNumberInformationResponse>(
4586            (numbers,),
4587            self.tx_id,
4588            0x15f5235855b02a3a,
4589            fidl::encoding::DynamicFlags::empty(),
4590        )
4591    }
4592}
4593
4594#[must_use = "FIDL methods require a response to be sent"]
4595#[derive(Debug)]
4596pub struct PeerHandlerSetNrecModeResponder {
4597    control_handle: std::mem::ManuallyDrop<PeerHandlerControlHandle>,
4598    tx_id: u32,
4599}
4600
4601/// Set the the channel to be shutdown (see [`PeerHandlerControlHandle::shutdown`])
4602/// if the responder is dropped without sending a response, so that the client
4603/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4604impl std::ops::Drop for PeerHandlerSetNrecModeResponder {
4605    fn drop(&mut self) {
4606        self.control_handle.shutdown();
4607        // Safety: drops once, never accessed again
4608        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4609    }
4610}
4611
4612impl fidl::endpoints::Responder for PeerHandlerSetNrecModeResponder {
4613    type ControlHandle = PeerHandlerControlHandle;
4614
4615    fn control_handle(&self) -> &PeerHandlerControlHandle {
4616        &self.control_handle
4617    }
4618
4619    fn drop_without_shutdown(mut self) {
4620        // Safety: drops once, never accessed again due to mem::forget
4621        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4622        // Prevent Drop from running (which would shut down the channel)
4623        std::mem::forget(self);
4624    }
4625}
4626
4627impl PeerHandlerSetNrecModeResponder {
4628    /// Sends a response to the FIDL transaction.
4629    ///
4630    /// Sets the channel to shutdown if an error occurs.
4631    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4632        let _result = self.send_raw(result);
4633        if _result.is_err() {
4634            self.control_handle.shutdown();
4635        }
4636        self.drop_without_shutdown();
4637        _result
4638    }
4639
4640    /// Similar to "send" but does not shutdown the channel if an error occurs.
4641    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4642        let _result = self.send_raw(result);
4643        self.drop_without_shutdown();
4644        _result
4645    }
4646
4647    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4648        self.control_handle
4649            .inner
4650            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4651                result,
4652                self.tx_id,
4653                0x2f8890d0f866672f,
4654                fidl::encoding::DynamicFlags::empty(),
4655            )
4656    }
4657}
4658
4659mod internal {
4660    use super::*;
4661    unsafe impl fidl::encoding::TypeMarker for CallDirection {
4662        type Owned = Self;
4663
4664        #[inline(always)]
4665        fn inline_align(_context: fidl::encoding::Context) -> usize {
4666            std::mem::align_of::<u32>()
4667        }
4668
4669        #[inline(always)]
4670        fn inline_size(_context: fidl::encoding::Context) -> usize {
4671            std::mem::size_of::<u32>()
4672        }
4673
4674        #[inline(always)]
4675        fn encode_is_copy() -> bool {
4676            true
4677        }
4678
4679        #[inline(always)]
4680        fn decode_is_copy() -> bool {
4681            false
4682        }
4683    }
4684
4685    impl fidl::encoding::ValueTypeMarker for CallDirection {
4686        type Borrowed<'a> = Self;
4687        #[inline(always)]
4688        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4689            *value
4690        }
4691    }
4692
4693    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for CallDirection {
4694        #[inline]
4695        unsafe fn encode(
4696            self,
4697            encoder: &mut fidl::encoding::Encoder<'_, D>,
4698            offset: usize,
4699            _depth: fidl::encoding::Depth,
4700        ) -> fidl::Result<()> {
4701            encoder.debug_check_bounds::<Self>(offset);
4702            encoder.write_num(self.into_primitive(), offset);
4703            Ok(())
4704        }
4705    }
4706
4707    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CallDirection {
4708        #[inline(always)]
4709        fn new_empty() -> Self {
4710            Self::MobileOriginated
4711        }
4712
4713        #[inline]
4714        unsafe fn decode(
4715            &mut self,
4716            decoder: &mut fidl::encoding::Decoder<'_, D>,
4717            offset: usize,
4718            _depth: fidl::encoding::Depth,
4719        ) -> fidl::Result<()> {
4720            decoder.debug_check_bounds::<Self>(offset);
4721            let prim = decoder.read_num::<u32>(offset);
4722
4723            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
4724            Ok(())
4725        }
4726    }
4727    unsafe impl fidl::encoding::TypeMarker for CallState {
4728        type Owned = Self;
4729
4730        #[inline(always)]
4731        fn inline_align(_context: fidl::encoding::Context) -> usize {
4732            std::mem::align_of::<u32>()
4733        }
4734
4735        #[inline(always)]
4736        fn inline_size(_context: fidl::encoding::Context) -> usize {
4737            std::mem::size_of::<u32>()
4738        }
4739
4740        #[inline(always)]
4741        fn encode_is_copy() -> bool {
4742            false
4743        }
4744
4745        #[inline(always)]
4746        fn decode_is_copy() -> bool {
4747            false
4748        }
4749    }
4750
4751    impl fidl::encoding::ValueTypeMarker for CallState {
4752        type Borrowed<'a> = Self;
4753        #[inline(always)]
4754        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4755            *value
4756        }
4757    }
4758
4759    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for CallState {
4760        #[inline]
4761        unsafe fn encode(
4762            self,
4763            encoder: &mut fidl::encoding::Encoder<'_, D>,
4764            offset: usize,
4765            _depth: fidl::encoding::Depth,
4766        ) -> fidl::Result<()> {
4767            encoder.debug_check_bounds::<Self>(offset);
4768            encoder.write_num(self.into_primitive(), offset);
4769            Ok(())
4770        }
4771    }
4772
4773    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CallState {
4774        #[inline(always)]
4775        fn new_empty() -> Self {
4776            Self::unknown()
4777        }
4778
4779        #[inline]
4780        unsafe fn decode(
4781            &mut self,
4782            decoder: &mut fidl::encoding::Decoder<'_, D>,
4783            offset: usize,
4784            _depth: fidl::encoding::Depth,
4785        ) -> fidl::Result<()> {
4786            decoder.debug_check_bounds::<Self>(offset);
4787            let prim = decoder.read_num::<u32>(offset);
4788
4789            *self = Self::from_primitive_allow_unknown(prim);
4790            Ok(())
4791        }
4792    }
4793    unsafe impl fidl::encoding::TypeMarker for DtmfCode {
4794        type Owned = Self;
4795
4796        #[inline(always)]
4797        fn inline_align(_context: fidl::encoding::Context) -> usize {
4798            std::mem::align_of::<u8>()
4799        }
4800
4801        #[inline(always)]
4802        fn inline_size(_context: fidl::encoding::Context) -> usize {
4803            std::mem::size_of::<u8>()
4804        }
4805
4806        #[inline(always)]
4807        fn encode_is_copy() -> bool {
4808            true
4809        }
4810
4811        #[inline(always)]
4812        fn decode_is_copy() -> bool {
4813            false
4814        }
4815    }
4816
4817    impl fidl::encoding::ValueTypeMarker for DtmfCode {
4818        type Borrowed<'a> = Self;
4819        #[inline(always)]
4820        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4821            *value
4822        }
4823    }
4824
4825    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for DtmfCode {
4826        #[inline]
4827        unsafe fn encode(
4828            self,
4829            encoder: &mut fidl::encoding::Encoder<'_, D>,
4830            offset: usize,
4831            _depth: fidl::encoding::Depth,
4832        ) -> fidl::Result<()> {
4833            encoder.debug_check_bounds::<Self>(offset);
4834            encoder.write_num(self.into_primitive(), offset);
4835            Ok(())
4836        }
4837    }
4838
4839    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DtmfCode {
4840        #[inline(always)]
4841        fn new_empty() -> Self {
4842            Self::NumberSign
4843        }
4844
4845        #[inline]
4846        unsafe fn decode(
4847            &mut self,
4848            decoder: &mut fidl::encoding::Decoder<'_, D>,
4849            offset: usize,
4850            _depth: fidl::encoding::Depth,
4851        ) -> fidl::Result<()> {
4852            decoder.debug_check_bounds::<Self>(offset);
4853            let prim = decoder.read_num::<u8>(offset);
4854
4855            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
4856            Ok(())
4857        }
4858    }
4859    unsafe impl fidl::encoding::TypeMarker for SignalStrength {
4860        type Owned = Self;
4861
4862        #[inline(always)]
4863        fn inline_align(_context: fidl::encoding::Context) -> usize {
4864            std::mem::align_of::<i8>()
4865        }
4866
4867        #[inline(always)]
4868        fn inline_size(_context: fidl::encoding::Context) -> usize {
4869            std::mem::size_of::<i8>()
4870        }
4871
4872        #[inline(always)]
4873        fn encode_is_copy() -> bool {
4874            true
4875        }
4876
4877        #[inline(always)]
4878        fn decode_is_copy() -> bool {
4879            false
4880        }
4881    }
4882
4883    impl fidl::encoding::ValueTypeMarker for SignalStrength {
4884        type Borrowed<'a> = Self;
4885        #[inline(always)]
4886        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
4887            *value
4888        }
4889    }
4890
4891    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for SignalStrength {
4892        #[inline]
4893        unsafe fn encode(
4894            self,
4895            encoder: &mut fidl::encoding::Encoder<'_, D>,
4896            offset: usize,
4897            _depth: fidl::encoding::Depth,
4898        ) -> fidl::Result<()> {
4899            encoder.debug_check_bounds::<Self>(offset);
4900            encoder.write_num(self.into_primitive(), offset);
4901            Ok(())
4902        }
4903    }
4904
4905    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SignalStrength {
4906        #[inline(always)]
4907        fn new_empty() -> Self {
4908            Self::None
4909        }
4910
4911        #[inline]
4912        unsafe fn decode(
4913            &mut self,
4914            decoder: &mut fidl::encoding::Decoder<'_, D>,
4915            offset: usize,
4916            _depth: fidl::encoding::Depth,
4917        ) -> fidl::Result<()> {
4918            decoder.debug_check_bounds::<Self>(offset);
4919            let prim = decoder.read_num::<i8>(offset);
4920
4921            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
4922            Ok(())
4923        }
4924    }
4925
4926    impl fidl::encoding::ResourceTypeMarker for CallManagerPeerConnectedRequest {
4927        type Borrowed<'a> = &'a mut Self;
4928        fn take_or_borrow<'a>(
4929            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4930        ) -> Self::Borrowed<'a> {
4931            value
4932        }
4933    }
4934
4935    unsafe impl fidl::encoding::TypeMarker for CallManagerPeerConnectedRequest {
4936        type Owned = Self;
4937
4938        #[inline(always)]
4939        fn inline_align(_context: fidl::encoding::Context) -> usize {
4940            8
4941        }
4942
4943        #[inline(always)]
4944        fn inline_size(_context: fidl::encoding::Context) -> usize {
4945            16
4946        }
4947    }
4948
4949    unsafe impl
4950        fidl::encoding::Encode<
4951            CallManagerPeerConnectedRequest,
4952            fidl::encoding::DefaultFuchsiaResourceDialect,
4953        > for &mut CallManagerPeerConnectedRequest
4954    {
4955        #[inline]
4956        unsafe fn encode(
4957            self,
4958            encoder: &mut fidl::encoding::Encoder<
4959                '_,
4960                fidl::encoding::DefaultFuchsiaResourceDialect,
4961            >,
4962            offset: usize,
4963            _depth: fidl::encoding::Depth,
4964        ) -> fidl::Result<()> {
4965            encoder.debug_check_bounds::<CallManagerPeerConnectedRequest>(offset);
4966            // Delegate to tuple encoding.
4967            fidl::encoding::Encode::<CallManagerPeerConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4968                (
4969                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
4970                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerHandlerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handle),
4971                ),
4972                encoder, offset, _depth
4973            )
4974        }
4975    }
4976    unsafe impl<
4977            T0: fidl::encoding::Encode<
4978                fidl_fuchsia_bluetooth::PeerId,
4979                fidl::encoding::DefaultFuchsiaResourceDialect,
4980            >,
4981            T1: fidl::encoding::Encode<
4982                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerHandlerMarker>>,
4983                fidl::encoding::DefaultFuchsiaResourceDialect,
4984            >,
4985        >
4986        fidl::encoding::Encode<
4987            CallManagerPeerConnectedRequest,
4988            fidl::encoding::DefaultFuchsiaResourceDialect,
4989        > for (T0, T1)
4990    {
4991        #[inline]
4992        unsafe fn encode(
4993            self,
4994            encoder: &mut fidl::encoding::Encoder<
4995                '_,
4996                fidl::encoding::DefaultFuchsiaResourceDialect,
4997            >,
4998            offset: usize,
4999            depth: fidl::encoding::Depth,
5000        ) -> fidl::Result<()> {
5001            encoder.debug_check_bounds::<CallManagerPeerConnectedRequest>(offset);
5002            // Zero out padding regions. There's no need to apply masks
5003            // because the unmasked parts will be overwritten by fields.
5004            unsafe {
5005                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
5006                (ptr as *mut u64).write_unaligned(0);
5007            }
5008            // Write the fields.
5009            self.0.encode(encoder, offset + 0, depth)?;
5010            self.1.encode(encoder, offset + 8, depth)?;
5011            Ok(())
5012        }
5013    }
5014
5015    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5016        for CallManagerPeerConnectedRequest
5017    {
5018        #[inline(always)]
5019        fn new_empty() -> Self {
5020            Self {
5021                id: fidl::new_empty!(
5022                    fidl_fuchsia_bluetooth::PeerId,
5023                    fidl::encoding::DefaultFuchsiaResourceDialect
5024                ),
5025                handle: fidl::new_empty!(
5026                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerHandlerMarker>>,
5027                    fidl::encoding::DefaultFuchsiaResourceDialect
5028                ),
5029            }
5030        }
5031
5032        #[inline]
5033        unsafe fn decode(
5034            &mut self,
5035            decoder: &mut fidl::encoding::Decoder<
5036                '_,
5037                fidl::encoding::DefaultFuchsiaResourceDialect,
5038            >,
5039            offset: usize,
5040            _depth: fidl::encoding::Depth,
5041        ) -> fidl::Result<()> {
5042            decoder.debug_check_bounds::<Self>(offset);
5043            // Verify that padding bytes are zero.
5044            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
5045            let padval = unsafe { (ptr as *const u64).read_unaligned() };
5046            let mask = 0xffffffff00000000u64;
5047            let maskedval = padval & mask;
5048            if maskedval != 0 {
5049                return Err(fidl::Error::NonZeroPadding {
5050                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
5051                });
5052            }
5053            fidl::decode!(
5054                fidl_fuchsia_bluetooth::PeerId,
5055                fidl::encoding::DefaultFuchsiaResourceDialect,
5056                &mut self.id,
5057                decoder,
5058                offset + 0,
5059                _depth
5060            )?;
5061            fidl::decode!(
5062                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerHandlerMarker>>,
5063                fidl::encoding::DefaultFuchsiaResourceDialect,
5064                &mut self.handle,
5065                decoder,
5066                offset + 8,
5067                _depth
5068            )?;
5069            Ok(())
5070        }
5071    }
5072
5073    impl fidl::encoding::ValueTypeMarker for CallSendDtmfCodeRequest {
5074        type Borrowed<'a> = &'a Self;
5075        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5076            value
5077        }
5078    }
5079
5080    unsafe impl fidl::encoding::TypeMarker for CallSendDtmfCodeRequest {
5081        type Owned = Self;
5082
5083        #[inline(always)]
5084        fn inline_align(_context: fidl::encoding::Context) -> usize {
5085            1
5086        }
5087
5088        #[inline(always)]
5089        fn inline_size(_context: fidl::encoding::Context) -> usize {
5090            1
5091        }
5092    }
5093
5094    unsafe impl<D: fidl::encoding::ResourceDialect>
5095        fidl::encoding::Encode<CallSendDtmfCodeRequest, D> for &CallSendDtmfCodeRequest
5096    {
5097        #[inline]
5098        unsafe fn encode(
5099            self,
5100            encoder: &mut fidl::encoding::Encoder<'_, D>,
5101            offset: usize,
5102            _depth: fidl::encoding::Depth,
5103        ) -> fidl::Result<()> {
5104            encoder.debug_check_bounds::<CallSendDtmfCodeRequest>(offset);
5105            // Delegate to tuple encoding.
5106            fidl::encoding::Encode::<CallSendDtmfCodeRequest, D>::encode(
5107                (<DtmfCode as fidl::encoding::ValueTypeMarker>::borrow(&self.code),),
5108                encoder,
5109                offset,
5110                _depth,
5111            )
5112        }
5113    }
5114    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<DtmfCode, D>>
5115        fidl::encoding::Encode<CallSendDtmfCodeRequest, D> for (T0,)
5116    {
5117        #[inline]
5118        unsafe fn encode(
5119            self,
5120            encoder: &mut fidl::encoding::Encoder<'_, D>,
5121            offset: usize,
5122            depth: fidl::encoding::Depth,
5123        ) -> fidl::Result<()> {
5124            encoder.debug_check_bounds::<CallSendDtmfCodeRequest>(offset);
5125            // Zero out padding regions. There's no need to apply masks
5126            // because the unmasked parts will be overwritten by fields.
5127            // Write the fields.
5128            self.0.encode(encoder, offset + 0, depth)?;
5129            Ok(())
5130        }
5131    }
5132
5133    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
5134        for CallSendDtmfCodeRequest
5135    {
5136        #[inline(always)]
5137        fn new_empty() -> Self {
5138            Self { code: fidl::new_empty!(DtmfCode, D) }
5139        }
5140
5141        #[inline]
5142        unsafe fn decode(
5143            &mut self,
5144            decoder: &mut fidl::encoding::Decoder<'_, D>,
5145            offset: usize,
5146            _depth: fidl::encoding::Depth,
5147        ) -> fidl::Result<()> {
5148            decoder.debug_check_bounds::<Self>(offset);
5149            // Verify that padding bytes are zero.
5150            fidl::decode!(DtmfCode, D, &mut self.code, decoder, offset + 0, _depth)?;
5151            Ok(())
5152        }
5153    }
5154
5155    impl fidl::encoding::ValueTypeMarker for CallWatchStateResponse {
5156        type Borrowed<'a> = &'a Self;
5157        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5158            value
5159        }
5160    }
5161
5162    unsafe impl fidl::encoding::TypeMarker for CallWatchStateResponse {
5163        type Owned = Self;
5164
5165        #[inline(always)]
5166        fn inline_align(_context: fidl::encoding::Context) -> usize {
5167            4
5168        }
5169
5170        #[inline(always)]
5171        fn inline_size(_context: fidl::encoding::Context) -> usize {
5172            4
5173        }
5174    }
5175
5176    unsafe impl<D: fidl::encoding::ResourceDialect>
5177        fidl::encoding::Encode<CallWatchStateResponse, D> for &CallWatchStateResponse
5178    {
5179        #[inline]
5180        unsafe fn encode(
5181            self,
5182            encoder: &mut fidl::encoding::Encoder<'_, D>,
5183            offset: usize,
5184            _depth: fidl::encoding::Depth,
5185        ) -> fidl::Result<()> {
5186            encoder.debug_check_bounds::<CallWatchStateResponse>(offset);
5187            // Delegate to tuple encoding.
5188            fidl::encoding::Encode::<CallWatchStateResponse, D>::encode(
5189                (<CallState as fidl::encoding::ValueTypeMarker>::borrow(&self.state),),
5190                encoder,
5191                offset,
5192                _depth,
5193            )
5194        }
5195    }
5196    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<CallState, D>>
5197        fidl::encoding::Encode<CallWatchStateResponse, D> for (T0,)
5198    {
5199        #[inline]
5200        unsafe fn encode(
5201            self,
5202            encoder: &mut fidl::encoding::Encoder<'_, D>,
5203            offset: usize,
5204            depth: fidl::encoding::Depth,
5205        ) -> fidl::Result<()> {
5206            encoder.debug_check_bounds::<CallWatchStateResponse>(offset);
5207            // Zero out padding regions. There's no need to apply masks
5208            // because the unmasked parts will be overwritten by fields.
5209            // Write the fields.
5210            self.0.encode(encoder, offset + 0, depth)?;
5211            Ok(())
5212        }
5213    }
5214
5215    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
5216        for CallWatchStateResponse
5217    {
5218        #[inline(always)]
5219        fn new_empty() -> Self {
5220            Self { state: fidl::new_empty!(CallState, D) }
5221        }
5222
5223        #[inline]
5224        unsafe fn decode(
5225            &mut self,
5226            decoder: &mut fidl::encoding::Decoder<'_, D>,
5227            offset: usize,
5228            _depth: fidl::encoding::Depth,
5229        ) -> fidl::Result<()> {
5230            decoder.debug_check_bounds::<Self>(offset);
5231            // Verify that padding bytes are zero.
5232            fidl::decode!(CallState, D, &mut self.state, decoder, offset + 0, _depth)?;
5233            Ok(())
5234        }
5235    }
5236
5237    impl fidl::encoding::ResourceTypeMarker for HandsFreeWatchPeerConnectedResponse {
5238        type Borrowed<'a> = &'a mut Self;
5239        fn take_or_borrow<'a>(
5240            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5241        ) -> Self::Borrowed<'a> {
5242            value
5243        }
5244    }
5245
5246    unsafe impl fidl::encoding::TypeMarker for HandsFreeWatchPeerConnectedResponse {
5247        type Owned = Self;
5248
5249        #[inline(always)]
5250        fn inline_align(_context: fidl::encoding::Context) -> usize {
5251            8
5252        }
5253
5254        #[inline(always)]
5255        fn inline_size(_context: fidl::encoding::Context) -> usize {
5256            16
5257        }
5258    }
5259
5260    unsafe impl
5261        fidl::encoding::Encode<
5262            HandsFreeWatchPeerConnectedResponse,
5263            fidl::encoding::DefaultFuchsiaResourceDialect,
5264        > for &mut HandsFreeWatchPeerConnectedResponse
5265    {
5266        #[inline]
5267        unsafe fn encode(
5268            self,
5269            encoder: &mut fidl::encoding::Encoder<
5270                '_,
5271                fidl::encoding::DefaultFuchsiaResourceDialect,
5272            >,
5273            offset: usize,
5274            _depth: fidl::encoding::Depth,
5275        ) -> fidl::Result<()> {
5276            encoder.debug_check_bounds::<HandsFreeWatchPeerConnectedResponse>(offset);
5277            // Delegate to tuple encoding.
5278            fidl::encoding::Encode::<HandsFreeWatchPeerConnectedResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5279                (
5280                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
5281                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PeerHandlerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handle),
5282                ),
5283                encoder, offset, _depth
5284            )
5285        }
5286    }
5287    unsafe impl<
5288            T0: fidl::encoding::Encode<
5289                fidl_fuchsia_bluetooth::PeerId,
5290                fidl::encoding::DefaultFuchsiaResourceDialect,
5291            >,
5292            T1: fidl::encoding::Encode<
5293                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PeerHandlerMarker>>,
5294                fidl::encoding::DefaultFuchsiaResourceDialect,
5295            >,
5296        >
5297        fidl::encoding::Encode<
5298            HandsFreeWatchPeerConnectedResponse,
5299            fidl::encoding::DefaultFuchsiaResourceDialect,
5300        > for (T0, T1)
5301    {
5302        #[inline]
5303        unsafe fn encode(
5304            self,
5305            encoder: &mut fidl::encoding::Encoder<
5306                '_,
5307                fidl::encoding::DefaultFuchsiaResourceDialect,
5308            >,
5309            offset: usize,
5310            depth: fidl::encoding::Depth,
5311        ) -> fidl::Result<()> {
5312            encoder.debug_check_bounds::<HandsFreeWatchPeerConnectedResponse>(offset);
5313            // Zero out padding regions. There's no need to apply masks
5314            // because the unmasked parts will be overwritten by fields.
5315            unsafe {
5316                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
5317                (ptr as *mut u64).write_unaligned(0);
5318            }
5319            // Write the fields.
5320            self.0.encode(encoder, offset + 0, depth)?;
5321            self.1.encode(encoder, offset + 8, depth)?;
5322            Ok(())
5323        }
5324    }
5325
5326    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5327        for HandsFreeWatchPeerConnectedResponse
5328    {
5329        #[inline(always)]
5330        fn new_empty() -> Self {
5331            Self {
5332                id: fidl::new_empty!(
5333                    fidl_fuchsia_bluetooth::PeerId,
5334                    fidl::encoding::DefaultFuchsiaResourceDialect
5335                ),
5336                handle: fidl::new_empty!(
5337                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PeerHandlerMarker>>,
5338                    fidl::encoding::DefaultFuchsiaResourceDialect
5339                ),
5340            }
5341        }
5342
5343        #[inline]
5344        unsafe fn decode(
5345            &mut self,
5346            decoder: &mut fidl::encoding::Decoder<
5347                '_,
5348                fidl::encoding::DefaultFuchsiaResourceDialect,
5349            >,
5350            offset: usize,
5351            _depth: fidl::encoding::Depth,
5352        ) -> fidl::Result<()> {
5353            decoder.debug_check_bounds::<Self>(offset);
5354            // Verify that padding bytes are zero.
5355            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
5356            let padval = unsafe { (ptr as *const u64).read_unaligned() };
5357            let mask = 0xffffffff00000000u64;
5358            let maskedval = padval & mask;
5359            if maskedval != 0 {
5360                return Err(fidl::Error::NonZeroPadding {
5361                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
5362                });
5363            }
5364            fidl::decode!(
5365                fidl_fuchsia_bluetooth::PeerId,
5366                fidl::encoding::DefaultFuchsiaResourceDialect,
5367                &mut self.id,
5368                decoder,
5369                offset + 0,
5370                _depth
5371            )?;
5372            fidl::decode!(
5373                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PeerHandlerMarker>>,
5374                fidl::encoding::DefaultFuchsiaResourceDialect,
5375                &mut self.handle,
5376                decoder,
5377                offset + 8,
5378                _depth
5379            )?;
5380            Ok(())
5381        }
5382    }
5383
5384    impl fidl::encoding::ValueTypeMarker for HeadsetGainSetMicrophoneGainRequest {
5385        type Borrowed<'a> = &'a Self;
5386        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5387            value
5388        }
5389    }
5390
5391    unsafe impl fidl::encoding::TypeMarker for HeadsetGainSetMicrophoneGainRequest {
5392        type Owned = Self;
5393
5394        #[inline(always)]
5395        fn inline_align(_context: fidl::encoding::Context) -> usize {
5396            1
5397        }
5398
5399        #[inline(always)]
5400        fn inline_size(_context: fidl::encoding::Context) -> usize {
5401            1
5402        }
5403        #[inline(always)]
5404        fn encode_is_copy() -> bool {
5405            true
5406        }
5407
5408        #[inline(always)]
5409        fn decode_is_copy() -> bool {
5410            true
5411        }
5412    }
5413
5414    unsafe impl<D: fidl::encoding::ResourceDialect>
5415        fidl::encoding::Encode<HeadsetGainSetMicrophoneGainRequest, D>
5416        for &HeadsetGainSetMicrophoneGainRequest
5417    {
5418        #[inline]
5419        unsafe fn encode(
5420            self,
5421            encoder: &mut fidl::encoding::Encoder<'_, D>,
5422            offset: usize,
5423            _depth: fidl::encoding::Depth,
5424        ) -> fidl::Result<()> {
5425            encoder.debug_check_bounds::<HeadsetGainSetMicrophoneGainRequest>(offset);
5426            unsafe {
5427                // Copy the object into the buffer.
5428                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
5429                (buf_ptr as *mut HeadsetGainSetMicrophoneGainRequest)
5430                    .write_unaligned((self as *const HeadsetGainSetMicrophoneGainRequest).read());
5431                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
5432                // done second because the memcpy will write garbage to these bytes.
5433            }
5434            Ok(())
5435        }
5436    }
5437    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
5438        fidl::encoding::Encode<HeadsetGainSetMicrophoneGainRequest, D> for (T0,)
5439    {
5440        #[inline]
5441        unsafe fn encode(
5442            self,
5443            encoder: &mut fidl::encoding::Encoder<'_, D>,
5444            offset: usize,
5445            depth: fidl::encoding::Depth,
5446        ) -> fidl::Result<()> {
5447            encoder.debug_check_bounds::<HeadsetGainSetMicrophoneGainRequest>(offset);
5448            // Zero out padding regions. There's no need to apply masks
5449            // because the unmasked parts will be overwritten by fields.
5450            // Write the fields.
5451            self.0.encode(encoder, offset + 0, depth)?;
5452            Ok(())
5453        }
5454    }
5455
5456    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
5457        for HeadsetGainSetMicrophoneGainRequest
5458    {
5459        #[inline(always)]
5460        fn new_empty() -> Self {
5461            Self { requested: fidl::new_empty!(u8, D) }
5462        }
5463
5464        #[inline]
5465        unsafe fn decode(
5466            &mut self,
5467            decoder: &mut fidl::encoding::Decoder<'_, D>,
5468            offset: usize,
5469            _depth: fidl::encoding::Depth,
5470        ) -> fidl::Result<()> {
5471            decoder.debug_check_bounds::<Self>(offset);
5472            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
5473            // Verify that padding bytes are zero.
5474            // Copy from the buffer into the object.
5475            unsafe {
5476                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
5477            }
5478            Ok(())
5479        }
5480    }
5481
5482    impl fidl::encoding::ValueTypeMarker for HeadsetGainSetSpeakerGainRequest {
5483        type Borrowed<'a> = &'a Self;
5484        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5485            value
5486        }
5487    }
5488
5489    unsafe impl fidl::encoding::TypeMarker for HeadsetGainSetSpeakerGainRequest {
5490        type Owned = Self;
5491
5492        #[inline(always)]
5493        fn inline_align(_context: fidl::encoding::Context) -> usize {
5494            1
5495        }
5496
5497        #[inline(always)]
5498        fn inline_size(_context: fidl::encoding::Context) -> usize {
5499            1
5500        }
5501        #[inline(always)]
5502        fn encode_is_copy() -> bool {
5503            true
5504        }
5505
5506        #[inline(always)]
5507        fn decode_is_copy() -> bool {
5508            true
5509        }
5510    }
5511
5512    unsafe impl<D: fidl::encoding::ResourceDialect>
5513        fidl::encoding::Encode<HeadsetGainSetSpeakerGainRequest, D>
5514        for &HeadsetGainSetSpeakerGainRequest
5515    {
5516        #[inline]
5517        unsafe fn encode(
5518            self,
5519            encoder: &mut fidl::encoding::Encoder<'_, D>,
5520            offset: usize,
5521            _depth: fidl::encoding::Depth,
5522        ) -> fidl::Result<()> {
5523            encoder.debug_check_bounds::<HeadsetGainSetSpeakerGainRequest>(offset);
5524            unsafe {
5525                // Copy the object into the buffer.
5526                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
5527                (buf_ptr as *mut HeadsetGainSetSpeakerGainRequest)
5528                    .write_unaligned((self as *const HeadsetGainSetSpeakerGainRequest).read());
5529                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
5530                // done second because the memcpy will write garbage to these bytes.
5531            }
5532            Ok(())
5533        }
5534    }
5535    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
5536        fidl::encoding::Encode<HeadsetGainSetSpeakerGainRequest, D> for (T0,)
5537    {
5538        #[inline]
5539        unsafe fn encode(
5540            self,
5541            encoder: &mut fidl::encoding::Encoder<'_, D>,
5542            offset: usize,
5543            depth: fidl::encoding::Depth,
5544        ) -> fidl::Result<()> {
5545            encoder.debug_check_bounds::<HeadsetGainSetSpeakerGainRequest>(offset);
5546            // Zero out padding regions. There's no need to apply masks
5547            // because the unmasked parts will be overwritten by fields.
5548            // Write the fields.
5549            self.0.encode(encoder, offset + 0, depth)?;
5550            Ok(())
5551        }
5552    }
5553
5554    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
5555        for HeadsetGainSetSpeakerGainRequest
5556    {
5557        #[inline(always)]
5558        fn new_empty() -> Self {
5559            Self { requested: fidl::new_empty!(u8, D) }
5560        }
5561
5562        #[inline]
5563        unsafe fn decode(
5564            &mut self,
5565            decoder: &mut fidl::encoding::Decoder<'_, D>,
5566            offset: usize,
5567            _depth: fidl::encoding::Depth,
5568        ) -> fidl::Result<()> {
5569            decoder.debug_check_bounds::<Self>(offset);
5570            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
5571            // Verify that padding bytes are zero.
5572            // Copy from the buffer into the object.
5573            unsafe {
5574                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
5575            }
5576            Ok(())
5577        }
5578    }
5579
5580    impl fidl::encoding::ValueTypeMarker for HeadsetGainWatchMicrophoneGainResponse {
5581        type Borrowed<'a> = &'a Self;
5582        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5583            value
5584        }
5585    }
5586
5587    unsafe impl fidl::encoding::TypeMarker for HeadsetGainWatchMicrophoneGainResponse {
5588        type Owned = Self;
5589
5590        #[inline(always)]
5591        fn inline_align(_context: fidl::encoding::Context) -> usize {
5592            1
5593        }
5594
5595        #[inline(always)]
5596        fn inline_size(_context: fidl::encoding::Context) -> usize {
5597            1
5598        }
5599        #[inline(always)]
5600        fn encode_is_copy() -> bool {
5601            true
5602        }
5603
5604        #[inline(always)]
5605        fn decode_is_copy() -> bool {
5606            true
5607        }
5608    }
5609
5610    unsafe impl<D: fidl::encoding::ResourceDialect>
5611        fidl::encoding::Encode<HeadsetGainWatchMicrophoneGainResponse, D>
5612        for &HeadsetGainWatchMicrophoneGainResponse
5613    {
5614        #[inline]
5615        unsafe fn encode(
5616            self,
5617            encoder: &mut fidl::encoding::Encoder<'_, D>,
5618            offset: usize,
5619            _depth: fidl::encoding::Depth,
5620        ) -> fidl::Result<()> {
5621            encoder.debug_check_bounds::<HeadsetGainWatchMicrophoneGainResponse>(offset);
5622            unsafe {
5623                // Copy the object into the buffer.
5624                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
5625                (buf_ptr as *mut HeadsetGainWatchMicrophoneGainResponse).write_unaligned(
5626                    (self as *const HeadsetGainWatchMicrophoneGainResponse).read(),
5627                );
5628                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
5629                // done second because the memcpy will write garbage to these bytes.
5630            }
5631            Ok(())
5632        }
5633    }
5634    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
5635        fidl::encoding::Encode<HeadsetGainWatchMicrophoneGainResponse, D> for (T0,)
5636    {
5637        #[inline]
5638        unsafe fn encode(
5639            self,
5640            encoder: &mut fidl::encoding::Encoder<'_, D>,
5641            offset: usize,
5642            depth: fidl::encoding::Depth,
5643        ) -> fidl::Result<()> {
5644            encoder.debug_check_bounds::<HeadsetGainWatchMicrophoneGainResponse>(offset);
5645            // Zero out padding regions. There's no need to apply masks
5646            // because the unmasked parts will be overwritten by fields.
5647            // Write the fields.
5648            self.0.encode(encoder, offset + 0, depth)?;
5649            Ok(())
5650        }
5651    }
5652
5653    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
5654        for HeadsetGainWatchMicrophoneGainResponse
5655    {
5656        #[inline(always)]
5657        fn new_empty() -> Self {
5658            Self { gain: fidl::new_empty!(u8, D) }
5659        }
5660
5661        #[inline]
5662        unsafe fn decode(
5663            &mut self,
5664            decoder: &mut fidl::encoding::Decoder<'_, D>,
5665            offset: usize,
5666            _depth: fidl::encoding::Depth,
5667        ) -> fidl::Result<()> {
5668            decoder.debug_check_bounds::<Self>(offset);
5669            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
5670            // Verify that padding bytes are zero.
5671            // Copy from the buffer into the object.
5672            unsafe {
5673                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
5674            }
5675            Ok(())
5676        }
5677    }
5678
5679    impl fidl::encoding::ValueTypeMarker for HeadsetGainWatchSpeakerGainResponse {
5680        type Borrowed<'a> = &'a Self;
5681        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
5682            value
5683        }
5684    }
5685
5686    unsafe impl fidl::encoding::TypeMarker for HeadsetGainWatchSpeakerGainResponse {
5687        type Owned = Self;
5688
5689        #[inline(always)]
5690        fn inline_align(_context: fidl::encoding::Context) -> usize {
5691            1
5692        }
5693
5694        #[inline(always)]
5695        fn inline_size(_context: fidl::encoding::Context) -> usize {
5696            1
5697        }
5698        #[inline(always)]
5699        fn encode_is_copy() -> bool {
5700            true
5701        }
5702
5703        #[inline(always)]
5704        fn decode_is_copy() -> bool {
5705            true
5706        }
5707    }
5708
5709    unsafe impl<D: fidl::encoding::ResourceDialect>
5710        fidl::encoding::Encode<HeadsetGainWatchSpeakerGainResponse, D>
5711        for &HeadsetGainWatchSpeakerGainResponse
5712    {
5713        #[inline]
5714        unsafe fn encode(
5715            self,
5716            encoder: &mut fidl::encoding::Encoder<'_, D>,
5717            offset: usize,
5718            _depth: fidl::encoding::Depth,
5719        ) -> fidl::Result<()> {
5720            encoder.debug_check_bounds::<HeadsetGainWatchSpeakerGainResponse>(offset);
5721            unsafe {
5722                // Copy the object into the buffer.
5723                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
5724                (buf_ptr as *mut HeadsetGainWatchSpeakerGainResponse)
5725                    .write_unaligned((self as *const HeadsetGainWatchSpeakerGainResponse).read());
5726                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
5727                // done second because the memcpy will write garbage to these bytes.
5728            }
5729            Ok(())
5730        }
5731    }
5732    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
5733        fidl::encoding::Encode<HeadsetGainWatchSpeakerGainResponse, D> for (T0,)
5734    {
5735        #[inline]
5736        unsafe fn encode(
5737            self,
5738            encoder: &mut fidl::encoding::Encoder<'_, D>,
5739            offset: usize,
5740            depth: fidl::encoding::Depth,
5741        ) -> fidl::Result<()> {
5742            encoder.debug_check_bounds::<HeadsetGainWatchSpeakerGainResponse>(offset);
5743            // Zero out padding regions. There's no need to apply masks
5744            // because the unmasked parts will be overwritten by fields.
5745            // Write the fields.
5746            self.0.encode(encoder, offset + 0, depth)?;
5747            Ok(())
5748        }
5749    }
5750
5751    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
5752        for HeadsetGainWatchSpeakerGainResponse
5753    {
5754        #[inline(always)]
5755        fn new_empty() -> Self {
5756            Self { gain: fidl::new_empty!(u8, D) }
5757        }
5758
5759        #[inline]
5760        unsafe fn decode(
5761            &mut self,
5762            decoder: &mut fidl::encoding::Decoder<'_, D>,
5763            offset: usize,
5764            _depth: fidl::encoding::Depth,
5765        ) -> fidl::Result<()> {
5766            decoder.debug_check_bounds::<Self>(offset);
5767            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
5768            // Verify that padding bytes are zero.
5769            // Copy from the buffer into the object.
5770            unsafe {
5771                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
5772            }
5773            Ok(())
5774        }
5775    }
5776
5777    impl fidl::encoding::ResourceTypeMarker for HfpRegisterRequest {
5778        type Borrowed<'a> = &'a mut Self;
5779        fn take_or_borrow<'a>(
5780            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5781        ) -> Self::Borrowed<'a> {
5782            value
5783        }
5784    }
5785
5786    unsafe impl fidl::encoding::TypeMarker for HfpRegisterRequest {
5787        type Owned = Self;
5788
5789        #[inline(always)]
5790        fn inline_align(_context: fidl::encoding::Context) -> usize {
5791            4
5792        }
5793
5794        #[inline(always)]
5795        fn inline_size(_context: fidl::encoding::Context) -> usize {
5796            4
5797        }
5798    }
5799
5800    unsafe impl
5801        fidl::encoding::Encode<HfpRegisterRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
5802        for &mut HfpRegisterRequest
5803    {
5804        #[inline]
5805        unsafe fn encode(
5806            self,
5807            encoder: &mut fidl::encoding::Encoder<
5808                '_,
5809                fidl::encoding::DefaultFuchsiaResourceDialect,
5810            >,
5811            offset: usize,
5812            _depth: fidl::encoding::Depth,
5813        ) -> fidl::Result<()> {
5814            encoder.debug_check_bounds::<HfpRegisterRequest>(offset);
5815            // Delegate to tuple encoding.
5816            fidl::encoding::Encode::<HfpRegisterRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5817                (
5818                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallManagerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.manager),
5819                ),
5820                encoder, offset, _depth
5821            )
5822        }
5823    }
5824    unsafe impl<
5825            T0: fidl::encoding::Encode<
5826                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallManagerMarker>>,
5827                fidl::encoding::DefaultFuchsiaResourceDialect,
5828            >,
5829        >
5830        fidl::encoding::Encode<HfpRegisterRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
5831        for (T0,)
5832    {
5833        #[inline]
5834        unsafe fn encode(
5835            self,
5836            encoder: &mut fidl::encoding::Encoder<
5837                '_,
5838                fidl::encoding::DefaultFuchsiaResourceDialect,
5839            >,
5840            offset: usize,
5841            depth: fidl::encoding::Depth,
5842        ) -> fidl::Result<()> {
5843            encoder.debug_check_bounds::<HfpRegisterRequest>(offset);
5844            // Zero out padding regions. There's no need to apply masks
5845            // because the unmasked parts will be overwritten by fields.
5846            // Write the fields.
5847            self.0.encode(encoder, offset + 0, depth)?;
5848            Ok(())
5849        }
5850    }
5851
5852    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5853        for HfpRegisterRequest
5854    {
5855        #[inline(always)]
5856        fn new_empty() -> Self {
5857            Self {
5858                manager: fidl::new_empty!(
5859                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallManagerMarker>>,
5860                    fidl::encoding::DefaultFuchsiaResourceDialect
5861                ),
5862            }
5863        }
5864
5865        #[inline]
5866        unsafe fn decode(
5867            &mut self,
5868            decoder: &mut fidl::encoding::Decoder<
5869                '_,
5870                fidl::encoding::DefaultFuchsiaResourceDialect,
5871            >,
5872            offset: usize,
5873            _depth: fidl::encoding::Depth,
5874        ) -> fidl::Result<()> {
5875            decoder.debug_check_bounds::<Self>(offset);
5876            // Verify that padding bytes are zero.
5877            fidl::decode!(
5878                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallManagerMarker>>,
5879                fidl::encoding::DefaultFuchsiaResourceDialect,
5880                &mut self.manager,
5881                decoder,
5882                offset + 0,
5883                _depth
5884            )?;
5885            Ok(())
5886        }
5887    }
5888
5889    impl fidl::encoding::ResourceTypeMarker for PeerHandlerGainControlRequest {
5890        type Borrowed<'a> = &'a mut Self;
5891        fn take_or_borrow<'a>(
5892            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5893        ) -> Self::Borrowed<'a> {
5894            value
5895        }
5896    }
5897
5898    unsafe impl fidl::encoding::TypeMarker for PeerHandlerGainControlRequest {
5899        type Owned = Self;
5900
5901        #[inline(always)]
5902        fn inline_align(_context: fidl::encoding::Context) -> usize {
5903            4
5904        }
5905
5906        #[inline(always)]
5907        fn inline_size(_context: fidl::encoding::Context) -> usize {
5908            4
5909        }
5910    }
5911
5912    unsafe impl
5913        fidl::encoding::Encode<
5914            PeerHandlerGainControlRequest,
5915            fidl::encoding::DefaultFuchsiaResourceDialect,
5916        > for &mut PeerHandlerGainControlRequest
5917    {
5918        #[inline]
5919        unsafe fn encode(
5920            self,
5921            encoder: &mut fidl::encoding::Encoder<
5922                '_,
5923                fidl::encoding::DefaultFuchsiaResourceDialect,
5924            >,
5925            offset: usize,
5926            _depth: fidl::encoding::Depth,
5927        ) -> fidl::Result<()> {
5928            encoder.debug_check_bounds::<PeerHandlerGainControlRequest>(offset);
5929            // Delegate to tuple encoding.
5930            fidl::encoding::Encode::<PeerHandlerGainControlRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5931                (
5932                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HeadsetGainMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.control),
5933                ),
5934                encoder, offset, _depth
5935            )
5936        }
5937    }
5938    unsafe impl<
5939            T0: fidl::encoding::Encode<
5940                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HeadsetGainMarker>>,
5941                fidl::encoding::DefaultFuchsiaResourceDialect,
5942            >,
5943        >
5944        fidl::encoding::Encode<
5945            PeerHandlerGainControlRequest,
5946            fidl::encoding::DefaultFuchsiaResourceDialect,
5947        > for (T0,)
5948    {
5949        #[inline]
5950        unsafe fn encode(
5951            self,
5952            encoder: &mut fidl::encoding::Encoder<
5953                '_,
5954                fidl::encoding::DefaultFuchsiaResourceDialect,
5955            >,
5956            offset: usize,
5957            depth: fidl::encoding::Depth,
5958        ) -> fidl::Result<()> {
5959            encoder.debug_check_bounds::<PeerHandlerGainControlRequest>(offset);
5960            // Zero out padding regions. There's no need to apply masks
5961            // because the unmasked parts will be overwritten by fields.
5962            // Write the fields.
5963            self.0.encode(encoder, offset + 0, depth)?;
5964            Ok(())
5965        }
5966    }
5967
5968    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5969        for PeerHandlerGainControlRequest
5970    {
5971        #[inline(always)]
5972        fn new_empty() -> Self {
5973            Self {
5974                control: fidl::new_empty!(
5975                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HeadsetGainMarker>>,
5976                    fidl::encoding::DefaultFuchsiaResourceDialect
5977                ),
5978            }
5979        }
5980
5981        #[inline]
5982        unsafe fn decode(
5983            &mut self,
5984            decoder: &mut fidl::encoding::Decoder<
5985                '_,
5986                fidl::encoding::DefaultFuchsiaResourceDialect,
5987            >,
5988            offset: usize,
5989            _depth: fidl::encoding::Depth,
5990        ) -> fidl::Result<()> {
5991            decoder.debug_check_bounds::<Self>(offset);
5992            // Verify that padding bytes are zero.
5993            fidl::decode!(
5994                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HeadsetGainMarker>>,
5995                fidl::encoding::DefaultFuchsiaResourceDialect,
5996                &mut self.control,
5997                decoder,
5998                offset + 0,
5999                _depth
6000            )?;
6001            Ok(())
6002        }
6003    }
6004
6005    impl fidl::encoding::ValueTypeMarker for PeerHandlerQueryOperatorResponse {
6006        type Borrowed<'a> = &'a Self;
6007        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6008            value
6009        }
6010    }
6011
6012    unsafe impl fidl::encoding::TypeMarker for PeerHandlerQueryOperatorResponse {
6013        type Owned = Self;
6014
6015        #[inline(always)]
6016        fn inline_align(_context: fidl::encoding::Context) -> usize {
6017            8
6018        }
6019
6020        #[inline(always)]
6021        fn inline_size(_context: fidl::encoding::Context) -> usize {
6022            16
6023        }
6024    }
6025
6026    unsafe impl<D: fidl::encoding::ResourceDialect>
6027        fidl::encoding::Encode<PeerHandlerQueryOperatorResponse, D>
6028        for &PeerHandlerQueryOperatorResponse
6029    {
6030        #[inline]
6031        unsafe fn encode(
6032            self,
6033            encoder: &mut fidl::encoding::Encoder<'_, D>,
6034            offset: usize,
6035            _depth: fidl::encoding::Depth,
6036        ) -> fidl::Result<()> {
6037            encoder.debug_check_bounds::<PeerHandlerQueryOperatorResponse>(offset);
6038            // Delegate to tuple encoding.
6039            fidl::encoding::Encode::<PeerHandlerQueryOperatorResponse, D>::encode(
6040                (
6041                    <fidl::encoding::Optional<fidl::encoding::BoundedString<16>> as fidl::encoding::ValueTypeMarker>::borrow(&self.operator),
6042                ),
6043                encoder, offset, _depth
6044            )
6045        }
6046    }
6047    unsafe impl<
6048            D: fidl::encoding::ResourceDialect,
6049            T0: fidl::encoding::Encode<fidl::encoding::Optional<fidl::encoding::BoundedString<16>>, D>,
6050        > fidl::encoding::Encode<PeerHandlerQueryOperatorResponse, D> for (T0,)
6051    {
6052        #[inline]
6053        unsafe fn encode(
6054            self,
6055            encoder: &mut fidl::encoding::Encoder<'_, D>,
6056            offset: usize,
6057            depth: fidl::encoding::Depth,
6058        ) -> fidl::Result<()> {
6059            encoder.debug_check_bounds::<PeerHandlerQueryOperatorResponse>(offset);
6060            // Zero out padding regions. There's no need to apply masks
6061            // because the unmasked parts will be overwritten by fields.
6062            // Write the fields.
6063            self.0.encode(encoder, offset + 0, depth)?;
6064            Ok(())
6065        }
6066    }
6067
6068    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
6069        for PeerHandlerQueryOperatorResponse
6070    {
6071        #[inline(always)]
6072        fn new_empty() -> Self {
6073            Self {
6074                operator: fidl::new_empty!(
6075                    fidl::encoding::Optional<fidl::encoding::BoundedString<16>>,
6076                    D
6077                ),
6078            }
6079        }
6080
6081        #[inline]
6082        unsafe fn decode(
6083            &mut self,
6084            decoder: &mut fidl::encoding::Decoder<'_, D>,
6085            offset: usize,
6086            _depth: fidl::encoding::Depth,
6087        ) -> fidl::Result<()> {
6088            decoder.debug_check_bounds::<Self>(offset);
6089            // Verify that padding bytes are zero.
6090            fidl::decode!(
6091                fidl::encoding::Optional<fidl::encoding::BoundedString<16>>,
6092                D,
6093                &mut self.operator,
6094                decoder,
6095                offset + 0,
6096                _depth
6097            )?;
6098            Ok(())
6099        }
6100    }
6101
6102    impl fidl::encoding::ValueTypeMarker for PeerHandlerReportHeadsetBatteryLevelRequest {
6103        type Borrowed<'a> = &'a Self;
6104        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6105            value
6106        }
6107    }
6108
6109    unsafe impl fidl::encoding::TypeMarker for PeerHandlerReportHeadsetBatteryLevelRequest {
6110        type Owned = Self;
6111
6112        #[inline(always)]
6113        fn inline_align(_context: fidl::encoding::Context) -> usize {
6114            1
6115        }
6116
6117        #[inline(always)]
6118        fn inline_size(_context: fidl::encoding::Context) -> usize {
6119            1
6120        }
6121        #[inline(always)]
6122        fn encode_is_copy() -> bool {
6123            true
6124        }
6125
6126        #[inline(always)]
6127        fn decode_is_copy() -> bool {
6128            true
6129        }
6130    }
6131
6132    unsafe impl<D: fidl::encoding::ResourceDialect>
6133        fidl::encoding::Encode<PeerHandlerReportHeadsetBatteryLevelRequest, D>
6134        for &PeerHandlerReportHeadsetBatteryLevelRequest
6135    {
6136        #[inline]
6137        unsafe fn encode(
6138            self,
6139            encoder: &mut fidl::encoding::Encoder<'_, D>,
6140            offset: usize,
6141            _depth: fidl::encoding::Depth,
6142        ) -> fidl::Result<()> {
6143            encoder.debug_check_bounds::<PeerHandlerReportHeadsetBatteryLevelRequest>(offset);
6144            unsafe {
6145                // Copy the object into the buffer.
6146                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
6147                (buf_ptr as *mut PeerHandlerReportHeadsetBatteryLevelRequest).write_unaligned(
6148                    (self as *const PeerHandlerReportHeadsetBatteryLevelRequest).read(),
6149                );
6150                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
6151                // done second because the memcpy will write garbage to these bytes.
6152            }
6153            Ok(())
6154        }
6155    }
6156    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
6157        fidl::encoding::Encode<PeerHandlerReportHeadsetBatteryLevelRequest, D> for (T0,)
6158    {
6159        #[inline]
6160        unsafe fn encode(
6161            self,
6162            encoder: &mut fidl::encoding::Encoder<'_, D>,
6163            offset: usize,
6164            depth: fidl::encoding::Depth,
6165        ) -> fidl::Result<()> {
6166            encoder.debug_check_bounds::<PeerHandlerReportHeadsetBatteryLevelRequest>(offset);
6167            // Zero out padding regions. There's no need to apply masks
6168            // because the unmasked parts will be overwritten by fields.
6169            // Write the fields.
6170            self.0.encode(encoder, offset + 0, depth)?;
6171            Ok(())
6172        }
6173    }
6174
6175    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
6176        for PeerHandlerReportHeadsetBatteryLevelRequest
6177    {
6178        #[inline(always)]
6179        fn new_empty() -> Self {
6180            Self { level: fidl::new_empty!(u8, D) }
6181        }
6182
6183        #[inline]
6184        unsafe fn decode(
6185            &mut self,
6186            decoder: &mut fidl::encoding::Decoder<'_, D>,
6187            offset: usize,
6188            _depth: fidl::encoding::Depth,
6189        ) -> fidl::Result<()> {
6190            decoder.debug_check_bounds::<Self>(offset);
6191            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
6192            // Verify that padding bytes are zero.
6193            // Copy from the buffer into the object.
6194            unsafe {
6195                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
6196            }
6197            Ok(())
6198        }
6199    }
6200
6201    impl fidl::encoding::ValueTypeMarker for PeerHandlerRequestOutgoingCallRequest {
6202        type Borrowed<'a> = &'a Self;
6203        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6204            value
6205        }
6206    }
6207
6208    unsafe impl fidl::encoding::TypeMarker for PeerHandlerRequestOutgoingCallRequest {
6209        type Owned = Self;
6210
6211        #[inline(always)]
6212        fn inline_align(_context: fidl::encoding::Context) -> usize {
6213            8
6214        }
6215
6216        #[inline(always)]
6217        fn inline_size(_context: fidl::encoding::Context) -> usize {
6218            16
6219        }
6220    }
6221
6222    unsafe impl<D: fidl::encoding::ResourceDialect>
6223        fidl::encoding::Encode<PeerHandlerRequestOutgoingCallRequest, D>
6224        for &PeerHandlerRequestOutgoingCallRequest
6225    {
6226        #[inline]
6227        unsafe fn encode(
6228            self,
6229            encoder: &mut fidl::encoding::Encoder<'_, D>,
6230            offset: usize,
6231            _depth: fidl::encoding::Depth,
6232        ) -> fidl::Result<()> {
6233            encoder.debug_check_bounds::<PeerHandlerRequestOutgoingCallRequest>(offset);
6234            // Delegate to tuple encoding.
6235            fidl::encoding::Encode::<PeerHandlerRequestOutgoingCallRequest, D>::encode(
6236                (<CallAction as fidl::encoding::ValueTypeMarker>::borrow(&self.action),),
6237                encoder,
6238                offset,
6239                _depth,
6240            )
6241        }
6242    }
6243    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<CallAction, D>>
6244        fidl::encoding::Encode<PeerHandlerRequestOutgoingCallRequest, D> for (T0,)
6245    {
6246        #[inline]
6247        unsafe fn encode(
6248            self,
6249            encoder: &mut fidl::encoding::Encoder<'_, D>,
6250            offset: usize,
6251            depth: fidl::encoding::Depth,
6252        ) -> fidl::Result<()> {
6253            encoder.debug_check_bounds::<PeerHandlerRequestOutgoingCallRequest>(offset);
6254            // Zero out padding regions. There's no need to apply masks
6255            // because the unmasked parts will be overwritten by fields.
6256            // Write the fields.
6257            self.0.encode(encoder, offset + 0, depth)?;
6258            Ok(())
6259        }
6260    }
6261
6262    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
6263        for PeerHandlerRequestOutgoingCallRequest
6264    {
6265        #[inline(always)]
6266        fn new_empty() -> Self {
6267            Self { action: fidl::new_empty!(CallAction, D) }
6268        }
6269
6270        #[inline]
6271        unsafe fn decode(
6272            &mut self,
6273            decoder: &mut fidl::encoding::Decoder<'_, D>,
6274            offset: usize,
6275            _depth: fidl::encoding::Depth,
6276        ) -> fidl::Result<()> {
6277            decoder.debug_check_bounds::<Self>(offset);
6278            // Verify that padding bytes are zero.
6279            fidl::decode!(CallAction, D, &mut self.action, decoder, offset + 0, _depth)?;
6280            Ok(())
6281        }
6282    }
6283
6284    impl fidl::encoding::ValueTypeMarker for PeerHandlerSetNrecModeRequest {
6285        type Borrowed<'a> = &'a Self;
6286        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6287            value
6288        }
6289    }
6290
6291    unsafe impl fidl::encoding::TypeMarker for PeerHandlerSetNrecModeRequest {
6292        type Owned = Self;
6293
6294        #[inline(always)]
6295        fn inline_align(_context: fidl::encoding::Context) -> usize {
6296            1
6297        }
6298
6299        #[inline(always)]
6300        fn inline_size(_context: fidl::encoding::Context) -> usize {
6301            1
6302        }
6303    }
6304
6305    unsafe impl<D: fidl::encoding::ResourceDialect>
6306        fidl::encoding::Encode<PeerHandlerSetNrecModeRequest, D>
6307        for &PeerHandlerSetNrecModeRequest
6308    {
6309        #[inline]
6310        unsafe fn encode(
6311            self,
6312            encoder: &mut fidl::encoding::Encoder<'_, D>,
6313            offset: usize,
6314            _depth: fidl::encoding::Depth,
6315        ) -> fidl::Result<()> {
6316            encoder.debug_check_bounds::<PeerHandlerSetNrecModeRequest>(offset);
6317            // Delegate to tuple encoding.
6318            fidl::encoding::Encode::<PeerHandlerSetNrecModeRequest, D>::encode(
6319                (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enabled),),
6320                encoder,
6321                offset,
6322                _depth,
6323            )
6324        }
6325    }
6326    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
6327        fidl::encoding::Encode<PeerHandlerSetNrecModeRequest, D> for (T0,)
6328    {
6329        #[inline]
6330        unsafe fn encode(
6331            self,
6332            encoder: &mut fidl::encoding::Encoder<'_, D>,
6333            offset: usize,
6334            depth: fidl::encoding::Depth,
6335        ) -> fidl::Result<()> {
6336            encoder.debug_check_bounds::<PeerHandlerSetNrecModeRequest>(offset);
6337            // Zero out padding regions. There's no need to apply masks
6338            // because the unmasked parts will be overwritten by fields.
6339            // Write the fields.
6340            self.0.encode(encoder, offset + 0, depth)?;
6341            Ok(())
6342        }
6343    }
6344
6345    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
6346        for PeerHandlerSetNrecModeRequest
6347    {
6348        #[inline(always)]
6349        fn new_empty() -> Self {
6350            Self { enabled: fidl::new_empty!(bool, D) }
6351        }
6352
6353        #[inline]
6354        unsafe fn decode(
6355            &mut self,
6356            decoder: &mut fidl::encoding::Decoder<'_, D>,
6357            offset: usize,
6358            _depth: fidl::encoding::Depth,
6359        ) -> fidl::Result<()> {
6360            decoder.debug_check_bounds::<Self>(offset);
6361            // Verify that padding bytes are zero.
6362            fidl::decode!(bool, D, &mut self.enabled, decoder, offset + 0, _depth)?;
6363            Ok(())
6364        }
6365    }
6366
6367    impl fidl::encoding::ValueTypeMarker for PeerHandlerSubscriberNumberInformationResponse {
6368        type Borrowed<'a> = &'a Self;
6369        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6370            value
6371        }
6372    }
6373
6374    unsafe impl fidl::encoding::TypeMarker for PeerHandlerSubscriberNumberInformationResponse {
6375        type Owned = Self;
6376
6377        #[inline(always)]
6378        fn inline_align(_context: fidl::encoding::Context) -> usize {
6379            8
6380        }
6381
6382        #[inline(always)]
6383        fn inline_size(_context: fidl::encoding::Context) -> usize {
6384            16
6385        }
6386    }
6387
6388    unsafe impl<D: fidl::encoding::ResourceDialect>
6389        fidl::encoding::Encode<PeerHandlerSubscriberNumberInformationResponse, D>
6390        for &PeerHandlerSubscriberNumberInformationResponse
6391    {
6392        #[inline]
6393        unsafe fn encode(
6394            self,
6395            encoder: &mut fidl::encoding::Encoder<'_, D>,
6396            offset: usize,
6397            _depth: fidl::encoding::Depth,
6398        ) -> fidl::Result<()> {
6399            encoder.debug_check_bounds::<PeerHandlerSubscriberNumberInformationResponse>(offset);
6400            // Delegate to tuple encoding.
6401            fidl::encoding::Encode::<PeerHandlerSubscriberNumberInformationResponse, D>::encode(
6402                (
6403                    <fidl::encoding::Vector<fidl::encoding::BoundedString<256>, 128> as fidl::encoding::ValueTypeMarker>::borrow(&self.numbers),
6404                ),
6405                encoder, offset, _depth
6406            )
6407        }
6408    }
6409    unsafe impl<
6410            D: fidl::encoding::ResourceDialect,
6411            T0: fidl::encoding::Encode<
6412                fidl::encoding::Vector<fidl::encoding::BoundedString<256>, 128>,
6413                D,
6414            >,
6415        > fidl::encoding::Encode<PeerHandlerSubscriberNumberInformationResponse, D> for (T0,)
6416    {
6417        #[inline]
6418        unsafe fn encode(
6419            self,
6420            encoder: &mut fidl::encoding::Encoder<'_, D>,
6421            offset: usize,
6422            depth: fidl::encoding::Depth,
6423        ) -> fidl::Result<()> {
6424            encoder.debug_check_bounds::<PeerHandlerSubscriberNumberInformationResponse>(offset);
6425            // Zero out padding regions. There's no need to apply masks
6426            // because the unmasked parts will be overwritten by fields.
6427            // Write the fields.
6428            self.0.encode(encoder, offset + 0, depth)?;
6429            Ok(())
6430        }
6431    }
6432
6433    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
6434        for PeerHandlerSubscriberNumberInformationResponse
6435    {
6436        #[inline(always)]
6437        fn new_empty() -> Self {
6438            Self {
6439                numbers: fidl::new_empty!(
6440                    fidl::encoding::Vector<fidl::encoding::BoundedString<256>, 128>,
6441                    D
6442                ),
6443            }
6444        }
6445
6446        #[inline]
6447        unsafe fn decode(
6448            &mut self,
6449            decoder: &mut fidl::encoding::Decoder<'_, D>,
6450            offset: usize,
6451            _depth: fidl::encoding::Depth,
6452        ) -> fidl::Result<()> {
6453            decoder.debug_check_bounds::<Self>(offset);
6454            // Verify that padding bytes are zero.
6455            fidl::decode!(
6456                fidl::encoding::Vector<fidl::encoding::BoundedString<256>, 128>,
6457                D,
6458                &mut self.numbers,
6459                decoder,
6460                offset + 0,
6461                _depth
6462            )?;
6463            Ok(())
6464        }
6465    }
6466
6467    impl fidl::encoding::ValueTypeMarker for PeerHandlerWatchNetworkInformationResponse {
6468        type Borrowed<'a> = &'a Self;
6469        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6470            value
6471        }
6472    }
6473
6474    unsafe impl fidl::encoding::TypeMarker for PeerHandlerWatchNetworkInformationResponse {
6475        type Owned = Self;
6476
6477        #[inline(always)]
6478        fn inline_align(_context: fidl::encoding::Context) -> usize {
6479            8
6480        }
6481
6482        #[inline(always)]
6483        fn inline_size(_context: fidl::encoding::Context) -> usize {
6484            16
6485        }
6486    }
6487
6488    unsafe impl<D: fidl::encoding::ResourceDialect>
6489        fidl::encoding::Encode<PeerHandlerWatchNetworkInformationResponse, D>
6490        for &PeerHandlerWatchNetworkInformationResponse
6491    {
6492        #[inline]
6493        unsafe fn encode(
6494            self,
6495            encoder: &mut fidl::encoding::Encoder<'_, D>,
6496            offset: usize,
6497            _depth: fidl::encoding::Depth,
6498        ) -> fidl::Result<()> {
6499            encoder.debug_check_bounds::<PeerHandlerWatchNetworkInformationResponse>(offset);
6500            // Delegate to tuple encoding.
6501            fidl::encoding::Encode::<PeerHandlerWatchNetworkInformationResponse, D>::encode(
6502                (<NetworkInformation as fidl::encoding::ValueTypeMarker>::borrow(&self.update),),
6503                encoder,
6504                offset,
6505                _depth,
6506            )
6507        }
6508    }
6509    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<NetworkInformation, D>>
6510        fidl::encoding::Encode<PeerHandlerWatchNetworkInformationResponse, D> for (T0,)
6511    {
6512        #[inline]
6513        unsafe fn encode(
6514            self,
6515            encoder: &mut fidl::encoding::Encoder<'_, D>,
6516            offset: usize,
6517            depth: fidl::encoding::Depth,
6518        ) -> fidl::Result<()> {
6519            encoder.debug_check_bounds::<PeerHandlerWatchNetworkInformationResponse>(offset);
6520            // Zero out padding regions. There's no need to apply masks
6521            // because the unmasked parts will be overwritten by fields.
6522            // Write the fields.
6523            self.0.encode(encoder, offset + 0, depth)?;
6524            Ok(())
6525        }
6526    }
6527
6528    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
6529        for PeerHandlerWatchNetworkInformationResponse
6530    {
6531        #[inline(always)]
6532        fn new_empty() -> Self {
6533            Self { update: fidl::new_empty!(NetworkInformation, D) }
6534        }
6535
6536        #[inline]
6537        unsafe fn decode(
6538            &mut self,
6539            decoder: &mut fidl::encoding::Decoder<'_, D>,
6540            offset: usize,
6541            _depth: fidl::encoding::Depth,
6542        ) -> fidl::Result<()> {
6543            decoder.debug_check_bounds::<Self>(offset);
6544            // Verify that padding bytes are zero.
6545            fidl::decode!(NetworkInformation, D, &mut self.update, decoder, offset + 0, _depth)?;
6546            Ok(())
6547        }
6548    }
6549
6550    impl fidl::encoding::ResourceTypeMarker for PeerHandlerWatchNextCallResponse {
6551        type Borrowed<'a> = &'a mut Self;
6552        fn take_or_borrow<'a>(
6553            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6554        ) -> Self::Borrowed<'a> {
6555            value
6556        }
6557    }
6558
6559    unsafe impl fidl::encoding::TypeMarker for PeerHandlerWatchNextCallResponse {
6560        type Owned = Self;
6561
6562        #[inline(always)]
6563        fn inline_align(_context: fidl::encoding::Context) -> usize {
6564            8
6565        }
6566
6567        #[inline(always)]
6568        fn inline_size(_context: fidl::encoding::Context) -> usize {
6569            16
6570        }
6571    }
6572
6573    unsafe impl
6574        fidl::encoding::Encode<
6575            PeerHandlerWatchNextCallResponse,
6576            fidl::encoding::DefaultFuchsiaResourceDialect,
6577        > for &mut PeerHandlerWatchNextCallResponse
6578    {
6579        #[inline]
6580        unsafe fn encode(
6581            self,
6582            encoder: &mut fidl::encoding::Encoder<
6583                '_,
6584                fidl::encoding::DefaultFuchsiaResourceDialect,
6585            >,
6586            offset: usize,
6587            _depth: fidl::encoding::Depth,
6588        ) -> fidl::Result<()> {
6589            encoder.debug_check_bounds::<PeerHandlerWatchNextCallResponse>(offset);
6590            // Delegate to tuple encoding.
6591            fidl::encoding::Encode::<
6592                PeerHandlerWatchNextCallResponse,
6593                fidl::encoding::DefaultFuchsiaResourceDialect,
6594            >::encode(
6595                (<NextCall as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.call),),
6596                encoder,
6597                offset,
6598                _depth,
6599            )
6600        }
6601    }
6602    unsafe impl<T0: fidl::encoding::Encode<NextCall, fidl::encoding::DefaultFuchsiaResourceDialect>>
6603        fidl::encoding::Encode<
6604            PeerHandlerWatchNextCallResponse,
6605            fidl::encoding::DefaultFuchsiaResourceDialect,
6606        > for (T0,)
6607    {
6608        #[inline]
6609        unsafe fn encode(
6610            self,
6611            encoder: &mut fidl::encoding::Encoder<
6612                '_,
6613                fidl::encoding::DefaultFuchsiaResourceDialect,
6614            >,
6615            offset: usize,
6616            depth: fidl::encoding::Depth,
6617        ) -> fidl::Result<()> {
6618            encoder.debug_check_bounds::<PeerHandlerWatchNextCallResponse>(offset);
6619            // Zero out padding regions. There's no need to apply masks
6620            // because the unmasked parts will be overwritten by fields.
6621            // Write the fields.
6622            self.0.encode(encoder, offset + 0, depth)?;
6623            Ok(())
6624        }
6625    }
6626
6627    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6628        for PeerHandlerWatchNextCallResponse
6629    {
6630        #[inline(always)]
6631        fn new_empty() -> Self {
6632            Self { call: fidl::new_empty!(NextCall, fidl::encoding::DefaultFuchsiaResourceDialect) }
6633        }
6634
6635        #[inline]
6636        unsafe fn decode(
6637            &mut self,
6638            decoder: &mut fidl::encoding::Decoder<
6639                '_,
6640                fidl::encoding::DefaultFuchsiaResourceDialect,
6641            >,
6642            offset: usize,
6643            _depth: fidl::encoding::Depth,
6644        ) -> fidl::Result<()> {
6645            decoder.debug_check_bounds::<Self>(offset);
6646            // Verify that padding bytes are zero.
6647            fidl::decode!(
6648                NextCall,
6649                fidl::encoding::DefaultFuchsiaResourceDialect,
6650                &mut self.call,
6651                decoder,
6652                offset + 0,
6653                _depth
6654            )?;
6655            Ok(())
6656        }
6657    }
6658
6659    impl fidl::encoding::ValueTypeMarker for RedialLast {
6660        type Borrowed<'a> = &'a Self;
6661        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6662            value
6663        }
6664    }
6665
6666    unsafe impl fidl::encoding::TypeMarker for RedialLast {
6667        type Owned = Self;
6668
6669        #[inline(always)]
6670        fn inline_align(_context: fidl::encoding::Context) -> usize {
6671            1
6672        }
6673
6674        #[inline(always)]
6675        fn inline_size(_context: fidl::encoding::Context) -> usize {
6676            1
6677        }
6678    }
6679
6680    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RedialLast, D>
6681        for &RedialLast
6682    {
6683        #[inline]
6684        unsafe fn encode(
6685            self,
6686            encoder: &mut fidl::encoding::Encoder<'_, D>,
6687            offset: usize,
6688            _depth: fidl::encoding::Depth,
6689        ) -> fidl::Result<()> {
6690            encoder.debug_check_bounds::<RedialLast>(offset);
6691            encoder.write_num(0u8, offset);
6692            Ok(())
6693        }
6694    }
6695
6696    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RedialLast {
6697        #[inline(always)]
6698        fn new_empty() -> Self {
6699            Self
6700        }
6701
6702        #[inline]
6703        unsafe fn decode(
6704            &mut self,
6705            decoder: &mut fidl::encoding::Decoder<'_, D>,
6706            offset: usize,
6707            _depth: fidl::encoding::Depth,
6708        ) -> fidl::Result<()> {
6709            decoder.debug_check_bounds::<Self>(offset);
6710            match decoder.read_num::<u8>(offset) {
6711                0 => Ok(()),
6712                _ => Err(fidl::Error::Invalid),
6713            }
6714        }
6715    }
6716
6717    impl fidl::encoding::ValueTypeMarker for TransferActive {
6718        type Borrowed<'a> = &'a Self;
6719        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6720            value
6721        }
6722    }
6723
6724    unsafe impl fidl::encoding::TypeMarker for TransferActive {
6725        type Owned = Self;
6726
6727        #[inline(always)]
6728        fn inline_align(_context: fidl::encoding::Context) -> usize {
6729            1
6730        }
6731
6732        #[inline(always)]
6733        fn inline_size(_context: fidl::encoding::Context) -> usize {
6734            1
6735        }
6736    }
6737
6738    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<TransferActive, D>
6739        for &TransferActive
6740    {
6741        #[inline]
6742        unsafe fn encode(
6743            self,
6744            encoder: &mut fidl::encoding::Encoder<'_, D>,
6745            offset: usize,
6746            _depth: fidl::encoding::Depth,
6747        ) -> fidl::Result<()> {
6748            encoder.debug_check_bounds::<TransferActive>(offset);
6749            encoder.write_num(0u8, offset);
6750            Ok(())
6751        }
6752    }
6753
6754    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TransferActive {
6755        #[inline(always)]
6756        fn new_empty() -> Self {
6757            Self
6758        }
6759
6760        #[inline]
6761        unsafe fn decode(
6762            &mut self,
6763            decoder: &mut fidl::encoding::Decoder<'_, D>,
6764            offset: usize,
6765            _depth: fidl::encoding::Depth,
6766        ) -> fidl::Result<()> {
6767            decoder.debug_check_bounds::<Self>(offset);
6768            match decoder.read_num::<u8>(offset) {
6769                0 => Ok(()),
6770                _ => Err(fidl::Error::Invalid),
6771            }
6772        }
6773    }
6774
6775    impl NetworkInformation {
6776        #[inline(always)]
6777        fn max_ordinal_present(&self) -> u64 {
6778            if let Some(_) = self.roaming {
6779                return 3;
6780            }
6781            if let Some(_) = self.signal_strength {
6782                return 2;
6783            }
6784            if let Some(_) = self.service_available {
6785                return 1;
6786            }
6787            0
6788        }
6789    }
6790
6791    impl fidl::encoding::ValueTypeMarker for NetworkInformation {
6792        type Borrowed<'a> = &'a Self;
6793        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
6794            value
6795        }
6796    }
6797
6798    unsafe impl fidl::encoding::TypeMarker for NetworkInformation {
6799        type Owned = Self;
6800
6801        #[inline(always)]
6802        fn inline_align(_context: fidl::encoding::Context) -> usize {
6803            8
6804        }
6805
6806        #[inline(always)]
6807        fn inline_size(_context: fidl::encoding::Context) -> usize {
6808            16
6809        }
6810    }
6811
6812    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<NetworkInformation, D>
6813        for &NetworkInformation
6814    {
6815        unsafe fn encode(
6816            self,
6817            encoder: &mut fidl::encoding::Encoder<'_, D>,
6818            offset: usize,
6819            mut depth: fidl::encoding::Depth,
6820        ) -> fidl::Result<()> {
6821            encoder.debug_check_bounds::<NetworkInformation>(offset);
6822            // Vector header
6823            let max_ordinal: u64 = self.max_ordinal_present();
6824            encoder.write_num(max_ordinal, offset);
6825            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6826            // Calling encoder.out_of_line_offset(0) is not allowed.
6827            if max_ordinal == 0 {
6828                return Ok(());
6829            }
6830            depth.increment()?;
6831            let envelope_size = 8;
6832            let bytes_len = max_ordinal as usize * envelope_size;
6833            #[allow(unused_variables)]
6834            let offset = encoder.out_of_line_offset(bytes_len);
6835            let mut _prev_end_offset: usize = 0;
6836            if 1 > max_ordinal {
6837                return Ok(());
6838            }
6839
6840            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6841            // are envelope_size bytes.
6842            let cur_offset: usize = (1 - 1) * envelope_size;
6843
6844            // Zero reserved fields.
6845            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6846
6847            // Safety:
6848            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6849            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6850            //   envelope_size bytes, there is always sufficient room.
6851            fidl::encoding::encode_in_envelope_optional::<bool, D>(
6852                self.service_available
6853                    .as_ref()
6854                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
6855                encoder,
6856                offset + cur_offset,
6857                depth,
6858            )?;
6859
6860            _prev_end_offset = cur_offset + envelope_size;
6861            if 2 > max_ordinal {
6862                return Ok(());
6863            }
6864
6865            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6866            // are envelope_size bytes.
6867            let cur_offset: usize = (2 - 1) * envelope_size;
6868
6869            // Zero reserved fields.
6870            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6871
6872            // Safety:
6873            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6874            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6875            //   envelope_size bytes, there is always sufficient room.
6876            fidl::encoding::encode_in_envelope_optional::<SignalStrength, D>(
6877                self.signal_strength
6878                    .as_ref()
6879                    .map(<SignalStrength as fidl::encoding::ValueTypeMarker>::borrow),
6880                encoder,
6881                offset + cur_offset,
6882                depth,
6883            )?;
6884
6885            _prev_end_offset = cur_offset + envelope_size;
6886            if 3 > max_ordinal {
6887                return Ok(());
6888            }
6889
6890            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6891            // are envelope_size bytes.
6892            let cur_offset: usize = (3 - 1) * envelope_size;
6893
6894            // Zero reserved fields.
6895            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6896
6897            // Safety:
6898            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6899            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6900            //   envelope_size bytes, there is always sufficient room.
6901            fidl::encoding::encode_in_envelope_optional::<bool, D>(
6902                self.roaming.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
6903                encoder,
6904                offset + cur_offset,
6905                depth,
6906            )?;
6907
6908            _prev_end_offset = cur_offset + envelope_size;
6909
6910            Ok(())
6911        }
6912    }
6913
6914    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for NetworkInformation {
6915        #[inline(always)]
6916        fn new_empty() -> Self {
6917            Self::default()
6918        }
6919
6920        unsafe fn decode(
6921            &mut self,
6922            decoder: &mut fidl::encoding::Decoder<'_, D>,
6923            offset: usize,
6924            mut depth: fidl::encoding::Depth,
6925        ) -> fidl::Result<()> {
6926            decoder.debug_check_bounds::<Self>(offset);
6927            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6928                None => return Err(fidl::Error::NotNullable),
6929                Some(len) => len,
6930            };
6931            // Calling decoder.out_of_line_offset(0) is not allowed.
6932            if len == 0 {
6933                return Ok(());
6934            };
6935            depth.increment()?;
6936            let envelope_size = 8;
6937            let bytes_len = len * envelope_size;
6938            let offset = decoder.out_of_line_offset(bytes_len)?;
6939            // Decode the envelope for each type.
6940            let mut _next_ordinal_to_read = 0;
6941            let mut next_offset = offset;
6942            let end_offset = offset + bytes_len;
6943            _next_ordinal_to_read += 1;
6944            if next_offset >= end_offset {
6945                return Ok(());
6946            }
6947
6948            // Decode unknown envelopes for gaps in ordinals.
6949            while _next_ordinal_to_read < 1 {
6950                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6951                _next_ordinal_to_read += 1;
6952                next_offset += envelope_size;
6953            }
6954
6955            let next_out_of_line = decoder.next_out_of_line();
6956            let handles_before = decoder.remaining_handles();
6957            if let Some((inlined, num_bytes, num_handles)) =
6958                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6959            {
6960                let member_inline_size =
6961                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6962                if inlined != (member_inline_size <= 4) {
6963                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6964                }
6965                let inner_offset;
6966                let mut inner_depth = depth.clone();
6967                if inlined {
6968                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6969                    inner_offset = next_offset;
6970                } else {
6971                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6972                    inner_depth.increment()?;
6973                }
6974                let val_ref =
6975                    self.service_available.get_or_insert_with(|| fidl::new_empty!(bool, D));
6976                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
6977                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6978                {
6979                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6980                }
6981                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6982                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6983                }
6984            }
6985
6986            next_offset += envelope_size;
6987            _next_ordinal_to_read += 1;
6988            if next_offset >= end_offset {
6989                return Ok(());
6990            }
6991
6992            // Decode unknown envelopes for gaps in ordinals.
6993            while _next_ordinal_to_read < 2 {
6994                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6995                _next_ordinal_to_read += 1;
6996                next_offset += envelope_size;
6997            }
6998
6999            let next_out_of_line = decoder.next_out_of_line();
7000            let handles_before = decoder.remaining_handles();
7001            if let Some((inlined, num_bytes, num_handles)) =
7002                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7003            {
7004                let member_inline_size =
7005                    <SignalStrength as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7006                if inlined != (member_inline_size <= 4) {
7007                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7008                }
7009                let inner_offset;
7010                let mut inner_depth = depth.clone();
7011                if inlined {
7012                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7013                    inner_offset = next_offset;
7014                } else {
7015                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7016                    inner_depth.increment()?;
7017                }
7018                let val_ref =
7019                    self.signal_strength.get_or_insert_with(|| fidl::new_empty!(SignalStrength, D));
7020                fidl::decode!(SignalStrength, D, val_ref, decoder, inner_offset, inner_depth)?;
7021                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7022                {
7023                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7024                }
7025                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7026                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7027                }
7028            }
7029
7030            next_offset += envelope_size;
7031            _next_ordinal_to_read += 1;
7032            if next_offset >= end_offset {
7033                return Ok(());
7034            }
7035
7036            // Decode unknown envelopes for gaps in ordinals.
7037            while _next_ordinal_to_read < 3 {
7038                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7039                _next_ordinal_to_read += 1;
7040                next_offset += envelope_size;
7041            }
7042
7043            let next_out_of_line = decoder.next_out_of_line();
7044            let handles_before = decoder.remaining_handles();
7045            if let Some((inlined, num_bytes, num_handles)) =
7046                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7047            {
7048                let member_inline_size =
7049                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7050                if inlined != (member_inline_size <= 4) {
7051                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7052                }
7053                let inner_offset;
7054                let mut inner_depth = depth.clone();
7055                if inlined {
7056                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7057                    inner_offset = next_offset;
7058                } else {
7059                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7060                    inner_depth.increment()?;
7061                }
7062                let val_ref = self.roaming.get_or_insert_with(|| fidl::new_empty!(bool, D));
7063                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
7064                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7065                {
7066                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7067                }
7068                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7069                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7070                }
7071            }
7072
7073            next_offset += envelope_size;
7074
7075            // Decode the remaining unknown envelopes.
7076            while next_offset < end_offset {
7077                _next_ordinal_to_read += 1;
7078                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7079                next_offset += envelope_size;
7080            }
7081
7082            Ok(())
7083        }
7084    }
7085
7086    impl NextCall {
7087        #[inline(always)]
7088        fn max_ordinal_present(&self) -> u64 {
7089            if let Some(_) = self.direction {
7090                return 4;
7091            }
7092            if let Some(_) = self.state {
7093                return 3;
7094            }
7095            if let Some(_) = self.remote {
7096                return 2;
7097            }
7098            if let Some(_) = self.call {
7099                return 1;
7100            }
7101            0
7102        }
7103    }
7104
7105    impl fidl::encoding::ResourceTypeMarker for NextCall {
7106        type Borrowed<'a> = &'a mut Self;
7107        fn take_or_borrow<'a>(
7108            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7109        ) -> Self::Borrowed<'a> {
7110            value
7111        }
7112    }
7113
7114    unsafe impl fidl::encoding::TypeMarker for NextCall {
7115        type Owned = Self;
7116
7117        #[inline(always)]
7118        fn inline_align(_context: fidl::encoding::Context) -> usize {
7119            8
7120        }
7121
7122        #[inline(always)]
7123        fn inline_size(_context: fidl::encoding::Context) -> usize {
7124            16
7125        }
7126    }
7127
7128    unsafe impl fidl::encoding::Encode<NextCall, fidl::encoding::DefaultFuchsiaResourceDialect>
7129        for &mut NextCall
7130    {
7131        unsafe fn encode(
7132            self,
7133            encoder: &mut fidl::encoding::Encoder<
7134                '_,
7135                fidl::encoding::DefaultFuchsiaResourceDialect,
7136            >,
7137            offset: usize,
7138            mut depth: fidl::encoding::Depth,
7139        ) -> fidl::Result<()> {
7140            encoder.debug_check_bounds::<NextCall>(offset);
7141            // Vector header
7142            let max_ordinal: u64 = self.max_ordinal_present();
7143            encoder.write_num(max_ordinal, offset);
7144            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7145            // Calling encoder.out_of_line_offset(0) is not allowed.
7146            if max_ordinal == 0 {
7147                return Ok(());
7148            }
7149            depth.increment()?;
7150            let envelope_size = 8;
7151            let bytes_len = max_ordinal as usize * envelope_size;
7152            #[allow(unused_variables)]
7153            let offset = encoder.out_of_line_offset(bytes_len);
7154            let mut _prev_end_offset: usize = 0;
7155            if 1 > max_ordinal {
7156                return Ok(());
7157            }
7158
7159            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7160            // are envelope_size bytes.
7161            let cur_offset: usize = (1 - 1) * envelope_size;
7162
7163            // Zero reserved fields.
7164            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7165
7166            // Safety:
7167            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7168            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7169            //   envelope_size bytes, there is always sufficient room.
7170            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
7171            self.call.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
7172            encoder, offset + cur_offset, depth
7173        )?;
7174
7175            _prev_end_offset = cur_offset + envelope_size;
7176            if 2 > max_ordinal {
7177                return Ok(());
7178            }
7179
7180            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7181            // are envelope_size bytes.
7182            let cur_offset: usize = (2 - 1) * envelope_size;
7183
7184            // Zero reserved fields.
7185            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7186
7187            // Safety:
7188            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7189            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7190            //   envelope_size bytes, there is always sufficient room.
7191            fidl::encoding::encode_in_envelope_optional::<
7192                fidl::encoding::BoundedString<256>,
7193                fidl::encoding::DefaultFuchsiaResourceDialect,
7194            >(
7195                self.remote.as_ref().map(
7196                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow,
7197                ),
7198                encoder,
7199                offset + cur_offset,
7200                depth,
7201            )?;
7202
7203            _prev_end_offset = cur_offset + envelope_size;
7204            if 3 > max_ordinal {
7205                return Ok(());
7206            }
7207
7208            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7209            // are envelope_size bytes.
7210            let cur_offset: usize = (3 - 1) * envelope_size;
7211
7212            // Zero reserved fields.
7213            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7214
7215            // Safety:
7216            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7217            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7218            //   envelope_size bytes, there is always sufficient room.
7219            fidl::encoding::encode_in_envelope_optional::<
7220                CallState,
7221                fidl::encoding::DefaultFuchsiaResourceDialect,
7222            >(
7223                self.state.as_ref().map(<CallState as fidl::encoding::ValueTypeMarker>::borrow),
7224                encoder,
7225                offset + cur_offset,
7226                depth,
7227            )?;
7228
7229            _prev_end_offset = cur_offset + envelope_size;
7230            if 4 > max_ordinal {
7231                return Ok(());
7232            }
7233
7234            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7235            // are envelope_size bytes.
7236            let cur_offset: usize = (4 - 1) * envelope_size;
7237
7238            // Zero reserved fields.
7239            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7240
7241            // Safety:
7242            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7243            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7244            //   envelope_size bytes, there is always sufficient room.
7245            fidl::encoding::encode_in_envelope_optional::<
7246                CallDirection,
7247                fidl::encoding::DefaultFuchsiaResourceDialect,
7248            >(
7249                self.direction
7250                    .as_ref()
7251                    .map(<CallDirection as fidl::encoding::ValueTypeMarker>::borrow),
7252                encoder,
7253                offset + cur_offset,
7254                depth,
7255            )?;
7256
7257            _prev_end_offset = cur_offset + envelope_size;
7258
7259            Ok(())
7260        }
7261    }
7262
7263    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for NextCall {
7264        #[inline(always)]
7265        fn new_empty() -> Self {
7266            Self::default()
7267        }
7268
7269        unsafe fn decode(
7270            &mut self,
7271            decoder: &mut fidl::encoding::Decoder<
7272                '_,
7273                fidl::encoding::DefaultFuchsiaResourceDialect,
7274            >,
7275            offset: usize,
7276            mut depth: fidl::encoding::Depth,
7277        ) -> fidl::Result<()> {
7278            decoder.debug_check_bounds::<Self>(offset);
7279            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7280                None => return Err(fidl::Error::NotNullable),
7281                Some(len) => len,
7282            };
7283            // Calling decoder.out_of_line_offset(0) is not allowed.
7284            if len == 0 {
7285                return Ok(());
7286            };
7287            depth.increment()?;
7288            let envelope_size = 8;
7289            let bytes_len = len * envelope_size;
7290            let offset = decoder.out_of_line_offset(bytes_len)?;
7291            // Decode the envelope for each type.
7292            let mut _next_ordinal_to_read = 0;
7293            let mut next_offset = offset;
7294            let end_offset = offset + bytes_len;
7295            _next_ordinal_to_read += 1;
7296            if next_offset >= end_offset {
7297                return Ok(());
7298            }
7299
7300            // Decode unknown envelopes for gaps in ordinals.
7301            while _next_ordinal_to_read < 1 {
7302                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7303                _next_ordinal_to_read += 1;
7304                next_offset += envelope_size;
7305            }
7306
7307            let next_out_of_line = decoder.next_out_of_line();
7308            let handles_before = decoder.remaining_handles();
7309            if let Some((inlined, num_bytes, num_handles)) =
7310                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7311            {
7312                let member_inline_size = <fidl::encoding::Endpoint<
7313                    fidl::endpoints::ClientEnd<CallMarker>,
7314                > as fidl::encoding::TypeMarker>::inline_size(
7315                    decoder.context
7316                );
7317                if inlined != (member_inline_size <= 4) {
7318                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7319                }
7320                let inner_offset;
7321                let mut inner_depth = depth.clone();
7322                if inlined {
7323                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7324                    inner_offset = next_offset;
7325                } else {
7326                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7327                    inner_depth.increment()?;
7328                }
7329                let val_ref = self.call.get_or_insert_with(|| {
7330                    fidl::new_empty!(
7331                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallMarker>>,
7332                        fidl::encoding::DefaultFuchsiaResourceDialect
7333                    )
7334                });
7335                fidl::decode!(
7336                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<CallMarker>>,
7337                    fidl::encoding::DefaultFuchsiaResourceDialect,
7338                    val_ref,
7339                    decoder,
7340                    inner_offset,
7341                    inner_depth
7342                )?;
7343                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7344                {
7345                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7346                }
7347                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7348                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7349                }
7350            }
7351
7352            next_offset += envelope_size;
7353            _next_ordinal_to_read += 1;
7354            if next_offset >= end_offset {
7355                return Ok(());
7356            }
7357
7358            // Decode unknown envelopes for gaps in ordinals.
7359            while _next_ordinal_to_read < 2 {
7360                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7361                _next_ordinal_to_read += 1;
7362                next_offset += envelope_size;
7363            }
7364
7365            let next_out_of_line = decoder.next_out_of_line();
7366            let handles_before = decoder.remaining_handles();
7367            if let Some((inlined, num_bytes, num_handles)) =
7368                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7369            {
7370                let member_inline_size =
7371                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
7372                        decoder.context,
7373                    );
7374                if inlined != (member_inline_size <= 4) {
7375                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7376                }
7377                let inner_offset;
7378                let mut inner_depth = depth.clone();
7379                if inlined {
7380                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7381                    inner_offset = next_offset;
7382                } else {
7383                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7384                    inner_depth.increment()?;
7385                }
7386                let val_ref = self.remote.get_or_insert_with(|| {
7387                    fidl::new_empty!(
7388                        fidl::encoding::BoundedString<256>,
7389                        fidl::encoding::DefaultFuchsiaResourceDialect
7390                    )
7391                });
7392                fidl::decode!(
7393                    fidl::encoding::BoundedString<256>,
7394                    fidl::encoding::DefaultFuchsiaResourceDialect,
7395                    val_ref,
7396                    decoder,
7397                    inner_offset,
7398                    inner_depth
7399                )?;
7400                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7401                {
7402                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7403                }
7404                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7405                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7406                }
7407            }
7408
7409            next_offset += envelope_size;
7410            _next_ordinal_to_read += 1;
7411            if next_offset >= end_offset {
7412                return Ok(());
7413            }
7414
7415            // Decode unknown envelopes for gaps in ordinals.
7416            while _next_ordinal_to_read < 3 {
7417                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7418                _next_ordinal_to_read += 1;
7419                next_offset += envelope_size;
7420            }
7421
7422            let next_out_of_line = decoder.next_out_of_line();
7423            let handles_before = decoder.remaining_handles();
7424            if let Some((inlined, num_bytes, num_handles)) =
7425                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7426            {
7427                let member_inline_size =
7428                    <CallState as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7429                if inlined != (member_inline_size <= 4) {
7430                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7431                }
7432                let inner_offset;
7433                let mut inner_depth = depth.clone();
7434                if inlined {
7435                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7436                    inner_offset = next_offset;
7437                } else {
7438                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7439                    inner_depth.increment()?;
7440                }
7441                let val_ref = self.state.get_or_insert_with(|| {
7442                    fidl::new_empty!(CallState, fidl::encoding::DefaultFuchsiaResourceDialect)
7443                });
7444                fidl::decode!(
7445                    CallState,
7446                    fidl::encoding::DefaultFuchsiaResourceDialect,
7447                    val_ref,
7448                    decoder,
7449                    inner_offset,
7450                    inner_depth
7451                )?;
7452                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7453                {
7454                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7455                }
7456                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7457                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7458                }
7459            }
7460
7461            next_offset += envelope_size;
7462            _next_ordinal_to_read += 1;
7463            if next_offset >= end_offset {
7464                return Ok(());
7465            }
7466
7467            // Decode unknown envelopes for gaps in ordinals.
7468            while _next_ordinal_to_read < 4 {
7469                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7470                _next_ordinal_to_read += 1;
7471                next_offset += envelope_size;
7472            }
7473
7474            let next_out_of_line = decoder.next_out_of_line();
7475            let handles_before = decoder.remaining_handles();
7476            if let Some((inlined, num_bytes, num_handles)) =
7477                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7478            {
7479                let member_inline_size =
7480                    <CallDirection as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7481                if inlined != (member_inline_size <= 4) {
7482                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7483                }
7484                let inner_offset;
7485                let mut inner_depth = depth.clone();
7486                if inlined {
7487                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7488                    inner_offset = next_offset;
7489                } else {
7490                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7491                    inner_depth.increment()?;
7492                }
7493                let val_ref = self.direction.get_or_insert_with(|| {
7494                    fidl::new_empty!(CallDirection, fidl::encoding::DefaultFuchsiaResourceDialect)
7495                });
7496                fidl::decode!(
7497                    CallDirection,
7498                    fidl::encoding::DefaultFuchsiaResourceDialect,
7499                    val_ref,
7500                    decoder,
7501                    inner_offset,
7502                    inner_depth
7503                )?;
7504                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7505                {
7506                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7507                }
7508                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7509                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7510                }
7511            }
7512
7513            next_offset += envelope_size;
7514
7515            // Decode the remaining unknown envelopes.
7516            while next_offset < end_offset {
7517                _next_ordinal_to_read += 1;
7518                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7519                next_offset += envelope_size;
7520            }
7521
7522            Ok(())
7523        }
7524    }
7525
7526    impl fidl::encoding::ValueTypeMarker for CallAction {
7527        type Borrowed<'a> = &'a Self;
7528        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
7529            value
7530        }
7531    }
7532
7533    unsafe impl fidl::encoding::TypeMarker for CallAction {
7534        type Owned = Self;
7535
7536        #[inline(always)]
7537        fn inline_align(_context: fidl::encoding::Context) -> usize {
7538            8
7539        }
7540
7541        #[inline(always)]
7542        fn inline_size(_context: fidl::encoding::Context) -> usize {
7543            16
7544        }
7545    }
7546
7547    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CallAction, D>
7548        for &CallAction
7549    {
7550        #[inline]
7551        unsafe fn encode(
7552            self,
7553            encoder: &mut fidl::encoding::Encoder<'_, D>,
7554            offset: usize,
7555            _depth: fidl::encoding::Depth,
7556        ) -> fidl::Result<()> {
7557            encoder.debug_check_bounds::<CallAction>(offset);
7558            encoder.write_num::<u64>(self.ordinal(), offset);
7559            match self {
7560                CallAction::DialFromNumber(ref val) => fidl::encoding::encode_in_envelope::<
7561                    fidl::encoding::BoundedString<256>,
7562                    D,
7563                >(
7564                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
7565                        val,
7566                    ),
7567                    encoder,
7568                    offset + 8,
7569                    _depth,
7570                ),
7571                CallAction::DialFromLocation(ref val) => fidl::encoding::encode_in_envelope::<
7572                    fidl::encoding::BoundedString<256>,
7573                    D,
7574                >(
7575                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
7576                        val,
7577                    ),
7578                    encoder,
7579                    offset + 8,
7580                    _depth,
7581                ),
7582                CallAction::RedialLast(ref val) => {
7583                    fidl::encoding::encode_in_envelope::<RedialLast, D>(
7584                        <RedialLast as fidl::encoding::ValueTypeMarker>::borrow(val),
7585                        encoder,
7586                        offset + 8,
7587                        _depth,
7588                    )
7589                }
7590                CallAction::TransferActive(ref val) => {
7591                    fidl::encoding::encode_in_envelope::<TransferActive, D>(
7592                        <TransferActive as fidl::encoding::ValueTypeMarker>::borrow(val),
7593                        encoder,
7594                        offset + 8,
7595                        _depth,
7596                    )
7597                }
7598            }
7599        }
7600    }
7601
7602    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CallAction {
7603        #[inline(always)]
7604        fn new_empty() -> Self {
7605            Self::DialFromNumber(fidl::new_empty!(fidl::encoding::BoundedString<256>, D))
7606        }
7607
7608        #[inline]
7609        unsafe fn decode(
7610            &mut self,
7611            decoder: &mut fidl::encoding::Decoder<'_, D>,
7612            offset: usize,
7613            mut depth: fidl::encoding::Depth,
7614        ) -> fidl::Result<()> {
7615            decoder.debug_check_bounds::<Self>(offset);
7616            #[allow(unused_variables)]
7617            let next_out_of_line = decoder.next_out_of_line();
7618            let handles_before = decoder.remaining_handles();
7619            let (ordinal, inlined, num_bytes, num_handles) =
7620                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
7621
7622            let member_inline_size = match ordinal {
7623                1 => {
7624                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
7625                        decoder.context,
7626                    )
7627                }
7628                2 => {
7629                    <fidl::encoding::BoundedString<256> as fidl::encoding::TypeMarker>::inline_size(
7630                        decoder.context,
7631                    )
7632                }
7633                3 => <RedialLast as fidl::encoding::TypeMarker>::inline_size(decoder.context),
7634                4 => <TransferActive as fidl::encoding::TypeMarker>::inline_size(decoder.context),
7635                _ => return Err(fidl::Error::UnknownUnionTag),
7636            };
7637
7638            if inlined != (member_inline_size <= 4) {
7639                return Err(fidl::Error::InvalidInlineBitInEnvelope);
7640            }
7641            let _inner_offset;
7642            if inlined {
7643                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
7644                _inner_offset = offset + 8;
7645            } else {
7646                depth.increment()?;
7647                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7648            }
7649            match ordinal {
7650                1 => {
7651                    #[allow(irrefutable_let_patterns)]
7652                    if let CallAction::DialFromNumber(_) = self {
7653                        // Do nothing, read the value into the object
7654                    } else {
7655                        // Initialize `self` to the right variant
7656                        *self = CallAction::DialFromNumber(fidl::new_empty!(
7657                            fidl::encoding::BoundedString<256>,
7658                            D
7659                        ));
7660                    }
7661                    #[allow(irrefutable_let_patterns)]
7662                    if let CallAction::DialFromNumber(ref mut val) = self {
7663                        fidl::decode!(
7664                            fidl::encoding::BoundedString<256>,
7665                            D,
7666                            val,
7667                            decoder,
7668                            _inner_offset,
7669                            depth
7670                        )?;
7671                    } else {
7672                        unreachable!()
7673                    }
7674                }
7675                2 => {
7676                    #[allow(irrefutable_let_patterns)]
7677                    if let CallAction::DialFromLocation(_) = self {
7678                        // Do nothing, read the value into the object
7679                    } else {
7680                        // Initialize `self` to the right variant
7681                        *self = CallAction::DialFromLocation(fidl::new_empty!(
7682                            fidl::encoding::BoundedString<256>,
7683                            D
7684                        ));
7685                    }
7686                    #[allow(irrefutable_let_patterns)]
7687                    if let CallAction::DialFromLocation(ref mut val) = self {
7688                        fidl::decode!(
7689                            fidl::encoding::BoundedString<256>,
7690                            D,
7691                            val,
7692                            decoder,
7693                            _inner_offset,
7694                            depth
7695                        )?;
7696                    } else {
7697                        unreachable!()
7698                    }
7699                }
7700                3 => {
7701                    #[allow(irrefutable_let_patterns)]
7702                    if let CallAction::RedialLast(_) = self {
7703                        // Do nothing, read the value into the object
7704                    } else {
7705                        // Initialize `self` to the right variant
7706                        *self = CallAction::RedialLast(fidl::new_empty!(RedialLast, D));
7707                    }
7708                    #[allow(irrefutable_let_patterns)]
7709                    if let CallAction::RedialLast(ref mut val) = self {
7710                        fidl::decode!(RedialLast, D, val, decoder, _inner_offset, depth)?;
7711                    } else {
7712                        unreachable!()
7713                    }
7714                }
7715                4 => {
7716                    #[allow(irrefutable_let_patterns)]
7717                    if let CallAction::TransferActive(_) = self {
7718                        // Do nothing, read the value into the object
7719                    } else {
7720                        // Initialize `self` to the right variant
7721                        *self = CallAction::TransferActive(fidl::new_empty!(TransferActive, D));
7722                    }
7723                    #[allow(irrefutable_let_patterns)]
7724                    if let CallAction::TransferActive(ref mut val) = self {
7725                        fidl::decode!(TransferActive, D, val, decoder, _inner_offset, depth)?;
7726                    } else {
7727                        unreachable!()
7728                    }
7729                }
7730                ordinal => panic!("unexpected ordinal {:?}", ordinal),
7731            }
7732            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
7733                return Err(fidl::Error::InvalidNumBytesInEnvelope);
7734            }
7735            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7736                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7737            }
7738            Ok(())
7739        }
7740    }
7741}