fidl_fuchsia_bluetooth_host/
fidl_fuchsia_bluetooth_host.rs

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