Skip to main content

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