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 { Some((responder)) } else { None }
3103    }
3104
3105    #[allow(irrefutable_let_patterns)]
3106    pub fn into_set_local_data(
3107        self,
3108    ) -> Option<(fidl_fuchsia_bluetooth_sys::HostData, HostControlHandle)> {
3109        if let HostRequest::SetLocalData { payload, control_handle } = self {
3110            Some((payload, control_handle))
3111        } else {
3112            None
3113        }
3114    }
3115
3116    #[allow(irrefutable_let_patterns)]
3117    pub fn into_set_peer_watcher(
3118        self,
3119    ) -> Option<(fidl::endpoints::ServerEnd<PeerWatcherMarker>, HostControlHandle)> {
3120        if let HostRequest::SetPeerWatcher { peer_watcher, control_handle } = self {
3121            Some((peer_watcher, control_handle))
3122        } else {
3123            None
3124        }
3125    }
3126
3127    #[allow(irrefutable_let_patterns)]
3128    pub fn into_set_local_name(self) -> Option<(String, HostSetLocalNameResponder)> {
3129        if let HostRequest::SetLocalName { local_name, responder } = self {
3130            Some((local_name, responder))
3131        } else {
3132            None
3133        }
3134    }
3135
3136    #[allow(irrefutable_let_patterns)]
3137    pub fn into_set_device_class(
3138        self,
3139    ) -> Option<(fidl_fuchsia_bluetooth::DeviceClass, HostSetDeviceClassResponder)> {
3140        if let HostRequest::SetDeviceClass { device_class, responder } = self {
3141            Some((device_class, responder))
3142        } else {
3143            None
3144        }
3145    }
3146
3147    #[allow(irrefutable_let_patterns)]
3148    pub fn into_start_discovery(self) -> Option<(HostStartDiscoveryRequest, HostControlHandle)> {
3149        if let HostRequest::StartDiscovery { payload, control_handle } = self {
3150            Some((payload, control_handle))
3151        } else {
3152            None
3153        }
3154    }
3155
3156    #[allow(irrefutable_let_patterns)]
3157    pub fn into_set_connectable(self) -> Option<(bool, HostSetConnectableResponder)> {
3158        if let HostRequest::SetConnectable { enabled, responder } = self {
3159            Some((enabled, responder))
3160        } else {
3161            None
3162        }
3163    }
3164
3165    #[allow(irrefutable_let_patterns)]
3166    pub fn into_set_discoverable(self) -> Option<(bool, HostSetDiscoverableResponder)> {
3167        if let HostRequest::SetDiscoverable { enabled, responder } = self {
3168            Some((enabled, responder))
3169        } else {
3170            None
3171        }
3172    }
3173
3174    #[allow(irrefutable_let_patterns)]
3175    pub fn into_connect(self) -> Option<(fidl_fuchsia_bluetooth::PeerId, HostConnectResponder)> {
3176        if let HostRequest::Connect { id, responder } = self { Some((id, responder)) } else { None }
3177    }
3178
3179    #[allow(irrefutable_let_patterns)]
3180    pub fn into_disconnect(
3181        self,
3182    ) -> Option<(fidl_fuchsia_bluetooth::PeerId, HostDisconnectResponder)> {
3183        if let HostRequest::Disconnect { id, responder } = self {
3184            Some((id, responder))
3185        } else {
3186            None
3187        }
3188    }
3189
3190    #[allow(irrefutable_let_patterns)]
3191    pub fn into_pair(
3192        self,
3193    ) -> Option<(
3194        fidl_fuchsia_bluetooth::PeerId,
3195        fidl_fuchsia_bluetooth_sys::PairingOptions,
3196        HostPairResponder,
3197    )> {
3198        if let HostRequest::Pair { id, options, responder } = self {
3199            Some((id, options, responder))
3200        } else {
3201            None
3202        }
3203    }
3204
3205    #[allow(irrefutable_let_patterns)]
3206    pub fn into_forget(self) -> Option<(fidl_fuchsia_bluetooth::PeerId, HostForgetResponder)> {
3207        if let HostRequest::Forget { id, responder } = self { Some((id, responder)) } else { None }
3208    }
3209
3210    #[allow(irrefutable_let_patterns)]
3211    pub fn into_enable_background_scan(self) -> Option<(bool, HostControlHandle)> {
3212        if let HostRequest::EnableBackgroundScan { enabled, control_handle } = self {
3213            Some((enabled, control_handle))
3214        } else {
3215            None
3216        }
3217    }
3218
3219    #[allow(irrefutable_let_patterns)]
3220    pub fn into_enable_privacy(self) -> Option<(bool, HostControlHandle)> {
3221        if let HostRequest::EnablePrivacy { enabled, control_handle } = self {
3222            Some((enabled, control_handle))
3223        } else {
3224            None
3225        }
3226    }
3227
3228    #[allow(irrefutable_let_patterns)]
3229    pub fn into_set_br_edr_security_mode(
3230        self,
3231    ) -> Option<(fidl_fuchsia_bluetooth_sys::BrEdrSecurityMode, HostControlHandle)> {
3232        if let HostRequest::SetBrEdrSecurityMode { bredr_security_mode, control_handle } = self {
3233            Some((bredr_security_mode, control_handle))
3234        } else {
3235            None
3236        }
3237    }
3238
3239    #[allow(irrefutable_let_patterns)]
3240    pub fn into_set_le_security_mode(
3241        self,
3242    ) -> Option<(fidl_fuchsia_bluetooth_sys::LeSecurityMode, HostControlHandle)> {
3243        if let HostRequest::SetLeSecurityMode { le_security_mode, control_handle } = self {
3244            Some((le_security_mode, control_handle))
3245        } else {
3246            None
3247        }
3248    }
3249
3250    #[allow(irrefutable_let_patterns)]
3251    pub fn into_set_pairing_delegate(
3252        self,
3253    ) -> Option<(
3254        fidl_fuchsia_bluetooth_sys::InputCapability,
3255        fidl_fuchsia_bluetooth_sys::OutputCapability,
3256        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth_sys::PairingDelegateMarker>,
3257        HostControlHandle,
3258    )> {
3259        if let HostRequest::SetPairingDelegate { input, output, delegate, control_handle } = self {
3260            Some((input, output, delegate, control_handle))
3261        } else {
3262            None
3263        }
3264    }
3265
3266    #[allow(irrefutable_let_patterns)]
3267    pub fn into_set_bonding_delegate(
3268        self,
3269    ) -> Option<(fidl::endpoints::ServerEnd<BondingDelegateMarker>, HostControlHandle)> {
3270        if let HostRequest::SetBondingDelegate { delegate, control_handle } = self {
3271            Some((delegate, control_handle))
3272        } else {
3273            None
3274        }
3275    }
3276
3277    /// Name of the method defined in FIDL
3278    pub fn method_name(&self) -> &'static str {
3279        match *self {
3280            HostRequest::RequestProtocol { .. } => "request_protocol",
3281            HostRequest::Shutdown { .. } => "shutdown",
3282            HostRequest::WatchState { .. } => "watch_state",
3283            HostRequest::SetLocalData { .. } => "set_local_data",
3284            HostRequest::SetPeerWatcher { .. } => "set_peer_watcher",
3285            HostRequest::SetLocalName { .. } => "set_local_name",
3286            HostRequest::SetDeviceClass { .. } => "set_device_class",
3287            HostRequest::StartDiscovery { .. } => "start_discovery",
3288            HostRequest::SetConnectable { .. } => "set_connectable",
3289            HostRequest::SetDiscoverable { .. } => "set_discoverable",
3290            HostRequest::Connect { .. } => "connect",
3291            HostRequest::Disconnect { .. } => "disconnect",
3292            HostRequest::Pair { .. } => "pair",
3293            HostRequest::Forget { .. } => "forget",
3294            HostRequest::EnableBackgroundScan { .. } => "enable_background_scan",
3295            HostRequest::EnablePrivacy { .. } => "enable_privacy",
3296            HostRequest::SetBrEdrSecurityMode { .. } => "set_br_edr_security_mode",
3297            HostRequest::SetLeSecurityMode { .. } => "set_le_security_mode",
3298            HostRequest::SetPairingDelegate { .. } => "set_pairing_delegate",
3299            HostRequest::SetBondingDelegate { .. } => "set_bonding_delegate",
3300            HostRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
3301                "unknown one-way method"
3302            }
3303            HostRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
3304                "unknown two-way method"
3305            }
3306        }
3307    }
3308}
3309
3310#[derive(Debug, Clone)]
3311pub struct HostControlHandle {
3312    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3313}
3314
3315impl fidl::endpoints::ControlHandle for HostControlHandle {
3316    fn shutdown(&self) {
3317        self.inner.shutdown()
3318    }
3319    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3320        self.inner.shutdown_with_epitaph(status)
3321    }
3322
3323    fn is_closed(&self) -> bool {
3324        self.inner.channel().is_closed()
3325    }
3326    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3327        self.inner.channel().on_closed()
3328    }
3329
3330    #[cfg(target_os = "fuchsia")]
3331    fn signal_peer(
3332        &self,
3333        clear_mask: zx::Signals,
3334        set_mask: zx::Signals,
3335    ) -> Result<(), zx_status::Status> {
3336        use fidl::Peered;
3337        self.inner.channel().signal_peer(clear_mask, set_mask)
3338    }
3339}
3340
3341impl HostControlHandle {}
3342
3343#[must_use = "FIDL methods require a response to be sent"]
3344#[derive(Debug)]
3345pub struct HostWatchStateResponder {
3346    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3347    tx_id: u32,
3348}
3349
3350/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3351/// if the responder is dropped without sending a response, so that the client
3352/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3353impl std::ops::Drop for HostWatchStateResponder {
3354    fn drop(&mut self) {
3355        self.control_handle.shutdown();
3356        // Safety: drops once, never accessed again
3357        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3358    }
3359}
3360
3361impl fidl::endpoints::Responder for HostWatchStateResponder {
3362    type ControlHandle = HostControlHandle;
3363
3364    fn control_handle(&self) -> &HostControlHandle {
3365        &self.control_handle
3366    }
3367
3368    fn drop_without_shutdown(mut self) {
3369        // Safety: drops once, never accessed again due to mem::forget
3370        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3371        // Prevent Drop from running (which would shut down the channel)
3372        std::mem::forget(self);
3373    }
3374}
3375
3376impl HostWatchStateResponder {
3377    /// Sends a response to the FIDL transaction.
3378    ///
3379    /// Sets the channel to shutdown if an error occurs.
3380    pub fn send(self, mut info: &fidl_fuchsia_bluetooth_sys::HostInfo) -> Result<(), fidl::Error> {
3381        let _result = self.send_raw(info);
3382        if _result.is_err() {
3383            self.control_handle.shutdown();
3384        }
3385        self.drop_without_shutdown();
3386        _result
3387    }
3388
3389    /// Similar to "send" but does not shutdown the channel if an error occurs.
3390    pub fn send_no_shutdown_on_err(
3391        self,
3392        mut info: &fidl_fuchsia_bluetooth_sys::HostInfo,
3393    ) -> Result<(), fidl::Error> {
3394        let _result = self.send_raw(info);
3395        self.drop_without_shutdown();
3396        _result
3397    }
3398
3399    fn send_raw(&self, mut info: &fidl_fuchsia_bluetooth_sys::HostInfo) -> Result<(), fidl::Error> {
3400        self.control_handle.inner.send::<fidl::encoding::FlexibleType<HostWatchStateResponse>>(
3401            fidl::encoding::Flexible::new((info,)),
3402            self.tx_id,
3403            0x19157554e2a3db52,
3404            fidl::encoding::DynamicFlags::FLEXIBLE,
3405        )
3406    }
3407}
3408
3409#[must_use = "FIDL methods require a response to be sent"]
3410#[derive(Debug)]
3411pub struct HostSetLocalNameResponder {
3412    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3413    tx_id: u32,
3414}
3415
3416/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3417/// if the responder is dropped without sending a response, so that the client
3418/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3419impl std::ops::Drop for HostSetLocalNameResponder {
3420    fn drop(&mut self) {
3421        self.control_handle.shutdown();
3422        // Safety: drops once, never accessed again
3423        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3424    }
3425}
3426
3427impl fidl::endpoints::Responder for HostSetLocalNameResponder {
3428    type ControlHandle = HostControlHandle;
3429
3430    fn control_handle(&self) -> &HostControlHandle {
3431        &self.control_handle
3432    }
3433
3434    fn drop_without_shutdown(mut self) {
3435        // Safety: drops once, never accessed again due to mem::forget
3436        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3437        // Prevent Drop from running (which would shut down the channel)
3438        std::mem::forget(self);
3439    }
3440}
3441
3442impl HostSetLocalNameResponder {
3443    /// Sends a response to the FIDL transaction.
3444    ///
3445    /// Sets the channel to shutdown if an error occurs.
3446    pub fn send(
3447        self,
3448        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3449    ) -> Result<(), fidl::Error> {
3450        let _result = self.send_raw(result);
3451        if _result.is_err() {
3452            self.control_handle.shutdown();
3453        }
3454        self.drop_without_shutdown();
3455        _result
3456    }
3457
3458    /// Similar to "send" but does not shutdown the channel if an error occurs.
3459    pub fn send_no_shutdown_on_err(
3460        self,
3461        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3462    ) -> Result<(), fidl::Error> {
3463        let _result = self.send_raw(result);
3464        self.drop_without_shutdown();
3465        _result
3466    }
3467
3468    fn send_raw(
3469        &self,
3470        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3471    ) -> Result<(), fidl::Error> {
3472        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3473            fidl::encoding::EmptyStruct,
3474            fidl_fuchsia_bluetooth_sys::Error,
3475        >>(
3476            fidl::encoding::FlexibleResult::new(result),
3477            self.tx_id,
3478            0x85e98b56b98f123,
3479            fidl::encoding::DynamicFlags::FLEXIBLE,
3480        )
3481    }
3482}
3483
3484#[must_use = "FIDL methods require a response to be sent"]
3485#[derive(Debug)]
3486pub struct HostSetDeviceClassResponder {
3487    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3488    tx_id: u32,
3489}
3490
3491/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3492/// if the responder is dropped without sending a response, so that the client
3493/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3494impl std::ops::Drop for HostSetDeviceClassResponder {
3495    fn drop(&mut self) {
3496        self.control_handle.shutdown();
3497        // Safety: drops once, never accessed again
3498        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3499    }
3500}
3501
3502impl fidl::endpoints::Responder for HostSetDeviceClassResponder {
3503    type ControlHandle = HostControlHandle;
3504
3505    fn control_handle(&self) -> &HostControlHandle {
3506        &self.control_handle
3507    }
3508
3509    fn drop_without_shutdown(mut self) {
3510        // Safety: drops once, never accessed again due to mem::forget
3511        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3512        // Prevent Drop from running (which would shut down the channel)
3513        std::mem::forget(self);
3514    }
3515}
3516
3517impl HostSetDeviceClassResponder {
3518    /// Sends a response to the FIDL transaction.
3519    ///
3520    /// Sets the channel to shutdown if an error occurs.
3521    pub fn send(
3522        self,
3523        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3524    ) -> Result<(), fidl::Error> {
3525        let _result = self.send_raw(result);
3526        if _result.is_err() {
3527            self.control_handle.shutdown();
3528        }
3529        self.drop_without_shutdown();
3530        _result
3531    }
3532
3533    /// Similar to "send" but does not shutdown the channel if an error occurs.
3534    pub fn send_no_shutdown_on_err(
3535        self,
3536        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3537    ) -> Result<(), fidl::Error> {
3538        let _result = self.send_raw(result);
3539        self.drop_without_shutdown();
3540        _result
3541    }
3542
3543    fn send_raw(
3544        &self,
3545        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3546    ) -> Result<(), fidl::Error> {
3547        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3548            fidl::encoding::EmptyStruct,
3549            fidl_fuchsia_bluetooth_sys::Error,
3550        >>(
3551            fidl::encoding::FlexibleResult::new(result),
3552            self.tx_id,
3553            0x4caef8f835950de2,
3554            fidl::encoding::DynamicFlags::FLEXIBLE,
3555        )
3556    }
3557}
3558
3559#[must_use = "FIDL methods require a response to be sent"]
3560#[derive(Debug)]
3561pub struct HostSetConnectableResponder {
3562    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3563    tx_id: u32,
3564}
3565
3566/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3567/// if the responder is dropped without sending a response, so that the client
3568/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3569impl std::ops::Drop for HostSetConnectableResponder {
3570    fn drop(&mut self) {
3571        self.control_handle.shutdown();
3572        // Safety: drops once, never accessed again
3573        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3574    }
3575}
3576
3577impl fidl::endpoints::Responder for HostSetConnectableResponder {
3578    type ControlHandle = HostControlHandle;
3579
3580    fn control_handle(&self) -> &HostControlHandle {
3581        &self.control_handle
3582    }
3583
3584    fn drop_without_shutdown(mut self) {
3585        // Safety: drops once, never accessed again due to mem::forget
3586        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3587        // Prevent Drop from running (which would shut down the channel)
3588        std::mem::forget(self);
3589    }
3590}
3591
3592impl HostSetConnectableResponder {
3593    /// Sends a response to the FIDL transaction.
3594    ///
3595    /// Sets the channel to shutdown if an error occurs.
3596    pub fn send(
3597        self,
3598        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3599    ) -> Result<(), fidl::Error> {
3600        let _result = self.send_raw(result);
3601        if _result.is_err() {
3602            self.control_handle.shutdown();
3603        }
3604        self.drop_without_shutdown();
3605        _result
3606    }
3607
3608    /// Similar to "send" but does not shutdown the channel if an error occurs.
3609    pub fn send_no_shutdown_on_err(
3610        self,
3611        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3612    ) -> Result<(), fidl::Error> {
3613        let _result = self.send_raw(result);
3614        self.drop_without_shutdown();
3615        _result
3616    }
3617
3618    fn send_raw(
3619        &self,
3620        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3621    ) -> Result<(), fidl::Error> {
3622        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3623            fidl::encoding::EmptyStruct,
3624            fidl_fuchsia_bluetooth_sys::Error,
3625        >>(
3626            fidl::encoding::FlexibleResult::new(result),
3627            self.tx_id,
3628            0x187a6a82e811fa92,
3629            fidl::encoding::DynamicFlags::FLEXIBLE,
3630        )
3631    }
3632}
3633
3634#[must_use = "FIDL methods require a response to be sent"]
3635#[derive(Debug)]
3636pub struct HostSetDiscoverableResponder {
3637    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3638    tx_id: u32,
3639}
3640
3641/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3642/// if the responder is dropped without sending a response, so that the client
3643/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3644impl std::ops::Drop for HostSetDiscoverableResponder {
3645    fn drop(&mut self) {
3646        self.control_handle.shutdown();
3647        // Safety: drops once, never accessed again
3648        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3649    }
3650}
3651
3652impl fidl::endpoints::Responder for HostSetDiscoverableResponder {
3653    type ControlHandle = HostControlHandle;
3654
3655    fn control_handle(&self) -> &HostControlHandle {
3656        &self.control_handle
3657    }
3658
3659    fn drop_without_shutdown(mut self) {
3660        // Safety: drops once, never accessed again due to mem::forget
3661        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3662        // Prevent Drop from running (which would shut down the channel)
3663        std::mem::forget(self);
3664    }
3665}
3666
3667impl HostSetDiscoverableResponder {
3668    /// Sends a response to the FIDL transaction.
3669    ///
3670    /// Sets the channel to shutdown if an error occurs.
3671    pub fn send(
3672        self,
3673        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3674    ) -> Result<(), fidl::Error> {
3675        let _result = self.send_raw(result);
3676        if _result.is_err() {
3677            self.control_handle.shutdown();
3678        }
3679        self.drop_without_shutdown();
3680        _result
3681    }
3682
3683    /// Similar to "send" but does not shutdown the channel if an error occurs.
3684    pub fn send_no_shutdown_on_err(
3685        self,
3686        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3687    ) -> Result<(), fidl::Error> {
3688        let _result = self.send_raw(result);
3689        self.drop_without_shutdown();
3690        _result
3691    }
3692
3693    fn send_raw(
3694        &self,
3695        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3696    ) -> Result<(), fidl::Error> {
3697        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3698            fidl::encoding::EmptyStruct,
3699            fidl_fuchsia_bluetooth_sys::Error,
3700        >>(
3701            fidl::encoding::FlexibleResult::new(result),
3702            self.tx_id,
3703            0x89f8c7da63e36de,
3704            fidl::encoding::DynamicFlags::FLEXIBLE,
3705        )
3706    }
3707}
3708
3709#[must_use = "FIDL methods require a response to be sent"]
3710#[derive(Debug)]
3711pub struct HostConnectResponder {
3712    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3713    tx_id: u32,
3714}
3715
3716/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3717/// if the responder is dropped without sending a response, so that the client
3718/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3719impl std::ops::Drop for HostConnectResponder {
3720    fn drop(&mut self) {
3721        self.control_handle.shutdown();
3722        // Safety: drops once, never accessed again
3723        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3724    }
3725}
3726
3727impl fidl::endpoints::Responder for HostConnectResponder {
3728    type ControlHandle = HostControlHandle;
3729
3730    fn control_handle(&self) -> &HostControlHandle {
3731        &self.control_handle
3732    }
3733
3734    fn drop_without_shutdown(mut self) {
3735        // Safety: drops once, never accessed again due to mem::forget
3736        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3737        // Prevent Drop from running (which would shut down the channel)
3738        std::mem::forget(self);
3739    }
3740}
3741
3742impl HostConnectResponder {
3743    /// Sends a response to the FIDL transaction.
3744    ///
3745    /// Sets the channel to shutdown if an error occurs.
3746    pub fn send(
3747        self,
3748        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3749    ) -> Result<(), fidl::Error> {
3750        let _result = self.send_raw(result);
3751        if _result.is_err() {
3752            self.control_handle.shutdown();
3753        }
3754        self.drop_without_shutdown();
3755        _result
3756    }
3757
3758    /// Similar to "send" but does not shutdown the channel if an error occurs.
3759    pub fn send_no_shutdown_on_err(
3760        self,
3761        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3762    ) -> Result<(), fidl::Error> {
3763        let _result = self.send_raw(result);
3764        self.drop_without_shutdown();
3765        _result
3766    }
3767
3768    fn send_raw(
3769        &self,
3770        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3771    ) -> Result<(), fidl::Error> {
3772        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3773            fidl::encoding::EmptyStruct,
3774            fidl_fuchsia_bluetooth_sys::Error,
3775        >>(
3776            fidl::encoding::FlexibleResult::new(result),
3777            self.tx_id,
3778            0x5a56139c993e7240,
3779            fidl::encoding::DynamicFlags::FLEXIBLE,
3780        )
3781    }
3782}
3783
3784#[must_use = "FIDL methods require a response to be sent"]
3785#[derive(Debug)]
3786pub struct HostDisconnectResponder {
3787    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3788    tx_id: u32,
3789}
3790
3791/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3792/// if the responder is dropped without sending a response, so that the client
3793/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3794impl std::ops::Drop for HostDisconnectResponder {
3795    fn drop(&mut self) {
3796        self.control_handle.shutdown();
3797        // Safety: drops once, never accessed again
3798        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3799    }
3800}
3801
3802impl fidl::endpoints::Responder for HostDisconnectResponder {
3803    type ControlHandle = HostControlHandle;
3804
3805    fn control_handle(&self) -> &HostControlHandle {
3806        &self.control_handle
3807    }
3808
3809    fn drop_without_shutdown(mut self) {
3810        // Safety: drops once, never accessed again due to mem::forget
3811        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3812        // Prevent Drop from running (which would shut down the channel)
3813        std::mem::forget(self);
3814    }
3815}
3816
3817impl HostDisconnectResponder {
3818    /// Sends a response to the FIDL transaction.
3819    ///
3820    /// Sets the channel to shutdown if an error occurs.
3821    pub fn send(
3822        self,
3823        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3824    ) -> Result<(), fidl::Error> {
3825        let _result = self.send_raw(result);
3826        if _result.is_err() {
3827            self.control_handle.shutdown();
3828        }
3829        self.drop_without_shutdown();
3830        _result
3831    }
3832
3833    /// Similar to "send" but does not shutdown the channel if an error occurs.
3834    pub fn send_no_shutdown_on_err(
3835        self,
3836        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3837    ) -> Result<(), fidl::Error> {
3838        let _result = self.send_raw(result);
3839        self.drop_without_shutdown();
3840        _result
3841    }
3842
3843    fn send_raw(
3844        &self,
3845        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3846    ) -> Result<(), fidl::Error> {
3847        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3848            fidl::encoding::EmptyStruct,
3849            fidl_fuchsia_bluetooth_sys::Error,
3850        >>(
3851            fidl::encoding::FlexibleResult::new(result),
3852            self.tx_id,
3853            0x33211717491121b1,
3854            fidl::encoding::DynamicFlags::FLEXIBLE,
3855        )
3856    }
3857}
3858
3859#[must_use = "FIDL methods require a response to be sent"]
3860#[derive(Debug)]
3861pub struct HostPairResponder {
3862    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3863    tx_id: u32,
3864}
3865
3866/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3867/// if the responder is dropped without sending a response, so that the client
3868/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3869impl std::ops::Drop for HostPairResponder {
3870    fn drop(&mut self) {
3871        self.control_handle.shutdown();
3872        // Safety: drops once, never accessed again
3873        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3874    }
3875}
3876
3877impl fidl::endpoints::Responder for HostPairResponder {
3878    type ControlHandle = HostControlHandle;
3879
3880    fn control_handle(&self) -> &HostControlHandle {
3881        &self.control_handle
3882    }
3883
3884    fn drop_without_shutdown(mut self) {
3885        // Safety: drops once, never accessed again due to mem::forget
3886        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3887        // Prevent Drop from running (which would shut down the channel)
3888        std::mem::forget(self);
3889    }
3890}
3891
3892impl HostPairResponder {
3893    /// Sends a response to the FIDL transaction.
3894    ///
3895    /// Sets the channel to shutdown if an error occurs.
3896    pub fn send(
3897        self,
3898        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3899    ) -> Result<(), fidl::Error> {
3900        let _result = self.send_raw(result);
3901        if _result.is_err() {
3902            self.control_handle.shutdown();
3903        }
3904        self.drop_without_shutdown();
3905        _result
3906    }
3907
3908    /// Similar to "send" but does not shutdown the channel if an error occurs.
3909    pub fn send_no_shutdown_on_err(
3910        self,
3911        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3912    ) -> Result<(), fidl::Error> {
3913        let _result = self.send_raw(result);
3914        self.drop_without_shutdown();
3915        _result
3916    }
3917
3918    fn send_raw(
3919        &self,
3920        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3921    ) -> Result<(), fidl::Error> {
3922        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3923            fidl::encoding::EmptyStruct,
3924            fidl_fuchsia_bluetooth_sys::Error,
3925        >>(
3926            fidl::encoding::FlexibleResult::new(result),
3927            self.tx_id,
3928            0x2efaec6dc5d62ca2,
3929            fidl::encoding::DynamicFlags::FLEXIBLE,
3930        )
3931    }
3932}
3933
3934#[must_use = "FIDL methods require a response to be sent"]
3935#[derive(Debug)]
3936pub struct HostForgetResponder {
3937    control_handle: std::mem::ManuallyDrop<HostControlHandle>,
3938    tx_id: u32,
3939}
3940
3941/// Set the the channel to be shutdown (see [`HostControlHandle::shutdown`])
3942/// if the responder is dropped without sending a response, so that the client
3943/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3944impl std::ops::Drop for HostForgetResponder {
3945    fn drop(&mut self) {
3946        self.control_handle.shutdown();
3947        // Safety: drops once, never accessed again
3948        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3949    }
3950}
3951
3952impl fidl::endpoints::Responder for HostForgetResponder {
3953    type ControlHandle = HostControlHandle;
3954
3955    fn control_handle(&self) -> &HostControlHandle {
3956        &self.control_handle
3957    }
3958
3959    fn drop_without_shutdown(mut self) {
3960        // Safety: drops once, never accessed again due to mem::forget
3961        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3962        // Prevent Drop from running (which would shut down the channel)
3963        std::mem::forget(self);
3964    }
3965}
3966
3967impl HostForgetResponder {
3968    /// Sends a response to the FIDL transaction.
3969    ///
3970    /// Sets the channel to shutdown if an error occurs.
3971    pub fn send(
3972        self,
3973        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3974    ) -> Result<(), fidl::Error> {
3975        let _result = self.send_raw(result);
3976        if _result.is_err() {
3977            self.control_handle.shutdown();
3978        }
3979        self.drop_without_shutdown();
3980        _result
3981    }
3982
3983    /// Similar to "send" but does not shutdown the channel if an error occurs.
3984    pub fn send_no_shutdown_on_err(
3985        self,
3986        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3987    ) -> Result<(), fidl::Error> {
3988        let _result = self.send_raw(result);
3989        self.drop_without_shutdown();
3990        _result
3991    }
3992
3993    fn send_raw(
3994        &self,
3995        mut result: Result<(), fidl_fuchsia_bluetooth_sys::Error>,
3996    ) -> Result<(), fidl::Error> {
3997        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3998            fidl::encoding::EmptyStruct,
3999            fidl_fuchsia_bluetooth_sys::Error,
4000        >>(
4001            fidl::encoding::FlexibleResult::new(result),
4002            self.tx_id,
4003            0x904f58dbdd4490a,
4004            fidl::encoding::DynamicFlags::FLEXIBLE,
4005        )
4006    }
4007}
4008
4009#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4010pub struct PeerWatcherMarker;
4011
4012impl fidl::endpoints::ProtocolMarker for PeerWatcherMarker {
4013    type Proxy = PeerWatcherProxy;
4014    type RequestStream = PeerWatcherRequestStream;
4015    #[cfg(target_os = "fuchsia")]
4016    type SynchronousProxy = PeerWatcherSynchronousProxy;
4017
4018    const DEBUG_NAME: &'static str = "(anonymous) PeerWatcher";
4019}
4020
4021pub trait PeerWatcherProxyInterface: Send + Sync {
4022    type GetNextResponseFut: std::future::Future<Output = Result<PeerWatcherGetNextResponse, fidl::Error>>
4023        + Send;
4024    fn r#get_next(&self) -> Self::GetNextResponseFut;
4025}
4026#[derive(Debug)]
4027#[cfg(target_os = "fuchsia")]
4028pub struct PeerWatcherSynchronousProxy {
4029    client: fidl::client::sync::Client,
4030}
4031
4032#[cfg(target_os = "fuchsia")]
4033impl fidl::endpoints::SynchronousProxy for PeerWatcherSynchronousProxy {
4034    type Proxy = PeerWatcherProxy;
4035    type Protocol = PeerWatcherMarker;
4036
4037    fn from_channel(inner: fidl::Channel) -> Self {
4038        Self::new(inner)
4039    }
4040
4041    fn into_channel(self) -> fidl::Channel {
4042        self.client.into_channel()
4043    }
4044
4045    fn as_channel(&self) -> &fidl::Channel {
4046        self.client.as_channel()
4047    }
4048}
4049
4050#[cfg(target_os = "fuchsia")]
4051impl PeerWatcherSynchronousProxy {
4052    pub fn new(channel: fidl::Channel) -> Self {
4053        let protocol_name = <PeerWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4054        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4055    }
4056
4057    pub fn into_channel(self) -> fidl::Channel {
4058        self.client.into_channel()
4059    }
4060
4061    /// Waits until an event arrives and returns it. It is safe for other
4062    /// threads to make concurrent requests while waiting for an event.
4063    pub fn wait_for_event(
4064        &self,
4065        deadline: zx::MonotonicInstant,
4066    ) -> Result<PeerWatcherEvent, fidl::Error> {
4067        PeerWatcherEvent::decode(self.client.wait_for_event(deadline)?)
4068    }
4069
4070    /// Get the next peer update. The request will hang until the next update.
4071    pub fn r#get_next(
4072        &self,
4073        ___deadline: zx::MonotonicInstant,
4074    ) -> Result<PeerWatcherGetNextResponse, fidl::Error> {
4075        let _response = self.client.send_query::<
4076            fidl::encoding::EmptyPayload,
4077            fidl::encoding::FlexibleType<PeerWatcherGetNextResponse>,
4078        >(
4079            (),
4080            0x31b4855de7565b77,
4081            fidl::encoding::DynamicFlags::FLEXIBLE,
4082            ___deadline,
4083        )?
4084        .into_result::<PeerWatcherMarker>("get_next")?;
4085        Ok(_response)
4086    }
4087}
4088
4089#[cfg(target_os = "fuchsia")]
4090impl From<PeerWatcherSynchronousProxy> for zx::Handle {
4091    fn from(value: PeerWatcherSynchronousProxy) -> Self {
4092        value.into_channel().into()
4093    }
4094}
4095
4096#[cfg(target_os = "fuchsia")]
4097impl From<fidl::Channel> for PeerWatcherSynchronousProxy {
4098    fn from(value: fidl::Channel) -> Self {
4099        Self::new(value)
4100    }
4101}
4102
4103#[cfg(target_os = "fuchsia")]
4104impl fidl::endpoints::FromClient for PeerWatcherSynchronousProxy {
4105    type Protocol = PeerWatcherMarker;
4106
4107    fn from_client(value: fidl::endpoints::ClientEnd<PeerWatcherMarker>) -> Self {
4108        Self::new(value.into_channel())
4109    }
4110}
4111
4112#[derive(Debug, Clone)]
4113pub struct PeerWatcherProxy {
4114    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4115}
4116
4117impl fidl::endpoints::Proxy for PeerWatcherProxy {
4118    type Protocol = PeerWatcherMarker;
4119
4120    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4121        Self::new(inner)
4122    }
4123
4124    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4125        self.client.into_channel().map_err(|client| Self { client })
4126    }
4127
4128    fn as_channel(&self) -> &::fidl::AsyncChannel {
4129        self.client.as_channel()
4130    }
4131}
4132
4133impl PeerWatcherProxy {
4134    /// Create a new Proxy for fuchsia.bluetooth.host/PeerWatcher.
4135    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4136        let protocol_name = <PeerWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4137        Self { client: fidl::client::Client::new(channel, protocol_name) }
4138    }
4139
4140    /// Get a Stream of events from the remote end of the protocol.
4141    ///
4142    /// # Panics
4143    ///
4144    /// Panics if the event stream was already taken.
4145    pub fn take_event_stream(&self) -> PeerWatcherEventStream {
4146        PeerWatcherEventStream { event_receiver: self.client.take_event_receiver() }
4147    }
4148
4149    /// Get the next peer update. The request will hang until the next update.
4150    pub fn r#get_next(
4151        &self,
4152    ) -> fidl::client::QueryResponseFut<
4153        PeerWatcherGetNextResponse,
4154        fidl::encoding::DefaultFuchsiaResourceDialect,
4155    > {
4156        PeerWatcherProxyInterface::r#get_next(self)
4157    }
4158}
4159
4160impl PeerWatcherProxyInterface for PeerWatcherProxy {
4161    type GetNextResponseFut = fidl::client::QueryResponseFut<
4162        PeerWatcherGetNextResponse,
4163        fidl::encoding::DefaultFuchsiaResourceDialect,
4164    >;
4165    fn r#get_next(&self) -> Self::GetNextResponseFut {
4166        fn _decode(
4167            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4168        ) -> Result<PeerWatcherGetNextResponse, fidl::Error> {
4169            let _response = fidl::client::decode_transaction_body::<
4170                fidl::encoding::FlexibleType<PeerWatcherGetNextResponse>,
4171                fidl::encoding::DefaultFuchsiaResourceDialect,
4172                0x31b4855de7565b77,
4173            >(_buf?)?
4174            .into_result::<PeerWatcherMarker>("get_next")?;
4175            Ok(_response)
4176        }
4177        self.client
4178            .send_query_and_decode::<fidl::encoding::EmptyPayload, PeerWatcherGetNextResponse>(
4179                (),
4180                0x31b4855de7565b77,
4181                fidl::encoding::DynamicFlags::FLEXIBLE,
4182                _decode,
4183            )
4184    }
4185}
4186
4187pub struct PeerWatcherEventStream {
4188    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4189}
4190
4191impl std::marker::Unpin for PeerWatcherEventStream {}
4192
4193impl futures::stream::FusedStream for PeerWatcherEventStream {
4194    fn is_terminated(&self) -> bool {
4195        self.event_receiver.is_terminated()
4196    }
4197}
4198
4199impl futures::Stream for PeerWatcherEventStream {
4200    type Item = Result<PeerWatcherEvent, fidl::Error>;
4201
4202    fn poll_next(
4203        mut self: std::pin::Pin<&mut Self>,
4204        cx: &mut std::task::Context<'_>,
4205    ) -> std::task::Poll<Option<Self::Item>> {
4206        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4207            &mut self.event_receiver,
4208            cx
4209        )?) {
4210            Some(buf) => std::task::Poll::Ready(Some(PeerWatcherEvent::decode(buf))),
4211            None => std::task::Poll::Ready(None),
4212        }
4213    }
4214}
4215
4216#[derive(Debug)]
4217pub enum PeerWatcherEvent {
4218    #[non_exhaustive]
4219    _UnknownEvent {
4220        /// Ordinal of the event that was sent.
4221        ordinal: u64,
4222    },
4223}
4224
4225impl PeerWatcherEvent {
4226    /// Decodes a message buffer as a [`PeerWatcherEvent`].
4227    fn decode(
4228        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4229    ) -> Result<PeerWatcherEvent, fidl::Error> {
4230        let (bytes, _handles) = buf.split_mut();
4231        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4232        debug_assert_eq!(tx_header.tx_id, 0);
4233        match tx_header.ordinal {
4234            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4235                Ok(PeerWatcherEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4236            }
4237            _ => Err(fidl::Error::UnknownOrdinal {
4238                ordinal: tx_header.ordinal,
4239                protocol_name: <PeerWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4240            }),
4241        }
4242    }
4243}
4244
4245/// A Stream of incoming requests for fuchsia.bluetooth.host/PeerWatcher.
4246pub struct PeerWatcherRequestStream {
4247    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4248    is_terminated: bool,
4249}
4250
4251impl std::marker::Unpin for PeerWatcherRequestStream {}
4252
4253impl futures::stream::FusedStream for PeerWatcherRequestStream {
4254    fn is_terminated(&self) -> bool {
4255        self.is_terminated
4256    }
4257}
4258
4259impl fidl::endpoints::RequestStream for PeerWatcherRequestStream {
4260    type Protocol = PeerWatcherMarker;
4261    type ControlHandle = PeerWatcherControlHandle;
4262
4263    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4264        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4265    }
4266
4267    fn control_handle(&self) -> Self::ControlHandle {
4268        PeerWatcherControlHandle { inner: self.inner.clone() }
4269    }
4270
4271    fn into_inner(
4272        self,
4273    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4274    {
4275        (self.inner, self.is_terminated)
4276    }
4277
4278    fn from_inner(
4279        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4280        is_terminated: bool,
4281    ) -> Self {
4282        Self { inner, is_terminated }
4283    }
4284}
4285
4286impl futures::Stream for PeerWatcherRequestStream {
4287    type Item = Result<PeerWatcherRequest, fidl::Error>;
4288
4289    fn poll_next(
4290        mut self: std::pin::Pin<&mut Self>,
4291        cx: &mut std::task::Context<'_>,
4292    ) -> std::task::Poll<Option<Self::Item>> {
4293        let this = &mut *self;
4294        if this.inner.check_shutdown(cx) {
4295            this.is_terminated = true;
4296            return std::task::Poll::Ready(None);
4297        }
4298        if this.is_terminated {
4299            panic!("polled PeerWatcherRequestStream after completion");
4300        }
4301        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4302            |bytes, handles| {
4303                match this.inner.channel().read_etc(cx, bytes, handles) {
4304                    std::task::Poll::Ready(Ok(())) => {}
4305                    std::task::Poll::Pending => return std::task::Poll::Pending,
4306                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4307                        this.is_terminated = true;
4308                        return std::task::Poll::Ready(None);
4309                    }
4310                    std::task::Poll::Ready(Err(e)) => {
4311                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4312                            e.into(),
4313                        ))));
4314                    }
4315                }
4316
4317                // A message has been received from the channel
4318                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4319
4320                std::task::Poll::Ready(Some(match header.ordinal {
4321                    0x31b4855de7565b77 => {
4322                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4323                        let mut req = fidl::new_empty!(
4324                            fidl::encoding::EmptyPayload,
4325                            fidl::encoding::DefaultFuchsiaResourceDialect
4326                        );
4327                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4328                        let control_handle = PeerWatcherControlHandle { inner: this.inner.clone() };
4329                        Ok(PeerWatcherRequest::GetNext {
4330                            responder: PeerWatcherGetNextResponder {
4331                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4332                                tx_id: header.tx_id,
4333                            },
4334                        })
4335                    }
4336                    _ if header.tx_id == 0
4337                        && header
4338                            .dynamic_flags()
4339                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4340                    {
4341                        Ok(PeerWatcherRequest::_UnknownMethod {
4342                            ordinal: header.ordinal,
4343                            control_handle: PeerWatcherControlHandle { inner: this.inner.clone() },
4344                            method_type: fidl::MethodType::OneWay,
4345                        })
4346                    }
4347                    _ if header
4348                        .dynamic_flags()
4349                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4350                    {
4351                        this.inner.send_framework_err(
4352                            fidl::encoding::FrameworkErr::UnknownMethod,
4353                            header.tx_id,
4354                            header.ordinal,
4355                            header.dynamic_flags(),
4356                            (bytes, handles),
4357                        )?;
4358                        Ok(PeerWatcherRequest::_UnknownMethod {
4359                            ordinal: header.ordinal,
4360                            control_handle: PeerWatcherControlHandle { inner: this.inner.clone() },
4361                            method_type: fidl::MethodType::TwoWay,
4362                        })
4363                    }
4364                    _ => Err(fidl::Error::UnknownOrdinal {
4365                        ordinal: header.ordinal,
4366                        protocol_name:
4367                            <PeerWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4368                    }),
4369                }))
4370            },
4371        )
4372    }
4373}
4374
4375#[derive(Debug)]
4376pub enum PeerWatcherRequest {
4377    /// Get the next peer update. The request will hang until the next update.
4378    GetNext { responder: PeerWatcherGetNextResponder },
4379    /// An interaction was received which does not match any known method.
4380    #[non_exhaustive]
4381    _UnknownMethod {
4382        /// Ordinal of the method that was called.
4383        ordinal: u64,
4384        control_handle: PeerWatcherControlHandle,
4385        method_type: fidl::MethodType,
4386    },
4387}
4388
4389impl PeerWatcherRequest {
4390    #[allow(irrefutable_let_patterns)]
4391    pub fn into_get_next(self) -> Option<(PeerWatcherGetNextResponder)> {
4392        if let PeerWatcherRequest::GetNext { responder } = self { Some((responder)) } else { None }
4393    }
4394
4395    /// Name of the method defined in FIDL
4396    pub fn method_name(&self) -> &'static str {
4397        match *self {
4398            PeerWatcherRequest::GetNext { .. } => "get_next",
4399            PeerWatcherRequest::_UnknownMethod {
4400                method_type: fidl::MethodType::OneWay, ..
4401            } => "unknown one-way method",
4402            PeerWatcherRequest::_UnknownMethod {
4403                method_type: fidl::MethodType::TwoWay, ..
4404            } => "unknown two-way method",
4405        }
4406    }
4407}
4408
4409#[derive(Debug, Clone)]
4410pub struct PeerWatcherControlHandle {
4411    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4412}
4413
4414impl fidl::endpoints::ControlHandle for PeerWatcherControlHandle {
4415    fn shutdown(&self) {
4416        self.inner.shutdown()
4417    }
4418    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4419        self.inner.shutdown_with_epitaph(status)
4420    }
4421
4422    fn is_closed(&self) -> bool {
4423        self.inner.channel().is_closed()
4424    }
4425    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4426        self.inner.channel().on_closed()
4427    }
4428
4429    #[cfg(target_os = "fuchsia")]
4430    fn signal_peer(
4431        &self,
4432        clear_mask: zx::Signals,
4433        set_mask: zx::Signals,
4434    ) -> Result<(), zx_status::Status> {
4435        use fidl::Peered;
4436        self.inner.channel().signal_peer(clear_mask, set_mask)
4437    }
4438}
4439
4440impl PeerWatcherControlHandle {}
4441
4442#[must_use = "FIDL methods require a response to be sent"]
4443#[derive(Debug)]
4444pub struct PeerWatcherGetNextResponder {
4445    control_handle: std::mem::ManuallyDrop<PeerWatcherControlHandle>,
4446    tx_id: u32,
4447}
4448
4449/// Set the the channel to be shutdown (see [`PeerWatcherControlHandle::shutdown`])
4450/// if the responder is dropped without sending a response, so that the client
4451/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4452impl std::ops::Drop for PeerWatcherGetNextResponder {
4453    fn drop(&mut self) {
4454        self.control_handle.shutdown();
4455        // Safety: drops once, never accessed again
4456        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4457    }
4458}
4459
4460impl fidl::endpoints::Responder for PeerWatcherGetNextResponder {
4461    type ControlHandle = PeerWatcherControlHandle;
4462
4463    fn control_handle(&self) -> &PeerWatcherControlHandle {
4464        &self.control_handle
4465    }
4466
4467    fn drop_without_shutdown(mut self) {
4468        // Safety: drops once, never accessed again due to mem::forget
4469        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4470        // Prevent Drop from running (which would shut down the channel)
4471        std::mem::forget(self);
4472    }
4473}
4474
4475impl PeerWatcherGetNextResponder {
4476    /// Sends a response to the FIDL transaction.
4477    ///
4478    /// Sets the channel to shutdown if an error occurs.
4479    pub fn send(self, mut payload: &PeerWatcherGetNextResponse) -> Result<(), fidl::Error> {
4480        let _result = self.send_raw(payload);
4481        if _result.is_err() {
4482            self.control_handle.shutdown();
4483        }
4484        self.drop_without_shutdown();
4485        _result
4486    }
4487
4488    /// Similar to "send" but does not shutdown the channel if an error occurs.
4489    pub fn send_no_shutdown_on_err(
4490        self,
4491        mut payload: &PeerWatcherGetNextResponse,
4492    ) -> Result<(), fidl::Error> {
4493        let _result = self.send_raw(payload);
4494        self.drop_without_shutdown();
4495        _result
4496    }
4497
4498    fn send_raw(&self, mut payload: &PeerWatcherGetNextResponse) -> Result<(), fidl::Error> {
4499        self.control_handle.inner.send::<fidl::encoding::FlexibleType<PeerWatcherGetNextResponse>>(
4500            fidl::encoding::Flexible::new(payload),
4501            self.tx_id,
4502            0x31b4855de7565b77,
4503            fidl::encoding::DynamicFlags::FLEXIBLE,
4504        )
4505    }
4506}
4507
4508#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4509pub struct ReceiverMarker;
4510
4511impl fidl::endpoints::ProtocolMarker for ReceiverMarker {
4512    type Proxy = ReceiverProxy;
4513    type RequestStream = ReceiverRequestStream;
4514    #[cfg(target_os = "fuchsia")]
4515    type SynchronousProxy = ReceiverSynchronousProxy;
4516
4517    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.host.Receiver";
4518}
4519impl fidl::endpoints::DiscoverableProtocolMarker for ReceiverMarker {}
4520
4521pub trait ReceiverProxyInterface: Send + Sync {
4522    fn r#add_host(
4523        &self,
4524        request: fidl::endpoints::ClientEnd<HostMarker>,
4525    ) -> Result<(), fidl::Error>;
4526}
4527#[derive(Debug)]
4528#[cfg(target_os = "fuchsia")]
4529pub struct ReceiverSynchronousProxy {
4530    client: fidl::client::sync::Client,
4531}
4532
4533#[cfg(target_os = "fuchsia")]
4534impl fidl::endpoints::SynchronousProxy for ReceiverSynchronousProxy {
4535    type Proxy = ReceiverProxy;
4536    type Protocol = ReceiverMarker;
4537
4538    fn from_channel(inner: fidl::Channel) -> Self {
4539        Self::new(inner)
4540    }
4541
4542    fn into_channel(self) -> fidl::Channel {
4543        self.client.into_channel()
4544    }
4545
4546    fn as_channel(&self) -> &fidl::Channel {
4547        self.client.as_channel()
4548    }
4549}
4550
4551#[cfg(target_os = "fuchsia")]
4552impl ReceiverSynchronousProxy {
4553    pub fn new(channel: fidl::Channel) -> Self {
4554        let protocol_name = <ReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4555        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4556    }
4557
4558    pub fn into_channel(self) -> fidl::Channel {
4559        self.client.into_channel()
4560    }
4561
4562    /// Waits until an event arrives and returns it. It is safe for other
4563    /// threads to make concurrent requests while waiting for an event.
4564    pub fn wait_for_event(
4565        &self,
4566        deadline: zx::MonotonicInstant,
4567    ) -> Result<ReceiverEvent, fidl::Error> {
4568        ReceiverEvent::decode(self.client.wait_for_event(deadline)?)
4569    }
4570
4571    /// Adds a new bt-host. If `request` cannot be handled, it should be closed.
4572    pub fn r#add_host(
4573        &self,
4574        mut request: fidl::endpoints::ClientEnd<HostMarker>,
4575    ) -> Result<(), fidl::Error> {
4576        self.client.send::<ReceiverAddHostRequest>(
4577            (request,),
4578            0x2089233075765e8c,
4579            fidl::encoding::DynamicFlags::FLEXIBLE,
4580        )
4581    }
4582}
4583
4584#[cfg(target_os = "fuchsia")]
4585impl From<ReceiverSynchronousProxy> for zx::Handle {
4586    fn from(value: ReceiverSynchronousProxy) -> Self {
4587        value.into_channel().into()
4588    }
4589}
4590
4591#[cfg(target_os = "fuchsia")]
4592impl From<fidl::Channel> for ReceiverSynchronousProxy {
4593    fn from(value: fidl::Channel) -> Self {
4594        Self::new(value)
4595    }
4596}
4597
4598#[cfg(target_os = "fuchsia")]
4599impl fidl::endpoints::FromClient for ReceiverSynchronousProxy {
4600    type Protocol = ReceiverMarker;
4601
4602    fn from_client(value: fidl::endpoints::ClientEnd<ReceiverMarker>) -> Self {
4603        Self::new(value.into_channel())
4604    }
4605}
4606
4607#[derive(Debug, Clone)]
4608pub struct ReceiverProxy {
4609    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4610}
4611
4612impl fidl::endpoints::Proxy for ReceiverProxy {
4613    type Protocol = ReceiverMarker;
4614
4615    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4616        Self::new(inner)
4617    }
4618
4619    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4620        self.client.into_channel().map_err(|client| Self { client })
4621    }
4622
4623    fn as_channel(&self) -> &::fidl::AsyncChannel {
4624        self.client.as_channel()
4625    }
4626}
4627
4628impl ReceiverProxy {
4629    /// Create a new Proxy for fuchsia.bluetooth.host/Receiver.
4630    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4631        let protocol_name = <ReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4632        Self { client: fidl::client::Client::new(channel, protocol_name) }
4633    }
4634
4635    /// Get a Stream of events from the remote end of the protocol.
4636    ///
4637    /// # Panics
4638    ///
4639    /// Panics if the event stream was already taken.
4640    pub fn take_event_stream(&self) -> ReceiverEventStream {
4641        ReceiverEventStream { event_receiver: self.client.take_event_receiver() }
4642    }
4643
4644    /// Adds a new bt-host. If `request` cannot be handled, it should be closed.
4645    pub fn r#add_host(
4646        &self,
4647        mut request: fidl::endpoints::ClientEnd<HostMarker>,
4648    ) -> Result<(), fidl::Error> {
4649        ReceiverProxyInterface::r#add_host(self, request)
4650    }
4651}
4652
4653impl ReceiverProxyInterface for ReceiverProxy {
4654    fn r#add_host(
4655        &self,
4656        mut request: fidl::endpoints::ClientEnd<HostMarker>,
4657    ) -> Result<(), fidl::Error> {
4658        self.client.send::<ReceiverAddHostRequest>(
4659            (request,),
4660            0x2089233075765e8c,
4661            fidl::encoding::DynamicFlags::FLEXIBLE,
4662        )
4663    }
4664}
4665
4666pub struct ReceiverEventStream {
4667    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4668}
4669
4670impl std::marker::Unpin for ReceiverEventStream {}
4671
4672impl futures::stream::FusedStream for ReceiverEventStream {
4673    fn is_terminated(&self) -> bool {
4674        self.event_receiver.is_terminated()
4675    }
4676}
4677
4678impl futures::Stream for ReceiverEventStream {
4679    type Item = Result<ReceiverEvent, fidl::Error>;
4680
4681    fn poll_next(
4682        mut self: std::pin::Pin<&mut Self>,
4683        cx: &mut std::task::Context<'_>,
4684    ) -> std::task::Poll<Option<Self::Item>> {
4685        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4686            &mut self.event_receiver,
4687            cx
4688        )?) {
4689            Some(buf) => std::task::Poll::Ready(Some(ReceiverEvent::decode(buf))),
4690            None => std::task::Poll::Ready(None),
4691        }
4692    }
4693}
4694
4695#[derive(Debug)]
4696pub enum ReceiverEvent {
4697    #[non_exhaustive]
4698    _UnknownEvent {
4699        /// Ordinal of the event that was sent.
4700        ordinal: u64,
4701    },
4702}
4703
4704impl ReceiverEvent {
4705    /// Decodes a message buffer as a [`ReceiverEvent`].
4706    fn decode(
4707        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4708    ) -> Result<ReceiverEvent, fidl::Error> {
4709        let (bytes, _handles) = buf.split_mut();
4710        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4711        debug_assert_eq!(tx_header.tx_id, 0);
4712        match tx_header.ordinal {
4713            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4714                Ok(ReceiverEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4715            }
4716            _ => Err(fidl::Error::UnknownOrdinal {
4717                ordinal: tx_header.ordinal,
4718                protocol_name: <ReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4719            }),
4720        }
4721    }
4722}
4723
4724/// A Stream of incoming requests for fuchsia.bluetooth.host/Receiver.
4725pub struct ReceiverRequestStream {
4726    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4727    is_terminated: bool,
4728}
4729
4730impl std::marker::Unpin for ReceiverRequestStream {}
4731
4732impl futures::stream::FusedStream for ReceiverRequestStream {
4733    fn is_terminated(&self) -> bool {
4734        self.is_terminated
4735    }
4736}
4737
4738impl fidl::endpoints::RequestStream for ReceiverRequestStream {
4739    type Protocol = ReceiverMarker;
4740    type ControlHandle = ReceiverControlHandle;
4741
4742    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4743        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4744    }
4745
4746    fn control_handle(&self) -> Self::ControlHandle {
4747        ReceiverControlHandle { inner: self.inner.clone() }
4748    }
4749
4750    fn into_inner(
4751        self,
4752    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4753    {
4754        (self.inner, self.is_terminated)
4755    }
4756
4757    fn from_inner(
4758        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4759        is_terminated: bool,
4760    ) -> Self {
4761        Self { inner, is_terminated }
4762    }
4763}
4764
4765impl futures::Stream for ReceiverRequestStream {
4766    type Item = Result<ReceiverRequest, fidl::Error>;
4767
4768    fn poll_next(
4769        mut self: std::pin::Pin<&mut Self>,
4770        cx: &mut std::task::Context<'_>,
4771    ) -> std::task::Poll<Option<Self::Item>> {
4772        let this = &mut *self;
4773        if this.inner.check_shutdown(cx) {
4774            this.is_terminated = true;
4775            return std::task::Poll::Ready(None);
4776        }
4777        if this.is_terminated {
4778            panic!("polled ReceiverRequestStream after completion");
4779        }
4780        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4781            |bytes, handles| {
4782                match this.inner.channel().read_etc(cx, bytes, handles) {
4783                    std::task::Poll::Ready(Ok(())) => {}
4784                    std::task::Poll::Pending => return std::task::Poll::Pending,
4785                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4786                        this.is_terminated = true;
4787                        return std::task::Poll::Ready(None);
4788                    }
4789                    std::task::Poll::Ready(Err(e)) => {
4790                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4791                            e.into(),
4792                        ))));
4793                    }
4794                }
4795
4796                // A message has been received from the channel
4797                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4798
4799                std::task::Poll::Ready(Some(match header.ordinal {
4800                    0x2089233075765e8c => {
4801                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4802                        let mut req = fidl::new_empty!(
4803                            ReceiverAddHostRequest,
4804                            fidl::encoding::DefaultFuchsiaResourceDialect
4805                        );
4806                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ReceiverAddHostRequest>(&header, _body_bytes, handles, &mut req)?;
4807                        let control_handle = ReceiverControlHandle { inner: this.inner.clone() };
4808                        Ok(ReceiverRequest::AddHost { request: req.request, control_handle })
4809                    }
4810                    _ if header.tx_id == 0
4811                        && header
4812                            .dynamic_flags()
4813                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4814                    {
4815                        Ok(ReceiverRequest::_UnknownMethod {
4816                            ordinal: header.ordinal,
4817                            control_handle: ReceiverControlHandle { inner: this.inner.clone() },
4818                            method_type: fidl::MethodType::OneWay,
4819                        })
4820                    }
4821                    _ if header
4822                        .dynamic_flags()
4823                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4824                    {
4825                        this.inner.send_framework_err(
4826                            fidl::encoding::FrameworkErr::UnknownMethod,
4827                            header.tx_id,
4828                            header.ordinal,
4829                            header.dynamic_flags(),
4830                            (bytes, handles),
4831                        )?;
4832                        Ok(ReceiverRequest::_UnknownMethod {
4833                            ordinal: header.ordinal,
4834                            control_handle: ReceiverControlHandle { inner: this.inner.clone() },
4835                            method_type: fidl::MethodType::TwoWay,
4836                        })
4837                    }
4838                    _ => Err(fidl::Error::UnknownOrdinal {
4839                        ordinal: header.ordinal,
4840                        protocol_name:
4841                            <ReceiverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4842                    }),
4843                }))
4844            },
4845        )
4846    }
4847}
4848
4849/// Receives a bt-host by protocol for use in the Bluetooth Host Subsystem
4850#[derive(Debug)]
4851pub enum ReceiverRequest {
4852    /// Adds a new bt-host. If `request` cannot be handled, it should be closed.
4853    AddHost {
4854        request: fidl::endpoints::ClientEnd<HostMarker>,
4855        control_handle: ReceiverControlHandle,
4856    },
4857    /// An interaction was received which does not match any known method.
4858    #[non_exhaustive]
4859    _UnknownMethod {
4860        /// Ordinal of the method that was called.
4861        ordinal: u64,
4862        control_handle: ReceiverControlHandle,
4863        method_type: fidl::MethodType,
4864    },
4865}
4866
4867impl ReceiverRequest {
4868    #[allow(irrefutable_let_patterns)]
4869    pub fn into_add_host(
4870        self,
4871    ) -> Option<(fidl::endpoints::ClientEnd<HostMarker>, ReceiverControlHandle)> {
4872        if let ReceiverRequest::AddHost { request, control_handle } = self {
4873            Some((request, control_handle))
4874        } else {
4875            None
4876        }
4877    }
4878
4879    /// Name of the method defined in FIDL
4880    pub fn method_name(&self) -> &'static str {
4881        match *self {
4882            ReceiverRequest::AddHost { .. } => "add_host",
4883            ReceiverRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
4884                "unknown one-way method"
4885            }
4886            ReceiverRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
4887                "unknown two-way method"
4888            }
4889        }
4890    }
4891}
4892
4893#[derive(Debug, Clone)]
4894pub struct ReceiverControlHandle {
4895    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4896}
4897
4898impl fidl::endpoints::ControlHandle for ReceiverControlHandle {
4899    fn shutdown(&self) {
4900        self.inner.shutdown()
4901    }
4902    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4903        self.inner.shutdown_with_epitaph(status)
4904    }
4905
4906    fn is_closed(&self) -> bool {
4907        self.inner.channel().is_closed()
4908    }
4909    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4910        self.inner.channel().on_closed()
4911    }
4912
4913    #[cfg(target_os = "fuchsia")]
4914    fn signal_peer(
4915        &self,
4916        clear_mask: zx::Signals,
4917        set_mask: zx::Signals,
4918    ) -> Result<(), zx_status::Status> {
4919        use fidl::Peered;
4920        self.inner.channel().signal_peer(clear_mask, set_mask)
4921    }
4922}
4923
4924impl ReceiverControlHandle {}
4925
4926mod internal {
4927    use super::*;
4928
4929    impl fidl::encoding::ResourceTypeMarker for HostSetBondingDelegateRequest {
4930        type Borrowed<'a> = &'a mut Self;
4931        fn take_or_borrow<'a>(
4932            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4933        ) -> Self::Borrowed<'a> {
4934            value
4935        }
4936    }
4937
4938    unsafe impl fidl::encoding::TypeMarker for HostSetBondingDelegateRequest {
4939        type Owned = Self;
4940
4941        #[inline(always)]
4942        fn inline_align(_context: fidl::encoding::Context) -> usize {
4943            4
4944        }
4945
4946        #[inline(always)]
4947        fn inline_size(_context: fidl::encoding::Context) -> usize {
4948            4
4949        }
4950    }
4951
4952    unsafe impl
4953        fidl::encoding::Encode<
4954            HostSetBondingDelegateRequest,
4955            fidl::encoding::DefaultFuchsiaResourceDialect,
4956        > for &mut HostSetBondingDelegateRequest
4957    {
4958        #[inline]
4959        unsafe fn encode(
4960            self,
4961            encoder: &mut fidl::encoding::Encoder<
4962                '_,
4963                fidl::encoding::DefaultFuchsiaResourceDialect,
4964            >,
4965            offset: usize,
4966            _depth: fidl::encoding::Depth,
4967        ) -> fidl::Result<()> {
4968            encoder.debug_check_bounds::<HostSetBondingDelegateRequest>(offset);
4969            // Delegate to tuple encoding.
4970            fidl::encoding::Encode::<HostSetBondingDelegateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4971                (
4972                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BondingDelegateMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.delegate),
4973                ),
4974                encoder, offset, _depth
4975            )
4976        }
4977    }
4978    unsafe impl<
4979        T0: fidl::encoding::Encode<
4980                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BondingDelegateMarker>>,
4981                fidl::encoding::DefaultFuchsiaResourceDialect,
4982            >,
4983    >
4984        fidl::encoding::Encode<
4985            HostSetBondingDelegateRequest,
4986            fidl::encoding::DefaultFuchsiaResourceDialect,
4987        > for (T0,)
4988    {
4989        #[inline]
4990        unsafe fn encode(
4991            self,
4992            encoder: &mut fidl::encoding::Encoder<
4993                '_,
4994                fidl::encoding::DefaultFuchsiaResourceDialect,
4995            >,
4996            offset: usize,
4997            depth: fidl::encoding::Depth,
4998        ) -> fidl::Result<()> {
4999            encoder.debug_check_bounds::<HostSetBondingDelegateRequest>(offset);
5000            // Zero out padding regions. There's no need to apply masks
5001            // because the unmasked parts will be overwritten by fields.
5002            // Write the fields.
5003            self.0.encode(encoder, offset + 0, depth)?;
5004            Ok(())
5005        }
5006    }
5007
5008    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5009        for HostSetBondingDelegateRequest
5010    {
5011        #[inline(always)]
5012        fn new_empty() -> Self {
5013            Self {
5014                delegate: fidl::new_empty!(
5015                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BondingDelegateMarker>>,
5016                    fidl::encoding::DefaultFuchsiaResourceDialect
5017                ),
5018            }
5019        }
5020
5021        #[inline]
5022        unsafe fn decode(
5023            &mut self,
5024            decoder: &mut fidl::encoding::Decoder<
5025                '_,
5026                fidl::encoding::DefaultFuchsiaResourceDialect,
5027            >,
5028            offset: usize,
5029            _depth: fidl::encoding::Depth,
5030        ) -> fidl::Result<()> {
5031            decoder.debug_check_bounds::<Self>(offset);
5032            // Verify that padding bytes are zero.
5033            fidl::decode!(
5034                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BondingDelegateMarker>>,
5035                fidl::encoding::DefaultFuchsiaResourceDialect,
5036                &mut self.delegate,
5037                decoder,
5038                offset + 0,
5039                _depth
5040            )?;
5041            Ok(())
5042        }
5043    }
5044
5045    impl fidl::encoding::ResourceTypeMarker for HostSetPairingDelegateRequest {
5046        type Borrowed<'a> = &'a mut Self;
5047        fn take_or_borrow<'a>(
5048            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5049        ) -> Self::Borrowed<'a> {
5050            value
5051        }
5052    }
5053
5054    unsafe impl fidl::encoding::TypeMarker for HostSetPairingDelegateRequest {
5055        type Owned = Self;
5056
5057        #[inline(always)]
5058        fn inline_align(_context: fidl::encoding::Context) -> usize {
5059            4
5060        }
5061
5062        #[inline(always)]
5063        fn inline_size(_context: fidl::encoding::Context) -> usize {
5064            12
5065        }
5066    }
5067
5068    unsafe impl
5069        fidl::encoding::Encode<
5070            HostSetPairingDelegateRequest,
5071            fidl::encoding::DefaultFuchsiaResourceDialect,
5072        > for &mut HostSetPairingDelegateRequest
5073    {
5074        #[inline]
5075        unsafe fn encode(
5076            self,
5077            encoder: &mut fidl::encoding::Encoder<
5078                '_,
5079                fidl::encoding::DefaultFuchsiaResourceDialect,
5080            >,
5081            offset: usize,
5082            _depth: fidl::encoding::Depth,
5083        ) -> fidl::Result<()> {
5084            encoder.debug_check_bounds::<HostSetPairingDelegateRequest>(offset);
5085            // Delegate to tuple encoding.
5086            fidl::encoding::Encode::<HostSetPairingDelegateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5087                (
5088                    <fidl_fuchsia_bluetooth_sys::InputCapability as fidl::encoding::ValueTypeMarker>::borrow(&self.input),
5089                    <fidl_fuchsia_bluetooth_sys::OutputCapability as fidl::encoding::ValueTypeMarker>::borrow(&self.output),
5090                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth_sys::PairingDelegateMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.delegate),
5091                ),
5092                encoder, offset, _depth
5093            )
5094        }
5095    }
5096    unsafe impl<
5097        T0: fidl::encoding::Encode<
5098                fidl_fuchsia_bluetooth_sys::InputCapability,
5099                fidl::encoding::DefaultFuchsiaResourceDialect,
5100            >,
5101        T1: fidl::encoding::Encode<
5102                fidl_fuchsia_bluetooth_sys::OutputCapability,
5103                fidl::encoding::DefaultFuchsiaResourceDialect,
5104            >,
5105        T2: fidl::encoding::Encode<
5106                fidl::encoding::Endpoint<
5107                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth_sys::PairingDelegateMarker>,
5108                >,
5109                fidl::encoding::DefaultFuchsiaResourceDialect,
5110            >,
5111    >
5112        fidl::encoding::Encode<
5113            HostSetPairingDelegateRequest,
5114            fidl::encoding::DefaultFuchsiaResourceDialect,
5115        > for (T0, T1, T2)
5116    {
5117        #[inline]
5118        unsafe fn encode(
5119            self,
5120            encoder: &mut fidl::encoding::Encoder<
5121                '_,
5122                fidl::encoding::DefaultFuchsiaResourceDialect,
5123            >,
5124            offset: usize,
5125            depth: fidl::encoding::Depth,
5126        ) -> fidl::Result<()> {
5127            encoder.debug_check_bounds::<HostSetPairingDelegateRequest>(offset);
5128            // Zero out padding regions. There's no need to apply masks
5129            // because the unmasked parts will be overwritten by fields.
5130            // Write the fields.
5131            self.0.encode(encoder, offset + 0, depth)?;
5132            self.1.encode(encoder, offset + 4, depth)?;
5133            self.2.encode(encoder, offset + 8, depth)?;
5134            Ok(())
5135        }
5136    }
5137
5138    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5139        for HostSetPairingDelegateRequest
5140    {
5141        #[inline(always)]
5142        fn new_empty() -> Self {
5143            Self {
5144                input: fidl::new_empty!(
5145                    fidl_fuchsia_bluetooth_sys::InputCapability,
5146                    fidl::encoding::DefaultFuchsiaResourceDialect
5147                ),
5148                output: fidl::new_empty!(
5149                    fidl_fuchsia_bluetooth_sys::OutputCapability,
5150                    fidl::encoding::DefaultFuchsiaResourceDialect
5151                ),
5152                delegate: fidl::new_empty!(
5153                    fidl::encoding::Endpoint<
5154                        fidl::endpoints::ClientEnd<
5155                            fidl_fuchsia_bluetooth_sys::PairingDelegateMarker,
5156                        >,
5157                    >,
5158                    fidl::encoding::DefaultFuchsiaResourceDialect
5159                ),
5160            }
5161        }
5162
5163        #[inline]
5164        unsafe fn decode(
5165            &mut self,
5166            decoder: &mut fidl::encoding::Decoder<
5167                '_,
5168                fidl::encoding::DefaultFuchsiaResourceDialect,
5169            >,
5170            offset: usize,
5171            _depth: fidl::encoding::Depth,
5172        ) -> fidl::Result<()> {
5173            decoder.debug_check_bounds::<Self>(offset);
5174            // Verify that padding bytes are zero.
5175            fidl::decode!(
5176                fidl_fuchsia_bluetooth_sys::InputCapability,
5177                fidl::encoding::DefaultFuchsiaResourceDialect,
5178                &mut self.input,
5179                decoder,
5180                offset + 0,
5181                _depth
5182            )?;
5183            fidl::decode!(
5184                fidl_fuchsia_bluetooth_sys::OutputCapability,
5185                fidl::encoding::DefaultFuchsiaResourceDialect,
5186                &mut self.output,
5187                decoder,
5188                offset + 4,
5189                _depth
5190            )?;
5191            fidl::decode!(
5192                fidl::encoding::Endpoint<
5193                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth_sys::PairingDelegateMarker>,
5194                >,
5195                fidl::encoding::DefaultFuchsiaResourceDialect,
5196                &mut self.delegate,
5197                decoder,
5198                offset + 8,
5199                _depth
5200            )?;
5201            Ok(())
5202        }
5203    }
5204
5205    impl fidl::encoding::ResourceTypeMarker for HostSetPeerWatcherRequest {
5206        type Borrowed<'a> = &'a mut Self;
5207        fn take_or_borrow<'a>(
5208            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5209        ) -> Self::Borrowed<'a> {
5210            value
5211        }
5212    }
5213
5214    unsafe impl fidl::encoding::TypeMarker for HostSetPeerWatcherRequest {
5215        type Owned = Self;
5216
5217        #[inline(always)]
5218        fn inline_align(_context: fidl::encoding::Context) -> usize {
5219            4
5220        }
5221
5222        #[inline(always)]
5223        fn inline_size(_context: fidl::encoding::Context) -> usize {
5224            4
5225        }
5226    }
5227
5228    unsafe impl
5229        fidl::encoding::Encode<
5230            HostSetPeerWatcherRequest,
5231            fidl::encoding::DefaultFuchsiaResourceDialect,
5232        > for &mut HostSetPeerWatcherRequest
5233    {
5234        #[inline]
5235        unsafe fn encode(
5236            self,
5237            encoder: &mut fidl::encoding::Encoder<
5238                '_,
5239                fidl::encoding::DefaultFuchsiaResourceDialect,
5240            >,
5241            offset: usize,
5242            _depth: fidl::encoding::Depth,
5243        ) -> fidl::Result<()> {
5244            encoder.debug_check_bounds::<HostSetPeerWatcherRequest>(offset);
5245            // Delegate to tuple encoding.
5246            fidl::encoding::Encode::<HostSetPeerWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5247                (
5248                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.peer_watcher),
5249                ),
5250                encoder, offset, _depth
5251            )
5252        }
5253    }
5254    unsafe impl<
5255        T0: fidl::encoding::Encode<
5256                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerWatcherMarker>>,
5257                fidl::encoding::DefaultFuchsiaResourceDialect,
5258            >,
5259    >
5260        fidl::encoding::Encode<
5261            HostSetPeerWatcherRequest,
5262            fidl::encoding::DefaultFuchsiaResourceDialect,
5263        > for (T0,)
5264    {
5265        #[inline]
5266        unsafe fn encode(
5267            self,
5268            encoder: &mut fidl::encoding::Encoder<
5269                '_,
5270                fidl::encoding::DefaultFuchsiaResourceDialect,
5271            >,
5272            offset: usize,
5273            depth: fidl::encoding::Depth,
5274        ) -> fidl::Result<()> {
5275            encoder.debug_check_bounds::<HostSetPeerWatcherRequest>(offset);
5276            // Zero out padding regions. There's no need to apply masks
5277            // because the unmasked parts will be overwritten by fields.
5278            // Write the fields.
5279            self.0.encode(encoder, offset + 0, depth)?;
5280            Ok(())
5281        }
5282    }
5283
5284    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5285        for HostSetPeerWatcherRequest
5286    {
5287        #[inline(always)]
5288        fn new_empty() -> Self {
5289            Self {
5290                peer_watcher: fidl::new_empty!(
5291                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerWatcherMarker>>,
5292                    fidl::encoding::DefaultFuchsiaResourceDialect
5293                ),
5294            }
5295        }
5296
5297        #[inline]
5298        unsafe fn decode(
5299            &mut self,
5300            decoder: &mut fidl::encoding::Decoder<
5301                '_,
5302                fidl::encoding::DefaultFuchsiaResourceDialect,
5303            >,
5304            offset: usize,
5305            _depth: fidl::encoding::Depth,
5306        ) -> fidl::Result<()> {
5307            decoder.debug_check_bounds::<Self>(offset);
5308            // Verify that padding bytes are zero.
5309            fidl::decode!(
5310                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerWatcherMarker>>,
5311                fidl::encoding::DefaultFuchsiaResourceDialect,
5312                &mut self.peer_watcher,
5313                decoder,
5314                offset + 0,
5315                _depth
5316            )?;
5317            Ok(())
5318        }
5319    }
5320
5321    impl fidl::encoding::ResourceTypeMarker for ReceiverAddHostRequest {
5322        type Borrowed<'a> = &'a mut Self;
5323        fn take_or_borrow<'a>(
5324            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5325        ) -> Self::Borrowed<'a> {
5326            value
5327        }
5328    }
5329
5330    unsafe impl fidl::encoding::TypeMarker for ReceiverAddHostRequest {
5331        type Owned = Self;
5332
5333        #[inline(always)]
5334        fn inline_align(_context: fidl::encoding::Context) -> usize {
5335            4
5336        }
5337
5338        #[inline(always)]
5339        fn inline_size(_context: fidl::encoding::Context) -> usize {
5340            4
5341        }
5342    }
5343
5344    unsafe impl
5345        fidl::encoding::Encode<
5346            ReceiverAddHostRequest,
5347            fidl::encoding::DefaultFuchsiaResourceDialect,
5348        > for &mut ReceiverAddHostRequest
5349    {
5350        #[inline]
5351        unsafe fn encode(
5352            self,
5353            encoder: &mut fidl::encoding::Encoder<
5354                '_,
5355                fidl::encoding::DefaultFuchsiaResourceDialect,
5356            >,
5357            offset: usize,
5358            _depth: fidl::encoding::Depth,
5359        ) -> fidl::Result<()> {
5360            encoder.debug_check_bounds::<ReceiverAddHostRequest>(offset);
5361            // Delegate to tuple encoding.
5362            fidl::encoding::Encode::<ReceiverAddHostRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5363                (
5364                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.request),
5365                ),
5366                encoder, offset, _depth
5367            )
5368        }
5369    }
5370    unsafe impl<
5371        T0: fidl::encoding::Encode<
5372                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostMarker>>,
5373                fidl::encoding::DefaultFuchsiaResourceDialect,
5374            >,
5375    >
5376        fidl::encoding::Encode<
5377            ReceiverAddHostRequest,
5378            fidl::encoding::DefaultFuchsiaResourceDialect,
5379        > for (T0,)
5380    {
5381        #[inline]
5382        unsafe fn encode(
5383            self,
5384            encoder: &mut fidl::encoding::Encoder<
5385                '_,
5386                fidl::encoding::DefaultFuchsiaResourceDialect,
5387            >,
5388            offset: usize,
5389            depth: fidl::encoding::Depth,
5390        ) -> fidl::Result<()> {
5391            encoder.debug_check_bounds::<ReceiverAddHostRequest>(offset);
5392            // Zero out padding regions. There's no need to apply masks
5393            // because the unmasked parts will be overwritten by fields.
5394            // Write the fields.
5395            self.0.encode(encoder, offset + 0, depth)?;
5396            Ok(())
5397        }
5398    }
5399
5400    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5401        for ReceiverAddHostRequest
5402    {
5403        #[inline(always)]
5404        fn new_empty() -> Self {
5405            Self {
5406                request: fidl::new_empty!(
5407                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostMarker>>,
5408                    fidl::encoding::DefaultFuchsiaResourceDialect
5409                ),
5410            }
5411        }
5412
5413        #[inline]
5414        unsafe fn decode(
5415            &mut self,
5416            decoder: &mut fidl::encoding::Decoder<
5417                '_,
5418                fidl::encoding::DefaultFuchsiaResourceDialect,
5419            >,
5420            offset: usize,
5421            _depth: fidl::encoding::Depth,
5422        ) -> fidl::Result<()> {
5423            decoder.debug_check_bounds::<Self>(offset);
5424            // Verify that padding bytes are zero.
5425            fidl::decode!(
5426                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HostMarker>>,
5427                fidl::encoding::DefaultFuchsiaResourceDialect,
5428                &mut self.request,
5429                decoder,
5430                offset + 0,
5431                _depth
5432            )?;
5433            Ok(())
5434        }
5435    }
5436
5437    impl HostStartDiscoveryRequest {
5438        #[inline(always)]
5439        fn max_ordinal_present(&self) -> u64 {
5440            if let Some(_) = self.token {
5441                return 1;
5442            }
5443            0
5444        }
5445    }
5446
5447    impl fidl::encoding::ResourceTypeMarker for HostStartDiscoveryRequest {
5448        type Borrowed<'a> = &'a mut Self;
5449        fn take_or_borrow<'a>(
5450            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5451        ) -> Self::Borrowed<'a> {
5452            value
5453        }
5454    }
5455
5456    unsafe impl fidl::encoding::TypeMarker for HostStartDiscoveryRequest {
5457        type Owned = Self;
5458
5459        #[inline(always)]
5460        fn inline_align(_context: fidl::encoding::Context) -> usize {
5461            8
5462        }
5463
5464        #[inline(always)]
5465        fn inline_size(_context: fidl::encoding::Context) -> usize {
5466            16
5467        }
5468    }
5469
5470    unsafe impl
5471        fidl::encoding::Encode<
5472            HostStartDiscoveryRequest,
5473            fidl::encoding::DefaultFuchsiaResourceDialect,
5474        > for &mut HostStartDiscoveryRequest
5475    {
5476        unsafe fn encode(
5477            self,
5478            encoder: &mut fidl::encoding::Encoder<
5479                '_,
5480                fidl::encoding::DefaultFuchsiaResourceDialect,
5481            >,
5482            offset: usize,
5483            mut depth: fidl::encoding::Depth,
5484        ) -> fidl::Result<()> {
5485            encoder.debug_check_bounds::<HostStartDiscoveryRequest>(offset);
5486            // Vector header
5487            let max_ordinal: u64 = self.max_ordinal_present();
5488            encoder.write_num(max_ordinal, offset);
5489            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5490            // Calling encoder.out_of_line_offset(0) is not allowed.
5491            if max_ordinal == 0 {
5492                return Ok(());
5493            }
5494            depth.increment()?;
5495            let envelope_size = 8;
5496            let bytes_len = max_ordinal as usize * envelope_size;
5497            #[allow(unused_variables)]
5498            let offset = encoder.out_of_line_offset(bytes_len);
5499            let mut _prev_end_offset: usize = 0;
5500            if 1 > max_ordinal {
5501                return Ok(());
5502            }
5503
5504            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5505            // are envelope_size bytes.
5506            let cur_offset: usize = (1 - 1) * envelope_size;
5507
5508            // Zero reserved fields.
5509            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5510
5511            // Safety:
5512            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5513            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5514            //   envelope_size bytes, there is always sufficient room.
5515            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiscoverySessionMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5516            self.token.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiscoverySessionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
5517            encoder, offset + cur_offset, depth
5518        )?;
5519
5520            _prev_end_offset = cur_offset + envelope_size;
5521
5522            Ok(())
5523        }
5524    }
5525
5526    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5527        for HostStartDiscoveryRequest
5528    {
5529        #[inline(always)]
5530        fn new_empty() -> Self {
5531            Self::default()
5532        }
5533
5534        unsafe fn decode(
5535            &mut self,
5536            decoder: &mut fidl::encoding::Decoder<
5537                '_,
5538                fidl::encoding::DefaultFuchsiaResourceDialect,
5539            >,
5540            offset: usize,
5541            mut depth: fidl::encoding::Depth,
5542        ) -> fidl::Result<()> {
5543            decoder.debug_check_bounds::<Self>(offset);
5544            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5545                None => return Err(fidl::Error::NotNullable),
5546                Some(len) => len,
5547            };
5548            // Calling decoder.out_of_line_offset(0) is not allowed.
5549            if len == 0 {
5550                return Ok(());
5551            };
5552            depth.increment()?;
5553            let envelope_size = 8;
5554            let bytes_len = len * envelope_size;
5555            let offset = decoder.out_of_line_offset(bytes_len)?;
5556            // Decode the envelope for each type.
5557            let mut _next_ordinal_to_read = 0;
5558            let mut next_offset = offset;
5559            let end_offset = offset + bytes_len;
5560            _next_ordinal_to_read += 1;
5561            if next_offset >= end_offset {
5562                return Ok(());
5563            }
5564
5565            // Decode unknown envelopes for gaps in ordinals.
5566            while _next_ordinal_to_read < 1 {
5567                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5568                _next_ordinal_to_read += 1;
5569                next_offset += envelope_size;
5570            }
5571
5572            let next_out_of_line = decoder.next_out_of_line();
5573            let handles_before = decoder.remaining_handles();
5574            if let Some((inlined, num_bytes, num_handles)) =
5575                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5576            {
5577                let member_inline_size = <fidl::encoding::Endpoint<
5578                    fidl::endpoints::ServerEnd<DiscoverySessionMarker>,
5579                > as fidl::encoding::TypeMarker>::inline_size(
5580                    decoder.context
5581                );
5582                if inlined != (member_inline_size <= 4) {
5583                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5584                }
5585                let inner_offset;
5586                let mut inner_depth = depth.clone();
5587                if inlined {
5588                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5589                    inner_offset = next_offset;
5590                } else {
5591                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5592                    inner_depth.increment()?;
5593                }
5594                let val_ref = self.token.get_or_insert_with(|| {
5595                    fidl::new_empty!(
5596                        fidl::encoding::Endpoint<
5597                            fidl::endpoints::ServerEnd<DiscoverySessionMarker>,
5598                        >,
5599                        fidl::encoding::DefaultFuchsiaResourceDialect
5600                    )
5601                });
5602                fidl::decode!(
5603                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiscoverySessionMarker>>,
5604                    fidl::encoding::DefaultFuchsiaResourceDialect,
5605                    val_ref,
5606                    decoder,
5607                    inner_offset,
5608                    inner_depth
5609                )?;
5610                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5611                {
5612                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5613                }
5614                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5615                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5616                }
5617            }
5618
5619            next_offset += envelope_size;
5620
5621            // Decode the remaining unknown envelopes.
5622            while next_offset < end_offset {
5623                _next_ordinal_to_read += 1;
5624                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5625                next_offset += envelope_size;
5626            }
5627
5628            Ok(())
5629        }
5630    }
5631
5632    impl fidl::encoding::ResourceTypeMarker for ProtocolRequest {
5633        type Borrowed<'a> = &'a mut Self;
5634        fn take_or_borrow<'a>(
5635            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5636        ) -> Self::Borrowed<'a> {
5637            value
5638        }
5639    }
5640
5641    unsafe impl fidl::encoding::TypeMarker for ProtocolRequest {
5642        type Owned = Self;
5643
5644        #[inline(always)]
5645        fn inline_align(_context: fidl::encoding::Context) -> usize {
5646            8
5647        }
5648
5649        #[inline(always)]
5650        fn inline_size(_context: fidl::encoding::Context) -> usize {
5651            16
5652        }
5653    }
5654
5655    unsafe impl
5656        fidl::encoding::Encode<ProtocolRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
5657        for &mut ProtocolRequest
5658    {
5659        #[inline]
5660        unsafe fn encode(
5661            self,
5662            encoder: &mut fidl::encoding::Encoder<
5663                '_,
5664                fidl::encoding::DefaultFuchsiaResourceDialect,
5665            >,
5666            offset: usize,
5667            _depth: fidl::encoding::Depth,
5668        ) -> fidl::Result<()> {
5669            encoder.debug_check_bounds::<ProtocolRequest>(offset);
5670            encoder.write_num::<u64>(self.ordinal(), offset);
5671            match self {
5672                ProtocolRequest::Central(ref mut val) => fidl::encoding::encode_in_envelope::<
5673                    fidl::encoding::Endpoint<
5674                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_le::CentralMarker>,
5675                    >,
5676                    fidl::encoding::DefaultFuchsiaResourceDialect,
5677                >(
5678                    <fidl::encoding::Endpoint<
5679                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_le::CentralMarker>,
5680                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5681                        val
5682                    ),
5683                    encoder,
5684                    offset + 8,
5685                    _depth,
5686                ),
5687                ProtocolRequest::Peripheral(ref mut val) => fidl::encoding::encode_in_envelope::<
5688                    fidl::encoding::Endpoint<
5689                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_le::PeripheralMarker>,
5690                    >,
5691                    fidl::encoding::DefaultFuchsiaResourceDialect,
5692                >(
5693                    <fidl::encoding::Endpoint<
5694                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_le::PeripheralMarker>,
5695                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5696                        val
5697                    ),
5698                    encoder,
5699                    offset + 8,
5700                    _depth,
5701                ),
5702                ProtocolRequest::GattServer(ref mut val) => fidl::encoding::encode_in_envelope::<
5703                    fidl::encoding::Endpoint<
5704                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::Server_Marker>,
5705                    >,
5706                    fidl::encoding::DefaultFuchsiaResourceDialect,
5707                >(
5708                    <fidl::encoding::Endpoint<
5709                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::Server_Marker>,
5710                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5711                        val
5712                    ),
5713                    encoder,
5714                    offset + 8,
5715                    _depth,
5716                ),
5717                ProtocolRequest::Gatt2Server(ref mut val) => fidl::encoding::encode_in_envelope::<
5718                    fidl::encoding::Endpoint<
5719                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::Server_Marker>,
5720                    >,
5721                    fidl::encoding::DefaultFuchsiaResourceDialect,
5722                >(
5723                    <fidl::encoding::Endpoint<
5724                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::Server_Marker>,
5725                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5726                        val
5727                    ),
5728                    encoder,
5729                    offset + 8,
5730                    _depth,
5731                ),
5732                ProtocolRequest::Profile(ref mut val) => fidl::encoding::encode_in_envelope::<
5733                    fidl::encoding::Endpoint<
5734                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
5735                    >,
5736                    fidl::encoding::DefaultFuchsiaResourceDialect,
5737                >(
5738                    <fidl::encoding::Endpoint<
5739                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
5740                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5741                        val
5742                    ),
5743                    encoder,
5744                    offset + 8,
5745                    _depth,
5746                ),
5747                ProtocolRequest::PrivilegedPeripheral(ref mut val) => {
5748                    fidl::encoding::encode_in_envelope::<
5749                        fidl::encoding::Endpoint<
5750                            fidl::endpoints::ServerEnd<
5751                                fidl_fuchsia_bluetooth_le::PrivilegedPeripheralMarker,
5752                            >,
5753                        >,
5754                        fidl::encoding::DefaultFuchsiaResourceDialect,
5755                    >(
5756                        <fidl::encoding::Endpoint<
5757                            fidl::endpoints::ServerEnd<
5758                                fidl_fuchsia_bluetooth_le::PrivilegedPeripheralMarker,
5759                            >,
5760                        > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5761                            val
5762                        ),
5763                        encoder,
5764                        offset + 8,
5765                        _depth,
5766                    )
5767                }
5768                ProtocolRequest::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
5769            }
5770        }
5771    }
5772
5773    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5774        for ProtocolRequest
5775    {
5776        #[inline(always)]
5777        fn new_empty() -> Self {
5778            Self::__SourceBreaking { unknown_ordinal: 0 }
5779        }
5780
5781        #[inline]
5782        unsafe fn decode(
5783            &mut self,
5784            decoder: &mut fidl::encoding::Decoder<
5785                '_,
5786                fidl::encoding::DefaultFuchsiaResourceDialect,
5787            >,
5788            offset: usize,
5789            mut depth: fidl::encoding::Depth,
5790        ) -> fidl::Result<()> {
5791            decoder.debug_check_bounds::<Self>(offset);
5792            #[allow(unused_variables)]
5793            let next_out_of_line = decoder.next_out_of_line();
5794            let handles_before = decoder.remaining_handles();
5795            let (ordinal, inlined, num_bytes, num_handles) =
5796                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
5797
5798            let member_inline_size = match ordinal {
5799                1 => <fidl::encoding::Endpoint<
5800                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_le::CentralMarker>,
5801                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5802                2 => <fidl::encoding::Endpoint<
5803                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_le::PeripheralMarker>,
5804                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5805                3 => <fidl::encoding::Endpoint<
5806                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::Server_Marker>,
5807                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5808                4 => <fidl::encoding::Endpoint<
5809                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::Server_Marker>,
5810                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5811                5 => <fidl::encoding::Endpoint<
5812                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_bredr::ProfileMarker>,
5813                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5814                6 => <fidl::encoding::Endpoint<
5815                    fidl::endpoints::ServerEnd<
5816                        fidl_fuchsia_bluetooth_le::PrivilegedPeripheralMarker,
5817                    >,
5818                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5819                0 => return Err(fidl::Error::UnknownUnionTag),
5820                _ => num_bytes as usize,
5821            };
5822
5823            if inlined != (member_inline_size <= 4) {
5824                return Err(fidl::Error::InvalidInlineBitInEnvelope);
5825            }
5826            let _inner_offset;
5827            if inlined {
5828                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
5829                _inner_offset = offset + 8;
5830            } else {
5831                depth.increment()?;
5832                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5833            }
5834            match ordinal {
5835                1 => {
5836                    #[allow(irrefutable_let_patterns)]
5837                    if let ProtocolRequest::Central(_) = self {
5838                        // Do nothing, read the value into the object
5839                    } else {
5840                        // Initialize `self` to the right variant
5841                        *self = ProtocolRequest::Central(fidl::new_empty!(
5842                            fidl::encoding::Endpoint<
5843                                fidl::endpoints::ServerEnd<
5844                                    fidl_fuchsia_bluetooth_le::CentralMarker,
5845                                >,
5846                            >,
5847                            fidl::encoding::DefaultFuchsiaResourceDialect
5848                        ));
5849                    }
5850                    #[allow(irrefutable_let_patterns)]
5851                    if let ProtocolRequest::Central(ref mut val) = self {
5852                        fidl::decode!(
5853                            fidl::encoding::Endpoint<
5854                                fidl::endpoints::ServerEnd<
5855                                    fidl_fuchsia_bluetooth_le::CentralMarker,
5856                                >,
5857                            >,
5858                            fidl::encoding::DefaultFuchsiaResourceDialect,
5859                            val,
5860                            decoder,
5861                            _inner_offset,
5862                            depth
5863                        )?;
5864                    } else {
5865                        unreachable!()
5866                    }
5867                }
5868                2 => {
5869                    #[allow(irrefutable_let_patterns)]
5870                    if let ProtocolRequest::Peripheral(_) = self {
5871                        // Do nothing, read the value into the object
5872                    } else {
5873                        // Initialize `self` to the right variant
5874                        *self = ProtocolRequest::Peripheral(fidl::new_empty!(
5875                            fidl::encoding::Endpoint<
5876                                fidl::endpoints::ServerEnd<
5877                                    fidl_fuchsia_bluetooth_le::PeripheralMarker,
5878                                >,
5879                            >,
5880                            fidl::encoding::DefaultFuchsiaResourceDialect
5881                        ));
5882                    }
5883                    #[allow(irrefutable_let_patterns)]
5884                    if let ProtocolRequest::Peripheral(ref mut val) = self {
5885                        fidl::decode!(
5886                            fidl::encoding::Endpoint<
5887                                fidl::endpoints::ServerEnd<
5888                                    fidl_fuchsia_bluetooth_le::PeripheralMarker,
5889                                >,
5890                            >,
5891                            fidl::encoding::DefaultFuchsiaResourceDialect,
5892                            val,
5893                            decoder,
5894                            _inner_offset,
5895                            depth
5896                        )?;
5897                    } else {
5898                        unreachable!()
5899                    }
5900                }
5901                3 => {
5902                    #[allow(irrefutable_let_patterns)]
5903                    if let ProtocolRequest::GattServer(_) = self {
5904                        // Do nothing, read the value into the object
5905                    } else {
5906                        // Initialize `self` to the right variant
5907                        *self = ProtocolRequest::GattServer(fidl::new_empty!(
5908                            fidl::encoding::Endpoint<
5909                                fidl::endpoints::ServerEnd<
5910                                    fidl_fuchsia_bluetooth_gatt::Server_Marker,
5911                                >,
5912                            >,
5913                            fidl::encoding::DefaultFuchsiaResourceDialect
5914                        ));
5915                    }
5916                    #[allow(irrefutable_let_patterns)]
5917                    if let ProtocolRequest::GattServer(ref mut val) = self {
5918                        fidl::decode!(
5919                            fidl::encoding::Endpoint<
5920                                fidl::endpoints::ServerEnd<
5921                                    fidl_fuchsia_bluetooth_gatt::Server_Marker,
5922                                >,
5923                            >,
5924                            fidl::encoding::DefaultFuchsiaResourceDialect,
5925                            val,
5926                            decoder,
5927                            _inner_offset,
5928                            depth
5929                        )?;
5930                    } else {
5931                        unreachable!()
5932                    }
5933                }
5934                4 => {
5935                    #[allow(irrefutable_let_patterns)]
5936                    if let ProtocolRequest::Gatt2Server(_) = self {
5937                        // Do nothing, read the value into the object
5938                    } else {
5939                        // Initialize `self` to the right variant
5940                        *self = ProtocolRequest::Gatt2Server(fidl::new_empty!(
5941                            fidl::encoding::Endpoint<
5942                                fidl::endpoints::ServerEnd<
5943                                    fidl_fuchsia_bluetooth_gatt2::Server_Marker,
5944                                >,
5945                            >,
5946                            fidl::encoding::DefaultFuchsiaResourceDialect
5947                        ));
5948                    }
5949                    #[allow(irrefutable_let_patterns)]
5950                    if let ProtocolRequest::Gatt2Server(ref mut val) = self {
5951                        fidl::decode!(
5952                            fidl::encoding::Endpoint<
5953                                fidl::endpoints::ServerEnd<
5954                                    fidl_fuchsia_bluetooth_gatt2::Server_Marker,
5955                                >,
5956                            >,
5957                            fidl::encoding::DefaultFuchsiaResourceDialect,
5958                            val,
5959                            decoder,
5960                            _inner_offset,
5961                            depth
5962                        )?;
5963                    } else {
5964                        unreachable!()
5965                    }
5966                }
5967                5 => {
5968                    #[allow(irrefutable_let_patterns)]
5969                    if let ProtocolRequest::Profile(_) = self {
5970                        // Do nothing, read the value into the object
5971                    } else {
5972                        // Initialize `self` to the right variant
5973                        *self = ProtocolRequest::Profile(fidl::new_empty!(
5974                            fidl::encoding::Endpoint<
5975                                fidl::endpoints::ServerEnd<
5976                                    fidl_fuchsia_bluetooth_bredr::ProfileMarker,
5977                                >,
5978                            >,
5979                            fidl::encoding::DefaultFuchsiaResourceDialect
5980                        ));
5981                    }
5982                    #[allow(irrefutable_let_patterns)]
5983                    if let ProtocolRequest::Profile(ref mut val) = self {
5984                        fidl::decode!(
5985                            fidl::encoding::Endpoint<
5986                                fidl::endpoints::ServerEnd<
5987                                    fidl_fuchsia_bluetooth_bredr::ProfileMarker,
5988                                >,
5989                            >,
5990                            fidl::encoding::DefaultFuchsiaResourceDialect,
5991                            val,
5992                            decoder,
5993                            _inner_offset,
5994                            depth
5995                        )?;
5996                    } else {
5997                        unreachable!()
5998                    }
5999                }
6000                6 => {
6001                    #[allow(irrefutable_let_patterns)]
6002                    if let ProtocolRequest::PrivilegedPeripheral(_) = self {
6003                        // Do nothing, read the value into the object
6004                    } else {
6005                        // Initialize `self` to the right variant
6006                        *self = ProtocolRequest::PrivilegedPeripheral(fidl::new_empty!(
6007                            fidl::encoding::Endpoint<
6008                                fidl::endpoints::ServerEnd<
6009                                    fidl_fuchsia_bluetooth_le::PrivilegedPeripheralMarker,
6010                                >,
6011                            >,
6012                            fidl::encoding::DefaultFuchsiaResourceDialect
6013                        ));
6014                    }
6015                    #[allow(irrefutable_let_patterns)]
6016                    if let ProtocolRequest::PrivilegedPeripheral(ref mut val) = self {
6017                        fidl::decode!(
6018                            fidl::encoding::Endpoint<
6019                                fidl::endpoints::ServerEnd<
6020                                    fidl_fuchsia_bluetooth_le::PrivilegedPeripheralMarker,
6021                                >,
6022                            >,
6023                            fidl::encoding::DefaultFuchsiaResourceDialect,
6024                            val,
6025                            decoder,
6026                            _inner_offset,
6027                            depth
6028                        )?;
6029                    } else {
6030                        unreachable!()
6031                    }
6032                }
6033                #[allow(deprecated)]
6034                ordinal => {
6035                    for _ in 0..num_handles {
6036                        decoder.drop_next_handle()?;
6037                    }
6038                    *self = ProtocolRequest::__SourceBreaking { unknown_ordinal: ordinal };
6039                }
6040            }
6041            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
6042                return Err(fidl::Error::InvalidNumBytesInEnvelope);
6043            }
6044            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6045                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6046            }
6047            Ok(())
6048        }
6049    }
6050}