Skip to main content

fidl_fuchsia_bluetooth_host/
fidl_fuchsia_bluetooth_host.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_bluetooth_host__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct HostSetBondingDelegateRequest {
16    pub delegate: fidl::endpoints::ServerEnd<BondingDelegateMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for HostSetBondingDelegateRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct HostSetPairingDelegateRequest {
26    pub input: fidl_fuchsia_bluetooth_sys::InputCapability,
27    pub output: fidl_fuchsia_bluetooth_sys::OutputCapability,
28    pub delegate: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth_sys::PairingDelegateMarker>,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
32    for HostSetPairingDelegateRequest
33{
34}
35
36#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
37pub struct HostSetPeerWatcherRequest {
38    pub peer_watcher: fidl::endpoints::ServerEnd<PeerWatcherMarker>,
39}
40
41impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for HostSetPeerWatcherRequest {}
42
43#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
44pub struct ReceiverAddHostRequest {
45    pub request: fidl::endpoints::ClientEnd<HostMarker>,
46}
47
48impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ReceiverAddHostRequest {}
49
50#[derive(Debug, Default, PartialEq)]
51pub struct HostStartDiscoveryRequest {
52    /// Required.
53    pub token: Option<fidl::endpoints::ServerEnd<DiscoverySessionMarker>>,
54    #[doc(hidden)]
55    pub __source_breaking: fidl::marker::SourceBreaking,
56}
57
58impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for HostStartDiscoveryRequest {}
59
60#[derive(Debug)]
61pub enum ProtocolRequest {
62    Central(fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_le::CentralMarker>),
63    Peripheral(fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_le::PeripheralMarker>),
64    GattServer(fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::Server_Marker>),
65    Gatt2Server(fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::Server_Marker>),
66    Profile(fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>),
67    PrivilegedPeripheral(
68        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_le::PrivilegedPeripheralMarker>,
69    ),
70    #[doc(hidden)]
71    __SourceBreaking {
72        unknown_ordinal: u64,
73    },
74}
75
76/// Pattern that matches an unknown `ProtocolRequest` member.
77#[macro_export]
78macro_rules! ProtocolRequestUnknown {
79    () => {
80        _
81    };
82}
83
84// Custom PartialEq so that unknown variants are not equal to themselves.
85impl PartialEq for ProtocolRequest {
86    fn eq(&self, other: &Self) -> bool {
87        match (self, other) {
88            (Self::Central(x), Self::Central(y)) => *x == *y,
89            (Self::Peripheral(x), Self::Peripheral(y)) => *x == *y,
90            (Self::GattServer(x), Self::GattServer(y)) => *x == *y,
91            (Self::Gatt2Server(x), Self::Gatt2Server(y)) => *x == *y,
92            (Self::Profile(x), Self::Profile(y)) => *x == *y,
93            (Self::PrivilegedPeripheral(x), Self::PrivilegedPeripheral(y)) => *x == *y,
94            _ => false,
95        }
96    }
97}
98
99impl ProtocolRequest {
100    #[inline]
101    pub fn ordinal(&self) -> u64 {
102        match *self {
103            Self::Central(_) => 1,
104            Self::Peripheral(_) => 2,
105            Self::GattServer(_) => 3,
106            Self::Gatt2Server(_) => 4,
107            Self::Profile(_) => 5,
108            Self::PrivilegedPeripheral(_) => 6,
109            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
110        }
111    }
112
113    #[inline]
114    pub fn unknown_variant_for_testing() -> Self {
115        Self::__SourceBreaking { unknown_ordinal: 0 }
116    }
117
118    #[inline]
119    pub fn is_unknown(&self) -> bool {
120        match self {
121            Self::__SourceBreaking { .. } => true,
122            _ => false,
123        }
124    }
125}
126
127impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ProtocolRequest {}
128
129#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
130pub struct BondingDelegateMarker;
131
132impl fidl::endpoints::ProtocolMarker for BondingDelegateMarker {
133    type Proxy = BondingDelegateProxy;
134    type RequestStream = BondingDelegateRequestStream;
135    #[cfg(target_os = "fuchsia")]
136    type SynchronousProxy = BondingDelegateSynchronousProxy;
137
138    const DEBUG_NAME: &'static str = "(anonymous) BondingDelegate";
139}
140
141pub trait BondingDelegateProxyInterface: Send + Sync {
142    type RestoreBondsResponseFut: std::future::Future<
143            Output = Result<Vec<fidl_fuchsia_bluetooth_sys::BondingData>, fidl::Error>,
144        > + Send;
145    fn r#restore_bonds(
146        &self,
147        bonds: &[fidl_fuchsia_bluetooth_sys::BondingData],
148    ) -> Self::RestoreBondsResponseFut;
149    type WatchBondsResponseFut: std::future::Future<Output = Result<BondingDelegateWatchBondsResponse, fidl::Error>>
150        + Send;
151    fn r#watch_bonds(&self) -> Self::WatchBondsResponseFut;
152}
153#[derive(Debug)]
154#[cfg(target_os = "fuchsia")]
155pub struct BondingDelegateSynchronousProxy {
156    client: fidl::client::sync::Client,
157}
158
159#[cfg(target_os = "fuchsia")]
160impl fidl::endpoints::SynchronousProxy for BondingDelegateSynchronousProxy {
161    type Proxy = BondingDelegateProxy;
162    type Protocol = BondingDelegateMarker;
163
164    fn from_channel(inner: fidl::Channel) -> Self {
165        Self::new(inner)
166    }
167
168    fn into_channel(self) -> fidl::Channel {
169        self.client.into_channel()
170    }
171
172    fn as_channel(&self) -> &fidl::Channel {
173        self.client.as_channel()
174    }
175}
176
177#[cfg(target_os = "fuchsia")]
178impl BondingDelegateSynchronousProxy {
179    pub fn new(channel: fidl::Channel) -> Self {
180        Self { client: fidl::client::sync::Client::new(channel) }
181    }
182
183    pub fn into_channel(self) -> fidl::Channel {
184        self.client.into_channel()
185    }
186
187    /// Waits until an event arrives and returns it. It is safe for other
188    /// threads to make concurrent requests while waiting for an event.
189    pub fn wait_for_event(
190        &self,
191        deadline: zx::MonotonicInstant,
192    ) -> Result<BondingDelegateEvent, fidl::Error> {
193        BondingDelegateEvent::decode(self.client.wait_for_event::<BondingDelegateMarker>(deadline)?)
194    }
195
196    /// Restores existing bonded devices to the host. An authenticated session will be established
197    /// for future connections using the provided bonding data.
198    ///
199    /// If bonding data for the LE transport is available, then the host will establish a connection
200    /// if the peer directs connectable advertisements to us.
201    ///
202    /// If any of the entries in `bonds` could not be restored, then they will be returned in
203    /// `errors`. This can happen for entries that are malformed and for peers that are already
204    /// known to the bt-host. An empty `errors` list indicates that all bonds were successfully
205    /// restored.
206    pub fn r#restore_bonds(
207        &self,
208        mut bonds: &[fidl_fuchsia_bluetooth_sys::BondingData],
209        ___deadline: zx::MonotonicInstant,
210    ) -> Result<Vec<fidl_fuchsia_bluetooth_sys::BondingData>, fidl::Error> {
211        let _response = self.client.send_query::<
212            BondingDelegateRestoreBondsRequest,
213            fidl::encoding::FlexibleType<BondingDelegateRestoreBondsResponse>,
214            BondingDelegateMarker,
215        >(
216            (bonds,),
217            0x2f17e533f2475e96,
218            fidl::encoding::DynamicFlags::FLEXIBLE,
219            ___deadline,
220        )?
221        .into_result::<BondingDelegateMarker>("restore_bonds")?;
222        Ok(_response.errors)
223    }
224
225    /// Get the next bonding update. The request will hang until the next update.
226    pub fn r#watch_bonds(
227        &self,
228        ___deadline: zx::MonotonicInstant,
229    ) -> Result<BondingDelegateWatchBondsResponse, fidl::Error> {
230        let _response = self.client.send_query::<
231            fidl::encoding::EmptyPayload,
232            fidl::encoding::FlexibleType<BondingDelegateWatchBondsResponse>,
233            BondingDelegateMarker,
234        >(
235            (),
236            0x48313cadc60cd07a,
237            fidl::encoding::DynamicFlags::FLEXIBLE,
238            ___deadline,
239        )?
240        .into_result::<BondingDelegateMarker>("watch_bonds")?;
241        Ok(_response)
242    }
243}
244
245#[cfg(target_os = "fuchsia")]
246impl From<BondingDelegateSynchronousProxy> for zx::NullableHandle {
247    fn from(value: BondingDelegateSynchronousProxy) -> Self {
248        value.into_channel().into()
249    }
250}
251
252#[cfg(target_os = "fuchsia")]
253impl From<fidl::Channel> for BondingDelegateSynchronousProxy {
254    fn from(value: fidl::Channel) -> Self {
255        Self::new(value)
256    }
257}
258
259#[cfg(target_os = "fuchsia")]
260impl fidl::endpoints::FromClient for BondingDelegateSynchronousProxy {
261    type Protocol = BondingDelegateMarker;
262
263    fn from_client(value: fidl::endpoints::ClientEnd<BondingDelegateMarker>) -> Self {
264        Self::new(value.into_channel())
265    }
266}
267
268#[derive(Debug, Clone)]
269pub struct BondingDelegateProxy {
270    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
271}
272
273impl fidl::endpoints::Proxy for BondingDelegateProxy {
274    type Protocol = BondingDelegateMarker;
275
276    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
277        Self::new(inner)
278    }
279
280    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
281        self.client.into_channel().map_err(|client| Self { client })
282    }
283
284    fn as_channel(&self) -> &::fidl::AsyncChannel {
285        self.client.as_channel()
286    }
287}
288
289impl BondingDelegateProxy {
290    /// Create a new Proxy for fuchsia.bluetooth.host/BondingDelegate.
291    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
292        let protocol_name = <BondingDelegateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
293        Self { client: fidl::client::Client::new(channel, protocol_name) }
294    }
295
296    /// Get a Stream of events from the remote end of the protocol.
297    ///
298    /// # Panics
299    ///
300    /// Panics if the event stream was already taken.
301    pub fn take_event_stream(&self) -> BondingDelegateEventStream {
302        BondingDelegateEventStream { event_receiver: self.client.take_event_receiver() }
303    }
304
305    /// Restores existing bonded devices to the host. An authenticated session will be established
306    /// for future connections using the provided bonding data.
307    ///
308    /// If bonding data for the LE transport is available, then the host will establish a connection
309    /// if the peer directs connectable advertisements to us.
310    ///
311    /// If any of the entries in `bonds` could not be restored, then they will be returned in
312    /// `errors`. This can happen for entries that are malformed and for peers that are already
313    /// known to the bt-host. An empty `errors` list indicates that all bonds were successfully
314    /// restored.
315    pub fn r#restore_bonds(
316        &self,
317        mut bonds: &[fidl_fuchsia_bluetooth_sys::BondingData],
318    ) -> fidl::client::QueryResponseFut<
319        Vec<fidl_fuchsia_bluetooth_sys::BondingData>,
320        fidl::encoding::DefaultFuchsiaResourceDialect,
321    > {
322        BondingDelegateProxyInterface::r#restore_bonds(self, bonds)
323    }
324
325    /// Get the next bonding update. The request will hang until the next update.
326    pub fn r#watch_bonds(
327        &self,
328    ) -> fidl::client::QueryResponseFut<
329        BondingDelegateWatchBondsResponse,
330        fidl::encoding::DefaultFuchsiaResourceDialect,
331    > {
332        BondingDelegateProxyInterface::r#watch_bonds(self)
333    }
334}
335
336impl BondingDelegateProxyInterface for BondingDelegateProxy {
337    type RestoreBondsResponseFut = fidl::client::QueryResponseFut<
338        Vec<fidl_fuchsia_bluetooth_sys::BondingData>,
339        fidl::encoding::DefaultFuchsiaResourceDialect,
340    >;
341    fn r#restore_bonds(
342        &self,
343        mut bonds: &[fidl_fuchsia_bluetooth_sys::BondingData],
344    ) -> Self::RestoreBondsResponseFut {
345        fn _decode(
346            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
347        ) -> Result<Vec<fidl_fuchsia_bluetooth_sys::BondingData>, fidl::Error> {
348            let _response = fidl::client::decode_transaction_body::<
349                fidl::encoding::FlexibleType<BondingDelegateRestoreBondsResponse>,
350                fidl::encoding::DefaultFuchsiaResourceDialect,
351                0x2f17e533f2475e96,
352            >(_buf?)?
353            .into_result::<BondingDelegateMarker>("restore_bonds")?;
354            Ok(_response.errors)
355        }
356        self.client.send_query_and_decode::<
357            BondingDelegateRestoreBondsRequest,
358            Vec<fidl_fuchsia_bluetooth_sys::BondingData>,
359        >(
360            (bonds,),
361            0x2f17e533f2475e96,
362            fidl::encoding::DynamicFlags::FLEXIBLE,
363            _decode,
364        )
365    }
366
367    type WatchBondsResponseFut = fidl::client::QueryResponseFut<
368        BondingDelegateWatchBondsResponse,
369        fidl::encoding::DefaultFuchsiaResourceDialect,
370    >;
371    fn r#watch_bonds(&self) -> Self::WatchBondsResponseFut {
372        fn _decode(
373            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
374        ) -> Result<BondingDelegateWatchBondsResponse, fidl::Error> {
375            let _response = fidl::client::decode_transaction_body::<
376                fidl::encoding::FlexibleType<BondingDelegateWatchBondsResponse>,
377                fidl::encoding::DefaultFuchsiaResourceDialect,
378                0x48313cadc60cd07a,
379            >(_buf?)?
380            .into_result::<BondingDelegateMarker>("watch_bonds")?;
381            Ok(_response)
382        }
383        self.client.send_query_and_decode::<
384            fidl::encoding::EmptyPayload,
385            BondingDelegateWatchBondsResponse,
386        >(
387            (),
388            0x48313cadc60cd07a,
389            fidl::encoding::DynamicFlags::FLEXIBLE,
390            _decode,
391        )
392    }
393}
394
395pub struct BondingDelegateEventStream {
396    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
397}
398
399impl std::marker::Unpin for BondingDelegateEventStream {}
400
401impl futures::stream::FusedStream for BondingDelegateEventStream {
402    fn is_terminated(&self) -> bool {
403        self.event_receiver.is_terminated()
404    }
405}
406
407impl futures::Stream for BondingDelegateEventStream {
408    type Item = Result<BondingDelegateEvent, fidl::Error>;
409
410    fn poll_next(
411        mut self: std::pin::Pin<&mut Self>,
412        cx: &mut std::task::Context<'_>,
413    ) -> std::task::Poll<Option<Self::Item>> {
414        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
415            &mut self.event_receiver,
416            cx
417        )?) {
418            Some(buf) => std::task::Poll::Ready(Some(BondingDelegateEvent::decode(buf))),
419            None => std::task::Poll::Ready(None),
420        }
421    }
422}
423
424#[derive(Debug)]
425pub enum BondingDelegateEvent {
426    #[non_exhaustive]
427    _UnknownEvent {
428        /// Ordinal of the event that was sent.
429        ordinal: u64,
430    },
431}
432
433impl BondingDelegateEvent {
434    /// Decodes a message buffer as a [`BondingDelegateEvent`].
435    fn decode(
436        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
437    ) -> Result<BondingDelegateEvent, fidl::Error> {
438        let (bytes, _handles) = buf.split_mut();
439        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
440        debug_assert_eq!(tx_header.tx_id, 0);
441        match tx_header.ordinal {
442            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
443                Ok(BondingDelegateEvent::_UnknownEvent { ordinal: tx_header.ordinal })
444            }
445            _ => Err(fidl::Error::UnknownOrdinal {
446                ordinal: tx_header.ordinal,
447                protocol_name:
448                    <BondingDelegateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
449            }),
450        }
451    }
452}
453
454/// A Stream of incoming requests for fuchsia.bluetooth.host/BondingDelegate.
455pub struct BondingDelegateRequestStream {
456    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
457    is_terminated: bool,
458}
459
460impl std::marker::Unpin for BondingDelegateRequestStream {}
461
462impl futures::stream::FusedStream for BondingDelegateRequestStream {
463    fn is_terminated(&self) -> bool {
464        self.is_terminated
465    }
466}
467
468impl fidl::endpoints::RequestStream for BondingDelegateRequestStream {
469    type Protocol = BondingDelegateMarker;
470    type ControlHandle = BondingDelegateControlHandle;
471
472    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
473        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
474    }
475
476    fn control_handle(&self) -> Self::ControlHandle {
477        BondingDelegateControlHandle { inner: self.inner.clone() }
478    }
479
480    fn into_inner(
481        self,
482    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
483    {
484        (self.inner, self.is_terminated)
485    }
486
487    fn from_inner(
488        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
489        is_terminated: bool,
490    ) -> Self {
491        Self { inner, is_terminated }
492    }
493}
494
495impl futures::Stream for BondingDelegateRequestStream {
496    type Item = Result<BondingDelegateRequest, fidl::Error>;
497
498    fn poll_next(
499        mut self: std::pin::Pin<&mut Self>,
500        cx: &mut std::task::Context<'_>,
501    ) -> std::task::Poll<Option<Self::Item>> {
502        let this = &mut *self;
503        if this.inner.check_shutdown(cx) {
504            this.is_terminated = true;
505            return std::task::Poll::Ready(None);
506        }
507        if this.is_terminated {
508            panic!("polled BondingDelegateRequestStream after completion");
509        }
510        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
511            |bytes, handles| {
512                match this.inner.channel().read_etc(cx, bytes, handles) {
513                    std::task::Poll::Ready(Ok(())) => {}
514                    std::task::Poll::Pending => return std::task::Poll::Pending,
515                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
516                        this.is_terminated = true;
517                        return std::task::Poll::Ready(None);
518                    }
519                    std::task::Poll::Ready(Err(e)) => {
520                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
521                            e.into(),
522                        ))));
523                    }
524                }
525
526                // A message has been received from the channel
527                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
528
529                std::task::Poll::Ready(Some(match header.ordinal {
530                    0x2f17e533f2475e96 => {
531                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
532                        let mut req = fidl::new_empty!(
533                            BondingDelegateRestoreBondsRequest,
534                            fidl::encoding::DefaultFuchsiaResourceDialect
535                        );
536                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BondingDelegateRestoreBondsRequest>(&header, _body_bytes, handles, &mut req)?;
537                        let control_handle =
538                            BondingDelegateControlHandle { inner: this.inner.clone() };
539                        Ok(BondingDelegateRequest::RestoreBonds {
540                            bonds: req.bonds,
541
542                            responder: BondingDelegateRestoreBondsResponder {
543                                control_handle: std::mem::ManuallyDrop::new(control_handle),
544                                tx_id: header.tx_id,
545                            },
546                        })
547                    }
548                    0x48313cadc60cd07a => {
549                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
550                        let mut req = fidl::new_empty!(
551                            fidl::encoding::EmptyPayload,
552                            fidl::encoding::DefaultFuchsiaResourceDialect
553                        );
554                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
555                        let control_handle =
556                            BondingDelegateControlHandle { inner: this.inner.clone() };
557                        Ok(BondingDelegateRequest::WatchBonds {
558                            responder: BondingDelegateWatchBondsResponder {
559                                control_handle: std::mem::ManuallyDrop::new(control_handle),
560                                tx_id: header.tx_id,
561                            },
562                        })
563                    }
564                    _ if header.tx_id == 0
565                        && header
566                            .dynamic_flags()
567                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
568                    {
569                        Ok(BondingDelegateRequest::_UnknownMethod {
570                            ordinal: header.ordinal,
571                            control_handle: BondingDelegateControlHandle {
572                                inner: this.inner.clone(),
573                            },
574                            method_type: fidl::MethodType::OneWay,
575                        })
576                    }
577                    _ if header
578                        .dynamic_flags()
579                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
580                    {
581                        this.inner.send_framework_err(
582                            fidl::encoding::FrameworkErr::UnknownMethod,
583                            header.tx_id,
584                            header.ordinal,
585                            header.dynamic_flags(),
586                            (bytes, handles),
587                        )?;
588                        Ok(BondingDelegateRequest::_UnknownMethod {
589                            ordinal: header.ordinal,
590                            control_handle: BondingDelegateControlHandle {
591                                inner: this.inner.clone(),
592                            },
593                            method_type: fidl::MethodType::TwoWay,
594                        })
595                    }
596                    _ => Err(fidl::Error::UnknownOrdinal {
597                        ordinal: header.ordinal,
598                        protocol_name:
599                            <BondingDelegateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
600                    }),
601                }))
602            },
603        )
604    }
605}
606
607#[derive(Debug)]
608pub enum BondingDelegateRequest {
609    /// Restores existing bonded devices to the host. An authenticated session will be established
610    /// for future connections using the provided bonding data.
611    ///
612    /// If bonding data for the LE transport is available, then the host will establish a connection
613    /// if the peer directs connectable advertisements to us.
614    ///
615    /// If any of the entries in `bonds` could not be restored, then they will be returned in
616    /// `errors`. This can happen for entries that are malformed and for peers that are already
617    /// known to the bt-host. An empty `errors` list indicates that all bonds were successfully
618    /// restored.
619    RestoreBonds {
620        bonds: Vec<fidl_fuchsia_bluetooth_sys::BondingData>,
621        responder: BondingDelegateRestoreBondsResponder,
622    },
623    /// Get the next bonding update. The request will hang until the next update.
624    WatchBonds { responder: BondingDelegateWatchBondsResponder },
625    /// An interaction was received which does not match any known method.
626    #[non_exhaustive]
627    _UnknownMethod {
628        /// Ordinal of the method that was called.
629        ordinal: u64,
630        control_handle: BondingDelegateControlHandle,
631        method_type: fidl::MethodType,
632    },
633}
634
635impl BondingDelegateRequest {
636    #[allow(irrefutable_let_patterns)]
637    pub fn into_restore_bonds(
638        self,
639    ) -> Option<(Vec<fidl_fuchsia_bluetooth_sys::BondingData>, BondingDelegateRestoreBondsResponder)>
640    {
641        if let BondingDelegateRequest::RestoreBonds { bonds, responder } = self {
642            Some((bonds, responder))
643        } else {
644            None
645        }
646    }
647
648    #[allow(irrefutable_let_patterns)]
649    pub fn into_watch_bonds(self) -> Option<(BondingDelegateWatchBondsResponder)> {
650        if let BondingDelegateRequest::WatchBonds { responder } = self {
651            Some((responder))
652        } else {
653            None
654        }
655    }
656
657    /// Name of the method defined in FIDL
658    pub fn method_name(&self) -> &'static str {
659        match *self {
660            BondingDelegateRequest::RestoreBonds { .. } => "restore_bonds",
661            BondingDelegateRequest::WatchBonds { .. } => "watch_bonds",
662            BondingDelegateRequest::_UnknownMethod {
663                method_type: fidl::MethodType::OneWay,
664                ..
665            } => "unknown one-way method",
666            BondingDelegateRequest::_UnknownMethod {
667                method_type: fidl::MethodType::TwoWay,
668                ..
669            } => "unknown two-way method",
670        }
671    }
672}
673
674#[derive(Debug, Clone)]
675pub struct BondingDelegateControlHandle {
676    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
677}
678
679impl fidl::endpoints::ControlHandle for BondingDelegateControlHandle {
680    fn shutdown(&self) {
681        self.inner.shutdown()
682    }
683
684    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
685        self.inner.shutdown_with_epitaph(status)
686    }
687
688    fn is_closed(&self) -> bool {
689        self.inner.channel().is_closed()
690    }
691    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
692        self.inner.channel().on_closed()
693    }
694
695    #[cfg(target_os = "fuchsia")]
696    fn signal_peer(
697        &self,
698        clear_mask: zx::Signals,
699        set_mask: zx::Signals,
700    ) -> Result<(), zx_status::Status> {
701        use fidl::Peered;
702        self.inner.channel().signal_peer(clear_mask, set_mask)
703    }
704}
705
706impl BondingDelegateControlHandle {}
707
708#[must_use = "FIDL methods require a response to be sent"]
709#[derive(Debug)]
710pub struct BondingDelegateRestoreBondsResponder {
711    control_handle: std::mem::ManuallyDrop<BondingDelegateControlHandle>,
712    tx_id: u32,
713}
714
715/// Set the the channel to be shutdown (see [`BondingDelegateControlHandle::shutdown`])
716/// if the responder is dropped without sending a response, so that the client
717/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
718impl std::ops::Drop for BondingDelegateRestoreBondsResponder {
719    fn drop(&mut self) {
720        self.control_handle.shutdown();
721        // Safety: drops once, never accessed again
722        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
723    }
724}
725
726impl fidl::endpoints::Responder for BondingDelegateRestoreBondsResponder {
727    type ControlHandle = BondingDelegateControlHandle;
728
729    fn control_handle(&self) -> &BondingDelegateControlHandle {
730        &self.control_handle
731    }
732
733    fn drop_without_shutdown(mut self) {
734        // Safety: drops once, never accessed again due to mem::forget
735        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
736        // Prevent Drop from running (which would shut down the channel)
737        std::mem::forget(self);
738    }
739}
740
741impl BondingDelegateRestoreBondsResponder {
742    /// Sends a response to the FIDL transaction.
743    ///
744    /// Sets the channel to shutdown if an error occurs.
745    pub fn send(
746        self,
747        mut errors: &[fidl_fuchsia_bluetooth_sys::BondingData],
748    ) -> Result<(), fidl::Error> {
749        let _result = self.send_raw(errors);
750        if _result.is_err() {
751            self.control_handle.shutdown();
752        }
753        self.drop_without_shutdown();
754        _result
755    }
756
757    /// Similar to "send" but does not shutdown the channel if an error occurs.
758    pub fn send_no_shutdown_on_err(
759        self,
760        mut errors: &[fidl_fuchsia_bluetooth_sys::BondingData],
761    ) -> Result<(), fidl::Error> {
762        let _result = self.send_raw(errors);
763        self.drop_without_shutdown();
764        _result
765    }
766
767    fn send_raw(
768        &self,
769        mut errors: &[fidl_fuchsia_bluetooth_sys::BondingData],
770    ) -> Result<(), fidl::Error> {
771        self.control_handle
772            .inner
773            .send::<fidl::encoding::FlexibleType<BondingDelegateRestoreBondsResponse>>(
774                fidl::encoding::Flexible::new((errors,)),
775                self.tx_id,
776                0x2f17e533f2475e96,
777                fidl::encoding::DynamicFlags::FLEXIBLE,
778            )
779    }
780}
781
782#[must_use = "FIDL methods require a response to be sent"]
783#[derive(Debug)]
784pub struct BondingDelegateWatchBondsResponder {
785    control_handle: std::mem::ManuallyDrop<BondingDelegateControlHandle>,
786    tx_id: u32,
787}
788
789/// Set the the channel to be shutdown (see [`BondingDelegateControlHandle::shutdown`])
790/// if the responder is dropped without sending a response, so that the client
791/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
792impl std::ops::Drop for BondingDelegateWatchBondsResponder {
793    fn drop(&mut self) {
794        self.control_handle.shutdown();
795        // Safety: drops once, never accessed again
796        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
797    }
798}
799
800impl fidl::endpoints::Responder for BondingDelegateWatchBondsResponder {
801    type ControlHandle = BondingDelegateControlHandle;
802
803    fn control_handle(&self) -> &BondingDelegateControlHandle {
804        &self.control_handle
805    }
806
807    fn drop_without_shutdown(mut self) {
808        // Safety: drops once, never accessed again due to mem::forget
809        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
810        // Prevent Drop from running (which would shut down the channel)
811        std::mem::forget(self);
812    }
813}
814
815impl BondingDelegateWatchBondsResponder {
816    /// Sends a response to the FIDL transaction.
817    ///
818    /// Sets the channel to shutdown if an error occurs.
819    pub fn send(self, mut payload: &BondingDelegateWatchBondsResponse) -> Result<(), fidl::Error> {
820        let _result = self.send_raw(payload);
821        if _result.is_err() {
822            self.control_handle.shutdown();
823        }
824        self.drop_without_shutdown();
825        _result
826    }
827
828    /// Similar to "send" but does not shutdown the channel if an error occurs.
829    pub fn send_no_shutdown_on_err(
830        self,
831        mut payload: &BondingDelegateWatchBondsResponse,
832    ) -> Result<(), fidl::Error> {
833        let _result = self.send_raw(payload);
834        self.drop_without_shutdown();
835        _result
836    }
837
838    fn send_raw(&self, mut payload: &BondingDelegateWatchBondsResponse) -> Result<(), fidl::Error> {
839        self.control_handle
840            .inner
841            .send::<fidl::encoding::FlexibleType<BondingDelegateWatchBondsResponse>>(
842                fidl::encoding::Flexible::new(payload),
843                self.tx_id,
844                0x48313cadc60cd07a,
845                fidl::encoding::DynamicFlags::FLEXIBLE,
846            )
847    }
848}
849
850#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
851pub struct DiscoverySessionMarker;
852
853impl fidl::endpoints::ProtocolMarker for DiscoverySessionMarker {
854    type Proxy = DiscoverySessionProxy;
855    type RequestStream = DiscoverySessionRequestStream;
856    #[cfg(target_os = "fuchsia")]
857    type SynchronousProxy = DiscoverySessionSynchronousProxy;
858
859    const DEBUG_NAME: &'static str = "(anonymous) DiscoverySession";
860}
861
862pub trait DiscoverySessionProxyInterface: Send + Sync {
863    fn r#stop(&self) -> Result<(), fidl::Error>;
864}
865#[derive(Debug)]
866#[cfg(target_os = "fuchsia")]
867pub struct DiscoverySessionSynchronousProxy {
868    client: fidl::client::sync::Client,
869}
870
871#[cfg(target_os = "fuchsia")]
872impl fidl::endpoints::SynchronousProxy for DiscoverySessionSynchronousProxy {
873    type Proxy = DiscoverySessionProxy;
874    type Protocol = DiscoverySessionMarker;
875
876    fn from_channel(inner: fidl::Channel) -> Self {
877        Self::new(inner)
878    }
879
880    fn into_channel(self) -> fidl::Channel {
881        self.client.into_channel()
882    }
883
884    fn as_channel(&self) -> &fidl::Channel {
885        self.client.as_channel()
886    }
887}
888
889#[cfg(target_os = "fuchsia")]
890impl DiscoverySessionSynchronousProxy {
891    pub fn new(channel: fidl::Channel) -> Self {
892        Self { client: fidl::client::sync::Client::new(channel) }
893    }
894
895    pub fn into_channel(self) -> fidl::Channel {
896        self.client.into_channel()
897    }
898
899    /// Waits until an event arrives and returns it. It is safe for other
900    /// threads to make concurrent requests while waiting for an event.
901    pub fn wait_for_event(
902        &self,
903        deadline: zx::MonotonicInstant,
904    ) -> Result<DiscoverySessionEvent, fidl::Error> {
905        DiscoverySessionEvent::decode(
906            self.client.wait_for_event::<DiscoverySessionMarker>(deadline)?,
907        )
908    }
909
910    /// Closes this DiscoverySession on the server end, ending discovery if this is the last open
911    /// DiscoverySession. This can be used to synchronize the closure on both ends of the protocol.
912    /// If synchronization is not required, the DiscoverySession protocol can simply be closed
913    /// instead.
914    pub fn r#stop(&self) -> Result<(), fidl::Error> {
915        self.client.send::<fidl::encoding::EmptyPayload>(
916            (),
917            0x3cbbd11b42632198,
918            fidl::encoding::DynamicFlags::FLEXIBLE,
919        )
920    }
921}
922
923#[cfg(target_os = "fuchsia")]
924impl From<DiscoverySessionSynchronousProxy> for zx::NullableHandle {
925    fn from(value: DiscoverySessionSynchronousProxy) -> Self {
926        value.into_channel().into()
927    }
928}
929
930#[cfg(target_os = "fuchsia")]
931impl From<fidl::Channel> for DiscoverySessionSynchronousProxy {
932    fn from(value: fidl::Channel) -> Self {
933        Self::new(value)
934    }
935}
936
937#[cfg(target_os = "fuchsia")]
938impl fidl::endpoints::FromClient for DiscoverySessionSynchronousProxy {
939    type Protocol = DiscoverySessionMarker;
940
941    fn from_client(value: fidl::endpoints::ClientEnd<DiscoverySessionMarker>) -> Self {
942        Self::new(value.into_channel())
943    }
944}
945
946#[derive(Debug, Clone)]
947pub struct DiscoverySessionProxy {
948    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
949}
950
951impl fidl::endpoints::Proxy for DiscoverySessionProxy {
952    type Protocol = DiscoverySessionMarker;
953
954    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
955        Self::new(inner)
956    }
957
958    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
959        self.client.into_channel().map_err(|client| Self { client })
960    }
961
962    fn as_channel(&self) -> &::fidl::AsyncChannel {
963        self.client.as_channel()
964    }
965}
966
967impl DiscoverySessionProxy {
968    /// Create a new Proxy for fuchsia.bluetooth.host/DiscoverySession.
969    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
970        let protocol_name = <DiscoverySessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
971        Self { client: fidl::client::Client::new(channel, protocol_name) }
972    }
973
974    /// Get a Stream of events from the remote end of the protocol.
975    ///
976    /// # Panics
977    ///
978    /// Panics if the event stream was already taken.
979    pub fn take_event_stream(&self) -> DiscoverySessionEventStream {
980        DiscoverySessionEventStream { event_receiver: self.client.take_event_receiver() }
981    }
982
983    /// Closes this DiscoverySession on the server end, ending discovery if this is the last open
984    /// DiscoverySession. This can be used to synchronize the closure on both ends of the protocol.
985    /// If synchronization is not required, the DiscoverySession protocol can simply be closed
986    /// instead.
987    pub fn r#stop(&self) -> Result<(), fidl::Error> {
988        DiscoverySessionProxyInterface::r#stop(self)
989    }
990}
991
992impl DiscoverySessionProxyInterface for DiscoverySessionProxy {
993    fn r#stop(&self) -> Result<(), fidl::Error> {
994        self.client.send::<fidl::encoding::EmptyPayload>(
995            (),
996            0x3cbbd11b42632198,
997            fidl::encoding::DynamicFlags::FLEXIBLE,
998        )
999    }
1000}
1001
1002pub struct DiscoverySessionEventStream {
1003    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1004}
1005
1006impl std::marker::Unpin for DiscoverySessionEventStream {}
1007
1008impl futures::stream::FusedStream for DiscoverySessionEventStream {
1009    fn is_terminated(&self) -> bool {
1010        self.event_receiver.is_terminated()
1011    }
1012}
1013
1014impl futures::Stream for DiscoverySessionEventStream {
1015    type Item = Result<DiscoverySessionEvent, fidl::Error>;
1016
1017    fn poll_next(
1018        mut self: std::pin::Pin<&mut Self>,
1019        cx: &mut std::task::Context<'_>,
1020    ) -> std::task::Poll<Option<Self::Item>> {
1021        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1022            &mut self.event_receiver,
1023            cx
1024        )?) {
1025            Some(buf) => std::task::Poll::Ready(Some(DiscoverySessionEvent::decode(buf))),
1026            None => std::task::Poll::Ready(None),
1027        }
1028    }
1029}
1030
1031#[derive(Debug)]
1032pub enum DiscoverySessionEvent {
1033    #[non_exhaustive]
1034    _UnknownEvent {
1035        /// Ordinal of the event that was sent.
1036        ordinal: u64,
1037    },
1038}
1039
1040impl DiscoverySessionEvent {
1041    /// Decodes a message buffer as a [`DiscoverySessionEvent`].
1042    fn decode(
1043        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1044    ) -> Result<DiscoverySessionEvent, fidl::Error> {
1045        let (bytes, _handles) = buf.split_mut();
1046        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1047        debug_assert_eq!(tx_header.tx_id, 0);
1048        match tx_header.ordinal {
1049            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1050                Ok(DiscoverySessionEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1051            }
1052            _ => Err(fidl::Error::UnknownOrdinal {
1053                ordinal: tx_header.ordinal,
1054                protocol_name:
1055                    <DiscoverySessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1056            }),
1057        }
1058    }
1059}
1060
1061/// A Stream of incoming requests for fuchsia.bluetooth.host/DiscoverySession.
1062pub struct DiscoverySessionRequestStream {
1063    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1064    is_terminated: bool,
1065}
1066
1067impl std::marker::Unpin for DiscoverySessionRequestStream {}
1068
1069impl futures::stream::FusedStream for DiscoverySessionRequestStream {
1070    fn is_terminated(&self) -> bool {
1071        self.is_terminated
1072    }
1073}
1074
1075impl fidl::endpoints::RequestStream for DiscoverySessionRequestStream {
1076    type Protocol = DiscoverySessionMarker;
1077    type ControlHandle = DiscoverySessionControlHandle;
1078
1079    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1080        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1081    }
1082
1083    fn control_handle(&self) -> Self::ControlHandle {
1084        DiscoverySessionControlHandle { inner: self.inner.clone() }
1085    }
1086
1087    fn into_inner(
1088        self,
1089    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1090    {
1091        (self.inner, self.is_terminated)
1092    }
1093
1094    fn from_inner(
1095        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1096        is_terminated: bool,
1097    ) -> Self {
1098        Self { inner, is_terminated }
1099    }
1100}
1101
1102impl futures::Stream for DiscoverySessionRequestStream {
1103    type Item = Result<DiscoverySessionRequest, fidl::Error>;
1104
1105    fn poll_next(
1106        mut self: std::pin::Pin<&mut Self>,
1107        cx: &mut std::task::Context<'_>,
1108    ) -> std::task::Poll<Option<Self::Item>> {
1109        let this = &mut *self;
1110        if this.inner.check_shutdown(cx) {
1111            this.is_terminated = true;
1112            return std::task::Poll::Ready(None);
1113        }
1114        if this.is_terminated {
1115            panic!("polled DiscoverySessionRequestStream after completion");
1116        }
1117        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1118            |bytes, handles| {
1119                match this.inner.channel().read_etc(cx, bytes, handles) {
1120                    std::task::Poll::Ready(Ok(())) => {}
1121                    std::task::Poll::Pending => return std::task::Poll::Pending,
1122                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1123                        this.is_terminated = true;
1124                        return std::task::Poll::Ready(None);
1125                    }
1126                    std::task::Poll::Ready(Err(e)) => {
1127                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1128                            e.into(),
1129                        ))));
1130                    }
1131                }
1132
1133                // A message has been received from the channel
1134                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1135
1136                std::task::Poll::Ready(Some(match header.ordinal {
1137                    0x3cbbd11b42632198 => {
1138                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1139                        let mut req = fidl::new_empty!(
1140                            fidl::encoding::EmptyPayload,
1141                            fidl::encoding::DefaultFuchsiaResourceDialect
1142                        );
1143                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1144                        let control_handle =
1145                            DiscoverySessionControlHandle { inner: this.inner.clone() };
1146                        Ok(DiscoverySessionRequest::Stop { control_handle })
1147                    }
1148                    _ if header.tx_id == 0
1149                        && header
1150                            .dynamic_flags()
1151                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1152                    {
1153                        Ok(DiscoverySessionRequest::_UnknownMethod {
1154                            ordinal: header.ordinal,
1155                            control_handle: DiscoverySessionControlHandle {
1156                                inner: this.inner.clone(),
1157                            },
1158                            method_type: fidl::MethodType::OneWay,
1159                        })
1160                    }
1161                    _ if header
1162                        .dynamic_flags()
1163                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1164                    {
1165                        this.inner.send_framework_err(
1166                            fidl::encoding::FrameworkErr::UnknownMethod,
1167                            header.tx_id,
1168                            header.ordinal,
1169                            header.dynamic_flags(),
1170                            (bytes, handles),
1171                        )?;
1172                        Ok(DiscoverySessionRequest::_UnknownMethod {
1173                            ordinal: header.ordinal,
1174                            control_handle: DiscoverySessionControlHandle {
1175                                inner: this.inner.clone(),
1176                            },
1177                            method_type: fidl::MethodType::TwoWay,
1178                        })
1179                    }
1180                    _ => Err(fidl::Error::UnknownOrdinal {
1181                        ordinal: header.ordinal,
1182                        protocol_name:
1183                            <DiscoverySessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1184                    }),
1185                }))
1186            },
1187        )
1188    }
1189}
1190
1191/// A token protocol representing discovery being enabled.
1192#[derive(Debug)]
1193pub enum DiscoverySessionRequest {
1194    /// Closes this DiscoverySession on the server end, ending discovery if this is the last open
1195    /// DiscoverySession. This can be used to synchronize the closure on both ends of the protocol.
1196    /// If synchronization is not required, the DiscoverySession protocol can simply be closed
1197    /// instead.
1198    Stop { control_handle: DiscoverySessionControlHandle },
1199    /// An interaction was received which does not match any known method.
1200    #[non_exhaustive]
1201    _UnknownMethod {
1202        /// Ordinal of the method that was called.
1203        ordinal: u64,
1204        control_handle: DiscoverySessionControlHandle,
1205        method_type: fidl::MethodType,
1206    },
1207}
1208
1209impl DiscoverySessionRequest {
1210    #[allow(irrefutable_let_patterns)]
1211    pub fn into_stop(self) -> Option<(DiscoverySessionControlHandle)> {
1212        if let DiscoverySessionRequest::Stop { control_handle } = self {
1213            Some((control_handle))
1214        } else {
1215            None
1216        }
1217    }
1218
1219    /// Name of the method defined in FIDL
1220    pub fn method_name(&self) -> &'static str {
1221        match *self {
1222            DiscoverySessionRequest::Stop { .. } => "stop",
1223            DiscoverySessionRequest::_UnknownMethod {
1224                method_type: fidl::MethodType::OneWay,
1225                ..
1226            } => "unknown one-way method",
1227            DiscoverySessionRequest::_UnknownMethod {
1228                method_type: fidl::MethodType::TwoWay,
1229                ..
1230            } => "unknown two-way method",
1231        }
1232    }
1233}
1234
1235#[derive(Debug, Clone)]
1236pub struct DiscoverySessionControlHandle {
1237    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1238}
1239
1240impl fidl::endpoints::ControlHandle for DiscoverySessionControlHandle {
1241    fn shutdown(&self) {
1242        self.inner.shutdown()
1243    }
1244
1245    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1246        self.inner.shutdown_with_epitaph(status)
1247    }
1248
1249    fn is_closed(&self) -> bool {
1250        self.inner.channel().is_closed()
1251    }
1252    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1253        self.inner.channel().on_closed()
1254    }
1255
1256    #[cfg(target_os = "fuchsia")]
1257    fn signal_peer(
1258        &self,
1259        clear_mask: zx::Signals,
1260        set_mask: zx::Signals,
1261    ) -> Result<(), zx_status::Status> {
1262        use fidl::Peered;
1263        self.inner.channel().signal_peer(clear_mask, set_mask)
1264    }
1265}
1266
1267impl DiscoverySessionControlHandle {}
1268
1269#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1270pub struct HostMarker;
1271
1272impl fidl::endpoints::ProtocolMarker for HostMarker {
1273    type Proxy = HostProxy;
1274    type RequestStream = HostRequestStream;
1275    #[cfg(target_os = "fuchsia")]
1276    type SynchronousProxy = HostSynchronousProxy;
1277
1278    const DEBUG_NAME: &'static str = "(anonymous) Host";
1279}
1280pub type HostSetLocalNameResult = Result<(), fidl_fuchsia_bluetooth_sys::Error>;
1281pub type HostSetDeviceClassResult = Result<(), fidl_fuchsia_bluetooth_sys::Error>;
1282pub type HostSetConnectableResult = Result<(), fidl_fuchsia_bluetooth_sys::Error>;
1283pub type HostSetDiscoverableResult = Result<(), fidl_fuchsia_bluetooth_sys::Error>;
1284pub type HostConnectResult = Result<(), fidl_fuchsia_bluetooth_sys::Error>;
1285pub type HostDisconnectResult = Result<(), fidl_fuchsia_bluetooth_sys::Error>;
1286pub type HostPairResult = Result<(), fidl_fuchsia_bluetooth_sys::Error>;
1287pub type HostForgetResult = Result<(), fidl_fuchsia_bluetooth_sys::Error>;
1288
1289pub trait HostProxyInterface: Send + Sync {
1290    fn r#request_protocol(&self, payload: ProtocolRequest) -> Result<(), fidl::Error>;
1291    fn r#shutdown(&self) -> Result<(), fidl::Error>;
1292    type WatchStateResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth_sys::HostInfo, fidl::Error>>
1293        + Send;
1294    fn r#watch_state(&self) -> Self::WatchStateResponseFut;
1295    fn r#set_local_data(
1296        &self,
1297        payload: &fidl_fuchsia_bluetooth_sys::HostData,
1298    ) -> Result<(), fidl::Error>;
1299    fn r#set_peer_watcher(
1300        &self,
1301        peer_watcher: fidl::endpoints::ServerEnd<PeerWatcherMarker>,
1302    ) -> Result<(), fidl::Error>;
1303    type SetLocalNameResponseFut: std::future::Future<Output = Result<HostSetLocalNameResult, fidl::Error>>
1304        + Send;
1305    fn r#set_local_name(&self, local_name: &str) -> Self::SetLocalNameResponseFut;
1306    type SetDeviceClassResponseFut: std::future::Future<Output = Result<HostSetDeviceClassResult, fidl::Error>>
1307        + Send;
1308    fn r#set_device_class(
1309        &self,
1310        device_class: &fidl_fuchsia_bluetooth::DeviceClass,
1311    ) -> Self::SetDeviceClassResponseFut;
1312    fn r#start_discovery(&self, payload: HostStartDiscoveryRequest) -> Result<(), fidl::Error>;
1313    type SetConnectableResponseFut: std::future::Future<Output = Result<HostSetConnectableResult, fidl::Error>>
1314        + Send;
1315    fn r#set_connectable(&self, enabled: bool) -> Self::SetConnectableResponseFut;
1316    type SetDiscoverableResponseFut: std::future::Future<Output = Result<HostSetDiscoverableResult, fidl::Error>>
1317        + Send;
1318    fn r#set_discoverable(&self, enabled: bool) -> Self::SetDiscoverableResponseFut;
1319    type ConnectResponseFut: std::future::Future<Output = Result<HostConnectResult, fidl::Error>>
1320        + Send;
1321    fn r#connect(&self, id: &fidl_fuchsia_bluetooth::PeerId) -> Self::ConnectResponseFut;
1322    type DisconnectResponseFut: std::future::Future<Output = Result<HostDisconnectResult, fidl::Error>>
1323        + Send;
1324    fn r#disconnect(&self, id: &fidl_fuchsia_bluetooth::PeerId) -> Self::DisconnectResponseFut;
1325    type PairResponseFut: std::future::Future<Output = Result<HostPairResult, fidl::Error>> + Send;
1326    fn r#pair(
1327        &self,
1328        id: &fidl_fuchsia_bluetooth::PeerId,
1329        options: &fidl_fuchsia_bluetooth_sys::PairingOptions,
1330    ) -> Self::PairResponseFut;
1331    type ForgetResponseFut: std::future::Future<Output = Result<HostForgetResult, fidl::Error>>
1332        + Send;
1333    fn r#forget(&self, id: &fidl_fuchsia_bluetooth::PeerId) -> Self::ForgetResponseFut;
1334    fn r#enable_background_scan(&self, enabled: bool) -> Result<(), fidl::Error>;
1335    fn r#enable_privacy(&self, enabled: bool) -> Result<(), fidl::Error>;
1336    fn r#set_br_edr_security_mode(
1337        &self,
1338        bredr_security_mode: fidl_fuchsia_bluetooth_sys::BrEdrSecurityMode,
1339    ) -> Result<(), fidl::Error>;
1340    fn r#set_le_security_mode(
1341        &self,
1342        le_security_mode: fidl_fuchsia_bluetooth_sys::LeSecurityMode,
1343    ) -> Result<(), fidl::Error>;
1344    fn r#set_pairing_delegate(
1345        &self,
1346        input: fidl_fuchsia_bluetooth_sys::InputCapability,
1347        output: fidl_fuchsia_bluetooth_sys::OutputCapability,
1348        delegate: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth_sys::PairingDelegateMarker>,
1349    ) -> Result<(), fidl::Error>;
1350    fn r#set_bonding_delegate(
1351        &self,
1352        delegate: fidl::endpoints::ServerEnd<BondingDelegateMarker>,
1353    ) -> Result<(), fidl::Error>;
1354}
1355#[derive(Debug)]
1356#[cfg(target_os = "fuchsia")]
1357pub struct HostSynchronousProxy {
1358    client: fidl::client::sync::Client,
1359}
1360
1361#[cfg(target_os = "fuchsia")]
1362impl fidl::endpoints::SynchronousProxy for HostSynchronousProxy {
1363    type Proxy = HostProxy;
1364    type Protocol = HostMarker;
1365
1366    fn from_channel(inner: fidl::Channel) -> Self {
1367        Self::new(inner)
1368    }
1369
1370    fn into_channel(self) -> fidl::Channel {
1371        self.client.into_channel()
1372    }
1373
1374    fn as_channel(&self) -> &fidl::Channel {
1375        self.client.as_channel()
1376    }
1377}
1378
1379#[cfg(target_os = "fuchsia")]
1380impl HostSynchronousProxy {
1381    pub fn new(channel: fidl::Channel) -> Self {
1382        Self { client: fidl::client::sync::Client::new(channel) }
1383    }
1384
1385    pub fn into_channel(self) -> fidl::Channel {
1386        self.client.into_channel()
1387    }
1388
1389    /// Waits until an event arrives and returns it. It is safe for other
1390    /// threads to make concurrent requests while waiting for an event.
1391    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<HostEvent, fidl::Error> {
1392        HostEvent::decode(self.client.wait_for_event::<HostMarker>(deadline)?)
1393    }
1394
1395    /// Fulfills a given protocol request. bt-host will start processing FIDL messages. If the
1396    /// request cannot be fulfilled, the bt-host device will close its end of the given channel.
1397    pub fn r#request_protocol(&self, mut payload: ProtocolRequest) -> Result<(), fidl::Error> {
1398        self.client.send::<ProtocolRequest>(
1399            &mut payload,
1400            0x45cb5bf9834016b4,
1401            fidl::encoding::DynamicFlags::FLEXIBLE,
1402        )
1403    }
1404
1405    /// Shuts down the host, ending all active Bluetooth procedures:
1406    ///
1407    /// * All FIDL interface handles associated with this host are closed and all
1408    ///   connections initiated via FIDL clients are severed.
1409    /// * All scan, discovery, and advertising procedures are stopped.
1410    /// * Bonded devices are cleared and removed from the auto-connect lists.
1411    /// * Auto-connected peripherals are disconnected.
1412    ///
1413    /// This effectively resets the host to its initial state and the host remains
1414    /// available for future requests.
1415    ///
1416    /// The Host will continue to send OnDeviceUpdated events as procedures get
1417    /// terminated.
1418    ///
1419    /// The Host protocol will close when shutdown is complete.
1420    pub fn r#shutdown(&self) -> Result<(), fidl::Error> {
1421        self.client.send::<fidl::encoding::EmptyPayload>(
1422            (),
1423            0x18747459244591c9,
1424            fidl::encoding::DynamicFlags::empty(),
1425        )
1426    }
1427
1428    /// Returns information about the Bluetooth host subsystem and controller managed by this Host
1429    /// instance. If there has been no change to the state since the last call to this method, the
1430    /// response will be deferred until there is a change.
1431    ///
1432    /// The returned `info` structure will be populated with the current state of the bt-host
1433    /// device. However the `active` parameter will never be populated. This field is managed
1434    /// by a higher layer.
1435    pub fn r#watch_state(
1436        &self,
1437        ___deadline: zx::MonotonicInstant,
1438    ) -> Result<fidl_fuchsia_bluetooth_sys::HostInfo, fidl::Error> {
1439        let _response = self.client.send_query::<
1440            fidl::encoding::EmptyPayload,
1441            fidl::encoding::FlexibleType<HostWatchStateResponse>,
1442            HostMarker,
1443        >(
1444            (),
1445            0x19157554e2a3db52,
1446            fidl::encoding::DynamicFlags::FLEXIBLE,
1447            ___deadline,
1448        )?
1449        .into_result::<HostMarker>("watch_state")?;
1450        Ok(_response.info)
1451    }
1452
1453    /// Assigns local data to this host.
1454    pub fn r#set_local_data(
1455        &self,
1456        mut payload: &fidl_fuchsia_bluetooth_sys::HostData,
1457    ) -> Result<(), fidl::Error> {
1458        self.client.send::<fidl_fuchsia_bluetooth_sys::HostData>(
1459            payload,
1460            0x57b70f72bb0a9187,
1461            fidl::encoding::DynamicFlags::empty(),
1462        )
1463    }
1464
1465    /// Sets a PeerWatcher protocol that will be notified of changes to peers.
1466    /// Only 1 PeerWatcher can be configured at a time.
1467    pub fn r#set_peer_watcher(
1468        &self,
1469        mut peer_watcher: fidl::endpoints::ServerEnd<PeerWatcherMarker>,
1470    ) -> Result<(), fidl::Error> {
1471        self.client.send::<HostSetPeerWatcherRequest>(
1472            (peer_watcher,),
1473            0x3dec6b3c99c0a437,
1474            fidl::encoding::DynamicFlags::FLEXIBLE,
1475        )
1476    }
1477
1478    /// Sets the local name for this host device.
1479    pub fn r#set_local_name(
1480        &self,
1481        mut local_name: &str,
1482        ___deadline: zx::MonotonicInstant,
1483    ) -> Result<HostSetLocalNameResult, fidl::Error> {
1484        let _response = self
1485            .client
1486            .send_query::<HostSetLocalNameRequest, fidl::encoding::FlexibleResultType<
1487                fidl::encoding::EmptyStruct,
1488                fidl_fuchsia_bluetooth_sys::Error,
1489            >, HostMarker>(
1490                (local_name,),
1491                0x85e98b56b98f123,
1492                fidl::encoding::DynamicFlags::FLEXIBLE,
1493                ___deadline,
1494            )?
1495            .into_result::<HostMarker>("set_local_name")?;
1496        Ok(_response.map(|x| x))
1497    }
1498
1499    /// Sets the device class for this host device.
1500    pub fn r#set_device_class(
1501        &self,
1502        mut device_class: &fidl_fuchsia_bluetooth::DeviceClass,
1503        ___deadline: zx::MonotonicInstant,
1504    ) -> Result<HostSetDeviceClassResult, fidl::Error> {
1505        let _response = self
1506            .client
1507            .send_query::<HostSetDeviceClassRequest, fidl::encoding::FlexibleResultType<
1508                fidl::encoding::EmptyStruct,
1509                fidl_fuchsia_bluetooth_sys::Error,
1510            >, HostMarker>(
1511                (device_class,),
1512                0x4caef8f835950de2,
1513                fidl::encoding::DynamicFlags::FLEXIBLE,
1514                ___deadline,
1515            )?
1516            .into_result::<HostMarker>("set_device_class")?;
1517        Ok(_response.map(|x| x))
1518    }
1519
1520    /// Initiates a general discovery procedure for BR/EDR and LE devices. On success, discovered
1521    /// peers can be monitored using the [`fuchsia.bluetooth.host/Host.WatchPeers`] method. On Error,
1522    /// an epitaph will be returned from `token`. If the device does not support BR/EDR, only LE
1523    /// discovery will be performed.
1524    ///
1525    /// On the LE transport, only general-discoverable and connectable peripherals will be reported.
1526    ///
1527    /// Discovery will continue until all discovery sessions are closed.
1528    ///
1529    /// + request `token` The DiscoverySession protocol that must be held open as long as
1530    ///     discovery should be enabled. Closing it will stop discovery if no other sessions
1531    ///     are open.
1532    pub fn r#start_discovery(
1533        &self,
1534        mut payload: HostStartDiscoveryRequest,
1535    ) -> Result<(), fidl::Error> {
1536        self.client.send::<HostStartDiscoveryRequest>(
1537            &mut payload,
1538            0x3f40a85341413e4,
1539            fidl::encoding::DynamicFlags::FLEXIBLE,
1540        )
1541    }
1542
1543    /// Sets whether this host should be connectable.
1544    pub fn r#set_connectable(
1545        &self,
1546        mut enabled: bool,
1547        ___deadline: zx::MonotonicInstant,
1548    ) -> Result<HostSetConnectableResult, fidl::Error> {
1549        let _response = self
1550            .client
1551            .send_query::<HostSetConnectableRequest, fidl::encoding::FlexibleResultType<
1552                fidl::encoding::EmptyStruct,
1553                fidl_fuchsia_bluetooth_sys::Error,
1554            >, HostMarker>(
1555                (enabled,),
1556                0x187a6a82e811fa92,
1557                fidl::encoding::DynamicFlags::FLEXIBLE,
1558                ___deadline,
1559            )?
1560            .into_result::<HostMarker>("set_connectable")?;
1561        Ok(_response.map(|x| x))
1562    }
1563
1564    /// Sets whether this host should be discoverable.
1565    pub fn r#set_discoverable(
1566        &self,
1567        mut enabled: bool,
1568        ___deadline: zx::MonotonicInstant,
1569    ) -> Result<HostSetDiscoverableResult, fidl::Error> {
1570        let _response = self
1571            .client
1572            .send_query::<HostSetDiscoverableRequest, fidl::encoding::FlexibleResultType<
1573                fidl::encoding::EmptyStruct,
1574                fidl_fuchsia_bluetooth_sys::Error,
1575            >, HostMarker>(
1576                (enabled,),
1577                0x89f8c7da63e36de,
1578                fidl::encoding::DynamicFlags::FLEXIBLE,
1579                ___deadline,
1580            )?
1581            .into_result::<HostMarker>("set_discoverable")?;
1582        Ok(_response.map(|x| x))
1583    }
1584
1585    /// Establish a BR/EDR and/or LE connection to the peer with identifier `id`:
1586    ///
1587    ///   - If the peer is known to support the BR/EDR transport then a logical link over that
1588    ///     transport will be established to the device. If the connection attempt is successful,
1589    ///     local services registered using "RequestProfile()" will be available to the peer.
1590    ///     Traditional services discovered on the peer will be notified to local services
1591    ///     asynchronously.
1592    ///
1593    ///   - If the peer is known to support the LE transport then a logical link over that
1594    ///     transport will be established to the device. If the connection attempt is successful,
1595    ///     GATT services in the local database (populated via RequestGattServer()) will become
1596    ///     available to the peer. Similarly, remote GATT services that are discovered on the
1597    ///     peer will become available to holders of a gatt.Client capability and to device drivers
1598    ///     that can bind to the bt-gatt-svc class of devices.
1599    ///
1600    /// The result of the procedure will be communicated via `status`. If the remote device
1601    /// supports both BR/EDR and LE transports and a link cannot be established over both, then an
1602    /// error Status will be returned and neither transport will be connected.
1603    pub fn r#connect(
1604        &self,
1605        mut id: &fidl_fuchsia_bluetooth::PeerId,
1606        ___deadline: zx::MonotonicInstant,
1607    ) -> Result<HostConnectResult, fidl::Error> {
1608        let _response = self
1609            .client
1610            .send_query::<HostConnectRequest, fidl::encoding::FlexibleResultType<
1611                fidl::encoding::EmptyStruct,
1612                fidl_fuchsia_bluetooth_sys::Error,
1613            >, HostMarker>(
1614                (id,),
1615                0x5a56139c993e7240,
1616                fidl::encoding::DynamicFlags::FLEXIBLE,
1617                ___deadline,
1618            )?
1619            .into_result::<HostMarker>("connect")?;
1620        Ok(_response.map(|x| x))
1621    }
1622
1623    /// Terminate all connections (BR/EDR or LE) to the remote peer with identifier `id`.
1624    ///
1625    /// + request `id` The identifier of the peer to disconnect.
1626    /// - response `status` Contains an error if either LE or BR/EDR transport fails to disconnect.
1627    ///                     Contains success when both transports are successfully disconnected or
1628    ///                     if the peer is already disconnected.
1629    pub fn r#disconnect(
1630        &self,
1631        mut id: &fidl_fuchsia_bluetooth::PeerId,
1632        ___deadline: zx::MonotonicInstant,
1633    ) -> Result<HostDisconnectResult, fidl::Error> {
1634        let _response = self
1635            .client
1636            .send_query::<HostDisconnectRequest, fidl::encoding::FlexibleResultType<
1637                fidl::encoding::EmptyStruct,
1638                fidl_fuchsia_bluetooth_sys::Error,
1639            >, HostMarker>(
1640                (id,),
1641                0x33211717491121b1,
1642                fidl::encoding::DynamicFlags::FLEXIBLE,
1643                ___deadline,
1644            )?
1645            .into_result::<HostMarker>("disconnect")?;
1646        Ok(_response.map(|x| x))
1647    }
1648
1649    /// Initiates pairing to the peer with the supplied `id` and `options`. Returns an error if no
1650    /// connected peer with `id` is found or the pairing procedure fails.
1651    ///
1652    /// If `options` specifies a higher security level than the current pairing, this method
1653    /// attempts to raise the security level. Otherwise this method has no effect and returns
1654    /// success.
1655    ///
1656    /// NOTE: This is intended to satisfy test scenarios that require pairing procedures to be
1657    /// initiated without relying on service access. In normal operation, Bluetooth security is
1658    /// enforced during service access.
1659    pub fn r#pair(
1660        &self,
1661        mut id: &fidl_fuchsia_bluetooth::PeerId,
1662        mut options: &fidl_fuchsia_bluetooth_sys::PairingOptions,
1663        ___deadline: zx::MonotonicInstant,
1664    ) -> Result<HostPairResult, fidl::Error> {
1665        let _response = self
1666            .client
1667            .send_query::<HostPairRequest, fidl::encoding::FlexibleResultType<
1668                fidl::encoding::EmptyStruct,
1669                fidl_fuchsia_bluetooth_sys::Error,
1670            >, HostMarker>(
1671                (id, options),
1672                0x2efaec6dc5d62ca2,
1673                fidl::encoding::DynamicFlags::FLEXIBLE,
1674                ___deadline,
1675            )?
1676            .into_result::<HostMarker>("pair")?;
1677        Ok(_response.map(|x| x))
1678    }
1679
1680    /// Deletes a peer from the Bluetooth host. If the peer is connected, it will be disconnected.
1681    /// `device_id` will no longer refer to any peer, even if a device with the same address is
1682    /// discovered again.
1683    ///
1684    /// Returns success after no peer exists that's identified by `device_id` (even if it didn't
1685    /// exist before Forget), failure if the peer specified by `device_id` could not be
1686    /// disconnected or deleted and still exists.
1687    pub fn r#forget(
1688        &self,
1689        mut id: &fidl_fuchsia_bluetooth::PeerId,
1690        ___deadline: zx::MonotonicInstant,
1691    ) -> Result<HostForgetResult, fidl::Error> {
1692        let _response = self
1693            .client
1694            .send_query::<HostForgetRequest, fidl::encoding::FlexibleResultType<
1695                fidl::encoding::EmptyStruct,
1696                fidl_fuchsia_bluetooth_sys::Error,
1697            >, HostMarker>(
1698                (id,),
1699                0x904f58dbdd4490a,
1700                fidl::encoding::DynamicFlags::FLEXIBLE,
1701                ___deadline,
1702            )?
1703            .into_result::<HostMarker>("forget")?;
1704        Ok(_response.map(|x| x))
1705    }
1706
1707    /// Enable or disable a passive LE background scan. When enabled, the bt-host
1708    /// device will continuously perform a passive LE scan in the background when
1709    /// no device discovery sessions are active and accept connection requests from
1710    /// bonded peripherals.
1711    pub fn r#enable_background_scan(&self, mut enabled: bool) -> Result<(), fidl::Error> {
1712        self.client.send::<HostEnableBackgroundScanRequest>(
1713            (enabled,),
1714            0x51f038a8cf498946,
1715            fidl::encoding::DynamicFlags::FLEXIBLE,
1716        )
1717    }
1718
1719    /// Enable or disable the LE privacy feature. When enabled, the bt-host device will use a
1720    /// private device address in all LE procedures. When disabled, the public identity address will
1721    /// be used instead (which is the default).
1722    pub fn r#enable_privacy(&self, mut enabled: bool) -> Result<(), fidl::Error> {
1723        self.client.send::<HostEnablePrivacyRequest>(
1724            (enabled,),
1725            0x370a76e1d2b5034b,
1726            fidl::encoding::DynamicFlags::empty(),
1727        )
1728    }
1729
1730    /// Set the GAP BR/EDR Security Mode of the host. bt-host only supports encrypted,
1731    /// connection-based security modes, i.e. Mode 4 and Secure Connections Only mode. If the
1732    /// security mode is set to Secure Connections Only, any existing encrypted connections which
1733    /// do not meet the security requirements of Secure Connections Only mode will be disconnected.
1734    pub fn r#set_br_edr_security_mode(
1735        &self,
1736        mut bredr_security_mode: fidl_fuchsia_bluetooth_sys::BrEdrSecurityMode,
1737    ) -> Result<(), fidl::Error> {
1738        self.client.send::<HostSetBrEdrSecurityModeRequest>(
1739            (bredr_security_mode,),
1740            0x1d94d20717459281,
1741            fidl::encoding::DynamicFlags::empty(),
1742        )
1743    }
1744
1745    /// Set the GAP LE Security Mode of the host. bt-host only supports encrypted, connection-based
1746    /// security modes, i.e. Mode 1 and Secure Connections Only mode. If the security mode is set
1747    /// to Secure Connections Only, any existing encrypted connections which do not meet the
1748    /// security requirements of Secure Connections Only mode will be disconnected.
1749    pub fn r#set_le_security_mode(
1750        &self,
1751        mut le_security_mode: fidl_fuchsia_bluetooth_sys::LeSecurityMode,
1752    ) -> Result<(), fidl::Error> {
1753        self.client.send::<HostSetLeSecurityModeRequest>(
1754            (le_security_mode,),
1755            0x6ef0a424a336a81,
1756            fidl::encoding::DynamicFlags::empty(),
1757        )
1758    }
1759
1760    /// Assigns the pairing delegate that will respond to authentication challenges using the given
1761    /// I/O capabilities. Calling this method cancels any on-going pairing procedure started
1762    /// using a previous delegate. Pairing requests will be rejected if no PairingDelegate has been
1763    /// assigned.
1764    pub fn r#set_pairing_delegate(
1765        &self,
1766        mut input: fidl_fuchsia_bluetooth_sys::InputCapability,
1767        mut output: fidl_fuchsia_bluetooth_sys::OutputCapability,
1768        mut delegate: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth_sys::PairingDelegateMarker>,
1769    ) -> Result<(), fidl::Error> {
1770        self.client.send::<HostSetPairingDelegateRequest>(
1771            (input, output, delegate),
1772            0x21a5bba5ffc9773e,
1773            fidl::encoding::DynamicFlags::FLEXIBLE,
1774        )
1775    }
1776
1777    /// Set a BondingDelegate protocol that will be notified of new and removed bonds that need to
1778    /// be persisted. If a delegate is already set, the new `delegate` will be closed with
1779    /// ALREADY_BOUND
1780    pub fn r#set_bonding_delegate(
1781        &self,
1782        mut delegate: fidl::endpoints::ServerEnd<BondingDelegateMarker>,
1783    ) -> Result<(), fidl::Error> {
1784        self.client.send::<HostSetBondingDelegateRequest>(
1785            (delegate,),
1786            0x651d446a05b664d4,
1787            fidl::encoding::DynamicFlags::FLEXIBLE,
1788        )
1789    }
1790}
1791
1792#[cfg(target_os = "fuchsia")]
1793impl From<HostSynchronousProxy> for zx::NullableHandle {
1794    fn from(value: HostSynchronousProxy) -> Self {
1795        value.into_channel().into()
1796    }
1797}
1798
1799#[cfg(target_os = "fuchsia")]
1800impl From<fidl::Channel> for HostSynchronousProxy {
1801    fn from(value: fidl::Channel) -> Self {
1802        Self::new(value)
1803    }
1804}
1805
1806#[cfg(target_os = "fuchsia")]
1807impl fidl::endpoints::FromClient for HostSynchronousProxy {
1808    type Protocol = HostMarker;
1809
1810    fn from_client(value: fidl::endpoints::ClientEnd<HostMarker>) -> Self {
1811        Self::new(value.into_channel())
1812    }
1813}
1814
1815#[derive(Debug, Clone)]
1816pub struct HostProxy {
1817    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1818}
1819
1820impl fidl::endpoints::Proxy for HostProxy {
1821    type Protocol = HostMarker;
1822
1823    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1824        Self::new(inner)
1825    }
1826
1827    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1828        self.client.into_channel().map_err(|client| Self { client })
1829    }
1830
1831    fn as_channel(&self) -> &::fidl::AsyncChannel {
1832        self.client.as_channel()
1833    }
1834}
1835
1836impl HostProxy {
1837    /// Create a new Proxy for fuchsia.bluetooth.host/Host.
1838    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1839        let protocol_name = <HostMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1840        Self { client: fidl::client::Client::new(channel, protocol_name) }
1841    }
1842
1843    /// Get a Stream of events from the remote end of the protocol.
1844    ///
1845    /// # Panics
1846    ///
1847    /// Panics if the event stream was already taken.
1848    pub fn take_event_stream(&self) -> HostEventStream {
1849        HostEventStream { event_receiver: self.client.take_event_receiver() }
1850    }
1851
1852    /// Fulfills a given protocol request. bt-host will start processing FIDL messages. If the
1853    /// request cannot be fulfilled, the bt-host device will close its end of the given channel.
1854    pub fn r#request_protocol(&self, mut payload: ProtocolRequest) -> Result<(), fidl::Error> {
1855        HostProxyInterface::r#request_protocol(self, payload)
1856    }
1857
1858    /// Shuts down the host, ending all active Bluetooth procedures:
1859    ///
1860    /// * All FIDL interface handles associated with this host are closed and all
1861    ///   connections initiated via FIDL clients are severed.
1862    /// * All scan, discovery, and advertising procedures are stopped.
1863    /// * Bonded devices are cleared and removed from the auto-connect lists.
1864    /// * Auto-connected peripherals are disconnected.
1865    ///
1866    /// This effectively resets the host to its initial state and the host remains
1867    /// available for future requests.
1868    ///
1869    /// The Host will continue to send OnDeviceUpdated events as procedures get
1870    /// terminated.
1871    ///
1872    /// The Host protocol will close when shutdown is complete.
1873    pub fn r#shutdown(&self) -> Result<(), fidl::Error> {
1874        HostProxyInterface::r#shutdown(self)
1875    }
1876
1877    /// Returns information about the Bluetooth host subsystem and controller managed by this Host
1878    /// instance. If there has been no change to the state since the last call to this method, the
1879    /// response will be deferred until there is a change.
1880    ///
1881    /// The returned `info` structure will be populated with the current state of the bt-host
1882    /// device. However the `active` parameter will never be populated. This field is managed
1883    /// by a higher layer.
1884    pub fn r#watch_state(
1885        &self,
1886    ) -> fidl::client::QueryResponseFut<
1887        fidl_fuchsia_bluetooth_sys::HostInfo,
1888        fidl::encoding::DefaultFuchsiaResourceDialect,
1889    > {
1890        HostProxyInterface::r#watch_state(self)
1891    }
1892
1893    /// Assigns local data to this host.
1894    pub fn r#set_local_data(
1895        &self,
1896        mut payload: &fidl_fuchsia_bluetooth_sys::HostData,
1897    ) -> Result<(), fidl::Error> {
1898        HostProxyInterface::r#set_local_data(self, payload)
1899    }
1900
1901    /// Sets a PeerWatcher protocol that will be notified of changes to peers.
1902    /// Only 1 PeerWatcher can be configured at a time.
1903    pub fn r#set_peer_watcher(
1904        &self,
1905        mut peer_watcher: fidl::endpoints::ServerEnd<PeerWatcherMarker>,
1906    ) -> Result<(), fidl::Error> {
1907        HostProxyInterface::r#set_peer_watcher(self, peer_watcher)
1908    }
1909
1910    /// Sets the local name for this host device.
1911    pub fn r#set_local_name(
1912        &self,
1913        mut local_name: &str,
1914    ) -> fidl::client::QueryResponseFut<
1915        HostSetLocalNameResult,
1916        fidl::encoding::DefaultFuchsiaResourceDialect,
1917    > {
1918        HostProxyInterface::r#set_local_name(self, local_name)
1919    }
1920
1921    /// Sets the device class for this host device.
1922    pub fn r#set_device_class(
1923        &self,
1924        mut device_class: &fidl_fuchsia_bluetooth::DeviceClass,
1925    ) -> fidl::client::QueryResponseFut<
1926        HostSetDeviceClassResult,
1927        fidl::encoding::DefaultFuchsiaResourceDialect,
1928    > {
1929        HostProxyInterface::r#set_device_class(self, device_class)
1930    }
1931
1932    /// Initiates a general discovery procedure for BR/EDR and LE devices. On success, discovered
1933    /// peers can be monitored using the [`fuchsia.bluetooth.host/Host.WatchPeers`] method. On Error,
1934    /// an epitaph will be returned from `token`. If the device does not support BR/EDR, only LE
1935    /// discovery will be performed.
1936    ///
1937    /// On the LE transport, only general-discoverable and connectable peripherals will be reported.
1938    ///
1939    /// Discovery will continue until all discovery sessions are closed.
1940    ///
1941    /// + request `token` The DiscoverySession protocol that must be held open as long as
1942    ///     discovery should be enabled. Closing it will stop discovery if no other sessions
1943    ///     are open.
1944    pub fn r#start_discovery(
1945        &self,
1946        mut payload: HostStartDiscoveryRequest,
1947    ) -> Result<(), fidl::Error> {
1948        HostProxyInterface::r#start_discovery(self, payload)
1949    }
1950
1951    /// Sets whether this host should be connectable.
1952    pub fn r#set_connectable(
1953        &self,
1954        mut enabled: bool,
1955    ) -> fidl::client::QueryResponseFut<
1956        HostSetConnectableResult,
1957        fidl::encoding::DefaultFuchsiaResourceDialect,
1958    > {
1959        HostProxyInterface::r#set_connectable(self, enabled)
1960    }
1961
1962    /// Sets whether this host should be discoverable.
1963    pub fn r#set_discoverable(
1964        &self,
1965        mut enabled: bool,
1966    ) -> fidl::client::QueryResponseFut<
1967        HostSetDiscoverableResult,
1968        fidl::encoding::DefaultFuchsiaResourceDialect,
1969    > {
1970        HostProxyInterface::r#set_discoverable(self, enabled)
1971    }
1972
1973    /// Establish a BR/EDR and/or LE connection to the peer with identifier `id`:
1974    ///
1975    ///   - If the peer is known to support the BR/EDR transport then a logical link over that
1976    ///     transport will be established to the device. If the connection attempt is successful,
1977    ///     local services registered using "RequestProfile()" will be available to the peer.
1978    ///     Traditional services discovered on the peer will be notified to local services
1979    ///     asynchronously.
1980    ///
1981    ///   - If the peer is known to support the LE transport then a logical link over that
1982    ///     transport will be established to the device. If the connection attempt is successful,
1983    ///     GATT services in the local database (populated via RequestGattServer()) will become
1984    ///     available to the peer. Similarly, remote GATT services that are discovered on the
1985    ///     peer will become available to holders of a gatt.Client capability and to device drivers
1986    ///     that can bind to the bt-gatt-svc class of devices.
1987    ///
1988    /// The result of the procedure will be communicated via `status`. If the remote device
1989    /// supports both BR/EDR and LE transports and a link cannot be established over both, then an
1990    /// error Status will be returned and neither transport will be connected.
1991    pub fn r#connect(
1992        &self,
1993        mut id: &fidl_fuchsia_bluetooth::PeerId,
1994    ) -> fidl::client::QueryResponseFut<
1995        HostConnectResult,
1996        fidl::encoding::DefaultFuchsiaResourceDialect,
1997    > {
1998        HostProxyInterface::r#connect(self, id)
1999    }
2000
2001    /// Terminate all connections (BR/EDR or LE) to the remote peer with identifier `id`.
2002    ///
2003    /// + request `id` The identifier of the peer to disconnect.
2004    /// - response `status` Contains an error if either LE or BR/EDR transport fails to disconnect.
2005    ///                     Contains success when both transports are successfully disconnected or
2006    ///                     if the peer is already disconnected.
2007    pub fn r#disconnect(
2008        &self,
2009        mut id: &fidl_fuchsia_bluetooth::PeerId,
2010    ) -> fidl::client::QueryResponseFut<
2011        HostDisconnectResult,
2012        fidl::encoding::DefaultFuchsiaResourceDialect,
2013    > {
2014        HostProxyInterface::r#disconnect(self, id)
2015    }
2016
2017    /// Initiates pairing to the peer with the supplied `id` and `options`. Returns an error if no
2018    /// connected peer with `id` is found or the pairing procedure fails.
2019    ///
2020    /// If `options` specifies a higher security level than the current pairing, this method
2021    /// attempts to raise the security level. Otherwise this method has no effect and returns
2022    /// success.
2023    ///
2024    /// NOTE: This is intended to satisfy test scenarios that require pairing procedures to be
2025    /// initiated without relying on service access. In normal operation, Bluetooth security is
2026    /// enforced during service access.
2027    pub fn r#pair(
2028        &self,
2029        mut id: &fidl_fuchsia_bluetooth::PeerId,
2030        mut options: &fidl_fuchsia_bluetooth_sys::PairingOptions,
2031    ) -> fidl::client::QueryResponseFut<HostPairResult, fidl::encoding::DefaultFuchsiaResourceDialect>
2032    {
2033        HostProxyInterface::r#pair(self, id, options)
2034    }
2035
2036    /// Deletes a peer from the Bluetooth host. If the peer is connected, it will be disconnected.
2037    /// `device_id` will no longer refer to any peer, even if a device with the same address is
2038    /// discovered again.
2039    ///
2040    /// Returns success after no peer exists that's identified by `device_id` (even if it didn't
2041    /// exist before Forget), failure if the peer specified by `device_id` could not be
2042    /// disconnected or deleted and still exists.
2043    pub fn r#forget(
2044        &self,
2045        mut id: &fidl_fuchsia_bluetooth::PeerId,
2046    ) -> fidl::client::QueryResponseFut<
2047        HostForgetResult,
2048        fidl::encoding::DefaultFuchsiaResourceDialect,
2049    > {
2050        HostProxyInterface::r#forget(self, id)
2051    }
2052
2053    /// Enable or disable a passive LE background scan. When enabled, the bt-host
2054    /// device will continuously perform a passive LE scan in the background when
2055    /// no device discovery sessions are active and accept connection requests from
2056    /// bonded peripherals.
2057    pub fn r#enable_background_scan(&self, mut enabled: bool) -> Result<(), fidl::Error> {
2058        HostProxyInterface::r#enable_background_scan(self, enabled)
2059    }
2060
2061    /// Enable or disable the LE privacy feature. When enabled, the bt-host device will use a
2062    /// private device address in all LE procedures. When disabled, the public identity address will
2063    /// be used instead (which is the default).
2064    pub fn r#enable_privacy(&self, mut enabled: bool) -> Result<(), fidl::Error> {
2065        HostProxyInterface::r#enable_privacy(self, enabled)
2066    }
2067
2068    /// Set the GAP BR/EDR Security Mode of the host. bt-host only supports encrypted,
2069    /// connection-based security modes, i.e. Mode 4 and Secure Connections Only mode. If the
2070    /// security mode is set to Secure Connections Only, any existing encrypted connections which
2071    /// do not meet the security requirements of Secure Connections Only mode will be disconnected.
2072    pub fn r#set_br_edr_security_mode(
2073        &self,
2074        mut bredr_security_mode: fidl_fuchsia_bluetooth_sys::BrEdrSecurityMode,
2075    ) -> Result<(), fidl::Error> {
2076        HostProxyInterface::r#set_br_edr_security_mode(self, bredr_security_mode)
2077    }
2078
2079    /// Set the GAP LE Security Mode of the host. bt-host only supports encrypted, connection-based
2080    /// security modes, i.e. Mode 1 and Secure Connections Only mode. If the security mode is set
2081    /// to Secure Connections Only, any existing encrypted connections which do not meet the
2082    /// security requirements of Secure Connections Only mode will be disconnected.
2083    pub fn r#set_le_security_mode(
2084        &self,
2085        mut le_security_mode: fidl_fuchsia_bluetooth_sys::LeSecurityMode,
2086    ) -> Result<(), fidl::Error> {
2087        HostProxyInterface::r#set_le_security_mode(self, le_security_mode)
2088    }
2089
2090    /// Assigns the pairing delegate that will respond to authentication challenges using the given
2091    /// I/O capabilities. Calling this method cancels any on-going pairing procedure started
2092    /// using a previous delegate. Pairing requests will be rejected if no PairingDelegate has been
2093    /// assigned.
2094    pub fn r#set_pairing_delegate(
2095        &self,
2096        mut input: fidl_fuchsia_bluetooth_sys::InputCapability,
2097        mut output: fidl_fuchsia_bluetooth_sys::OutputCapability,
2098        mut delegate: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth_sys::PairingDelegateMarker>,
2099    ) -> Result<(), fidl::Error> {
2100        HostProxyInterface::r#set_pairing_delegate(self, input, output, delegate)
2101    }
2102
2103    /// Set a BondingDelegate protocol that will be notified of new and removed bonds that need to
2104    /// be persisted. If a delegate is already set, the new `delegate` will be closed with
2105    /// ALREADY_BOUND
2106    pub fn r#set_bonding_delegate(
2107        &self,
2108        mut delegate: fidl::endpoints::ServerEnd<BondingDelegateMarker>,
2109    ) -> Result<(), fidl::Error> {
2110        HostProxyInterface::r#set_bonding_delegate(self, delegate)
2111    }
2112}
2113
2114impl HostProxyInterface for HostProxy {
2115    fn r#request_protocol(&self, mut payload: ProtocolRequest) -> Result<(), fidl::Error> {
2116        self.client.send::<ProtocolRequest>(
2117            &mut payload,
2118            0x45cb5bf9834016b4,
2119            fidl::encoding::DynamicFlags::FLEXIBLE,
2120        )
2121    }
2122
2123    fn r#shutdown(&self) -> Result<(), fidl::Error> {
2124        self.client.send::<fidl::encoding::EmptyPayload>(
2125            (),
2126            0x18747459244591c9,
2127            fidl::encoding::DynamicFlags::empty(),
2128        )
2129    }
2130
2131    type WatchStateResponseFut = fidl::client::QueryResponseFut<
2132        fidl_fuchsia_bluetooth_sys::HostInfo,
2133        fidl::encoding::DefaultFuchsiaResourceDialect,
2134    >;
2135    fn r#watch_state(&self) -> Self::WatchStateResponseFut {
2136        fn _decode(
2137            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2138        ) -> Result<fidl_fuchsia_bluetooth_sys::HostInfo, fidl::Error> {
2139            let _response = fidl::client::decode_transaction_body::<
2140                fidl::encoding::FlexibleType<HostWatchStateResponse>,
2141                fidl::encoding::DefaultFuchsiaResourceDialect,
2142                0x19157554e2a3db52,
2143            >(_buf?)?
2144            .into_result::<HostMarker>("watch_state")?;
2145            Ok(_response.info)
2146        }
2147        self.client.send_query_and_decode::<
2148            fidl::encoding::EmptyPayload,
2149            fidl_fuchsia_bluetooth_sys::HostInfo,
2150        >(
2151            (),
2152            0x19157554e2a3db52,
2153            fidl::encoding::DynamicFlags::FLEXIBLE,
2154            _decode,
2155        )
2156    }
2157
2158    fn r#set_local_data(
2159        &self,
2160        mut payload: &fidl_fuchsia_bluetooth_sys::HostData,
2161    ) -> Result<(), fidl::Error> {
2162        self.client.send::<fidl_fuchsia_bluetooth_sys::HostData>(
2163            payload,
2164            0x57b70f72bb0a9187,
2165            fidl::encoding::DynamicFlags::empty(),
2166        )
2167    }
2168
2169    fn r#set_peer_watcher(
2170        &self,
2171        mut peer_watcher: fidl::endpoints::ServerEnd<PeerWatcherMarker>,
2172    ) -> Result<(), fidl::Error> {
2173        self.client.send::<HostSetPeerWatcherRequest>(
2174            (peer_watcher,),
2175            0x3dec6b3c99c0a437,
2176            fidl::encoding::DynamicFlags::FLEXIBLE,
2177        )
2178    }
2179
2180    type SetLocalNameResponseFut = fidl::client::QueryResponseFut<
2181        HostSetLocalNameResult,
2182        fidl::encoding::DefaultFuchsiaResourceDialect,
2183    >;
2184    fn r#set_local_name(&self, mut local_name: &str) -> Self::SetLocalNameResponseFut {
2185        fn _decode(
2186            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2187        ) -> Result<HostSetLocalNameResult, fidl::Error> {
2188            let _response = fidl::client::decode_transaction_body::<
2189                fidl::encoding::FlexibleResultType<
2190                    fidl::encoding::EmptyStruct,
2191                    fidl_fuchsia_bluetooth_sys::Error,
2192                >,
2193                fidl::encoding::DefaultFuchsiaResourceDialect,
2194                0x85e98b56b98f123,
2195            >(_buf?)?
2196            .into_result::<HostMarker>("set_local_name")?;
2197            Ok(_response.map(|x| x))
2198        }
2199        self.client.send_query_and_decode::<HostSetLocalNameRequest, HostSetLocalNameResult>(
2200            (local_name,),
2201            0x85e98b56b98f123,
2202            fidl::encoding::DynamicFlags::FLEXIBLE,
2203            _decode,
2204        )
2205    }
2206
2207    type SetDeviceClassResponseFut = fidl::client::QueryResponseFut<
2208        HostSetDeviceClassResult,
2209        fidl::encoding::DefaultFuchsiaResourceDialect,
2210    >;
2211    fn r#set_device_class(
2212        &self,
2213        mut device_class: &fidl_fuchsia_bluetooth::DeviceClass,
2214    ) -> Self::SetDeviceClassResponseFut {
2215        fn _decode(
2216            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2217        ) -> Result<HostSetDeviceClassResult, fidl::Error> {
2218            let _response = fidl::client::decode_transaction_body::<
2219                fidl::encoding::FlexibleResultType<
2220                    fidl::encoding::EmptyStruct,
2221                    fidl_fuchsia_bluetooth_sys::Error,
2222                >,
2223                fidl::encoding::DefaultFuchsiaResourceDialect,
2224                0x4caef8f835950de2,
2225            >(_buf?)?
2226            .into_result::<HostMarker>("set_device_class")?;
2227            Ok(_response.map(|x| x))
2228        }
2229        self.client.send_query_and_decode::<HostSetDeviceClassRequest, HostSetDeviceClassResult>(
2230            (device_class,),
2231            0x4caef8f835950de2,
2232            fidl::encoding::DynamicFlags::FLEXIBLE,
2233            _decode,
2234        )
2235    }
2236
2237    fn r#start_discovery(&self, mut payload: HostStartDiscoveryRequest) -> Result<(), fidl::Error> {
2238        self.client.send::<HostStartDiscoveryRequest>(
2239            &mut payload,
2240            0x3f40a85341413e4,
2241            fidl::encoding::DynamicFlags::FLEXIBLE,
2242        )
2243    }
2244
2245    type SetConnectableResponseFut = fidl::client::QueryResponseFut<
2246        HostSetConnectableResult,
2247        fidl::encoding::DefaultFuchsiaResourceDialect,
2248    >;
2249    fn r#set_connectable(&self, mut enabled: bool) -> Self::SetConnectableResponseFut {
2250        fn _decode(
2251            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2252        ) -> Result<HostSetConnectableResult, fidl::Error> {
2253            let _response = fidl::client::decode_transaction_body::<
2254                fidl::encoding::FlexibleResultType<
2255                    fidl::encoding::EmptyStruct,
2256                    fidl_fuchsia_bluetooth_sys::Error,
2257                >,
2258                fidl::encoding::DefaultFuchsiaResourceDialect,
2259                0x187a6a82e811fa92,
2260            >(_buf?)?
2261            .into_result::<HostMarker>("set_connectable")?;
2262            Ok(_response.map(|x| x))
2263        }
2264        self.client.send_query_and_decode::<HostSetConnectableRequest, HostSetConnectableResult>(
2265            (enabled,),
2266            0x187a6a82e811fa92,
2267            fidl::encoding::DynamicFlags::FLEXIBLE,
2268            _decode,
2269        )
2270    }
2271
2272    type SetDiscoverableResponseFut = fidl::client::QueryResponseFut<
2273        HostSetDiscoverableResult,
2274        fidl::encoding::DefaultFuchsiaResourceDialect,
2275    >;
2276    fn r#set_discoverable(&self, mut enabled: bool) -> Self::SetDiscoverableResponseFut {
2277        fn _decode(
2278            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2279        ) -> Result<HostSetDiscoverableResult, fidl::Error> {
2280            let _response = fidl::client::decode_transaction_body::<
2281                fidl::encoding::FlexibleResultType<
2282                    fidl::encoding::EmptyStruct,
2283                    fidl_fuchsia_bluetooth_sys::Error,
2284                >,
2285                fidl::encoding::DefaultFuchsiaResourceDialect,
2286                0x89f8c7da63e36de,
2287            >(_buf?)?
2288            .into_result::<HostMarker>("set_discoverable")?;
2289            Ok(_response.map(|x| x))
2290        }
2291        self.client.send_query_and_decode::<HostSetDiscoverableRequest, HostSetDiscoverableResult>(
2292            (enabled,),
2293            0x89f8c7da63e36de,
2294            fidl::encoding::DynamicFlags::FLEXIBLE,
2295            _decode,
2296        )
2297    }
2298
2299    type ConnectResponseFut = fidl::client::QueryResponseFut<
2300        HostConnectResult,
2301        fidl::encoding::DefaultFuchsiaResourceDialect,
2302    >;
2303    fn r#connect(&self, mut id: &fidl_fuchsia_bluetooth::PeerId) -> Self::ConnectResponseFut {
2304        fn _decode(
2305            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2306        ) -> Result<HostConnectResult, fidl::Error> {
2307            let _response = fidl::client::decode_transaction_body::<
2308                fidl::encoding::FlexibleResultType<
2309                    fidl::encoding::EmptyStruct,
2310                    fidl_fuchsia_bluetooth_sys::Error,
2311                >,
2312                fidl::encoding::DefaultFuchsiaResourceDialect,
2313                0x5a56139c993e7240,
2314            >(_buf?)?
2315            .into_result::<HostMarker>("connect")?;
2316            Ok(_response.map(|x| x))
2317        }
2318        self.client.send_query_and_decode::<HostConnectRequest, HostConnectResult>(
2319            (id,),
2320            0x5a56139c993e7240,
2321            fidl::encoding::DynamicFlags::FLEXIBLE,
2322            _decode,
2323        )
2324    }
2325
2326    type DisconnectResponseFut = fidl::client::QueryResponseFut<
2327        HostDisconnectResult,
2328        fidl::encoding::DefaultFuchsiaResourceDialect,
2329    >;
2330    fn r#disconnect(&self, mut id: &fidl_fuchsia_bluetooth::PeerId) -> Self::DisconnectResponseFut {
2331        fn _decode(
2332            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2333        ) -> Result<HostDisconnectResult, fidl::Error> {
2334            let _response = fidl::client::decode_transaction_body::<
2335                fidl::encoding::FlexibleResultType<
2336                    fidl::encoding::EmptyStruct,
2337                    fidl_fuchsia_bluetooth_sys::Error,
2338                >,
2339                fidl::encoding::DefaultFuchsiaResourceDialect,
2340                0x33211717491121b1,
2341            >(_buf?)?
2342            .into_result::<HostMarker>("disconnect")?;
2343            Ok(_response.map(|x| x))
2344        }
2345        self.client.send_query_and_decode::<HostDisconnectRequest, HostDisconnectResult>(
2346            (id,),
2347            0x33211717491121b1,
2348            fidl::encoding::DynamicFlags::FLEXIBLE,
2349            _decode,
2350        )
2351    }
2352
2353    type PairResponseFut = fidl::client::QueryResponseFut<
2354        HostPairResult,
2355        fidl::encoding::DefaultFuchsiaResourceDialect,
2356    >;
2357    fn r#pair(
2358        &self,
2359        mut id: &fidl_fuchsia_bluetooth::PeerId,
2360        mut options: &fidl_fuchsia_bluetooth_sys::PairingOptions,
2361    ) -> Self::PairResponseFut {
2362        fn _decode(
2363            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2364        ) -> Result<HostPairResult, fidl::Error> {
2365            let _response = fidl::client::decode_transaction_body::<
2366                fidl::encoding::FlexibleResultType<
2367                    fidl::encoding::EmptyStruct,
2368                    fidl_fuchsia_bluetooth_sys::Error,
2369                >,
2370                fidl::encoding::DefaultFuchsiaResourceDialect,
2371                0x2efaec6dc5d62ca2,
2372            >(_buf?)?
2373            .into_result::<HostMarker>("pair")?;
2374            Ok(_response.map(|x| x))
2375        }
2376        self.client.send_query_and_decode::<HostPairRequest, HostPairResult>(
2377            (id, options),
2378            0x2efaec6dc5d62ca2,
2379            fidl::encoding::DynamicFlags::FLEXIBLE,
2380            _decode,
2381        )
2382    }
2383
2384    type ForgetResponseFut = fidl::client::QueryResponseFut<
2385        HostForgetResult,
2386        fidl::encoding::DefaultFuchsiaResourceDialect,
2387    >;
2388    fn r#forget(&self, mut id: &fidl_fuchsia_bluetooth::PeerId) -> Self::ForgetResponseFut {
2389        fn _decode(
2390            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2391        ) -> Result<HostForgetResult, fidl::Error> {
2392            let _response = fidl::client::decode_transaction_body::<
2393                fidl::encoding::FlexibleResultType<
2394                    fidl::encoding::EmptyStruct,
2395                    fidl_fuchsia_bluetooth_sys::Error,
2396                >,
2397                fidl::encoding::DefaultFuchsiaResourceDialect,
2398                0x904f58dbdd4490a,
2399            >(_buf?)?
2400            .into_result::<HostMarker>("forget")?;
2401            Ok(_response.map(|x| x))
2402        }
2403        self.client.send_query_and_decode::<HostForgetRequest, HostForgetResult>(
2404            (id,),
2405            0x904f58dbdd4490a,
2406            fidl::encoding::DynamicFlags::FLEXIBLE,
2407            _decode,
2408        )
2409    }
2410
2411    fn r#enable_background_scan(&self, mut enabled: bool) -> Result<(), fidl::Error> {
2412        self.client.send::<HostEnableBackgroundScanRequest>(
2413            (enabled,),
2414            0x51f038a8cf498946,
2415            fidl::encoding::DynamicFlags::FLEXIBLE,
2416        )
2417    }
2418
2419    fn r#enable_privacy(&self, mut enabled: bool) -> Result<(), fidl::Error> {
2420        self.client.send::<HostEnablePrivacyRequest>(
2421            (enabled,),
2422            0x370a76e1d2b5034b,
2423            fidl::encoding::DynamicFlags::empty(),
2424        )
2425    }
2426
2427    fn r#set_br_edr_security_mode(
2428        &self,
2429        mut bredr_security_mode: fidl_fuchsia_bluetooth_sys::BrEdrSecurityMode,
2430    ) -> Result<(), fidl::Error> {
2431        self.client.send::<HostSetBrEdrSecurityModeRequest>(
2432            (bredr_security_mode,),
2433            0x1d94d20717459281,
2434            fidl::encoding::DynamicFlags::empty(),
2435        )
2436    }
2437
2438    fn r#set_le_security_mode(
2439        &self,
2440        mut le_security_mode: fidl_fuchsia_bluetooth_sys::LeSecurityMode,
2441    ) -> Result<(), fidl::Error> {
2442        self.client.send::<HostSetLeSecurityModeRequest>(
2443            (le_security_mode,),
2444            0x6ef0a424a336a81,
2445            fidl::encoding::DynamicFlags::empty(),
2446        )
2447    }
2448
2449    fn r#set_pairing_delegate(
2450        &self,
2451        mut input: fidl_fuchsia_bluetooth_sys::InputCapability,
2452        mut output: fidl_fuchsia_bluetooth_sys::OutputCapability,
2453        mut delegate: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth_sys::PairingDelegateMarker>,
2454    ) -> Result<(), fidl::Error> {
2455        self.client.send::<HostSetPairingDelegateRequest>(
2456            (input, output, delegate),
2457            0x21a5bba5ffc9773e,
2458            fidl::encoding::DynamicFlags::FLEXIBLE,
2459        )
2460    }
2461
2462    fn r#set_bonding_delegate(
2463        &self,
2464        mut delegate: fidl::endpoints::ServerEnd<BondingDelegateMarker>,
2465    ) -> Result<(), fidl::Error> {
2466        self.client.send::<HostSetBondingDelegateRequest>(
2467            (delegate,),
2468            0x651d446a05b664d4,
2469            fidl::encoding::DynamicFlags::FLEXIBLE,
2470        )
2471    }
2472}
2473
2474pub struct HostEventStream {
2475    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2476}
2477
2478impl std::marker::Unpin for HostEventStream {}
2479
2480impl futures::stream::FusedStream for HostEventStream {
2481    fn is_terminated(&self) -> bool {
2482        self.event_receiver.is_terminated()
2483    }
2484}
2485
2486impl futures::Stream for HostEventStream {
2487    type Item = Result<HostEvent, fidl::Error>;
2488
2489    fn poll_next(
2490        mut self: std::pin::Pin<&mut Self>,
2491        cx: &mut std::task::Context<'_>,
2492    ) -> std::task::Poll<Option<Self::Item>> {
2493        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2494            &mut self.event_receiver,
2495            cx
2496        )?) {
2497            Some(buf) => std::task::Poll::Ready(Some(HostEvent::decode(buf))),
2498            None => std::task::Poll::Ready(None),
2499        }
2500    }
2501}
2502
2503#[derive(Debug)]
2504pub enum HostEvent {
2505    #[non_exhaustive]
2506    _UnknownEvent {
2507        /// Ordinal of the event that was sent.
2508        ordinal: u64,
2509    },
2510}
2511
2512impl HostEvent {
2513    /// Decodes a message buffer as a [`HostEvent`].
2514    fn decode(
2515        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2516    ) -> Result<HostEvent, fidl::Error> {
2517        let (bytes, _handles) = buf.split_mut();
2518        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2519        debug_assert_eq!(tx_header.tx_id, 0);
2520        match tx_header.ordinal {
2521            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2522                Ok(HostEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2523            }
2524            _ => Err(fidl::Error::UnknownOrdinal {
2525                ordinal: tx_header.ordinal,
2526                protocol_name: <HostMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2527            }),
2528        }
2529    }
2530}
2531
2532/// A Stream of incoming requests for fuchsia.bluetooth.host/Host.
2533pub struct HostRequestStream {
2534    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2535    is_terminated: bool,
2536}
2537
2538impl std::marker::Unpin for HostRequestStream {}
2539
2540impl futures::stream::FusedStream for HostRequestStream {
2541    fn is_terminated(&self) -> bool {
2542        self.is_terminated
2543    }
2544}
2545
2546impl fidl::endpoints::RequestStream for HostRequestStream {
2547    type Protocol = HostMarker;
2548    type ControlHandle = HostControlHandle;
2549
2550    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2551        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2552    }
2553
2554    fn control_handle(&self) -> Self::ControlHandle {
2555        HostControlHandle { inner: self.inner.clone() }
2556    }
2557
2558    fn into_inner(
2559        self,
2560    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2561    {
2562        (self.inner, self.is_terminated)
2563    }
2564
2565    fn from_inner(
2566        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2567        is_terminated: bool,
2568    ) -> Self {
2569        Self { inner, is_terminated }
2570    }
2571}
2572
2573impl futures::Stream for HostRequestStream {
2574    type Item = Result<HostRequest, fidl::Error>;
2575
2576    fn poll_next(
2577        mut self: std::pin::Pin<&mut Self>,
2578        cx: &mut std::task::Context<'_>,
2579    ) -> std::task::Poll<Option<Self::Item>> {
2580        let this = &mut *self;
2581        if this.inner.check_shutdown(cx) {
2582            this.is_terminated = true;
2583            return std::task::Poll::Ready(None);
2584        }
2585        if this.is_terminated {
2586            panic!("polled HostRequestStream after completion");
2587        }
2588        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2589            |bytes, handles| {
2590                match this.inner.channel().read_etc(cx, bytes, handles) {
2591                    std::task::Poll::Ready(Ok(())) => {}
2592                    std::task::Poll::Pending => return std::task::Poll::Pending,
2593                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2594                        this.is_terminated = true;
2595                        return std::task::Poll::Ready(None);
2596                    }
2597                    std::task::Poll::Ready(Err(e)) => {
2598                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2599                            e.into(),
2600                        ))));
2601                    }
2602                }
2603
2604                // A message has been received from the channel
2605                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2606
2607                std::task::Poll::Ready(Some(match header.ordinal {
2608                    0x45cb5bf9834016b4 => {
2609                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2610                        let mut req = fidl::new_empty!(
2611                            ProtocolRequest,
2612                            fidl::encoding::DefaultFuchsiaResourceDialect
2613                        );
2614                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProtocolRequest>(&header, _body_bytes, handles, &mut req)?;
2615                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2616                        Ok(HostRequest::RequestProtocol { payload: req, control_handle })
2617                    }
2618                    0x18747459244591c9 => {
2619                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2620                        let mut req = fidl::new_empty!(
2621                            fidl::encoding::EmptyPayload,
2622                            fidl::encoding::DefaultFuchsiaResourceDialect
2623                        );
2624                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2625                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2626                        Ok(HostRequest::Shutdown { control_handle })
2627                    }
2628                    0x19157554e2a3db52 => {
2629                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2630                        let mut req = fidl::new_empty!(
2631                            fidl::encoding::EmptyPayload,
2632                            fidl::encoding::DefaultFuchsiaResourceDialect
2633                        );
2634                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2635                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2636                        Ok(HostRequest::WatchState {
2637                            responder: HostWatchStateResponder {
2638                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2639                                tx_id: header.tx_id,
2640                            },
2641                        })
2642                    }
2643                    0x57b70f72bb0a9187 => {
2644                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2645                        let mut req = fidl::new_empty!(
2646                            fidl_fuchsia_bluetooth_sys::HostData,
2647                            fidl::encoding::DefaultFuchsiaResourceDialect
2648                        );
2649                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_bluetooth_sys::HostData>(&header, _body_bytes, handles, &mut req)?;
2650                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2651                        Ok(HostRequest::SetLocalData { payload: req, control_handle })
2652                    }
2653                    0x3dec6b3c99c0a437 => {
2654                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2655                        let mut req = fidl::new_empty!(
2656                            HostSetPeerWatcherRequest,
2657                            fidl::encoding::DefaultFuchsiaResourceDialect
2658                        );
2659                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostSetPeerWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
2660                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2661                        Ok(HostRequest::SetPeerWatcher {
2662                            peer_watcher: req.peer_watcher,
2663
2664                            control_handle,
2665                        })
2666                    }
2667                    0x85e98b56b98f123 => {
2668                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2669                        let mut req = fidl::new_empty!(
2670                            HostSetLocalNameRequest,
2671                            fidl::encoding::DefaultFuchsiaResourceDialect
2672                        );
2673                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostSetLocalNameRequest>(&header, _body_bytes, handles, &mut req)?;
2674                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2675                        Ok(HostRequest::SetLocalName {
2676                            local_name: req.local_name,
2677
2678                            responder: HostSetLocalNameResponder {
2679                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2680                                tx_id: header.tx_id,
2681                            },
2682                        })
2683                    }
2684                    0x4caef8f835950de2 => {
2685                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2686                        let mut req = fidl::new_empty!(
2687                            HostSetDeviceClassRequest,
2688                            fidl::encoding::DefaultFuchsiaResourceDialect
2689                        );
2690                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostSetDeviceClassRequest>(&header, _body_bytes, handles, &mut req)?;
2691                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2692                        Ok(HostRequest::SetDeviceClass {
2693                            device_class: req.device_class,
2694
2695                            responder: HostSetDeviceClassResponder {
2696                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2697                                tx_id: header.tx_id,
2698                            },
2699                        })
2700                    }
2701                    0x3f40a85341413e4 => {
2702                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2703                        let mut req = fidl::new_empty!(
2704                            HostStartDiscoveryRequest,
2705                            fidl::encoding::DefaultFuchsiaResourceDialect
2706                        );
2707                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostStartDiscoveryRequest>(&header, _body_bytes, handles, &mut req)?;
2708                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2709                        Ok(HostRequest::StartDiscovery { payload: req, control_handle })
2710                    }
2711                    0x187a6a82e811fa92 => {
2712                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2713                        let mut req = fidl::new_empty!(
2714                            HostSetConnectableRequest,
2715                            fidl::encoding::DefaultFuchsiaResourceDialect
2716                        );
2717                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostSetConnectableRequest>(&header, _body_bytes, handles, &mut req)?;
2718                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2719                        Ok(HostRequest::SetConnectable {
2720                            enabled: req.enabled,
2721
2722                            responder: HostSetConnectableResponder {
2723                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2724                                tx_id: header.tx_id,
2725                            },
2726                        })
2727                    }
2728                    0x89f8c7da63e36de => {
2729                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2730                        let mut req = fidl::new_empty!(
2731                            HostSetDiscoverableRequest,
2732                            fidl::encoding::DefaultFuchsiaResourceDialect
2733                        );
2734                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostSetDiscoverableRequest>(&header, _body_bytes, handles, &mut req)?;
2735                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2736                        Ok(HostRequest::SetDiscoverable {
2737                            enabled: req.enabled,
2738
2739                            responder: HostSetDiscoverableResponder {
2740                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2741                                tx_id: header.tx_id,
2742                            },
2743                        })
2744                    }
2745                    0x5a56139c993e7240 => {
2746                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2747                        let mut req = fidl::new_empty!(
2748                            HostConnectRequest,
2749                            fidl::encoding::DefaultFuchsiaResourceDialect
2750                        );
2751                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostConnectRequest>(&header, _body_bytes, handles, &mut req)?;
2752                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2753                        Ok(HostRequest::Connect {
2754                            id: req.id,
2755
2756                            responder: HostConnectResponder {
2757                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2758                                tx_id: header.tx_id,
2759                            },
2760                        })
2761                    }
2762                    0x33211717491121b1 => {
2763                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2764                        let mut req = fidl::new_empty!(
2765                            HostDisconnectRequest,
2766                            fidl::encoding::DefaultFuchsiaResourceDialect
2767                        );
2768                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostDisconnectRequest>(&header, _body_bytes, handles, &mut req)?;
2769                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2770                        Ok(HostRequest::Disconnect {
2771                            id: req.id,
2772
2773                            responder: HostDisconnectResponder {
2774                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2775                                tx_id: header.tx_id,
2776                            },
2777                        })
2778                    }
2779                    0x2efaec6dc5d62ca2 => {
2780                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2781                        let mut req = fidl::new_empty!(
2782                            HostPairRequest,
2783                            fidl::encoding::DefaultFuchsiaResourceDialect
2784                        );
2785                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostPairRequest>(&header, _body_bytes, handles, &mut req)?;
2786                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2787                        Ok(HostRequest::Pair {
2788                            id: req.id,
2789                            options: req.options,
2790
2791                            responder: HostPairResponder {
2792                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2793                                tx_id: header.tx_id,
2794                            },
2795                        })
2796                    }
2797                    0x904f58dbdd4490a => {
2798                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2799                        let mut req = fidl::new_empty!(
2800                            HostForgetRequest,
2801                            fidl::encoding::DefaultFuchsiaResourceDialect
2802                        );
2803                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostForgetRequest>(&header, _body_bytes, handles, &mut req)?;
2804                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2805                        Ok(HostRequest::Forget {
2806                            id: req.id,
2807
2808                            responder: HostForgetResponder {
2809                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2810                                tx_id: header.tx_id,
2811                            },
2812                        })
2813                    }
2814                    0x51f038a8cf498946 => {
2815                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2816                        let mut req = fidl::new_empty!(
2817                            HostEnableBackgroundScanRequest,
2818                            fidl::encoding::DefaultFuchsiaResourceDialect
2819                        );
2820                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostEnableBackgroundScanRequest>(&header, _body_bytes, handles, &mut req)?;
2821                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2822                        Ok(HostRequest::EnableBackgroundScan {
2823                            enabled: req.enabled,
2824
2825                            control_handle,
2826                        })
2827                    }
2828                    0x370a76e1d2b5034b => {
2829                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2830                        let mut req = fidl::new_empty!(
2831                            HostEnablePrivacyRequest,
2832                            fidl::encoding::DefaultFuchsiaResourceDialect
2833                        );
2834                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostEnablePrivacyRequest>(&header, _body_bytes, handles, &mut req)?;
2835                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2836                        Ok(HostRequest::EnablePrivacy { enabled: req.enabled, control_handle })
2837                    }
2838                    0x1d94d20717459281 => {
2839                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2840                        let mut req = fidl::new_empty!(
2841                            HostSetBrEdrSecurityModeRequest,
2842                            fidl::encoding::DefaultFuchsiaResourceDialect
2843                        );
2844                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostSetBrEdrSecurityModeRequest>(&header, _body_bytes, handles, &mut req)?;
2845                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2846                        Ok(HostRequest::SetBrEdrSecurityMode {
2847                            bredr_security_mode: req.bredr_security_mode,
2848
2849                            control_handle,
2850                        })
2851                    }
2852                    0x6ef0a424a336a81 => {
2853                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2854                        let mut req = fidl::new_empty!(
2855                            HostSetLeSecurityModeRequest,
2856                            fidl::encoding::DefaultFuchsiaResourceDialect
2857                        );
2858                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostSetLeSecurityModeRequest>(&header, _body_bytes, handles, &mut req)?;
2859                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2860                        Ok(HostRequest::SetLeSecurityMode {
2861                            le_security_mode: req.le_security_mode,
2862
2863                            control_handle,
2864                        })
2865                    }
2866                    0x21a5bba5ffc9773e => {
2867                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2868                        let mut req = fidl::new_empty!(
2869                            HostSetPairingDelegateRequest,
2870                            fidl::encoding::DefaultFuchsiaResourceDialect
2871                        );
2872                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostSetPairingDelegateRequest>(&header, _body_bytes, handles, &mut req)?;
2873                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2874                        Ok(HostRequest::SetPairingDelegate {
2875                            input: req.input,
2876                            output: req.output,
2877                            delegate: req.delegate,
2878
2879                            control_handle,
2880                        })
2881                    }
2882                    0x651d446a05b664d4 => {
2883                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2884                        let mut req = fidl::new_empty!(
2885                            HostSetBondingDelegateRequest,
2886                            fidl::encoding::DefaultFuchsiaResourceDialect
2887                        );
2888                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostSetBondingDelegateRequest>(&header, _body_bytes, handles, &mut req)?;
2889                        let control_handle = HostControlHandle { inner: this.inner.clone() };
2890                        Ok(HostRequest::SetBondingDelegate {
2891                            delegate: req.delegate,
2892
2893                            control_handle,
2894                        })
2895                    }
2896                    _ if header.tx_id == 0
2897                        && header
2898                            .dynamic_flags()
2899                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2900                    {
2901                        Ok(HostRequest::_UnknownMethod {
2902                            ordinal: header.ordinal,
2903                            control_handle: HostControlHandle { inner: this.inner.clone() },
2904                            method_type: fidl::MethodType::OneWay,
2905                        })
2906                    }
2907                    _ if header
2908                        .dynamic_flags()
2909                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2910                    {
2911                        this.inner.send_framework_err(
2912                            fidl::encoding::FrameworkErr::UnknownMethod,
2913                            header.tx_id,
2914                            header.ordinal,
2915                            header.dynamic_flags(),
2916                            (bytes, handles),
2917                        )?;
2918                        Ok(HostRequest::_UnknownMethod {
2919                            ordinal: header.ordinal,
2920                            control_handle: HostControlHandle { inner: this.inner.clone() },
2921                            method_type: fidl::MethodType::TwoWay,
2922                        })
2923                    }
2924                    _ => Err(fidl::Error::UnknownOrdinal {
2925                        ordinal: header.ordinal,
2926                        protocol_name: <HostMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2927                    }),
2928                }))
2929            },
2930        )
2931    }
2932}
2933
2934/// Interface for interacting with a Bluetooth host device (bt-host)
2935#[derive(Debug)]
2936pub enum HostRequest {
2937    /// Fulfills a given protocol request. bt-host will start processing FIDL messages. If the
2938    /// request cannot be fulfilled, the bt-host device will close its end of the given channel.
2939    RequestProtocol { payload: ProtocolRequest, control_handle: HostControlHandle },
2940    /// Shuts down the host, ending all active Bluetooth procedures:
2941    ///
2942    /// * All FIDL interface handles associated with this host are closed and all
2943    ///   connections initiated via FIDL clients are severed.
2944    /// * All scan, discovery, and advertising procedures are stopped.
2945    /// * Bonded devices are cleared and removed from the auto-connect lists.
2946    /// * Auto-connected peripherals are disconnected.
2947    ///
2948    /// This effectively resets the host to its initial state and the host remains
2949    /// available for future requests.
2950    ///
2951    /// The Host will continue to send OnDeviceUpdated events as procedures get
2952    /// terminated.
2953    ///
2954    /// The Host protocol will close when shutdown is complete.
2955    Shutdown { control_handle: HostControlHandle },
2956    /// Returns information about the Bluetooth host subsystem and controller managed by this Host
2957    /// instance. If there has been no change to the state since the last call to this method, the
2958    /// response will be deferred until there is a change.
2959    ///
2960    /// The returned `info` structure will be populated with the current state of the bt-host
2961    /// device. However the `active` parameter will never be populated. This field is managed
2962    /// by a higher layer.
2963    WatchState { responder: HostWatchStateResponder },
2964    /// Assigns local data to this host.
2965    SetLocalData {
2966        payload: fidl_fuchsia_bluetooth_sys::HostData,
2967        control_handle: HostControlHandle,
2968    },
2969    /// Sets a PeerWatcher protocol that will be notified of changes to peers.
2970    /// Only 1 PeerWatcher can be configured at a time.
2971    SetPeerWatcher {
2972        peer_watcher: fidl::endpoints::ServerEnd<PeerWatcherMarker>,
2973        control_handle: HostControlHandle,
2974    },
2975    /// Sets the local name for this host device.
2976    SetLocalName { local_name: String, responder: HostSetLocalNameResponder },
2977    /// Sets the device class for this host device.
2978    SetDeviceClass {
2979        device_class: fidl_fuchsia_bluetooth::DeviceClass,
2980        responder: HostSetDeviceClassResponder,
2981    },
2982    /// Initiates a general discovery procedure for BR/EDR and LE devices. On success, discovered
2983    /// peers can be monitored using the [`fuchsia.bluetooth.host/Host.WatchPeers`] method. On Error,
2984    /// an epitaph will be returned from `token`. If the device does not support BR/EDR, only LE
2985    /// discovery will be performed.
2986    ///
2987    /// On the LE transport, only general-discoverable and connectable peripherals will be reported.
2988    ///
2989    /// Discovery will continue until all discovery sessions are closed.
2990    ///
2991    /// + request `token` The DiscoverySession protocol that must be held open as long as
2992    ///     discovery should be enabled. Closing it will stop discovery if no other sessions
2993    ///     are open.
2994    StartDiscovery { payload: HostStartDiscoveryRequest, control_handle: HostControlHandle },
2995    /// Sets whether this host should be connectable.
2996    SetConnectable { enabled: bool, responder: HostSetConnectableResponder },
2997    /// Sets whether this host should be discoverable.
2998    SetDiscoverable { enabled: bool, responder: HostSetDiscoverableResponder },
2999    /// Establish a BR/EDR and/or LE connection to the peer with identifier `id`:
3000    ///
3001    ///   - If the peer is known to support the BR/EDR transport then a logical link over that
3002    ///     transport will be established to the device. If the connection attempt is successful,
3003    ///     local services registered using "RequestProfile()" will be available to the peer.
3004    ///     Traditional services discovered on the peer will be notified to local services
3005    ///     asynchronously.
3006    ///
3007    ///   - If the peer is known to support the LE transport then a logical link over that
3008    ///     transport will be established to the device. If the connection attempt is successful,
3009    ///     GATT services in the local database (populated via RequestGattServer()) will become
3010    ///     available to the peer. Similarly, remote GATT services that are discovered on the
3011    ///     peer will become available to holders of a gatt.Client capability and to device drivers
3012    ///     that can bind to the bt-gatt-svc class of devices.
3013    ///
3014    /// The result of the procedure will be communicated via `status`. If the remote device
3015    /// supports both BR/EDR and LE transports and a link cannot be established over both, then an
3016    /// error Status will be returned and neither transport will be connected.
3017    Connect { id: fidl_fuchsia_bluetooth::PeerId, responder: HostConnectResponder },
3018    /// Terminate all connections (BR/EDR or LE) to the remote peer with identifier `id`.
3019    ///
3020    /// + request `id` The identifier of the peer to disconnect.
3021    /// - response `status` Contains an error if either LE or BR/EDR transport fails to disconnect.
3022    ///                     Contains success when both transports are successfully disconnected or
3023    ///                     if the peer is already disconnected.
3024    Disconnect { id: fidl_fuchsia_bluetooth::PeerId, responder: HostDisconnectResponder },
3025    /// Initiates pairing to the peer with the supplied `id` and `options`. Returns an error if no
3026    /// connected peer with `id` is found or the pairing procedure fails.
3027    ///
3028    /// If `options` specifies a higher security level than the current pairing, this method
3029    /// attempts to raise the security level. Otherwise this method has no effect and returns
3030    /// success.
3031    ///
3032    /// NOTE: This is intended to satisfy test scenarios that require pairing procedures to be
3033    /// initiated without relying on service access. In normal operation, Bluetooth security is
3034    /// enforced during service access.
3035    Pair {
3036        id: fidl_fuchsia_bluetooth::PeerId,
3037        options: fidl_fuchsia_bluetooth_sys::PairingOptions,
3038        responder: HostPairResponder,
3039    },
3040    /// Deletes a peer from the Bluetooth host. If the peer is connected, it will be disconnected.
3041    /// `device_id` will no longer refer to any peer, even if a device with the same address is
3042    /// discovered again.
3043    ///
3044    /// Returns success after no peer exists that's identified by `device_id` (even if it didn't
3045    /// exist before Forget), failure if the peer specified by `device_id` could not be
3046    /// disconnected or deleted and still exists.
3047    Forget { id: fidl_fuchsia_bluetooth::PeerId, responder: HostForgetResponder },
3048    /// Enable or disable a passive LE background scan. When enabled, the bt-host
3049    /// device will continuously perform a passive LE scan in the background when
3050    /// no device discovery sessions are active and accept connection requests from
3051    /// bonded peripherals.
3052    EnableBackgroundScan { enabled: bool, control_handle: HostControlHandle },
3053    /// Enable or disable the LE privacy feature. When enabled, the bt-host device will use a
3054    /// private device address in all LE procedures. When disabled, the public identity address will
3055    /// be used instead (which is the default).
3056    EnablePrivacy { enabled: bool, control_handle: HostControlHandle },
3057    /// Set the GAP BR/EDR Security Mode of the host. bt-host only supports encrypted,
3058    /// connection-based security modes, i.e. Mode 4 and Secure Connections Only mode. If the
3059    /// security mode is set to Secure Connections Only, any existing encrypted connections which
3060    /// do not meet the security requirements of Secure Connections Only mode will be disconnected.
3061    SetBrEdrSecurityMode {
3062        bredr_security_mode: fidl_fuchsia_bluetooth_sys::BrEdrSecurityMode,
3063        control_handle: HostControlHandle,
3064    },
3065    /// Set the GAP LE Security Mode of the host. bt-host only supports encrypted, connection-based
3066    /// security modes, i.e. Mode 1 and Secure Connections Only mode. If the security mode is set
3067    /// to Secure Connections Only, any existing encrypted connections which do not meet the
3068    /// security requirements of Secure Connections Only mode will be disconnected.
3069    SetLeSecurityMode {
3070        le_security_mode: fidl_fuchsia_bluetooth_sys::LeSecurityMode,
3071        control_handle: HostControlHandle,
3072    },
3073    /// Assigns the pairing delegate that will respond to authentication challenges using the given
3074    /// I/O capabilities. Calling this method cancels any on-going pairing procedure started
3075    /// using a previous delegate. Pairing requests will be rejected if no PairingDelegate has been
3076    /// assigned.
3077    SetPairingDelegate {
3078        input: fidl_fuchsia_bluetooth_sys::InputCapability,
3079        output: fidl_fuchsia_bluetooth_sys::OutputCapability,
3080        delegate: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth_sys::PairingDelegateMarker>,
3081        control_handle: HostControlHandle,
3082    },
3083    /// Set a BondingDelegate protocol that will be notified of new and removed bonds that need to
3084    /// be persisted. If a delegate is already set, the new `delegate` will be closed with
3085    /// ALREADY_BOUND
3086    SetBondingDelegate {
3087        delegate: fidl::endpoints::ServerEnd<BondingDelegateMarker>,
3088        control_handle: HostControlHandle,
3089    },
3090    /// An interaction was received which does not match any known method.
3091    #[non_exhaustive]
3092    _UnknownMethod {
3093        /// Ordinal of the method that was called.
3094        ordinal: u64,
3095        control_handle: HostControlHandle,
3096        method_type: fidl::MethodType,
3097    },
3098}
3099
3100impl HostRequest {
3101    #[allow(irrefutable_let_patterns)]
3102    pub fn into_request_protocol(self) -> Option<(ProtocolRequest, HostControlHandle)> {
3103        if let HostRequest::RequestProtocol { payload, control_handle } = self {
3104            Some((payload, control_handle))
3105        } else {
3106            None
3107        }
3108    }
3109
3110    #[allow(irrefutable_let_patterns)]
3111    pub fn into_shutdown(self) -> Option<(HostControlHandle)> {
3112        if let HostRequest::Shutdown { control_handle } = self {
3113            Some((control_handle))
3114        } else {
3115            None
3116        }
3117    }
3118
3119    #[allow(irrefutable_let_patterns)]
3120    pub fn into_watch_state(self) -> Option<(HostWatchStateResponder)> {
3121        if let HostRequest::WatchState { responder } = self { Some((responder)) } else { None }
3122    }
3123
3124    #[allow(irrefutable_let_patterns)]
3125    pub fn into_set_local_data(
3126        self,
3127    ) -> Option<(fidl_fuchsia_bluetooth_sys::HostData, HostControlHandle)> {
3128        if let HostRequest::SetLocalData { payload, control_handle } = self {
3129            Some((payload, control_handle))
3130        } else {
3131            None
3132        }
3133    }
3134
3135    #[allow(irrefutable_let_patterns)]
3136    pub fn into_set_peer_watcher(
3137        self,
3138    ) -> Option<(fidl::endpoints::ServerEnd<PeerWatcherMarker>, HostControlHandle)> {
3139        if let HostRequest::SetPeerWatcher { peer_watcher, control_handle } = self {
3140            Some((peer_watcher, control_handle))
3141        } else {
3142            None
3143        }
3144    }
3145
3146    #[allow(irrefutable_let_patterns)]
3147    pub fn into_set_local_name(self) -> Option<(String, HostSetLocalNameResponder)> {
3148        if let HostRequest::SetLocalName { local_name, responder } = self {
3149            Some((local_name, responder))
3150        } else {
3151            None
3152        }
3153    }
3154
3155    #[allow(irrefutable_let_patterns)]
3156    pub fn into_set_device_class(
3157        self,
3158    ) -> Option<(fidl_fuchsia_bluetooth::DeviceClass, HostSetDeviceClassResponder)> {
3159        if let HostRequest::SetDeviceClass { device_class, responder } = self {
3160            Some((device_class, responder))
3161        } else {
3162            None
3163        }
3164    }
3165
3166    #[allow(irrefutable_let_patterns)]
3167    pub fn into_start_discovery(self) -> Option<(HostStartDiscoveryRequest, HostControlHandle)> {
3168        if let HostRequest::StartDiscovery { payload, control_handle } = self {
3169            Some((payload, control_handle))
3170        } else {
3171            None
3172        }
3173    }
3174
3175    #[allow(irrefutable_let_patterns)]
3176    pub fn into_set_connectable(self) -> Option<(bool, HostSetConnectableResponder)> {
3177        if let HostRequest::SetConnectable { enabled, responder } = self {
3178            Some((enabled, responder))
3179        } else {
3180            None
3181        }
3182    }
3183
3184    #[allow(irrefutable_let_patterns)]
3185    pub fn into_set_discoverable(self) -> Option<(bool, HostSetDiscoverableResponder)> {
3186        if let HostRequest::SetDiscoverable { enabled, responder } = self {
3187            Some((enabled, responder))
3188        } else {
3189            None
3190        }
3191    }
3192
3193    #[allow(irrefutable_let_patterns)]
3194    pub fn into_connect(self) -> Option<(fidl_fuchsia_bluetooth::PeerId, HostConnectResponder)> {
3195        if let HostRequest::Connect { id, responder } = self { Some((id, responder)) } else { None }
3196    }
3197
3198    #[allow(irrefutable_let_patterns)]
3199    pub fn into_disconnect(
3200        self,
3201    ) -> Option<(fidl_fuchsia_bluetooth::PeerId, HostDisconnectResponder)> {
3202        if let HostRequest::Disconnect { id, responder } = self {
3203            Some((id, responder))
3204        } else {
3205            None
3206        }
3207    }
3208
3209    #[allow(irrefutable_let_patterns)]
3210    pub fn into_pair(
3211        self,
3212    ) -> Option<(
3213        fidl_fuchsia_bluetooth::PeerId,
3214        fidl_fuchsia_bluetooth_sys::PairingOptions,
3215        HostPairResponder,
3216    )> {
3217        if let HostRequest::Pair { id, options, responder } = self {
3218            Some((id, options, responder))
3219        } else {
3220            None
3221        }
3222    }
3223
3224    #[allow(irrefutable_let_patterns)]
3225    pub fn into_forget(self) -> Option<(fidl_fuchsia_bluetooth::PeerId, HostForgetResponder)> {
3226        if let HostRequest::Forget { id, responder } = self { Some((id, responder)) } else { None }
3227    }
3228
3229    #[allow(irrefutable_let_patterns)]
3230    pub fn into_enable_background_scan(self) -> Option<(bool, HostControlHandle)> {
3231        if let HostRequest::EnableBackgroundScan { enabled, control_handle } = self {
3232            Some((enabled, control_handle))
3233        } else {
3234            None
3235        }
3236    }
3237
3238    #[allow(irrefutable_let_patterns)]
3239    pub fn into_enable_privacy(self) -> Option<(bool, HostControlHandle)> {
3240        if let HostRequest::EnablePrivacy { enabled, control_handle } = self {
3241            Some((enabled, control_handle))
3242        } else {
3243            None
3244        }
3245    }
3246
3247    #[allow(irrefutable_let_patterns)]
3248    pub fn into_set_br_edr_security_mode(
3249        self,
3250    ) -> Option<(fidl_fuchsia_bluetooth_sys::BrEdrSecurityMode, HostControlHandle)> {
3251        if let HostRequest::SetBrEdrSecurityMode { bredr_security_mode, control_handle } = self {
3252            Some((bredr_security_mode, control_handle))
3253        } else {
3254            None
3255        }
3256    }
3257
3258    #[allow(irrefutable_let_patterns)]
3259    pub fn into_set_le_security_mode(
3260        self,
3261    ) -> Option<(fidl_fuchsia_bluetooth_sys::LeSecurityMode, HostControlHandle)> {
3262        if let HostRequest::SetLeSecurityMode { le_security_mode, control_handle } = self {
3263            Some((le_security_mode, control_handle))
3264        } else {
3265            None
3266        }
3267    }
3268
3269    #[allow(irrefutable_let_patterns)]
3270    pub fn into_set_pairing_delegate(
3271        self,
3272    ) -> Option<(
3273        fidl_fuchsia_bluetooth_sys::InputCapability,
3274        fidl_fuchsia_bluetooth_sys::OutputCapability,
3275        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth_sys::PairingDelegateMarker>,
3276        HostControlHandle,
3277    )> {
3278        if let HostRequest::SetPairingDelegate { input, output, delegate, control_handle } = self {
3279            Some((input, output, delegate, control_handle))
3280        } else {
3281            None
3282        }
3283    }
3284
3285    #[allow(irrefutable_let_patterns)]
3286    pub fn into_set_bonding_delegate(
3287        self,
3288    ) -> Option<(fidl::endpoints::ServerEnd<BondingDelegateMarker>, HostControlHandle)> {
3289        if let HostRequest::SetBondingDelegate { delegate, control_handle } = self {
3290            Some((delegate, control_handle))
3291        } else {
3292            None
3293        }
3294    }
3295
3296    /// Name of the method defined in FIDL
3297    pub fn method_name(&self) -> &'static str {
3298        match *self {
3299            HostRequest::RequestProtocol { .. } => "request_protocol",
3300            HostRequest::Shutdown { .. } => "shutdown",
3301            HostRequest::WatchState { .. } => "watch_state",
3302            HostRequest::SetLocalData { .. } => "set_local_data",
3303            HostRequest::SetPeerWatcher { .. } => "set_peer_watcher",
3304            HostRequest::SetLocalName { .. } => "set_local_name",
3305            HostRequest::SetDeviceClass { .. } => "set_device_class",
3306            HostRequest::StartDiscovery { .. } => "start_discovery",
3307            HostRequest::SetConnectable { .. } => "set_connectable",
3308            HostRequest::SetDiscoverable { .. } => "set_discoverable",
3309            HostRequest::Connect { .. } => "connect",
3310            HostRequest::Disconnect { .. } => "disconnect",
3311            HostRequest::Pair { .. } => "pair",
3312            HostRequest::Forget { .. } => "forget",
3313            HostRequest::EnableBackgroundScan { .. } => "enable_background_scan",
3314            HostRequest::EnablePrivacy { .. } => "enable_privacy",
3315            HostRequest::SetBrEdrSecurityMode { .. } => "set_br_edr_security_mode",
3316            HostRequest::SetLeSecurityMode { .. } => "set_le_security_mode",
3317            HostRequest::SetPairingDelegate { .. } => "set_pairing_delegate",
3318            HostRequest::SetBondingDelegate { .. } => "set_bonding_delegate",
3319            HostRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
3320                "unknown one-way method"
3321            }
3322            HostRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
3323                "unknown two-way method"
3324            }
3325        }
3326    }
3327}
3328
3329#[derive(Debug, Clone)]
3330pub struct HostControlHandle {
3331    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3332}
3333
3334impl fidl::endpoints::ControlHandle for HostControlHandle {
3335    fn shutdown(&self) {
3336        self.inner.shutdown()
3337    }
3338
3339    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3340        self.inner.shutdown_with_epitaph(status)
3341    }
3342
3343    fn is_closed(&self) -> bool {
3344        self.inner.channel().is_closed()
3345    }
3346    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3347        self.inner.channel().on_closed()
3348    }
3349
3350    #[cfg(target_os = "fuchsia")]
3351    fn signal_peer(
3352        &self,
3353        clear_mask: zx::Signals,
3354        set_mask: zx::Signals,
3355    ) -> Result<(), zx_status::Status> {
3356        use fidl::Peered;
3357        self.inner.channel().signal_peer(clear_mask, set_mask)
3358    }
3359}
3360
3361impl HostControlHandle {}
3362
3363#[must_use = "FIDL methods require a response to be sent"]
3364#[derive(Debug)]
3365pub struct HostWatchStateResponder {
3366    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3367    tx_id: u32,
3368}
3369
3370/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3371/// if the responder is dropped without sending a response, so that the client
3372/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3373impl std::ops::Drop for HostWatchStateResponder {
3374    fn drop(&mut self) {
3375        self.control_handle.shutdown();
3376        // Safety: drops once, never accessed again
3377        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3378    }
3379}
3380
3381impl fidl::endpoints::Responder for HostWatchStateResponder {
3382    type ControlHandle = HostControlHandle;
3383
3384    fn control_handle(&self) -> &HostControlHandle {
3385        &self.control_handle
3386    }
3387
3388    fn drop_without_shutdown(mut self) {
3389        // Safety: drops once, never accessed again due to mem::forget
3390        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3391        // Prevent Drop from running (which would shut down the channel)
3392        std::mem::forget(self);
3393    }
3394}
3395
3396impl HostWatchStateResponder {
3397    /// Sends a response to the FIDL transaction.
3398    ///
3399    /// Sets the channel to shutdown if an error occurs.
3400    pub fn send(self, mut info: &fidl_fuchsia_bluetooth_sys::HostInfo) -> Result<(), fidl::Error> {
3401        let _result = self.send_raw(info);
3402        if _result.is_err() {
3403            self.control_handle.shutdown();
3404        }
3405        self.drop_without_shutdown();
3406        _result
3407    }
3408
3409    /// Similar to "send" but does not shutdown the channel if an error occurs.
3410    pub fn send_no_shutdown_on_err(
3411        self,
3412        mut info: &fidl_fuchsia_bluetooth_sys::HostInfo,
3413    ) -> Result<(), fidl::Error> {
3414        let _result = self.send_raw(info);
3415        self.drop_without_shutdown();
3416        _result
3417    }
3418
3419    fn send_raw(&self, mut info: &fidl_fuchsia_bluetooth_sys::HostInfo) -> Result<(), fidl::Error> {
3420        self.control_handle.inner.send::<fidl::encoding::FlexibleType<HostWatchStateResponse>>(
3421            fidl::encoding::Flexible::new((info,)),
3422            self.tx_id,
3423            0x19157554e2a3db52,
3424            fidl::encoding::DynamicFlags::FLEXIBLE,
3425        )
3426    }
3427}
3428
3429#[must_use = "FIDL methods require a response to be sent"]
3430#[derive(Debug)]
3431pub struct HostSetLocalNameResponder {
3432    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3433    tx_id: u32,
3434}
3435
3436/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3437/// if the responder is dropped without sending a response, so that the client
3438/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3439impl std::ops::Drop for HostSetLocalNameResponder {
3440    fn drop(&mut self) {
3441        self.control_handle.shutdown();
3442        // Safety: drops once, never accessed again
3443        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3444    }
3445}
3446
3447impl fidl::endpoints::Responder for HostSetLocalNameResponder {
3448    type ControlHandle = HostControlHandle;
3449
3450    fn control_handle(&self) -> &HostControlHandle {
3451        &self.control_handle
3452    }
3453
3454    fn drop_without_shutdown(mut self) {
3455        // Safety: drops once, never accessed again due to mem::forget
3456        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3457        // Prevent Drop from running (which would shut down the channel)
3458        std::mem::forget(self);
3459    }
3460}
3461
3462impl HostSetLocalNameResponder {
3463    /// Sends a response to the FIDL transaction.
3464    ///
3465    /// Sets the channel to shutdown if an error occurs.
3466    pub fn send(
3467        self,
3468        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3469    ) -> Result<(), fidl::Error> {
3470        let _result = self.send_raw(result);
3471        if _result.is_err() {
3472            self.control_handle.shutdown();
3473        }
3474        self.drop_without_shutdown();
3475        _result
3476    }
3477
3478    /// Similar to "send" but does not shutdown the channel if an error occurs.
3479    pub fn send_no_shutdown_on_err(
3480        self,
3481        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3482    ) -> Result<(), fidl::Error> {
3483        let _result = self.send_raw(result);
3484        self.drop_without_shutdown();
3485        _result
3486    }
3487
3488    fn send_raw(
3489        &self,
3490        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3491    ) -> Result<(), fidl::Error> {
3492        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3493            fidl::encoding::EmptyStruct,
3494            fidl_fuchsia_bluetooth_sys::Error,
3495        >>(
3496            fidl::encoding::FlexibleResult::new(result),
3497            self.tx_id,
3498            0x85e98b56b98f123,
3499            fidl::encoding::DynamicFlags::FLEXIBLE,
3500        )
3501    }
3502}
3503
3504#[must_use = "FIDL methods require a response to be sent"]
3505#[derive(Debug)]
3506pub struct HostSetDeviceClassResponder {
3507    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3508    tx_id: u32,
3509}
3510
3511/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3512/// if the responder is dropped without sending a response, so that the client
3513/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3514impl std::ops::Drop for HostSetDeviceClassResponder {
3515    fn drop(&mut self) {
3516        self.control_handle.shutdown();
3517        // Safety: drops once, never accessed again
3518        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3519    }
3520}
3521
3522impl fidl::endpoints::Responder for HostSetDeviceClassResponder {
3523    type ControlHandle = HostControlHandle;
3524
3525    fn control_handle(&self) -> &HostControlHandle {
3526        &self.control_handle
3527    }
3528
3529    fn drop_without_shutdown(mut self) {
3530        // Safety: drops once, never accessed again due to mem::forget
3531        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3532        // Prevent Drop from running (which would shut down the channel)
3533        std::mem::forget(self);
3534    }
3535}
3536
3537impl HostSetDeviceClassResponder {
3538    /// Sends a response to the FIDL transaction.
3539    ///
3540    /// Sets the channel to shutdown if an error occurs.
3541    pub fn send(
3542        self,
3543        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3544    ) -> Result<(), fidl::Error> {
3545        let _result = self.send_raw(result);
3546        if _result.is_err() {
3547            self.control_handle.shutdown();
3548        }
3549        self.drop_without_shutdown();
3550        _result
3551    }
3552
3553    /// Similar to "send" but does not shutdown the channel if an error occurs.
3554    pub fn send_no_shutdown_on_err(
3555        self,
3556        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3557    ) -> Result<(), fidl::Error> {
3558        let _result = self.send_raw(result);
3559        self.drop_without_shutdown();
3560        _result
3561    }
3562
3563    fn send_raw(
3564        &self,
3565        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3566    ) -> Result<(), fidl::Error> {
3567        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3568            fidl::encoding::EmptyStruct,
3569            fidl_fuchsia_bluetooth_sys::Error,
3570        >>(
3571            fidl::encoding::FlexibleResult::new(result),
3572            self.tx_id,
3573            0x4caef8f835950de2,
3574            fidl::encoding::DynamicFlags::FLEXIBLE,
3575        )
3576    }
3577}
3578
3579#[must_use = "FIDL methods require a response to be sent"]
3580#[derive(Debug)]
3581pub struct HostSetConnectableResponder {
3582    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3583    tx_id: u32,
3584}
3585
3586/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3587/// if the responder is dropped without sending a response, so that the client
3588/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3589impl std::ops::Drop for HostSetConnectableResponder {
3590    fn drop(&mut self) {
3591        self.control_handle.shutdown();
3592        // Safety: drops once, never accessed again
3593        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3594    }
3595}
3596
3597impl fidl::endpoints::Responder for HostSetConnectableResponder {
3598    type ControlHandle = HostControlHandle;
3599
3600    fn control_handle(&self) -> &HostControlHandle {
3601        &self.control_handle
3602    }
3603
3604    fn drop_without_shutdown(mut self) {
3605        // Safety: drops once, never accessed again due to mem::forget
3606        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3607        // Prevent Drop from running (which would shut down the channel)
3608        std::mem::forget(self);
3609    }
3610}
3611
3612impl HostSetConnectableResponder {
3613    /// Sends a response to the FIDL transaction.
3614    ///
3615    /// Sets the channel to shutdown if an error occurs.
3616    pub fn send(
3617        self,
3618        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3619    ) -> Result<(), fidl::Error> {
3620        let _result = self.send_raw(result);
3621        if _result.is_err() {
3622            self.control_handle.shutdown();
3623        }
3624        self.drop_without_shutdown();
3625        _result
3626    }
3627
3628    /// Similar to "send" but does not shutdown the channel if an error occurs.
3629    pub fn send_no_shutdown_on_err(
3630        self,
3631        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3632    ) -> Result<(), fidl::Error> {
3633        let _result = self.send_raw(result);
3634        self.drop_without_shutdown();
3635        _result
3636    }
3637
3638    fn send_raw(
3639        &self,
3640        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3641    ) -> Result<(), fidl::Error> {
3642        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3643            fidl::encoding::EmptyStruct,
3644            fidl_fuchsia_bluetooth_sys::Error,
3645        >>(
3646            fidl::encoding::FlexibleResult::new(result),
3647            self.tx_id,
3648            0x187a6a82e811fa92,
3649            fidl::encoding::DynamicFlags::FLEXIBLE,
3650        )
3651    }
3652}
3653
3654#[must_use = "FIDL methods require a response to be sent"]
3655#[derive(Debug)]
3656pub struct HostSetDiscoverableResponder {
3657    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3658    tx_id: u32,
3659}
3660
3661/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3662/// if the responder is dropped without sending a response, so that the client
3663/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3664impl std::ops::Drop for HostSetDiscoverableResponder {
3665    fn drop(&mut self) {
3666        self.control_handle.shutdown();
3667        // Safety: drops once, never accessed again
3668        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3669    }
3670}
3671
3672impl fidl::endpoints::Responder for HostSetDiscoverableResponder {
3673    type ControlHandle = HostControlHandle;
3674
3675    fn control_handle(&self) -> &HostControlHandle {
3676        &self.control_handle
3677    }
3678
3679    fn drop_without_shutdown(mut self) {
3680        // Safety: drops once, never accessed again due to mem::forget
3681        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3682        // Prevent Drop from running (which would shut down the channel)
3683        std::mem::forget(self);
3684    }
3685}
3686
3687impl HostSetDiscoverableResponder {
3688    /// Sends a response to the FIDL transaction.
3689    ///
3690    /// Sets the channel to shutdown if an error occurs.
3691    pub fn send(
3692        self,
3693        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3694    ) -> Result<(), fidl::Error> {
3695        let _result = self.send_raw(result);
3696        if _result.is_err() {
3697            self.control_handle.shutdown();
3698        }
3699        self.drop_without_shutdown();
3700        _result
3701    }
3702
3703    /// Similar to "send" but does not shutdown the channel if an error occurs.
3704    pub fn send_no_shutdown_on_err(
3705        self,
3706        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3707    ) -> Result<(), fidl::Error> {
3708        let _result = self.send_raw(result);
3709        self.drop_without_shutdown();
3710        _result
3711    }
3712
3713    fn send_raw(
3714        &self,
3715        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3716    ) -> Result<(), fidl::Error> {
3717        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3718            fidl::encoding::EmptyStruct,
3719            fidl_fuchsia_bluetooth_sys::Error,
3720        >>(
3721            fidl::encoding::FlexibleResult::new(result),
3722            self.tx_id,
3723            0x89f8c7da63e36de,
3724            fidl::encoding::DynamicFlags::FLEXIBLE,
3725        )
3726    }
3727}
3728
3729#[must_use = "FIDL methods require a response to be sent"]
3730#[derive(Debug)]
3731pub struct HostConnectResponder {
3732    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3733    tx_id: u32,
3734}
3735
3736/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3737/// if the responder is dropped without sending a response, so that the client
3738/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3739impl std::ops::Drop for HostConnectResponder {
3740    fn drop(&mut self) {
3741        self.control_handle.shutdown();
3742        // Safety: drops once, never accessed again
3743        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3744    }
3745}
3746
3747impl fidl::endpoints::Responder for HostConnectResponder {
3748    type ControlHandle = HostControlHandle;
3749
3750    fn control_handle(&self) -> &HostControlHandle {
3751        &self.control_handle
3752    }
3753
3754    fn drop_without_shutdown(mut self) {
3755        // Safety: drops once, never accessed again due to mem::forget
3756        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3757        // Prevent Drop from running (which would shut down the channel)
3758        std::mem::forget(self);
3759    }
3760}
3761
3762impl HostConnectResponder {
3763    /// Sends a response to the FIDL transaction.
3764    ///
3765    /// Sets the channel to shutdown if an error occurs.
3766    pub fn send(
3767        self,
3768        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3769    ) -> Result<(), fidl::Error> {
3770        let _result = self.send_raw(result);
3771        if _result.is_err() {
3772            self.control_handle.shutdown();
3773        }
3774        self.drop_without_shutdown();
3775        _result
3776    }
3777
3778    /// Similar to "send" but does not shutdown the channel if an error occurs.
3779    pub fn send_no_shutdown_on_err(
3780        self,
3781        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3782    ) -> Result<(), fidl::Error> {
3783        let _result = self.send_raw(result);
3784        self.drop_without_shutdown();
3785        _result
3786    }
3787
3788    fn send_raw(
3789        &self,
3790        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3791    ) -> Result<(), fidl::Error> {
3792        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3793            fidl::encoding::EmptyStruct,
3794            fidl_fuchsia_bluetooth_sys::Error,
3795        >>(
3796            fidl::encoding::FlexibleResult::new(result),
3797            self.tx_id,
3798            0x5a56139c993e7240,
3799            fidl::encoding::DynamicFlags::FLEXIBLE,
3800        )
3801    }
3802}
3803
3804#[must_use = "FIDL methods require a response to be sent"]
3805#[derive(Debug)]
3806pub struct HostDisconnectResponder {
3807    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3808    tx_id: u32,
3809}
3810
3811/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3812/// if the responder is dropped without sending a response, so that the client
3813/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3814impl std::ops::Drop for HostDisconnectResponder {
3815    fn drop(&mut self) {
3816        self.control_handle.shutdown();
3817        // Safety: drops once, never accessed again
3818        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3819    }
3820}
3821
3822impl fidl::endpoints::Responder for HostDisconnectResponder {
3823    type ControlHandle = HostControlHandle;
3824
3825    fn control_handle(&self) -> &HostControlHandle {
3826        &self.control_handle
3827    }
3828
3829    fn drop_without_shutdown(mut self) {
3830        // Safety: drops once, never accessed again due to mem::forget
3831        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3832        // Prevent Drop from running (which would shut down the channel)
3833        std::mem::forget(self);
3834    }
3835}
3836
3837impl HostDisconnectResponder {
3838    /// Sends a response to the FIDL transaction.
3839    ///
3840    /// Sets the channel to shutdown if an error occurs.
3841    pub fn send(
3842        self,
3843        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3844    ) -> Result<(), fidl::Error> {
3845        let _result = self.send_raw(result);
3846        if _result.is_err() {
3847            self.control_handle.shutdown();
3848        }
3849        self.drop_without_shutdown();
3850        _result
3851    }
3852
3853    /// Similar to "send" but does not shutdown the channel if an error occurs.
3854    pub fn send_no_shutdown_on_err(
3855        self,
3856        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3857    ) -> Result<(), fidl::Error> {
3858        let _result = self.send_raw(result);
3859        self.drop_without_shutdown();
3860        _result
3861    }
3862
3863    fn send_raw(
3864        &self,
3865        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3866    ) -> Result<(), fidl::Error> {
3867        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3868            fidl::encoding::EmptyStruct,
3869            fidl_fuchsia_bluetooth_sys::Error,
3870        >>(
3871            fidl::encoding::FlexibleResult::new(result),
3872            self.tx_id,
3873            0x33211717491121b1,
3874            fidl::encoding::DynamicFlags::FLEXIBLE,
3875        )
3876    }
3877}
3878
3879#[must_use = "FIDL methods require a response to be sent"]
3880#[derive(Debug)]
3881pub struct HostPairResponder {
3882    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3883    tx_id: u32,
3884}
3885
3886/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3887/// if the responder is dropped without sending a response, so that the client
3888/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3889impl std::ops::Drop for HostPairResponder {
3890    fn drop(&mut self) {
3891        self.control_handle.shutdown();
3892        // Safety: drops once, never accessed again
3893        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3894    }
3895}
3896
3897impl fidl::endpoints::Responder for HostPairResponder {
3898    type ControlHandle = HostControlHandle;
3899
3900    fn control_handle(&self) -> &HostControlHandle {
3901        &self.control_handle
3902    }
3903
3904    fn drop_without_shutdown(mut self) {
3905        // Safety: drops once, never accessed again due to mem::forget
3906        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3907        // Prevent Drop from running (which would shut down the channel)
3908        std::mem::forget(self);
3909    }
3910}
3911
3912impl HostPairResponder {
3913    /// Sends a response to the FIDL transaction.
3914    ///
3915    /// Sets the channel to shutdown if an error occurs.
3916    pub fn send(
3917        self,
3918        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3919    ) -> Result<(), fidl::Error> {
3920        let _result = self.send_raw(result);
3921        if _result.is_err() {
3922            self.control_handle.shutdown();
3923        }
3924        self.drop_without_shutdown();
3925        _result
3926    }
3927
3928    /// Similar to "send" but does not shutdown the channel if an error occurs.
3929    pub fn send_no_shutdown_on_err(
3930        self,
3931        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3932    ) -> Result<(), fidl::Error> {
3933        let _result = self.send_raw(result);
3934        self.drop_without_shutdown();
3935        _result
3936    }
3937
3938    fn send_raw(
3939        &self,
3940        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3941    ) -> Result<(), fidl::Error> {
3942        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3943            fidl::encoding::EmptyStruct,
3944            fidl_fuchsia_bluetooth_sys::Error,
3945        >>(
3946            fidl::encoding::FlexibleResult::new(result),
3947            self.tx_id,
3948            0x2efaec6dc5d62ca2,
3949            fidl::encoding::DynamicFlags::FLEXIBLE,
3950        )
3951    }
3952}
3953
3954#[must_use = "FIDL methods require a response to be sent"]
3955#[derive(Debug)]
3956pub struct HostForgetResponder {
3957    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3958    tx_id: u32,
3959}
3960
3961/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3962/// if the responder is dropped without sending a response, so that the client
3963/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3964impl std::ops::Drop for HostForgetResponder {
3965    fn drop(&mut self) {
3966        self.control_handle.shutdown();
3967        // Safety: drops once, never accessed again
3968        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3969    }
3970}
3971
3972impl fidl::endpoints::Responder for HostForgetResponder {
3973    type ControlHandle = HostControlHandle;
3974
3975    fn control_handle(&self) -> &HostControlHandle {
3976        &self.control_handle
3977    }
3978
3979    fn drop_without_shutdown(mut self) {
3980        // Safety: drops once, never accessed again due to mem::forget
3981        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3982        // Prevent Drop from running (which would shut down the channel)
3983        std::mem::forget(self);
3984    }
3985}
3986
3987impl HostForgetResponder {
3988    /// Sends a response to the FIDL transaction.
3989    ///
3990    /// Sets the channel to shutdown if an error occurs.
3991    pub fn send(
3992        self,
3993        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3994    ) -> Result<(), fidl::Error> {
3995        let _result = self.send_raw(result);
3996        if _result.is_err() {
3997            self.control_handle.shutdown();
3998        }
3999        self.drop_without_shutdown();
4000        _result
4001    }
4002
4003    /// Similar to "send" but does not shutdown the channel if an error occurs.
4004    pub fn send_no_shutdown_on_err(
4005        self,
4006        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
4007    ) -> Result<(), fidl::Error> {
4008        let _result = self.send_raw(result);
4009        self.drop_without_shutdown();
4010        _result
4011    }
4012
4013    fn send_raw(
4014        &self,
4015        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
4016    ) -> Result<(), fidl::Error> {
4017        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4018            fidl::encoding::EmptyStruct,
4019            fidl_fuchsia_bluetooth_sys::Error,
4020        >>(
4021            fidl::encoding::FlexibleResult::new(result),
4022            self.tx_id,
4023            0x904f58dbdd4490a,
4024            fidl::encoding::DynamicFlags::FLEXIBLE,
4025        )
4026    }
4027}
4028
4029#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4030pub struct PeerWatcherMarker;
4031
4032impl fidl::endpoints::ProtocolMarker for PeerWatcherMarker {
4033    type Proxy = PeerWatcherProxy;
4034    type RequestStream = PeerWatcherRequestStream;
4035    #[cfg(target_os = "fuchsia")]
4036    type SynchronousProxy = PeerWatcherSynchronousProxy;
4037
4038    const DEBUG_NAME: &'static str = "(anonymous) PeerWatcher";
4039}
4040
4041pub trait PeerWatcherProxyInterface: Send + Sync {
4042    type GetNextResponseFut: std::future::Future<Output = Result<PeerWatcherGetNextResponse, fidl::Error>>
4043        + Send;
4044    fn r#get_next(&self) -> Self::GetNextResponseFut;
4045}
4046#[derive(Debug)]
4047#[cfg(target_os = "fuchsia")]
4048pub struct PeerWatcherSynchronousProxy {
4049    client: fidl::client::sync::Client,
4050}
4051
4052#[cfg(target_os = "fuchsia")]
4053impl fidl::endpoints::SynchronousProxy for PeerWatcherSynchronousProxy {
4054    type Proxy = PeerWatcherProxy;
4055    type Protocol = PeerWatcherMarker;
4056
4057    fn from_channel(inner: fidl::Channel) -> Self {
4058        Self::new(inner)
4059    }
4060
4061    fn into_channel(self) -> fidl::Channel {
4062        self.client.into_channel()
4063    }
4064
4065    fn as_channel(&self) -> &fidl::Channel {
4066        self.client.as_channel()
4067    }
4068}
4069
4070#[cfg(target_os = "fuchsia")]
4071impl PeerWatcherSynchronousProxy {
4072    pub fn new(channel: fidl::Channel) -> Self {
4073        Self { client: fidl::client::sync::Client::new(channel) }
4074    }
4075
4076    pub fn into_channel(self) -> fidl::Channel {
4077        self.client.into_channel()
4078    }
4079
4080    /// Waits until an event arrives and returns it. It is safe for other
4081    /// threads to make concurrent requests while waiting for an event.
4082    pub fn wait_for_event(
4083        &self,
4084        deadline: zx::MonotonicInstant,
4085    ) -> Result<PeerWatcherEvent, fidl::Error> {
4086        PeerWatcherEvent::decode(self.client.wait_for_event::<PeerWatcherMarker>(deadline)?)
4087    }
4088
4089    /// Get the next peer update. The request will hang until the next update.
4090    pub fn r#get_next(
4091        &self,
4092        ___deadline: zx::MonotonicInstant,
4093    ) -> Result<PeerWatcherGetNextResponse, fidl::Error> {
4094        let _response = self.client.send_query::<
4095            fidl::encoding::EmptyPayload,
4096            fidl::encoding::FlexibleType<PeerWatcherGetNextResponse>,
4097            PeerWatcherMarker,
4098        >(
4099            (),
4100            0x31b4855de7565b77,
4101            fidl::encoding::DynamicFlags::FLEXIBLE,
4102            ___deadline,
4103        )?
4104        .into_result::<PeerWatcherMarker>("get_next")?;
4105        Ok(_response)
4106    }
4107}
4108
4109#[cfg(target_os = "fuchsia")]
4110impl From<PeerWatcherSynchronousProxy> for zx::NullableHandle {
4111    fn from(value: PeerWatcherSynchronousProxy) -> Self {
4112        value.into_channel().into()
4113    }
4114}
4115
4116#[cfg(target_os = "fuchsia")]
4117impl From<fidl::Channel> for PeerWatcherSynchronousProxy {
4118    fn from(value: fidl::Channel) -> Self {
4119        Self::new(value)
4120    }
4121}
4122
4123#[cfg(target_os = "fuchsia")]
4124impl fidl::endpoints::FromClient for PeerWatcherSynchronousProxy {
4125    type Protocol = PeerWatcherMarker;
4126
4127    fn from_client(value: fidl::endpoints::ClientEnd<PeerWatcherMarker>) -> Self {
4128        Self::new(value.into_channel())
4129    }
4130}
4131
4132#[derive(Debug, Clone)]
4133pub struct PeerWatcherProxy {
4134    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4135}
4136
4137impl fidl::endpoints::Proxy for PeerWatcherProxy {
4138    type Protocol = PeerWatcherMarker;
4139
4140    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4141        Self::new(inner)
4142    }
4143
4144    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4145        self.client.into_channel().map_err(|client| Self { client })
4146    }
4147
4148    fn as_channel(&self) -> &::fidl::AsyncChannel {
4149        self.client.as_channel()
4150    }
4151}
4152
4153impl PeerWatcherProxy {
4154    /// Create a new Proxy for fuchsia.bluetooth.host/PeerWatcher.
4155    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4156        let protocol_name = <PeerWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4157        Self { client: fidl::client::Client::new(channel, protocol_name) }
4158    }
4159
4160    /// Get a Stream of events from the remote end of the protocol.
4161    ///
4162    /// # Panics
4163    ///
4164    /// Panics if the event stream was already taken.
4165    pub fn take_event_stream(&self) -> PeerWatcherEventStream {
4166        PeerWatcherEventStream { event_receiver: self.client.take_event_receiver() }
4167    }
4168
4169    /// Get the next peer update. The request will hang until the next update.
4170    pub fn r#get_next(
4171        &self,
4172    ) -> fidl::client::QueryResponseFut<
4173        PeerWatcherGetNextResponse,
4174        fidl::encoding::DefaultFuchsiaResourceDialect,
4175    > {
4176        PeerWatcherProxyInterface::r#get_next(self)
4177    }
4178}
4179
4180impl PeerWatcherProxyInterface for PeerWatcherProxy {
4181    type GetNextResponseFut = fidl::client::QueryResponseFut<
4182        PeerWatcherGetNextResponse,
4183        fidl::encoding::DefaultFuchsiaResourceDialect,
4184    >;
4185    fn r#get_next(&self) -> Self::GetNextResponseFut {
4186        fn _decode(
4187            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4188        ) -> Result<PeerWatcherGetNextResponse, fidl::Error> {
4189            let _response = fidl::client::decode_transaction_body::<
4190                fidl::encoding::FlexibleType<PeerWatcherGetNextResponse>,
4191                fidl::encoding::DefaultFuchsiaResourceDialect,
4192                0x31b4855de7565b77,
4193            >(_buf?)?
4194            .into_result::<PeerWatcherMarker>("get_next")?;
4195            Ok(_response)
4196        }
4197        self.client
4198            .send_query_and_decode::<fidl::encoding::EmptyPayload, PeerWatcherGetNextResponse>(
4199                (),
4200                0x31b4855de7565b77,
4201                fidl::encoding::DynamicFlags::FLEXIBLE,
4202                _decode,
4203            )
4204    }
4205}
4206
4207pub struct PeerWatcherEventStream {
4208    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4209}
4210
4211impl std::marker::Unpin for PeerWatcherEventStream {}
4212
4213impl futures::stream::FusedStream for PeerWatcherEventStream {
4214    fn is_terminated(&self) -> bool {
4215        self.event_receiver.is_terminated()
4216    }
4217}
4218
4219impl futures::Stream for PeerWatcherEventStream {
4220    type Item = Result<PeerWatcherEvent, fidl::Error>;
4221
4222    fn poll_next(
4223        mut self: std::pin::Pin<&mut Self>,
4224        cx: &mut std::task::Context<'_>,
4225    ) -> std::task::Poll<Option<Self::Item>> {
4226        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4227            &mut self.event_receiver,
4228            cx
4229        )?) {
4230            Some(buf) => std::task::Poll::Ready(Some(PeerWatcherEvent::decode(buf))),
4231            None => std::task::Poll::Ready(None),
4232        }
4233    }
4234}
4235
4236#[derive(Debug)]
4237pub enum PeerWatcherEvent {
4238    #[non_exhaustive]
4239    _UnknownEvent {
4240        /// Ordinal of the event that was sent.
4241        ordinal: u64,
4242    },
4243}
4244
4245impl PeerWatcherEvent {
4246    /// Decodes a message buffer as a [`PeerWatcherEvent`].
4247    fn decode(
4248        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4249    ) -> Result<PeerWatcherEvent, fidl::Error> {
4250        let (bytes, _handles) = buf.split_mut();
4251        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4252        debug_assert_eq!(tx_header.tx_id, 0);
4253        match tx_header.ordinal {
4254            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4255                Ok(PeerWatcherEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4256            }
4257            _ => Err(fidl::Error::UnknownOrdinal {
4258                ordinal: tx_header.ordinal,
4259                protocol_name: <PeerWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4260            }),
4261        }
4262    }
4263}
4264
4265/// A Stream of incoming requests for fuchsia.bluetooth.host/PeerWatcher.
4266pub struct PeerWatcherRequestStream {
4267    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4268    is_terminated: bool,
4269}
4270
4271impl std::marker::Unpin for PeerWatcherRequestStream {}
4272
4273impl futures::stream::FusedStream for PeerWatcherRequestStream {
4274    fn is_terminated(&self) -> bool {
4275        self.is_terminated
4276    }
4277}
4278
4279impl fidl::endpoints::RequestStream for PeerWatcherRequestStream {
4280    type Protocol = PeerWatcherMarker;
4281    type ControlHandle = PeerWatcherControlHandle;
4282
4283    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4284        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4285    }
4286
4287    fn control_handle(&self) -> Self::ControlHandle {
4288        PeerWatcherControlHandle { inner: self.inner.clone() }
4289    }
4290
4291    fn into_inner(
4292        self,
4293    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4294    {
4295        (self.inner, self.is_terminated)
4296    }
4297
4298    fn from_inner(
4299        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4300        is_terminated: bool,
4301    ) -> Self {
4302        Self { inner, is_terminated }
4303    }
4304}
4305
4306impl futures::Stream for PeerWatcherRequestStream {
4307    type Item = Result<PeerWatcherRequest, fidl::Error>;
4308
4309    fn poll_next(
4310        mut self: std::pin::Pin<&mut Self>,
4311        cx: &mut std::task::Context<'_>,
4312    ) -> std::task::Poll<Option<Self::Item>> {
4313        let this = &mut *self;
4314        if this.inner.check_shutdown(cx) {
4315            this.is_terminated = true;
4316            return std::task::Poll::Ready(None);
4317        }
4318        if this.is_terminated {
4319            panic!("polled PeerWatcherRequestStream after completion");
4320        }
4321        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4322            |bytes, handles| {
4323                match this.inner.channel().read_etc(cx, bytes, handles) {
4324                    std::task::Poll::Ready(Ok(())) => {}
4325                    std::task::Poll::Pending => return std::task::Poll::Pending,
4326                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4327                        this.is_terminated = true;
4328                        return std::task::Poll::Ready(None);
4329                    }
4330                    std::task::Poll::Ready(Err(e)) => {
4331                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4332                            e.into(),
4333                        ))));
4334                    }
4335                }
4336
4337                // A message has been received from the channel
4338                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4339
4340                std::task::Poll::Ready(Some(match header.ordinal {
4341                    0x31b4855de7565b77 => {
4342                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4343                        let mut req = fidl::new_empty!(
4344                            fidl::encoding::EmptyPayload,
4345                            fidl::encoding::DefaultFuchsiaResourceDialect
4346                        );
4347                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4348                        let control_handle = PeerWatcherControlHandle { inner: this.inner.clone() };
4349                        Ok(PeerWatcherRequest::GetNext {
4350                            responder: PeerWatcherGetNextResponder {
4351                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4352                                tx_id: header.tx_id,
4353                            },
4354                        })
4355                    }
4356                    _ if header.tx_id == 0
4357                        && header
4358                            .dynamic_flags()
4359                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4360                    {
4361                        Ok(PeerWatcherRequest::_UnknownMethod {
4362                            ordinal: header.ordinal,
4363                            control_handle: PeerWatcherControlHandle { inner: this.inner.clone() },
4364                            method_type: fidl::MethodType::OneWay,
4365                        })
4366                    }
4367                    _ if header
4368                        .dynamic_flags()
4369                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4370                    {
4371                        this.inner.send_framework_err(
4372                            fidl::encoding::FrameworkErr::UnknownMethod,
4373                            header.tx_id,
4374                            header.ordinal,
4375                            header.dynamic_flags(),
4376                            (bytes, handles),
4377                        )?;
4378                        Ok(PeerWatcherRequest::_UnknownMethod {
4379                            ordinal: header.ordinal,
4380                            control_handle: PeerWatcherControlHandle { inner: this.inner.clone() },
4381                            method_type: fidl::MethodType::TwoWay,
4382                        })
4383                    }
4384                    _ => Err(fidl::Error::UnknownOrdinal {
4385                        ordinal: header.ordinal,
4386                        protocol_name:
4387                            <PeerWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4388                    }),
4389                }))
4390            },
4391        )
4392    }
4393}
4394
4395#[derive(Debug)]
4396pub enum PeerWatcherRequest {
4397    /// Get the next peer update. The request will hang until the next update.
4398    GetNext { responder: PeerWatcherGetNextResponder },
4399    /// An interaction was received which does not match any known method.
4400    #[non_exhaustive]
4401    _UnknownMethod {
4402        /// Ordinal of the method that was called.
4403        ordinal: u64,
4404        control_handle: PeerWatcherControlHandle,
4405        method_type: fidl::MethodType,
4406    },
4407}
4408
4409impl PeerWatcherRequest {
4410    #[allow(irrefutable_let_patterns)]
4411    pub fn into_get_next(self) -> Option<(PeerWatcherGetNextResponder)> {
4412        if let PeerWatcherRequest::GetNext { responder } = self { Some((responder)) } else { None }
4413    }
4414
4415    /// Name of the method defined in FIDL
4416    pub fn method_name(&self) -> &'static str {
4417        match *self {
4418            PeerWatcherRequest::GetNext { .. } => "get_next",
4419            PeerWatcherRequest::_UnknownMethod {
4420                method_type: fidl::MethodType::OneWay, ..
4421            } => "unknown one-way method",
4422            PeerWatcherRequest::_UnknownMethod {
4423                method_type: fidl::MethodType::TwoWay, ..
4424            } => "unknown two-way method",
4425        }
4426    }
4427}
4428
4429#[derive(Debug, Clone)]
4430pub struct PeerWatcherControlHandle {
4431    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4432}
4433
4434impl fidl::endpoints::ControlHandle for PeerWatcherControlHandle {
4435    fn shutdown(&self) {
4436        self.inner.shutdown()
4437    }
4438
4439    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4440        self.inner.shutdown_with_epitaph(status)
4441    }
4442
4443    fn is_closed(&self) -> bool {
4444        self.inner.channel().is_closed()
4445    }
4446    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4447        self.inner.channel().on_closed()
4448    }
4449
4450    #[cfg(target_os = "fuchsia")]
4451    fn signal_peer(
4452        &self,
4453        clear_mask: zx::Signals,
4454        set_mask: zx::Signals,
4455    ) -> Result<(), zx_status::Status> {
4456        use fidl::Peered;
4457        self.inner.channel().signal_peer(clear_mask, set_mask)
4458    }
4459}
4460
4461impl PeerWatcherControlHandle {}
4462
4463#[must_use = "FIDL methods require a response to be sent"]
4464#[derive(Debug)]
4465pub struct PeerWatcherGetNextResponder {
4466    control_handle: std::mem::ManuallyDrop<PeerWatcherControlHandle>,
4467    tx_id: u32,
4468}
4469
4470/// Set the the channel to be shutdown (see [`PeerWatcherControlHandle::shutdown`])
4471/// if the responder is dropped without sending a response, so that the client
4472/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4473impl std::ops::Drop for PeerWatcherGetNextResponder {
4474    fn drop(&mut self) {
4475        self.control_handle.shutdown();
4476        // Safety: drops once, never accessed again
4477        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4478    }
4479}
4480
4481impl fidl::endpoints::Responder for PeerWatcherGetNextResponder {
4482    type ControlHandle = PeerWatcherControlHandle;
4483
4484    fn control_handle(&self) -> &PeerWatcherControlHandle {
4485        &self.control_handle
4486    }
4487
4488    fn drop_without_shutdown(mut self) {
4489        // Safety: drops once, never accessed again due to mem::forget
4490        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4491        // Prevent Drop from running (which would shut down the channel)
4492        std::mem::forget(self);
4493    }
4494}
4495
4496impl PeerWatcherGetNextResponder {
4497    /// Sends a response to the FIDL transaction.
4498    ///
4499    /// Sets the channel to shutdown if an error occurs.
4500    pub fn send(self, mut payload: &PeerWatcherGetNextResponse) -> Result<(), fidl::Error> {
4501        let _result = self.send_raw(payload);
4502        if _result.is_err() {
4503            self.control_handle.shutdown();
4504        }
4505        self.drop_without_shutdown();
4506        _result
4507    }
4508
4509    /// Similar to "send" but does not shutdown the channel if an error occurs.
4510    pub fn send_no_shutdown_on_err(
4511        self,
4512        mut payload: &PeerWatcherGetNextResponse,
4513    ) -> Result<(), fidl::Error> {
4514        let _result = self.send_raw(payload);
4515        self.drop_without_shutdown();
4516        _result
4517    }
4518
4519    fn send_raw(&self, mut payload: &PeerWatcherGetNextResponse) -> Result<(), fidl::Error> {
4520        self.control_handle.inner.send::<fidl::encoding::FlexibleType<PeerWatcherGetNextResponse>>(
4521            fidl::encoding::Flexible::new(payload),
4522            self.tx_id,
4523            0x31b4855de7565b77,
4524            fidl::encoding::DynamicFlags::FLEXIBLE,
4525        )
4526    }
4527}
4528
4529#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4530pub struct ReceiverMarker;
4531
4532impl fidl::endpoints::ProtocolMarker for ReceiverMarker {
4533    type Proxy = ReceiverProxy;
4534    type RequestStream = ReceiverRequestStream;
4535    #[cfg(target_os = "fuchsia")]
4536    type SynchronousProxy = ReceiverSynchronousProxy;
4537
4538    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.host.Receiver";
4539}
4540impl fidl::endpoints::DiscoverableProtocolMarker for ReceiverMarker {}
4541
4542pub trait ReceiverProxyInterface: Send + Sync {
4543    fn r#add_host(
4544        &self,
4545        request: fidl::endpoints::ClientEnd<HostMarker>,
4546    ) -> Result<(), fidl::Error>;
4547}
4548#[derive(Debug)]
4549#[cfg(target_os = "fuchsia")]
4550pub struct ReceiverSynchronousProxy {
4551    client: fidl::client::sync::Client,
4552}
4553
4554#[cfg(target_os = "fuchsia")]
4555impl fidl::endpoints::SynchronousProxy for ReceiverSynchronousProxy {
4556    type Proxy = ReceiverProxy;
4557    type Protocol = ReceiverMarker;
4558
4559    fn from_channel(inner: fidl::Channel) -> Self {
4560        Self::new(inner)
4561    }
4562
4563    fn into_channel(self) -> fidl::Channel {
4564        self.client.into_channel()
4565    }
4566
4567    fn as_channel(&self) -> &fidl::Channel {
4568        self.client.as_channel()
4569    }
4570}
4571
4572#[cfg(target_os = "fuchsia")]
4573impl ReceiverSynchronousProxy {
4574    pub fn new(channel: fidl::Channel) -> Self {
4575        Self { client: fidl::client::sync::Client::new(channel) }
4576    }
4577
4578    pub fn into_channel(self) -> fidl::Channel {
4579        self.client.into_channel()
4580    }
4581
4582    /// Waits until an event arrives and returns it. It is safe for other
4583    /// threads to make concurrent requests while waiting for an event.
4584    pub fn wait_for_event(
4585        &self,
4586        deadline: zx::MonotonicInstant,
4587    ) -> Result<ReceiverEvent, fidl::Error> {
4588        ReceiverEvent::decode(self.client.wait_for_event::<ReceiverMarker>(deadline)?)
4589    }
4590
4591    /// Adds a new bt-host. If `request` cannot be handled, it should be closed.
4592    pub fn r#add_host(
4593        &self,
4594        mut request: fidl::endpoints::ClientEnd<HostMarker>,
4595    ) -> Result<(), fidl::Error> {
4596        self.client.send::<ReceiverAddHostRequest>(
4597            (request,),
4598            0x2089233075765e8c,
4599            fidl::encoding::DynamicFlags::FLEXIBLE,
4600        )
4601    }
4602}
4603
4604#[cfg(target_os = "fuchsia")]
4605impl From<ReceiverSynchronousProxy> for zx::NullableHandle {
4606    fn from(value: ReceiverSynchronousProxy) -> Self {
4607        value.into_channel().into()
4608    }
4609}
4610
4611#[cfg(target_os = "fuchsia")]
4612impl From<fidl::Channel> for ReceiverSynchronousProxy {
4613    fn from(value: fidl::Channel) -> Self {
4614        Self::new(value)
4615    }
4616}
4617
4618#[cfg(target_os = "fuchsia")]
4619impl fidl::endpoints::FromClient for ReceiverSynchronousProxy {
4620    type Protocol = ReceiverMarker;
4621
4622    fn from_client(value: fidl::endpoints::ClientEnd<ReceiverMarker>) -> Self {
4623        Self::new(value.into_channel())
4624    }
4625}
4626
4627#[derive(Debug, Clone)]
4628pub struct ReceiverProxy {
4629    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4630}
4631
4632impl fidl::endpoints::Proxy for ReceiverProxy {
4633    type Protocol = ReceiverMarker;
4634
4635    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4636        Self::new(inner)
4637    }
4638
4639    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4640        self.client.into_channel().map_err(|client| Self { client })
4641    }
4642
4643    fn as_channel(&self) -> &::fidl::AsyncChannel {
4644        self.client.as_channel()
4645    }
4646}
4647
4648impl ReceiverProxy {
4649    /// Create a new Proxy for fuchsia.bluetooth.host/Receiver.
4650    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4651        let protocol_name = <ReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4652        Self { client: fidl::client::Client::new(channel, protocol_name) }
4653    }
4654
4655    /// Get a Stream of events from the remote end of the protocol.
4656    ///
4657    /// # Panics
4658    ///
4659    /// Panics if the event stream was already taken.
4660    pub fn take_event_stream(&self) -> ReceiverEventStream {
4661        ReceiverEventStream { event_receiver: self.client.take_event_receiver() }
4662    }
4663
4664    /// Adds a new bt-host. If `request` cannot be handled, it should be closed.
4665    pub fn r#add_host(
4666        &self,
4667        mut request: fidl::endpoints::ClientEnd<HostMarker>,
4668    ) -> Result<(), fidl::Error> {
4669        ReceiverProxyInterface::r#add_host(self, request)
4670    }
4671}
4672
4673impl ReceiverProxyInterface for ReceiverProxy {
4674    fn r#add_host(
4675        &self,
4676        mut request: fidl::endpoints::ClientEnd<HostMarker>,
4677    ) -> Result<(), fidl::Error> {
4678        self.client.send::<ReceiverAddHostRequest>(
4679            (request,),
4680            0x2089233075765e8c,
4681            fidl::encoding::DynamicFlags::FLEXIBLE,
4682        )
4683    }
4684}
4685
4686pub struct ReceiverEventStream {
4687    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4688}
4689
4690impl std::marker::Unpin for ReceiverEventStream {}
4691
4692impl futures::stream::FusedStream for ReceiverEventStream {
4693    fn is_terminated(&self) -> bool {
4694        self.event_receiver.is_terminated()
4695    }
4696}
4697
4698impl futures::Stream for ReceiverEventStream {
4699    type Item = Result<ReceiverEvent, fidl::Error>;
4700
4701    fn poll_next(
4702        mut self: std::pin::Pin<&mut Self>,
4703        cx: &mut std::task::Context<'_>,
4704    ) -> std::task::Poll<Option<Self::Item>> {
4705        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4706            &mut self.event_receiver,
4707            cx
4708        )?) {
4709            Some(buf) => std::task::Poll::Ready(Some(ReceiverEvent::decode(buf))),
4710            None => std::task::Poll::Ready(None),
4711        }
4712    }
4713}
4714
4715#[derive(Debug)]
4716pub enum ReceiverEvent {
4717    #[non_exhaustive]
4718    _UnknownEvent {
4719        /// Ordinal of the event that was sent.
4720        ordinal: u64,
4721    },
4722}
4723
4724impl ReceiverEvent {
4725    /// Decodes a message buffer as a [`ReceiverEvent`].
4726    fn decode(
4727        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4728    ) -> Result<ReceiverEvent, fidl::Error> {
4729        let (bytes, _handles) = buf.split_mut();
4730        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4731        debug_assert_eq!(tx_header.tx_id, 0);
4732        match tx_header.ordinal {
4733            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4734                Ok(ReceiverEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4735            }
4736            _ => Err(fidl::Error::UnknownOrdinal {
4737                ordinal: tx_header.ordinal,
4738                protocol_name: <ReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4739            }),
4740        }
4741    }
4742}
4743
4744/// A Stream of incoming requests for fuchsia.bluetooth.host/Receiver.
4745pub struct ReceiverRequestStream {
4746    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4747    is_terminated: bool,
4748}
4749
4750impl std::marker::Unpin for ReceiverRequestStream {}
4751
4752impl futures::stream::FusedStream for ReceiverRequestStream {
4753    fn is_terminated(&self) -> bool {
4754        self.is_terminated
4755    }
4756}
4757
4758impl fidl::endpoints::RequestStream for ReceiverRequestStream {
4759    type Protocol = ReceiverMarker;
4760    type ControlHandle = ReceiverControlHandle;
4761
4762    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4763        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4764    }
4765
4766    fn control_handle(&self) -> Self::ControlHandle {
4767        ReceiverControlHandle { inner: self.inner.clone() }
4768    }
4769
4770    fn into_inner(
4771        self,
4772    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4773    {
4774        (self.inner, self.is_terminated)
4775    }
4776
4777    fn from_inner(
4778        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4779        is_terminated: bool,
4780    ) -> Self {
4781        Self { inner, is_terminated }
4782    }
4783}
4784
4785impl futures::Stream for ReceiverRequestStream {
4786    type Item = Result<ReceiverRequest, fidl::Error>;
4787
4788    fn poll_next(
4789        mut self: std::pin::Pin<&mut Self>,
4790        cx: &mut std::task::Context<'_>,
4791    ) -> std::task::Poll<Option<Self::Item>> {
4792        let this = &mut *self;
4793        if this.inner.check_shutdown(cx) {
4794            this.is_terminated = true;
4795            return std::task::Poll::Ready(None);
4796        }
4797        if this.is_terminated {
4798            panic!("polled ReceiverRequestStream after completion");
4799        }
4800        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4801            |bytes, handles| {
4802                match this.inner.channel().read_etc(cx, bytes, handles) {
4803                    std::task::Poll::Ready(Ok(())) => {}
4804                    std::task::Poll::Pending => return std::task::Poll::Pending,
4805                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4806                        this.is_terminated = true;
4807                        return std::task::Poll::Ready(None);
4808                    }
4809                    std::task::Poll::Ready(Err(e)) => {
4810                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4811                            e.into(),
4812                        ))));
4813                    }
4814                }
4815
4816                // A message has been received from the channel
4817                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4818
4819                std::task::Poll::Ready(Some(match header.ordinal {
4820                    0x2089233075765e8c => {
4821                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4822                        let mut req = fidl::new_empty!(
4823                            ReceiverAddHostRequest,
4824                            fidl::encoding::DefaultFuchsiaResourceDialect
4825                        );
4826                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ReceiverAddHostRequest>(&header, _body_bytes, handles, &mut req)?;
4827                        let control_handle = ReceiverControlHandle { inner: this.inner.clone() };
4828                        Ok(ReceiverRequest::AddHost { request: req.request, control_handle })
4829                    }
4830                    _ if header.tx_id == 0
4831                        && header
4832                            .dynamic_flags()
4833                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4834                    {
4835                        Ok(ReceiverRequest::_UnknownMethod {
4836                            ordinal: header.ordinal,
4837                            control_handle: ReceiverControlHandle { inner: this.inner.clone() },
4838                            method_type: fidl::MethodType::OneWay,
4839                        })
4840                    }
4841                    _ if header
4842                        .dynamic_flags()
4843                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4844                    {
4845                        this.inner.send_framework_err(
4846                            fidl::encoding::FrameworkErr::UnknownMethod,
4847                            header.tx_id,
4848                            header.ordinal,
4849                            header.dynamic_flags(),
4850                            (bytes, handles),
4851                        )?;
4852                        Ok(ReceiverRequest::_UnknownMethod {
4853                            ordinal: header.ordinal,
4854                            control_handle: ReceiverControlHandle { inner: this.inner.clone() },
4855                            method_type: fidl::MethodType::TwoWay,
4856                        })
4857                    }
4858                    _ => Err(fidl::Error::UnknownOrdinal {
4859                        ordinal: header.ordinal,
4860                        protocol_name:
4861                            <ReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4862                    }),
4863                }))
4864            },
4865        )
4866    }
4867}
4868
4869/// Receives a bt-host by protocol for use in the Bluetooth Host Subsystem
4870#[derive(Debug)]
4871pub enum ReceiverRequest {
4872    /// Adds a new bt-host. If `request` cannot be handled, it should be closed.
4873    AddHost {
4874        request: fidl::endpoints::ClientEnd<HostMarker>,
4875        control_handle: ReceiverControlHandle,
4876    },
4877    /// An interaction was received which does not match any known method.
4878    #[non_exhaustive]
4879    _UnknownMethod {
4880        /// Ordinal of the method that was called.
4881        ordinal: u64,
4882        control_handle: ReceiverControlHandle,
4883        method_type: fidl::MethodType,
4884    },
4885}
4886
4887impl ReceiverRequest {
4888    #[allow(irrefutable_let_patterns)]
4889    pub fn into_add_host(
4890        self,
4891    ) -> Option<(fidl::endpoints::ClientEnd<HostMarker>, ReceiverControlHandle)> {
4892        if let ReceiverRequest::AddHost { request, control_handle } = self {
4893            Some((request, control_handle))
4894        } else {
4895            None
4896        }
4897    }
4898
4899    /// Name of the method defined in FIDL
4900    pub fn method_name(&self) -> &'static str {
4901        match *self {
4902            ReceiverRequest::AddHost { .. } => "add_host",
4903            ReceiverRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
4904                "unknown one-way method"
4905            }
4906            ReceiverRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
4907                "unknown two-way method"
4908            }
4909        }
4910    }
4911}
4912
4913#[derive(Debug, Clone)]
4914pub struct ReceiverControlHandle {
4915    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4916}
4917
4918impl fidl::endpoints::ControlHandle for ReceiverControlHandle {
4919    fn shutdown(&self) {
4920        self.inner.shutdown()
4921    }
4922
4923    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4924        self.inner.shutdown_with_epitaph(status)
4925    }
4926
4927    fn is_closed(&self) -> bool {
4928        self.inner.channel().is_closed()
4929    }
4930    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4931        self.inner.channel().on_closed()
4932    }
4933
4934    #[cfg(target_os = "fuchsia")]
4935    fn signal_peer(
4936        &self,
4937        clear_mask: zx::Signals,
4938        set_mask: zx::Signals,
4939    ) -> Result<(), zx_status::Status> {
4940        use fidl::Peered;
4941        self.inner.channel().signal_peer(clear_mask, set_mask)
4942    }
4943}
4944
4945impl ReceiverControlHandle {}
4946
4947mod internal {
4948    use super::*;
4949
4950    impl fidl::encoding::ResourceTypeMarker for HostSetBondingDelegateRequest {
4951        type Borrowed<'a> = &'a mut Self;
4952        fn take_or_borrow<'a>(
4953            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4954        ) -> Self::Borrowed<'a> {
4955            value
4956        }
4957    }
4958
4959    unsafe impl fidl::encoding::TypeMarker for HostSetBondingDelegateRequest {
4960        type Owned = Self;
4961
4962        #[inline(always)]
4963        fn inline_align(_context: fidl::encoding::Context) -> usize {
4964            4
4965        }
4966
4967        #[inline(always)]
4968        fn inline_size(_context: fidl::encoding::Context) -> usize {
4969            4
4970        }
4971    }
4972
4973    unsafe impl
4974        fidl::encoding::Encode<
4975            HostSetBondingDelegateRequest,
4976            fidl::encoding::DefaultFuchsiaResourceDialect,
4977        > for &mut HostSetBondingDelegateRequest
4978    {
4979        #[inline]
4980        unsafe fn encode(
4981            self,
4982            encoder: &mut fidl::encoding::Encoder<
4983                '_,
4984                fidl::encoding::DefaultFuchsiaResourceDialect,
4985            >,
4986            offset: usize,
4987            _depth: fidl::encoding::Depth,
4988        ) -> fidl::Result<()> {
4989            encoder.debug_check_bounds::<HostSetBondingDelegateRequest>(offset);
4990            // Delegate to tuple encoding.
4991            fidl::encoding::Encode::<HostSetBondingDelegateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4992                (
4993                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BondingDelegateMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.delegate),
4994                ),
4995                encoder, offset, _depth
4996            )
4997        }
4998    }
4999    unsafe impl<
5000        T0: fidl::encoding::Encode<
5001                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BondingDelegateMarker>>,
5002                fidl::encoding::DefaultFuchsiaResourceDialect,
5003            >,
5004    >
5005        fidl::encoding::Encode<
5006            HostSetBondingDelegateRequest,
5007            fidl::encoding::DefaultFuchsiaResourceDialect,
5008        > for (T0,)
5009    {
5010        #[inline]
5011        unsafe fn encode(
5012            self,
5013            encoder: &mut fidl::encoding::Encoder<
5014                '_,
5015                fidl::encoding::DefaultFuchsiaResourceDialect,
5016            >,
5017            offset: usize,
5018            depth: fidl::encoding::Depth,
5019        ) -> fidl::Result<()> {
5020            encoder.debug_check_bounds::<HostSetBondingDelegateRequest>(offset);
5021            // Zero out padding regions. There's no need to apply masks
5022            // because the unmasked parts will be overwritten by fields.
5023            // Write the fields.
5024            self.0.encode(encoder, offset + 0, depth)?;
5025            Ok(())
5026        }
5027    }
5028
5029    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5030        for HostSetBondingDelegateRequest
5031    {
5032        #[inline(always)]
5033        fn new_empty() -> Self {
5034            Self {
5035                delegate: fidl::new_empty!(
5036                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BondingDelegateMarker>>,
5037                    fidl::encoding::DefaultFuchsiaResourceDialect
5038                ),
5039            }
5040        }
5041
5042        #[inline]
5043        unsafe fn decode(
5044            &mut self,
5045            decoder: &mut fidl::encoding::Decoder<
5046                '_,
5047                fidl::encoding::DefaultFuchsiaResourceDialect,
5048            >,
5049            offset: usize,
5050            _depth: fidl::encoding::Depth,
5051        ) -> fidl::Result<()> {
5052            decoder.debug_check_bounds::<Self>(offset);
5053            // Verify that padding bytes are zero.
5054            fidl::decode!(
5055                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BondingDelegateMarker>>,
5056                fidl::encoding::DefaultFuchsiaResourceDialect,
5057                &mut self.delegate,
5058                decoder,
5059                offset + 0,
5060                _depth
5061            )?;
5062            Ok(())
5063        }
5064    }
5065
5066    impl fidl::encoding::ResourceTypeMarker for HostSetPairingDelegateRequest {
5067        type Borrowed<'a> = &'a mut Self;
5068        fn take_or_borrow<'a>(
5069            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5070        ) -> Self::Borrowed<'a> {
5071            value
5072        }
5073    }
5074
5075    unsafe impl fidl::encoding::TypeMarker for HostSetPairingDelegateRequest {
5076        type Owned = Self;
5077
5078        #[inline(always)]
5079        fn inline_align(_context: fidl::encoding::Context) -> usize {
5080            4
5081        }
5082
5083        #[inline(always)]
5084        fn inline_size(_context: fidl::encoding::Context) -> usize {
5085            12
5086        }
5087    }
5088
5089    unsafe impl
5090        fidl::encoding::Encode<
5091            HostSetPairingDelegateRequest,
5092            fidl::encoding::DefaultFuchsiaResourceDialect,
5093        > for &mut HostSetPairingDelegateRequest
5094    {
5095        #[inline]
5096        unsafe fn encode(
5097            self,
5098            encoder: &mut fidl::encoding::Encoder<
5099                '_,
5100                fidl::encoding::DefaultFuchsiaResourceDialect,
5101            >,
5102            offset: usize,
5103            _depth: fidl::encoding::Depth,
5104        ) -> fidl::Result<()> {
5105            encoder.debug_check_bounds::<HostSetPairingDelegateRequest>(offset);
5106            // Delegate to tuple encoding.
5107            fidl::encoding::Encode::<HostSetPairingDelegateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5108                (
5109                    <fidl_fuchsia_bluetooth_sys::InputCapability as fidl::encoding::ValueTypeMarker>::borrow(&self.input),
5110                    <fidl_fuchsia_bluetooth_sys::OutputCapability as fidl::encoding::ValueTypeMarker>::borrow(&self.output),
5111                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth_sys::PairingDelegateMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.delegate),
5112                ),
5113                encoder, offset, _depth
5114            )
5115        }
5116    }
5117    unsafe impl<
5118        T0: fidl::encoding::Encode<
5119                fidl_fuchsia_bluetooth_sys::InputCapability,
5120                fidl::encoding::DefaultFuchsiaResourceDialect,
5121            >,
5122        T1: fidl::encoding::Encode<
5123                fidl_fuchsia_bluetooth_sys::OutputCapability,
5124                fidl::encoding::DefaultFuchsiaResourceDialect,
5125            >,
5126        T2: fidl::encoding::Encode<
5127                fidl::encoding::Endpoint<
5128                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth_sys::PairingDelegateMarker>,
5129                >,
5130                fidl::encoding::DefaultFuchsiaResourceDialect,
5131            >,
5132    >
5133        fidl::encoding::Encode<
5134            HostSetPairingDelegateRequest,
5135            fidl::encoding::DefaultFuchsiaResourceDialect,
5136        > for (T0, T1, T2)
5137    {
5138        #[inline]
5139        unsafe fn encode(
5140            self,
5141            encoder: &mut fidl::encoding::Encoder<
5142                '_,
5143                fidl::encoding::DefaultFuchsiaResourceDialect,
5144            >,
5145            offset: usize,
5146            depth: fidl::encoding::Depth,
5147        ) -> fidl::Result<()> {
5148            encoder.debug_check_bounds::<HostSetPairingDelegateRequest>(offset);
5149            // Zero out padding regions. There's no need to apply masks
5150            // because the unmasked parts will be overwritten by fields.
5151            // Write the fields.
5152            self.0.encode(encoder, offset + 0, depth)?;
5153            self.1.encode(encoder, offset + 4, depth)?;
5154            self.2.encode(encoder, offset + 8, depth)?;
5155            Ok(())
5156        }
5157    }
5158
5159    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5160        for HostSetPairingDelegateRequest
5161    {
5162        #[inline(always)]
5163        fn new_empty() -> Self {
5164            Self {
5165                input: fidl::new_empty!(
5166                    fidl_fuchsia_bluetooth_sys::InputCapability,
5167                    fidl::encoding::DefaultFuchsiaResourceDialect
5168                ),
5169                output: fidl::new_empty!(
5170                    fidl_fuchsia_bluetooth_sys::OutputCapability,
5171                    fidl::encoding::DefaultFuchsiaResourceDialect
5172                ),
5173                delegate: fidl::new_empty!(
5174                    fidl::encoding::Endpoint<
5175                        fidl::endpoints::ClientEnd<
5176                            fidl_fuchsia_bluetooth_sys::PairingDelegateMarker,
5177                        >,
5178                    >,
5179                    fidl::encoding::DefaultFuchsiaResourceDialect
5180                ),
5181            }
5182        }
5183
5184        #[inline]
5185        unsafe fn decode(
5186            &mut self,
5187            decoder: &mut fidl::encoding::Decoder<
5188                '_,
5189                fidl::encoding::DefaultFuchsiaResourceDialect,
5190            >,
5191            offset: usize,
5192            _depth: fidl::encoding::Depth,
5193        ) -> fidl::Result<()> {
5194            decoder.debug_check_bounds::<Self>(offset);
5195            // Verify that padding bytes are zero.
5196            fidl::decode!(
5197                fidl_fuchsia_bluetooth_sys::InputCapability,
5198                fidl::encoding::DefaultFuchsiaResourceDialect,
5199                &mut self.input,
5200                decoder,
5201                offset + 0,
5202                _depth
5203            )?;
5204            fidl::decode!(
5205                fidl_fuchsia_bluetooth_sys::OutputCapability,
5206                fidl::encoding::DefaultFuchsiaResourceDialect,
5207                &mut self.output,
5208                decoder,
5209                offset + 4,
5210                _depth
5211            )?;
5212            fidl::decode!(
5213                fidl::encoding::Endpoint<
5214                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth_sys::PairingDelegateMarker>,
5215                >,
5216                fidl::encoding::DefaultFuchsiaResourceDialect,
5217                &mut self.delegate,
5218                decoder,
5219                offset + 8,
5220                _depth
5221            )?;
5222            Ok(())
5223        }
5224    }
5225
5226    impl fidl::encoding::ResourceTypeMarker for HostSetPeerWatcherRequest {
5227        type Borrowed<'a> = &'a mut Self;
5228        fn take_or_borrow<'a>(
5229            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5230        ) -> Self::Borrowed<'a> {
5231            value
5232        }
5233    }
5234
5235    unsafe impl fidl::encoding::TypeMarker for HostSetPeerWatcherRequest {
5236        type Owned = Self;
5237
5238        #[inline(always)]
5239        fn inline_align(_context: fidl::encoding::Context) -> usize {
5240            4
5241        }
5242
5243        #[inline(always)]
5244        fn inline_size(_context: fidl::encoding::Context) -> usize {
5245            4
5246        }
5247    }
5248
5249    unsafe impl
5250        fidl::encoding::Encode<
5251            HostSetPeerWatcherRequest,
5252            fidl::encoding::DefaultFuchsiaResourceDialect,
5253        > for &mut HostSetPeerWatcherRequest
5254    {
5255        #[inline]
5256        unsafe fn encode(
5257            self,
5258            encoder: &mut fidl::encoding::Encoder<
5259                '_,
5260                fidl::encoding::DefaultFuchsiaResourceDialect,
5261            >,
5262            offset: usize,
5263            _depth: fidl::encoding::Depth,
5264        ) -> fidl::Result<()> {
5265            encoder.debug_check_bounds::<HostSetPeerWatcherRequest>(offset);
5266            // Delegate to tuple encoding.
5267            fidl::encoding::Encode::<HostSetPeerWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5268                (
5269                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.peer_watcher),
5270                ),
5271                encoder, offset, _depth
5272            )
5273        }
5274    }
5275    unsafe impl<
5276        T0: fidl::encoding::Encode<
5277                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerWatcherMarker>>,
5278                fidl::encoding::DefaultFuchsiaResourceDialect,
5279            >,
5280    >
5281        fidl::encoding::Encode<
5282            HostSetPeerWatcherRequest,
5283            fidl::encoding::DefaultFuchsiaResourceDialect,
5284        > for (T0,)
5285    {
5286        #[inline]
5287        unsafe fn encode(
5288            self,
5289            encoder: &mut fidl::encoding::Encoder<
5290                '_,
5291                fidl::encoding::DefaultFuchsiaResourceDialect,
5292            >,
5293            offset: usize,
5294            depth: fidl::encoding::Depth,
5295        ) -> fidl::Result<()> {
5296            encoder.debug_check_bounds::<HostSetPeerWatcherRequest>(offset);
5297            // Zero out padding regions. There's no need to apply masks
5298            // because the unmasked parts will be overwritten by fields.
5299            // Write the fields.
5300            self.0.encode(encoder, offset + 0, depth)?;
5301            Ok(())
5302        }
5303    }
5304
5305    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5306        for HostSetPeerWatcherRequest
5307    {
5308        #[inline(always)]
5309        fn new_empty() -> Self {
5310            Self {
5311                peer_watcher: fidl::new_empty!(
5312                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerWatcherMarker>>,
5313                    fidl::encoding::DefaultFuchsiaResourceDialect
5314                ),
5315            }
5316        }
5317
5318        #[inline]
5319        unsafe fn decode(
5320            &mut self,
5321            decoder: &mut fidl::encoding::Decoder<
5322                '_,
5323                fidl::encoding::DefaultFuchsiaResourceDialect,
5324            >,
5325            offset: usize,
5326            _depth: fidl::encoding::Depth,
5327        ) -> fidl::Result<()> {
5328            decoder.debug_check_bounds::<Self>(offset);
5329            // Verify that padding bytes are zero.
5330            fidl::decode!(
5331                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerWatcherMarker>>,
5332                fidl::encoding::DefaultFuchsiaResourceDialect,
5333                &mut self.peer_watcher,
5334                decoder,
5335                offset + 0,
5336                _depth
5337            )?;
5338            Ok(())
5339        }
5340    }
5341
5342    impl fidl::encoding::ResourceTypeMarker for ReceiverAddHostRequest {
5343        type Borrowed<'a> = &'a mut Self;
5344        fn take_or_borrow<'a>(
5345            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5346        ) -> Self::Borrowed<'a> {
5347            value
5348        }
5349    }
5350
5351    unsafe impl fidl::encoding::TypeMarker for ReceiverAddHostRequest {
5352        type Owned = Self;
5353
5354        #[inline(always)]
5355        fn inline_align(_context: fidl::encoding::Context) -> usize {
5356            4
5357        }
5358
5359        #[inline(always)]
5360        fn inline_size(_context: fidl::encoding::Context) -> usize {
5361            4
5362        }
5363    }
5364
5365    unsafe impl
5366        fidl::encoding::Encode<
5367            ReceiverAddHostRequest,
5368            fidl::encoding::DefaultFuchsiaResourceDialect,
5369        > for &mut ReceiverAddHostRequest
5370    {
5371        #[inline]
5372        unsafe fn encode(
5373            self,
5374            encoder: &mut fidl::encoding::Encoder<
5375                '_,
5376                fidl::encoding::DefaultFuchsiaResourceDialect,
5377            >,
5378            offset: usize,
5379            _depth: fidl::encoding::Depth,
5380        ) -> fidl::Result<()> {
5381            encoder.debug_check_bounds::<ReceiverAddHostRequest>(offset);
5382            // Delegate to tuple encoding.
5383            fidl::encoding::Encode::<ReceiverAddHostRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5384                (
5385                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.request),
5386                ),
5387                encoder, offset, _depth
5388            )
5389        }
5390    }
5391    unsafe impl<
5392        T0: fidl::encoding::Encode<
5393                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostMarker>>,
5394                fidl::encoding::DefaultFuchsiaResourceDialect,
5395            >,
5396    >
5397        fidl::encoding::Encode<
5398            ReceiverAddHostRequest,
5399            fidl::encoding::DefaultFuchsiaResourceDialect,
5400        > for (T0,)
5401    {
5402        #[inline]
5403        unsafe fn encode(
5404            self,
5405            encoder: &mut fidl::encoding::Encoder<
5406                '_,
5407                fidl::encoding::DefaultFuchsiaResourceDialect,
5408            >,
5409            offset: usize,
5410            depth: fidl::encoding::Depth,
5411        ) -> fidl::Result<()> {
5412            encoder.debug_check_bounds::<ReceiverAddHostRequest>(offset);
5413            // Zero out padding regions. There's no need to apply masks
5414            // because the unmasked parts will be overwritten by fields.
5415            // Write the fields.
5416            self.0.encode(encoder, offset + 0, depth)?;
5417            Ok(())
5418        }
5419    }
5420
5421    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5422        for ReceiverAddHostRequest
5423    {
5424        #[inline(always)]
5425        fn new_empty() -> Self {
5426            Self {
5427                request: fidl::new_empty!(
5428                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostMarker>>,
5429                    fidl::encoding::DefaultFuchsiaResourceDialect
5430                ),
5431            }
5432        }
5433
5434        #[inline]
5435        unsafe fn decode(
5436            &mut self,
5437            decoder: &mut fidl::encoding::Decoder<
5438                '_,
5439                fidl::encoding::DefaultFuchsiaResourceDialect,
5440            >,
5441            offset: usize,
5442            _depth: fidl::encoding::Depth,
5443        ) -> fidl::Result<()> {
5444            decoder.debug_check_bounds::<Self>(offset);
5445            // Verify that padding bytes are zero.
5446            fidl::decode!(
5447                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostMarker>>,
5448                fidl::encoding::DefaultFuchsiaResourceDialect,
5449                &mut self.request,
5450                decoder,
5451                offset + 0,
5452                _depth
5453            )?;
5454            Ok(())
5455        }
5456    }
5457
5458    impl HostStartDiscoveryRequest {
5459        #[inline(always)]
5460        fn max_ordinal_present(&self) -> u64 {
5461            if let Some(_) = self.token {
5462                return 1;
5463            }
5464            0
5465        }
5466    }
5467
5468    impl fidl::encoding::ResourceTypeMarker for HostStartDiscoveryRequest {
5469        type Borrowed<'a> = &'a mut Self;
5470        fn take_or_borrow<'a>(
5471            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5472        ) -> Self::Borrowed<'a> {
5473            value
5474        }
5475    }
5476
5477    unsafe impl fidl::encoding::TypeMarker for HostStartDiscoveryRequest {
5478        type Owned = Self;
5479
5480        #[inline(always)]
5481        fn inline_align(_context: fidl::encoding::Context) -> usize {
5482            8
5483        }
5484
5485        #[inline(always)]
5486        fn inline_size(_context: fidl::encoding::Context) -> usize {
5487            16
5488        }
5489    }
5490
5491    unsafe impl
5492        fidl::encoding::Encode<
5493            HostStartDiscoveryRequest,
5494            fidl::encoding::DefaultFuchsiaResourceDialect,
5495        > for &mut HostStartDiscoveryRequest
5496    {
5497        unsafe fn encode(
5498            self,
5499            encoder: &mut fidl::encoding::Encoder<
5500                '_,
5501                fidl::encoding::DefaultFuchsiaResourceDialect,
5502            >,
5503            offset: usize,
5504            mut depth: fidl::encoding::Depth,
5505        ) -> fidl::Result<()> {
5506            encoder.debug_check_bounds::<HostStartDiscoveryRequest>(offset);
5507            // Vector header
5508            let max_ordinal: u64 = self.max_ordinal_present();
5509            encoder.write_num(max_ordinal, offset);
5510            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5511            // Calling encoder.out_of_line_offset(0) is not allowed.
5512            if max_ordinal == 0 {
5513                return Ok(());
5514            }
5515            depth.increment()?;
5516            let envelope_size = 8;
5517            let bytes_len = max_ordinal as usize * envelope_size;
5518            #[allow(unused_variables)]
5519            let offset = encoder.out_of_line_offset(bytes_len);
5520            let mut _prev_end_offset: usize = 0;
5521            if 1 > max_ordinal {
5522                return Ok(());
5523            }
5524
5525            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5526            // are envelope_size bytes.
5527            let cur_offset: usize = (1 - 1) * envelope_size;
5528
5529            // Zero reserved fields.
5530            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5531
5532            // Safety:
5533            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5534            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5535            //   envelope_size bytes, there is always sufficient room.
5536            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiscoverySessionMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5537            self.token.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiscoverySessionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
5538            encoder, offset + cur_offset, depth
5539        )?;
5540
5541            _prev_end_offset = cur_offset + envelope_size;
5542
5543            Ok(())
5544        }
5545    }
5546
5547    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5548        for HostStartDiscoveryRequest
5549    {
5550        #[inline(always)]
5551        fn new_empty() -> Self {
5552            Self::default()
5553        }
5554
5555        unsafe fn decode(
5556            &mut self,
5557            decoder: &mut fidl::encoding::Decoder<
5558                '_,
5559                fidl::encoding::DefaultFuchsiaResourceDialect,
5560            >,
5561            offset: usize,
5562            mut depth: fidl::encoding::Depth,
5563        ) -> fidl::Result<()> {
5564            decoder.debug_check_bounds::<Self>(offset);
5565            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5566                None => return Err(fidl::Error::NotNullable),
5567                Some(len) => len,
5568            };
5569            // Calling decoder.out_of_line_offset(0) is not allowed.
5570            if len == 0 {
5571                return Ok(());
5572            };
5573            depth.increment()?;
5574            let envelope_size = 8;
5575            let bytes_len = len * envelope_size;
5576            let offset = decoder.out_of_line_offset(bytes_len)?;
5577            // Decode the envelope for each type.
5578            let mut _next_ordinal_to_read = 0;
5579            let mut next_offset = offset;
5580            let end_offset = offset + bytes_len;
5581            _next_ordinal_to_read += 1;
5582            if next_offset >= end_offset {
5583                return Ok(());
5584            }
5585
5586            // Decode unknown envelopes for gaps in ordinals.
5587            while _next_ordinal_to_read < 1 {
5588                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5589                _next_ordinal_to_read += 1;
5590                next_offset += envelope_size;
5591            }
5592
5593            let next_out_of_line = decoder.next_out_of_line();
5594            let handles_before = decoder.remaining_handles();
5595            if let Some((inlined, num_bytes, num_handles)) =
5596                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5597            {
5598                let member_inline_size = <fidl::encoding::Endpoint<
5599                    fidl::endpoints::ServerEnd<DiscoverySessionMarker>,
5600                > as fidl::encoding::TypeMarker>::inline_size(
5601                    decoder.context
5602                );
5603                if inlined != (member_inline_size <= 4) {
5604                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5605                }
5606                let inner_offset;
5607                let mut inner_depth = depth.clone();
5608                if inlined {
5609                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5610                    inner_offset = next_offset;
5611                } else {
5612                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5613                    inner_depth.increment()?;
5614                }
5615                let val_ref = self.token.get_or_insert_with(|| {
5616                    fidl::new_empty!(
5617                        fidl::encoding::Endpoint<
5618                            fidl::endpoints::ServerEnd<DiscoverySessionMarker>,
5619                        >,
5620                        fidl::encoding::DefaultFuchsiaResourceDialect
5621                    )
5622                });
5623                fidl::decode!(
5624                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiscoverySessionMarker>>,
5625                    fidl::encoding::DefaultFuchsiaResourceDialect,
5626                    val_ref,
5627                    decoder,
5628                    inner_offset,
5629                    inner_depth
5630                )?;
5631                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5632                {
5633                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5634                }
5635                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5636                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5637                }
5638            }
5639
5640            next_offset += envelope_size;
5641
5642            // Decode the remaining unknown envelopes.
5643            while next_offset < end_offset {
5644                _next_ordinal_to_read += 1;
5645                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5646                next_offset += envelope_size;
5647            }
5648
5649            Ok(())
5650        }
5651    }
5652
5653    impl fidl::encoding::ResourceTypeMarker for ProtocolRequest {
5654        type Borrowed<'a> = &'a mut Self;
5655        fn take_or_borrow<'a>(
5656            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5657        ) -> Self::Borrowed<'a> {
5658            value
5659        }
5660    }
5661
5662    unsafe impl fidl::encoding::TypeMarker for ProtocolRequest {
5663        type Owned = Self;
5664
5665        #[inline(always)]
5666        fn inline_align(_context: fidl::encoding::Context) -> usize {
5667            8
5668        }
5669
5670        #[inline(always)]
5671        fn inline_size(_context: fidl::encoding::Context) -> usize {
5672            16
5673        }
5674    }
5675
5676    unsafe impl
5677        fidl::encoding::Encode<ProtocolRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
5678        for &mut ProtocolRequest
5679    {
5680        #[inline]
5681        unsafe fn encode(
5682            self,
5683            encoder: &mut fidl::encoding::Encoder<
5684                '_,
5685                fidl::encoding::DefaultFuchsiaResourceDialect,
5686            >,
5687            offset: usize,
5688            _depth: fidl::encoding::Depth,
5689        ) -> fidl::Result<()> {
5690            encoder.debug_check_bounds::<ProtocolRequest>(offset);
5691            encoder.write_num::<u64>(self.ordinal(), offset);
5692            match self {
5693                ProtocolRequest::Central(ref mut val) => fidl::encoding::encode_in_envelope::<
5694                    fidl::encoding::Endpoint<
5695                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_le::CentralMarker>,
5696                    >,
5697                    fidl::encoding::DefaultFuchsiaResourceDialect,
5698                >(
5699                    <fidl::encoding::Endpoint<
5700                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_le::CentralMarker>,
5701                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5702                        val
5703                    ),
5704                    encoder,
5705                    offset + 8,
5706                    _depth,
5707                ),
5708                ProtocolRequest::Peripheral(ref mut val) => fidl::encoding::encode_in_envelope::<
5709                    fidl::encoding::Endpoint<
5710                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_le::PeripheralMarker>,
5711                    >,
5712                    fidl::encoding::DefaultFuchsiaResourceDialect,
5713                >(
5714                    <fidl::encoding::Endpoint<
5715                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_le::PeripheralMarker>,
5716                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5717                        val
5718                    ),
5719                    encoder,
5720                    offset + 8,
5721                    _depth,
5722                ),
5723                ProtocolRequest::GattServer(ref mut val) => fidl::encoding::encode_in_envelope::<
5724                    fidl::encoding::Endpoint<
5725                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::Server_Marker>,
5726                    >,
5727                    fidl::encoding::DefaultFuchsiaResourceDialect,
5728                >(
5729                    <fidl::encoding::Endpoint<
5730                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::Server_Marker>,
5731                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5732                        val
5733                    ),
5734                    encoder,
5735                    offset + 8,
5736                    _depth,
5737                ),
5738                ProtocolRequest::Gatt2Server(ref mut val) => fidl::encoding::encode_in_envelope::<
5739                    fidl::encoding::Endpoint<
5740                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::Server_Marker>,
5741                    >,
5742                    fidl::encoding::DefaultFuchsiaResourceDialect,
5743                >(
5744                    <fidl::encoding::Endpoint<
5745                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::Server_Marker>,
5746                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5747                        val
5748                    ),
5749                    encoder,
5750                    offset + 8,
5751                    _depth,
5752                ),
5753                ProtocolRequest::Profile(ref mut val) => fidl::encoding::encode_in_envelope::<
5754                    fidl::encoding::Endpoint<
5755                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
5756                    >,
5757                    fidl::encoding::DefaultFuchsiaResourceDialect,
5758                >(
5759                    <fidl::encoding::Endpoint<
5760                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
5761                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5762                        val
5763                    ),
5764                    encoder,
5765                    offset + 8,
5766                    _depth,
5767                ),
5768                ProtocolRequest::PrivilegedPeripheral(ref mut val) => {
5769                    fidl::encoding::encode_in_envelope::<
5770                        fidl::encoding::Endpoint<
5771                            fidl::endpoints::ServerEnd<
5772                                fidl_fuchsia_bluetooth_le::PrivilegedPeripheralMarker,
5773                            >,
5774                        >,
5775                        fidl::encoding::DefaultFuchsiaResourceDialect,
5776                    >(
5777                        <fidl::encoding::Endpoint<
5778                            fidl::endpoints::ServerEnd<
5779                                fidl_fuchsia_bluetooth_le::PrivilegedPeripheralMarker,
5780                            >,
5781                        > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5782                            val
5783                        ),
5784                        encoder,
5785                        offset + 8,
5786                        _depth,
5787                    )
5788                }
5789                ProtocolRequest::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
5790            }
5791        }
5792    }
5793
5794    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5795        for ProtocolRequest
5796    {
5797        #[inline(always)]
5798        fn new_empty() -> Self {
5799            Self::__SourceBreaking { unknown_ordinal: 0 }
5800        }
5801
5802        #[inline]
5803        unsafe fn decode(
5804            &mut self,
5805            decoder: &mut fidl::encoding::Decoder<
5806                '_,
5807                fidl::encoding::DefaultFuchsiaResourceDialect,
5808            >,
5809            offset: usize,
5810            mut depth: fidl::encoding::Depth,
5811        ) -> fidl::Result<()> {
5812            decoder.debug_check_bounds::<Self>(offset);
5813            #[allow(unused_variables)]
5814            let next_out_of_line = decoder.next_out_of_line();
5815            let handles_before = decoder.remaining_handles();
5816            let (ordinal, inlined, num_bytes, num_handles) =
5817                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
5818
5819            let member_inline_size = match ordinal {
5820                1 => <fidl::encoding::Endpoint<
5821                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_le::CentralMarker>,
5822                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5823                2 => <fidl::encoding::Endpoint<
5824                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_le::PeripheralMarker>,
5825                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5826                3 => <fidl::encoding::Endpoint<
5827                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::Server_Marker>,
5828                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5829                4 => <fidl::encoding::Endpoint<
5830                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::Server_Marker>,
5831                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5832                5 => <fidl::encoding::Endpoint<
5833                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
5834                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5835                6 => <fidl::encoding::Endpoint<
5836                    fidl::endpoints::ServerEnd<
5837                        fidl_fuchsia_bluetooth_le::PrivilegedPeripheralMarker,
5838                    >,
5839                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5840                0 => return Err(fidl::Error::UnknownUnionTag),
5841                _ => num_bytes as usize,
5842            };
5843
5844            if inlined != (member_inline_size <= 4) {
5845                return Err(fidl::Error::InvalidInlineBitInEnvelope);
5846            }
5847            let _inner_offset;
5848            if inlined {
5849                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
5850                _inner_offset = offset + 8;
5851            } else {
5852                depth.increment()?;
5853                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5854            }
5855            match ordinal {
5856                1 => {
5857                    #[allow(irrefutable_let_patterns)]
5858                    if let ProtocolRequest::Central(_) = self {
5859                        // Do nothing, read the value into the object
5860                    } else {
5861                        // Initialize `self` to the right variant
5862                        *self = ProtocolRequest::Central(fidl::new_empty!(
5863                            fidl::encoding::Endpoint<
5864                                fidl::endpoints::ServerEnd<
5865                                    fidl_fuchsia_bluetooth_le::CentralMarker,
5866                                >,
5867                            >,
5868                            fidl::encoding::DefaultFuchsiaResourceDialect
5869                        ));
5870                    }
5871                    #[allow(irrefutable_let_patterns)]
5872                    if let ProtocolRequest::Central(ref mut val) = self {
5873                        fidl::decode!(
5874                            fidl::encoding::Endpoint<
5875                                fidl::endpoints::ServerEnd<
5876                                    fidl_fuchsia_bluetooth_le::CentralMarker,
5877                                >,
5878                            >,
5879                            fidl::encoding::DefaultFuchsiaResourceDialect,
5880                            val,
5881                            decoder,
5882                            _inner_offset,
5883                            depth
5884                        )?;
5885                    } else {
5886                        unreachable!()
5887                    }
5888                }
5889                2 => {
5890                    #[allow(irrefutable_let_patterns)]
5891                    if let ProtocolRequest::Peripheral(_) = self {
5892                        // Do nothing, read the value into the object
5893                    } else {
5894                        // Initialize `self` to the right variant
5895                        *self = ProtocolRequest::Peripheral(fidl::new_empty!(
5896                            fidl::encoding::Endpoint<
5897                                fidl::endpoints::ServerEnd<
5898                                    fidl_fuchsia_bluetooth_le::PeripheralMarker,
5899                                >,
5900                            >,
5901                            fidl::encoding::DefaultFuchsiaResourceDialect
5902                        ));
5903                    }
5904                    #[allow(irrefutable_let_patterns)]
5905                    if let ProtocolRequest::Peripheral(ref mut val) = self {
5906                        fidl::decode!(
5907                            fidl::encoding::Endpoint<
5908                                fidl::endpoints::ServerEnd<
5909                                    fidl_fuchsia_bluetooth_le::PeripheralMarker,
5910                                >,
5911                            >,
5912                            fidl::encoding::DefaultFuchsiaResourceDialect,
5913                            val,
5914                            decoder,
5915                            _inner_offset,
5916                            depth
5917                        )?;
5918                    } else {
5919                        unreachable!()
5920                    }
5921                }
5922                3 => {
5923                    #[allow(irrefutable_let_patterns)]
5924                    if let ProtocolRequest::GattServer(_) = self {
5925                        // Do nothing, read the value into the object
5926                    } else {
5927                        // Initialize `self` to the right variant
5928                        *self = ProtocolRequest::GattServer(fidl::new_empty!(
5929                            fidl::encoding::Endpoint<
5930                                fidl::endpoints::ServerEnd<
5931                                    fidl_fuchsia_bluetooth_gatt::Server_Marker,
5932                                >,
5933                            >,
5934                            fidl::encoding::DefaultFuchsiaResourceDialect
5935                        ));
5936                    }
5937                    #[allow(irrefutable_let_patterns)]
5938                    if let ProtocolRequest::GattServer(ref mut val) = self {
5939                        fidl::decode!(
5940                            fidl::encoding::Endpoint<
5941                                fidl::endpoints::ServerEnd<
5942                                    fidl_fuchsia_bluetooth_gatt::Server_Marker,
5943                                >,
5944                            >,
5945                            fidl::encoding::DefaultFuchsiaResourceDialect,
5946                            val,
5947                            decoder,
5948                            _inner_offset,
5949                            depth
5950                        )?;
5951                    } else {
5952                        unreachable!()
5953                    }
5954                }
5955                4 => {
5956                    #[allow(irrefutable_let_patterns)]
5957                    if let ProtocolRequest::Gatt2Server(_) = self {
5958                        // Do nothing, read the value into the object
5959                    } else {
5960                        // Initialize `self` to the right variant
5961                        *self = ProtocolRequest::Gatt2Server(fidl::new_empty!(
5962                            fidl::encoding::Endpoint<
5963                                fidl::endpoints::ServerEnd<
5964                                    fidl_fuchsia_bluetooth_gatt2::Server_Marker,
5965                                >,
5966                            >,
5967                            fidl::encoding::DefaultFuchsiaResourceDialect
5968                        ));
5969                    }
5970                    #[allow(irrefutable_let_patterns)]
5971                    if let ProtocolRequest::Gatt2Server(ref mut val) = self {
5972                        fidl::decode!(
5973                            fidl::encoding::Endpoint<
5974                                fidl::endpoints::ServerEnd<
5975                                    fidl_fuchsia_bluetooth_gatt2::Server_Marker,
5976                                >,
5977                            >,
5978                            fidl::encoding::DefaultFuchsiaResourceDialect,
5979                            val,
5980                            decoder,
5981                            _inner_offset,
5982                            depth
5983                        )?;
5984                    } else {
5985                        unreachable!()
5986                    }
5987                }
5988                5 => {
5989                    #[allow(irrefutable_let_patterns)]
5990                    if let ProtocolRequest::Profile(_) = self {
5991                        // Do nothing, read the value into the object
5992                    } else {
5993                        // Initialize `self` to the right variant
5994                        *self = ProtocolRequest::Profile(fidl::new_empty!(
5995                            fidl::encoding::Endpoint<
5996                                fidl::endpoints::ServerEnd<
5997                                    fidl_fuchsia_bluetooth_bredr::ProfileMarker,
5998                                >,
5999                            >,
6000                            fidl::encoding::DefaultFuchsiaResourceDialect
6001                        ));
6002                    }
6003                    #[allow(irrefutable_let_patterns)]
6004                    if let ProtocolRequest::Profile(ref mut val) = self {
6005                        fidl::decode!(
6006                            fidl::encoding::Endpoint<
6007                                fidl::endpoints::ServerEnd<
6008                                    fidl_fuchsia_bluetooth_bredr::ProfileMarker,
6009                                >,
6010                            >,
6011                            fidl::encoding::DefaultFuchsiaResourceDialect,
6012                            val,
6013                            decoder,
6014                            _inner_offset,
6015                            depth
6016                        )?;
6017                    } else {
6018                        unreachable!()
6019                    }
6020                }
6021                6 => {
6022                    #[allow(irrefutable_let_patterns)]
6023                    if let ProtocolRequest::PrivilegedPeripheral(_) = self {
6024                        // Do nothing, read the value into the object
6025                    } else {
6026                        // Initialize `self` to the right variant
6027                        *self = ProtocolRequest::PrivilegedPeripheral(fidl::new_empty!(
6028                            fidl::encoding::Endpoint<
6029                                fidl::endpoints::ServerEnd<
6030                                    fidl_fuchsia_bluetooth_le::PrivilegedPeripheralMarker,
6031                                >,
6032                            >,
6033                            fidl::encoding::DefaultFuchsiaResourceDialect
6034                        ));
6035                    }
6036                    #[allow(irrefutable_let_patterns)]
6037                    if let ProtocolRequest::PrivilegedPeripheral(ref mut val) = self {
6038                        fidl::decode!(
6039                            fidl::encoding::Endpoint<
6040                                fidl::endpoints::ServerEnd<
6041                                    fidl_fuchsia_bluetooth_le::PrivilegedPeripheralMarker,
6042                                >,
6043                            >,
6044                            fidl::encoding::DefaultFuchsiaResourceDialect,
6045                            val,
6046                            decoder,
6047                            _inner_offset,
6048                            depth
6049                        )?;
6050                    } else {
6051                        unreachable!()
6052                    }
6053                }
6054                #[allow(deprecated)]
6055                ordinal => {
6056                    for _ in 0..num_handles {
6057                        decoder.drop_next_handle()?;
6058                    }
6059                    *self = ProtocolRequest::__SourceBreaking { unknown_ordinal: ordinal };
6060                }
6061            }
6062            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
6063                return Err(fidl::Error::InvalidNumBytesInEnvelope);
6064            }
6065            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6066                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6067            }
6068            Ok(())
6069        }
6070    }
6071}