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