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