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