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 PeerControllerConnectPeerResult = Result<(), Error>;
3045pub type PeerControllerDisconnectPeerResult = Result<(), Error>;
3046pub type PeerControllerPairResult = Result<(), Error>;
3047pub type PeerControllerForgetPeerResult = Result<(), Error>;
3048pub type PeerControllerSetDiscoveryResult = Result<(), Error>;
3049
3050pub trait PeerControllerProxyInterface: Send + Sync {
3051    type GetKnownPeersResponseFut: std::future::Future<Output = Result<PeerControllerGetKnownPeersResult, fidl::Error>>
3052        + Send;
3053    fn r#get_known_peers(&self) -> Self::GetKnownPeersResponseFut;
3054    type ConnectPeerResponseFut: std::future::Future<Output = Result<PeerControllerConnectPeerResult, fidl::Error>>
3055        + Send;
3056    fn r#connect_peer(&self, payload: &PeerSelector) -> Self::ConnectPeerResponseFut;
3057    type DisconnectPeerResponseFut: std::future::Future<Output = Result<PeerControllerDisconnectPeerResult, fidl::Error>>
3058        + Send;
3059    fn r#disconnect_peer(&self, payload: &PeerSelector) -> Self::DisconnectPeerResponseFut;
3060    type PairResponseFut: std::future::Future<Output = Result<PeerControllerPairResult, fidl::Error>>
3061        + Send;
3062    fn r#pair(&self, payload: &PeerControllerPairRequest) -> Self::PairResponseFut;
3063    type ForgetPeerResponseFut: std::future::Future<Output = Result<PeerControllerForgetPeerResult, fidl::Error>>
3064        + Send;
3065    fn r#forget_peer(&self, payload: &PeerSelector) -> Self::ForgetPeerResponseFut;
3066    type SetDiscoveryResponseFut: std::future::Future<Output = Result<PeerControllerSetDiscoveryResult, fidl::Error>>
3067        + Send;
3068    fn r#set_discovery(
3069        &self,
3070        payload: &PeerControllerSetDiscoveryRequest,
3071    ) -> Self::SetDiscoveryResponseFut;
3072}
3073#[derive(Debug)]
3074#[cfg(target_os = "fuchsia")]
3075pub struct PeerControllerSynchronousProxy {
3076    client: fidl::client::sync::Client,
3077}
3078
3079#[cfg(target_os = "fuchsia")]
3080impl fidl::endpoints::SynchronousProxy for PeerControllerSynchronousProxy {
3081    type Proxy = PeerControllerProxy;
3082    type Protocol = PeerControllerMarker;
3083
3084    fn from_channel(inner: fidl::Channel) -> Self {
3085        Self::new(inner)
3086    }
3087
3088    fn into_channel(self) -> fidl::Channel {
3089        self.client.into_channel()
3090    }
3091
3092    fn as_channel(&self) -> &fidl::Channel {
3093        self.client.as_channel()
3094    }
3095}
3096
3097#[cfg(target_os = "fuchsia")]
3098impl PeerControllerSynchronousProxy {
3099    pub fn new(channel: fidl::Channel) -> Self {
3100        Self { client: fidl::client::sync::Client::new(channel) }
3101    }
3102
3103    pub fn into_channel(self) -> fidl::Channel {
3104        self.client.into_channel()
3105    }
3106
3107    /// Waits until an event arrives and returns it. It is safe for other
3108    /// threads to make concurrent requests while waiting for an event.
3109    pub fn wait_for_event(
3110        &self,
3111        deadline: zx::MonotonicInstant,
3112    ) -> Result<PeerControllerEvent, fidl::Error> {
3113        PeerControllerEvent::decode(self.client.wait_for_event::<PeerControllerMarker>(deadline)?)
3114    }
3115
3116    /// Get a list of discovered peers.
3117    ///
3118    /// * error Returns `INTERNAL` if the operation failed (check logs).
3119    pub fn r#get_known_peers(
3120        &self,
3121        ___deadline: zx::MonotonicInstant,
3122    ) -> Result<PeerControllerGetKnownPeersResult, fidl::Error> {
3123        let _response = self.client.send_query::<
3124            fidl::encoding::EmptyPayload,
3125            fidl::encoding::FlexibleResultType<PeerControllerGetKnownPeersResponse, Error>,
3126            PeerControllerMarker,
3127        >(
3128            (),
3129            0x482cf3745bab65f6,
3130            fidl::encoding::DynamicFlags::FLEXIBLE,
3131            ___deadline,
3132        )?
3133        .into_result::<PeerControllerMarker>("get_known_peers")?;
3134        Ok(_response.map(|x| x))
3135    }
3136
3137    /// Connect to a peer.
3138    ///
3139    /// * error Returns `INTERNAL` if the operation failed (check logs).
3140    /// * error Returns `MISSING_PARAMETERS` if the selector does not contain a peer ID.
3141    pub fn r#connect_peer(
3142        &self,
3143        mut payload: &PeerSelector,
3144        ___deadline: zx::MonotonicInstant,
3145    ) -> Result<PeerControllerConnectPeerResult, fidl::Error> {
3146        let _response = self.client.send_query::<
3147            PeerSelector,
3148            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3149            PeerControllerMarker,
3150        >(
3151            payload,
3152            0x13fbb990835acf66,
3153            fidl::encoding::DynamicFlags::FLEXIBLE,
3154            ___deadline,
3155        )?
3156        .into_result::<PeerControllerMarker>("connect_peer")?;
3157        Ok(_response.map(|x| x))
3158    }
3159
3160    /// Disconnect all logical links (BR/EDR & LE) to a peer.
3161    ///
3162    /// * error Returns `INTERNAL` if the operation failed (check logs).
3163    /// * error Returns `MISSING_PARAMETERS` if the selector does not contain a peer ID.
3164    pub fn r#disconnect_peer(
3165        &self,
3166        mut payload: &PeerSelector,
3167        ___deadline: zx::MonotonicInstant,
3168    ) -> Result<PeerControllerDisconnectPeerResult, fidl::Error> {
3169        let _response = self.client.send_query::<
3170            PeerSelector,
3171            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3172            PeerControllerMarker,
3173        >(
3174            payload,
3175            0x5f9992f066c664ad,
3176            fidl::encoding::DynamicFlags::FLEXIBLE,
3177            ___deadline,
3178        )?
3179        .into_result::<PeerControllerMarker>("disconnect_peer")?;
3180        Ok(_response.map(|x| x))
3181    }
3182
3183    /// Initiate pairing with a peer.
3184    ///
3185    /// * error Returns `INTERNAL` if the operation failed (check logs).
3186    /// * error Returns `MISSING_PARAMETERS` if `selector` or `options` is missing, or if `selector`
3187    ///   does not contain a peer ID.
3188    pub fn r#pair(
3189        &self,
3190        mut payload: &PeerControllerPairRequest,
3191        ___deadline: zx::MonotonicInstant,
3192    ) -> Result<PeerControllerPairResult, fidl::Error> {
3193        let _response = self.client.send_query::<
3194            PeerControllerPairRequest,
3195            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3196            PeerControllerMarker,
3197        >(
3198            payload,
3199            0x1991671d4d7eff26,
3200            fidl::encoding::DynamicFlags::FLEXIBLE,
3201            ___deadline,
3202        )?
3203        .into_result::<PeerControllerMarker>("pair")?;
3204        Ok(_response.map(|x| x))
3205    }
3206
3207    /// Forget a peer and all its bonding information.
3208    ///
3209    /// * error Returns `INTERNAL` if the operation failed (check logs).
3210    /// * error Returns `MISSING_PARAMETERS` if the selector does not contain a peer ID.
3211    pub fn r#forget_peer(
3212        &self,
3213        mut payload: &PeerSelector,
3214        ___deadline: zx::MonotonicInstant,
3215    ) -> Result<PeerControllerForgetPeerResult, fidl::Error> {
3216        let _response = self.client.send_query::<
3217            PeerSelector,
3218            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3219            PeerControllerMarker,
3220        >(
3221            payload,
3222            0x26011dbbd834f8c6,
3223            fidl::encoding::DynamicFlags::FLEXIBLE,
3224            ___deadline,
3225        )?
3226        .into_result::<PeerControllerMarker>("forget_peer")?;
3227        Ok(_response.map(|x| x))
3228    }
3229
3230    /// Set discovery state.
3231    ///
3232    /// * error Returns `INTERNAL` if the operation failed (check logs).
3233    /// * error Returns `MISSING_PARAMETERS` if `discovery` is missing.
3234    pub fn r#set_discovery(
3235        &self,
3236        mut payload: &PeerControllerSetDiscoveryRequest,
3237        ___deadline: zx::MonotonicInstant,
3238    ) -> Result<PeerControllerSetDiscoveryResult, fidl::Error> {
3239        let _response = self.client.send_query::<
3240            PeerControllerSetDiscoveryRequest,
3241            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3242            PeerControllerMarker,
3243        >(
3244            payload,
3245            0x3269624c9e1d6ab3,
3246            fidl::encoding::DynamicFlags::FLEXIBLE,
3247            ___deadline,
3248        )?
3249        .into_result::<PeerControllerMarker>("set_discovery")?;
3250        Ok(_response.map(|x| x))
3251    }
3252}
3253
3254#[cfg(target_os = "fuchsia")]
3255impl From<PeerControllerSynchronousProxy> for zx::NullableHandle {
3256    fn from(value: PeerControllerSynchronousProxy) -> Self {
3257        value.into_channel().into()
3258    }
3259}
3260
3261#[cfg(target_os = "fuchsia")]
3262impl From<fidl::Channel> for PeerControllerSynchronousProxy {
3263    fn from(value: fidl::Channel) -> Self {
3264        Self::new(value)
3265    }
3266}
3267
3268#[cfg(target_os = "fuchsia")]
3269impl fidl::endpoints::FromClient for PeerControllerSynchronousProxy {
3270    type Protocol = PeerControllerMarker;
3271
3272    fn from_client(value: fidl::endpoints::ClientEnd<PeerControllerMarker>) -> Self {
3273        Self::new(value.into_channel())
3274    }
3275}
3276
3277#[derive(Debug, Clone)]
3278pub struct PeerControllerProxy {
3279    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3280}
3281
3282impl fidl::endpoints::Proxy for PeerControllerProxy {
3283    type Protocol = PeerControllerMarker;
3284
3285    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3286        Self::new(inner)
3287    }
3288
3289    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3290        self.client.into_channel().map_err(|client| Self { client })
3291    }
3292
3293    fn as_channel(&self) -> &::fidl::AsyncChannel {
3294        self.client.as_channel()
3295    }
3296}
3297
3298impl PeerControllerProxy {
3299    /// Create a new Proxy for fuchsia.bluetooth.affordances/PeerController.
3300    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3301        let protocol_name = <PeerControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3302        Self { client: fidl::client::Client::new(channel, protocol_name) }
3303    }
3304
3305    /// Get a Stream of events from the remote end of the protocol.
3306    ///
3307    /// # Panics
3308    ///
3309    /// Panics if the event stream was already taken.
3310    pub fn take_event_stream(&self) -> PeerControllerEventStream {
3311        PeerControllerEventStream { event_receiver: self.client.take_event_receiver() }
3312    }
3313
3314    /// Get a list of discovered peers.
3315    ///
3316    /// * error Returns `INTERNAL` if the operation failed (check logs).
3317    pub fn r#get_known_peers(
3318        &self,
3319    ) -> fidl::client::QueryResponseFut<
3320        PeerControllerGetKnownPeersResult,
3321        fidl::encoding::DefaultFuchsiaResourceDialect,
3322    > {
3323        PeerControllerProxyInterface::r#get_known_peers(self)
3324    }
3325
3326    /// Connect to a peer.
3327    ///
3328    /// * error Returns `INTERNAL` if the operation failed (check logs).
3329    /// * error Returns `MISSING_PARAMETERS` if the selector does not contain a peer ID.
3330    pub fn r#connect_peer(
3331        &self,
3332        mut payload: &PeerSelector,
3333    ) -> fidl::client::QueryResponseFut<
3334        PeerControllerConnectPeerResult,
3335        fidl::encoding::DefaultFuchsiaResourceDialect,
3336    > {
3337        PeerControllerProxyInterface::r#connect_peer(self, payload)
3338    }
3339
3340    /// Disconnect all logical links (BR/EDR & LE) to a peer.
3341    ///
3342    /// * error Returns `INTERNAL` if the operation failed (check logs).
3343    /// * error Returns `MISSING_PARAMETERS` if the selector does not contain a peer ID.
3344    pub fn r#disconnect_peer(
3345        &self,
3346        mut payload: &PeerSelector,
3347    ) -> fidl::client::QueryResponseFut<
3348        PeerControllerDisconnectPeerResult,
3349        fidl::encoding::DefaultFuchsiaResourceDialect,
3350    > {
3351        PeerControllerProxyInterface::r#disconnect_peer(self, payload)
3352    }
3353
3354    /// Initiate pairing with a peer.
3355    ///
3356    /// * error Returns `INTERNAL` if the operation failed (check logs).
3357    /// * error Returns `MISSING_PARAMETERS` if `selector` or `options` is missing, or if `selector`
3358    ///   does not contain a peer ID.
3359    pub fn r#pair(
3360        &self,
3361        mut payload: &PeerControllerPairRequest,
3362    ) -> fidl::client::QueryResponseFut<
3363        PeerControllerPairResult,
3364        fidl::encoding::DefaultFuchsiaResourceDialect,
3365    > {
3366        PeerControllerProxyInterface::r#pair(self, payload)
3367    }
3368
3369    /// Forget a peer and all its bonding information.
3370    ///
3371    /// * error Returns `INTERNAL` if the operation failed (check logs).
3372    /// * error Returns `MISSING_PARAMETERS` if the selector does not contain a peer ID.
3373    pub fn r#forget_peer(
3374        &self,
3375        mut payload: &PeerSelector,
3376    ) -> fidl::client::QueryResponseFut<
3377        PeerControllerForgetPeerResult,
3378        fidl::encoding::DefaultFuchsiaResourceDialect,
3379    > {
3380        PeerControllerProxyInterface::r#forget_peer(self, payload)
3381    }
3382
3383    /// Set discovery state.
3384    ///
3385    /// * error Returns `INTERNAL` if the operation failed (check logs).
3386    /// * error Returns `MISSING_PARAMETERS` if `discovery` is missing.
3387    pub fn r#set_discovery(
3388        &self,
3389        mut payload: &PeerControllerSetDiscoveryRequest,
3390    ) -> fidl::client::QueryResponseFut<
3391        PeerControllerSetDiscoveryResult,
3392        fidl::encoding::DefaultFuchsiaResourceDialect,
3393    > {
3394        PeerControllerProxyInterface::r#set_discovery(self, payload)
3395    }
3396}
3397
3398impl PeerControllerProxyInterface for PeerControllerProxy {
3399    type GetKnownPeersResponseFut = fidl::client::QueryResponseFut<
3400        PeerControllerGetKnownPeersResult,
3401        fidl::encoding::DefaultFuchsiaResourceDialect,
3402    >;
3403    fn r#get_known_peers(&self) -> Self::GetKnownPeersResponseFut {
3404        fn _decode(
3405            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3406        ) -> Result<PeerControllerGetKnownPeersResult, fidl::Error> {
3407            let _response = fidl::client::decode_transaction_body::<
3408                fidl::encoding::FlexibleResultType<PeerControllerGetKnownPeersResponse, Error>,
3409                fidl::encoding::DefaultFuchsiaResourceDialect,
3410                0x482cf3745bab65f6,
3411            >(_buf?)?
3412            .into_result::<PeerControllerMarker>("get_known_peers")?;
3413            Ok(_response.map(|x| x))
3414        }
3415        self.client.send_query_and_decode::<
3416            fidl::encoding::EmptyPayload,
3417            PeerControllerGetKnownPeersResult,
3418        >(
3419            (),
3420            0x482cf3745bab65f6,
3421            fidl::encoding::DynamicFlags::FLEXIBLE,
3422            _decode,
3423        )
3424    }
3425
3426    type ConnectPeerResponseFut = fidl::client::QueryResponseFut<
3427        PeerControllerConnectPeerResult,
3428        fidl::encoding::DefaultFuchsiaResourceDialect,
3429    >;
3430    fn r#connect_peer(&self, mut payload: &PeerSelector) -> Self::ConnectPeerResponseFut {
3431        fn _decode(
3432            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3433        ) -> Result<PeerControllerConnectPeerResult, fidl::Error> {
3434            let _response = fidl::client::decode_transaction_body::<
3435                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3436                fidl::encoding::DefaultFuchsiaResourceDialect,
3437                0x13fbb990835acf66,
3438            >(_buf?)?
3439            .into_result::<PeerControllerMarker>("connect_peer")?;
3440            Ok(_response.map(|x| x))
3441        }
3442        self.client.send_query_and_decode::<PeerSelector, PeerControllerConnectPeerResult>(
3443            payload,
3444            0x13fbb990835acf66,
3445            fidl::encoding::DynamicFlags::FLEXIBLE,
3446            _decode,
3447        )
3448    }
3449
3450    type DisconnectPeerResponseFut = fidl::client::QueryResponseFut<
3451        PeerControllerDisconnectPeerResult,
3452        fidl::encoding::DefaultFuchsiaResourceDialect,
3453    >;
3454    fn r#disconnect_peer(&self, mut payload: &PeerSelector) -> Self::DisconnectPeerResponseFut {
3455        fn _decode(
3456            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3457        ) -> Result<PeerControllerDisconnectPeerResult, fidl::Error> {
3458            let _response = fidl::client::decode_transaction_body::<
3459                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3460                fidl::encoding::DefaultFuchsiaResourceDialect,
3461                0x5f9992f066c664ad,
3462            >(_buf?)?
3463            .into_result::<PeerControllerMarker>("disconnect_peer")?;
3464            Ok(_response.map(|x| x))
3465        }
3466        self.client.send_query_and_decode::<PeerSelector, PeerControllerDisconnectPeerResult>(
3467            payload,
3468            0x5f9992f066c664ad,
3469            fidl::encoding::DynamicFlags::FLEXIBLE,
3470            _decode,
3471        )
3472    }
3473
3474    type PairResponseFut = fidl::client::QueryResponseFut<
3475        PeerControllerPairResult,
3476        fidl::encoding::DefaultFuchsiaResourceDialect,
3477    >;
3478    fn r#pair(&self, mut payload: &PeerControllerPairRequest) -> Self::PairResponseFut {
3479        fn _decode(
3480            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3481        ) -> Result<PeerControllerPairResult, fidl::Error> {
3482            let _response = fidl::client::decode_transaction_body::<
3483                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3484                fidl::encoding::DefaultFuchsiaResourceDialect,
3485                0x1991671d4d7eff26,
3486            >(_buf?)?
3487            .into_result::<PeerControllerMarker>("pair")?;
3488            Ok(_response.map(|x| x))
3489        }
3490        self.client.send_query_and_decode::<PeerControllerPairRequest, PeerControllerPairResult>(
3491            payload,
3492            0x1991671d4d7eff26,
3493            fidl::encoding::DynamicFlags::FLEXIBLE,
3494            _decode,
3495        )
3496    }
3497
3498    type ForgetPeerResponseFut = fidl::client::QueryResponseFut<
3499        PeerControllerForgetPeerResult,
3500        fidl::encoding::DefaultFuchsiaResourceDialect,
3501    >;
3502    fn r#forget_peer(&self, mut payload: &PeerSelector) -> Self::ForgetPeerResponseFut {
3503        fn _decode(
3504            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3505        ) -> Result<PeerControllerForgetPeerResult, fidl::Error> {
3506            let _response = fidl::client::decode_transaction_body::<
3507                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3508                fidl::encoding::DefaultFuchsiaResourceDialect,
3509                0x26011dbbd834f8c6,
3510            >(_buf?)?
3511            .into_result::<PeerControllerMarker>("forget_peer")?;
3512            Ok(_response.map(|x| x))
3513        }
3514        self.client.send_query_and_decode::<PeerSelector, PeerControllerForgetPeerResult>(
3515            payload,
3516            0x26011dbbd834f8c6,
3517            fidl::encoding::DynamicFlags::FLEXIBLE,
3518            _decode,
3519        )
3520    }
3521
3522    type SetDiscoveryResponseFut = fidl::client::QueryResponseFut<
3523        PeerControllerSetDiscoveryResult,
3524        fidl::encoding::DefaultFuchsiaResourceDialect,
3525    >;
3526    fn r#set_discovery(
3527        &self,
3528        mut payload: &PeerControllerSetDiscoveryRequest,
3529    ) -> Self::SetDiscoveryResponseFut {
3530        fn _decode(
3531            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3532        ) -> Result<PeerControllerSetDiscoveryResult, fidl::Error> {
3533            let _response = fidl::client::decode_transaction_body::<
3534                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
3535                fidl::encoding::DefaultFuchsiaResourceDialect,
3536                0x3269624c9e1d6ab3,
3537            >(_buf?)?
3538            .into_result::<PeerControllerMarker>("set_discovery")?;
3539            Ok(_response.map(|x| x))
3540        }
3541        self.client.send_query_and_decode::<
3542            PeerControllerSetDiscoveryRequest,
3543            PeerControllerSetDiscoveryResult,
3544        >(
3545            payload,
3546            0x3269624c9e1d6ab3,
3547            fidl::encoding::DynamicFlags::FLEXIBLE,
3548            _decode,
3549        )
3550    }
3551}
3552
3553pub struct PeerControllerEventStream {
3554    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3555}
3556
3557impl std::marker::Unpin for PeerControllerEventStream {}
3558
3559impl futures::stream::FusedStream for PeerControllerEventStream {
3560    fn is_terminated(&self) -> bool {
3561        self.event_receiver.is_terminated()
3562    }
3563}
3564
3565impl futures::Stream for PeerControllerEventStream {
3566    type Item = Result<PeerControllerEvent, fidl::Error>;
3567
3568    fn poll_next(
3569        mut self: std::pin::Pin<&mut Self>,
3570        cx: &mut std::task::Context<'_>,
3571    ) -> std::task::Poll<Option<Self::Item>> {
3572        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3573            &mut self.event_receiver,
3574            cx
3575        )?) {
3576            Some(buf) => std::task::Poll::Ready(Some(PeerControllerEvent::decode(buf))),
3577            None => std::task::Poll::Ready(None),
3578        }
3579    }
3580}
3581
3582#[derive(Debug)]
3583pub enum PeerControllerEvent {
3584    #[non_exhaustive]
3585    _UnknownEvent {
3586        /// Ordinal of the event that was sent.
3587        ordinal: u64,
3588    },
3589}
3590
3591impl PeerControllerEvent {
3592    /// Decodes a message buffer as a [`PeerControllerEvent`].
3593    fn decode(
3594        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3595    ) -> Result<PeerControllerEvent, fidl::Error> {
3596        let (bytes, _handles) = buf.split_mut();
3597        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3598        debug_assert_eq!(tx_header.tx_id, 0);
3599        match tx_header.ordinal {
3600            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3601                Ok(PeerControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3602            }
3603            _ => Err(fidl::Error::UnknownOrdinal {
3604                ordinal: tx_header.ordinal,
3605                protocol_name:
3606                    <PeerControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3607            }),
3608        }
3609    }
3610}
3611
3612/// A Stream of incoming requests for fuchsia.bluetooth.affordances/PeerController.
3613pub struct PeerControllerRequestStream {
3614    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3615    is_terminated: bool,
3616}
3617
3618impl std::marker::Unpin for PeerControllerRequestStream {}
3619
3620impl futures::stream::FusedStream for PeerControllerRequestStream {
3621    fn is_terminated(&self) -> bool {
3622        self.is_terminated
3623    }
3624}
3625
3626impl fidl::endpoints::RequestStream for PeerControllerRequestStream {
3627    type Protocol = PeerControllerMarker;
3628    type ControlHandle = PeerControllerControlHandle;
3629
3630    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3631        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3632    }
3633
3634    fn control_handle(&self) -> Self::ControlHandle {
3635        PeerControllerControlHandle { inner: self.inner.clone() }
3636    }
3637
3638    fn into_inner(
3639        self,
3640    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3641    {
3642        (self.inner, self.is_terminated)
3643    }
3644
3645    fn from_inner(
3646        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3647        is_terminated: bool,
3648    ) -> Self {
3649        Self { inner, is_terminated }
3650    }
3651}
3652
3653impl futures::Stream for PeerControllerRequestStream {
3654    type Item = Result<PeerControllerRequest, fidl::Error>;
3655
3656    fn poll_next(
3657        mut self: std::pin::Pin<&mut Self>,
3658        cx: &mut std::task::Context<'_>,
3659    ) -> std::task::Poll<Option<Self::Item>> {
3660        let this = &mut *self;
3661        if this.inner.check_shutdown(cx) {
3662            this.is_terminated = true;
3663            return std::task::Poll::Ready(None);
3664        }
3665        if this.is_terminated {
3666            panic!("polled PeerControllerRequestStream after completion");
3667        }
3668        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3669            |bytes, handles| {
3670                match this.inner.channel().read_etc(cx, bytes, handles) {
3671                    std::task::Poll::Ready(Ok(())) => {}
3672                    std::task::Poll::Pending => return std::task::Poll::Pending,
3673                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3674                        this.is_terminated = true;
3675                        return std::task::Poll::Ready(None);
3676                    }
3677                    std::task::Poll::Ready(Err(e)) => {
3678                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3679                            e.into(),
3680                        ))));
3681                    }
3682                }
3683
3684                // A message has been received from the channel
3685                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3686
3687                std::task::Poll::Ready(Some(match header.ordinal {
3688                    0x482cf3745bab65f6 => {
3689                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3690                        let mut req = fidl::new_empty!(
3691                            fidl::encoding::EmptyPayload,
3692                            fidl::encoding::DefaultFuchsiaResourceDialect
3693                        );
3694                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3695                        let control_handle =
3696                            PeerControllerControlHandle { inner: this.inner.clone() };
3697                        Ok(PeerControllerRequest::GetKnownPeers {
3698                            responder: PeerControllerGetKnownPeersResponder {
3699                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3700                                tx_id: header.tx_id,
3701                            },
3702                        })
3703                    }
3704                    0x13fbb990835acf66 => {
3705                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3706                        let mut req = fidl::new_empty!(
3707                            PeerSelector,
3708                            fidl::encoding::DefaultFuchsiaResourceDialect
3709                        );
3710                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerSelector>(&header, _body_bytes, handles, &mut req)?;
3711                        let control_handle =
3712                            PeerControllerControlHandle { inner: this.inner.clone() };
3713                        Ok(PeerControllerRequest::ConnectPeer {
3714                            payload: req,
3715                            responder: PeerControllerConnectPeerResponder {
3716                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3717                                tx_id: header.tx_id,
3718                            },
3719                        })
3720                    }
3721                    0x5f9992f066c664ad => {
3722                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3723                        let mut req = fidl::new_empty!(
3724                            PeerSelector,
3725                            fidl::encoding::DefaultFuchsiaResourceDialect
3726                        );
3727                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerSelector>(&header, _body_bytes, handles, &mut req)?;
3728                        let control_handle =
3729                            PeerControllerControlHandle { inner: this.inner.clone() };
3730                        Ok(PeerControllerRequest::DisconnectPeer {
3731                            payload: req,
3732                            responder: PeerControllerDisconnectPeerResponder {
3733                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3734                                tx_id: header.tx_id,
3735                            },
3736                        })
3737                    }
3738                    0x1991671d4d7eff26 => {
3739                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3740                        let mut req = fidl::new_empty!(
3741                            PeerControllerPairRequest,
3742                            fidl::encoding::DefaultFuchsiaResourceDialect
3743                        );
3744                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerControllerPairRequest>(&header, _body_bytes, handles, &mut req)?;
3745                        let control_handle =
3746                            PeerControllerControlHandle { inner: this.inner.clone() };
3747                        Ok(PeerControllerRequest::Pair {
3748                            payload: req,
3749                            responder: PeerControllerPairResponder {
3750                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3751                                tx_id: header.tx_id,
3752                            },
3753                        })
3754                    }
3755                    0x26011dbbd834f8c6 => {
3756                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3757                        let mut req = fidl::new_empty!(
3758                            PeerSelector,
3759                            fidl::encoding::DefaultFuchsiaResourceDialect
3760                        );
3761                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerSelector>(&header, _body_bytes, handles, &mut req)?;
3762                        let control_handle =
3763                            PeerControllerControlHandle { inner: this.inner.clone() };
3764                        Ok(PeerControllerRequest::ForgetPeer {
3765                            payload: req,
3766                            responder: PeerControllerForgetPeerResponder {
3767                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3768                                tx_id: header.tx_id,
3769                            },
3770                        })
3771                    }
3772                    0x3269624c9e1d6ab3 => {
3773                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3774                        let mut req = fidl::new_empty!(
3775                            PeerControllerSetDiscoveryRequest,
3776                            fidl::encoding::DefaultFuchsiaResourceDialect
3777                        );
3778                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerControllerSetDiscoveryRequest>(&header, _body_bytes, handles, &mut req)?;
3779                        let control_handle =
3780                            PeerControllerControlHandle { inner: this.inner.clone() };
3781                        Ok(PeerControllerRequest::SetDiscovery {
3782                            payload: req,
3783                            responder: PeerControllerSetDiscoveryResponder {
3784                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3785                                tx_id: header.tx_id,
3786                            },
3787                        })
3788                    }
3789                    _ if header.tx_id == 0
3790                        && header
3791                            .dynamic_flags()
3792                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3793                    {
3794                        Ok(PeerControllerRequest::_UnknownMethod {
3795                            ordinal: header.ordinal,
3796                            control_handle: PeerControllerControlHandle {
3797                                inner: this.inner.clone(),
3798                            },
3799                            method_type: fidl::MethodType::OneWay,
3800                        })
3801                    }
3802                    _ if header
3803                        .dynamic_flags()
3804                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3805                    {
3806                        this.inner.send_framework_err(
3807                            fidl::encoding::FrameworkErr::UnknownMethod,
3808                            header.tx_id,
3809                            header.ordinal,
3810                            header.dynamic_flags(),
3811                            (bytes, handles),
3812                        )?;
3813                        Ok(PeerControllerRequest::_UnknownMethod {
3814                            ordinal: header.ordinal,
3815                            control_handle: PeerControllerControlHandle {
3816                                inner: this.inner.clone(),
3817                            },
3818                            method_type: fidl::MethodType::TwoWay,
3819                        })
3820                    }
3821                    _ => Err(fidl::Error::UnknownOrdinal {
3822                        ordinal: header.ordinal,
3823                        protocol_name:
3824                            <PeerControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3825                    }),
3826                }))
3827            },
3828        )
3829    }
3830}
3831
3832#[derive(Debug)]
3833pub enum PeerControllerRequest {
3834    /// Get a list of discovered peers.
3835    ///
3836    /// * error Returns `INTERNAL` if the operation failed (check logs).
3837    GetKnownPeers { responder: PeerControllerGetKnownPeersResponder },
3838    /// Connect to a peer.
3839    ///
3840    /// * error Returns `INTERNAL` if the operation failed (check logs).
3841    /// * error Returns `MISSING_PARAMETERS` if the selector does not contain a peer ID.
3842    ConnectPeer { payload: PeerSelector, responder: PeerControllerConnectPeerResponder },
3843    /// Disconnect all logical links (BR/EDR & LE) to a peer.
3844    ///
3845    /// * error Returns `INTERNAL` if the operation failed (check logs).
3846    /// * error Returns `MISSING_PARAMETERS` if the selector does not contain a peer ID.
3847    DisconnectPeer { payload: PeerSelector, responder: PeerControllerDisconnectPeerResponder },
3848    /// Initiate pairing with a peer.
3849    ///
3850    /// * error Returns `INTERNAL` if the operation failed (check logs).
3851    /// * error Returns `MISSING_PARAMETERS` if `selector` or `options` is missing, or if `selector`
3852    ///   does not contain a peer ID.
3853    Pair { payload: PeerControllerPairRequest, responder: PeerControllerPairResponder },
3854    /// Forget a peer and all its bonding information.
3855    ///
3856    /// * error Returns `INTERNAL` if the operation failed (check logs).
3857    /// * error Returns `MISSING_PARAMETERS` if the selector does not contain a peer ID.
3858    ForgetPeer { payload: PeerSelector, responder: PeerControllerForgetPeerResponder },
3859    /// Set discovery state.
3860    ///
3861    /// * error Returns `INTERNAL` if the operation failed (check logs).
3862    /// * error Returns `MISSING_PARAMETERS` if `discovery` is missing.
3863    SetDiscovery {
3864        payload: PeerControllerSetDiscoveryRequest,
3865        responder: PeerControllerSetDiscoveryResponder,
3866    },
3867    /// An interaction was received which does not match any known method.
3868    #[non_exhaustive]
3869    _UnknownMethod {
3870        /// Ordinal of the method that was called.
3871        ordinal: u64,
3872        control_handle: PeerControllerControlHandle,
3873        method_type: fidl::MethodType,
3874    },
3875}
3876
3877impl PeerControllerRequest {
3878    #[allow(irrefutable_let_patterns)]
3879    pub fn into_get_known_peers(self) -> Option<(PeerControllerGetKnownPeersResponder)> {
3880        if let PeerControllerRequest::GetKnownPeers { responder } = self {
3881            Some((responder))
3882        } else {
3883            None
3884        }
3885    }
3886
3887    #[allow(irrefutable_let_patterns)]
3888    pub fn into_connect_peer(self) -> Option<(PeerSelector, PeerControllerConnectPeerResponder)> {
3889        if let PeerControllerRequest::ConnectPeer { payload, responder } = self {
3890            Some((payload, responder))
3891        } else {
3892            None
3893        }
3894    }
3895
3896    #[allow(irrefutable_let_patterns)]
3897    pub fn into_disconnect_peer(
3898        self,
3899    ) -> Option<(PeerSelector, PeerControllerDisconnectPeerResponder)> {
3900        if let PeerControllerRequest::DisconnectPeer { payload, responder } = self {
3901            Some((payload, responder))
3902        } else {
3903            None
3904        }
3905    }
3906
3907    #[allow(irrefutable_let_patterns)]
3908    pub fn into_pair(self) -> Option<(PeerControllerPairRequest, PeerControllerPairResponder)> {
3909        if let PeerControllerRequest::Pair { payload, responder } = self {
3910            Some((payload, responder))
3911        } else {
3912            None
3913        }
3914    }
3915
3916    #[allow(irrefutable_let_patterns)]
3917    pub fn into_forget_peer(self) -> Option<(PeerSelector, PeerControllerForgetPeerResponder)> {
3918        if let PeerControllerRequest::ForgetPeer { payload, responder } = self {
3919            Some((payload, responder))
3920        } else {
3921            None
3922        }
3923    }
3924
3925    #[allow(irrefutable_let_patterns)]
3926    pub fn into_set_discovery(
3927        self,
3928    ) -> Option<(PeerControllerSetDiscoveryRequest, PeerControllerSetDiscoveryResponder)> {
3929        if let PeerControllerRequest::SetDiscovery { payload, responder } = self {
3930            Some((payload, responder))
3931        } else {
3932            None
3933        }
3934    }
3935
3936    /// Name of the method defined in FIDL
3937    pub fn method_name(&self) -> &'static str {
3938        match *self {
3939            PeerControllerRequest::GetKnownPeers { .. } => "get_known_peers",
3940            PeerControllerRequest::ConnectPeer { .. } => "connect_peer",
3941            PeerControllerRequest::DisconnectPeer { .. } => "disconnect_peer",
3942            PeerControllerRequest::Pair { .. } => "pair",
3943            PeerControllerRequest::ForgetPeer { .. } => "forget_peer",
3944            PeerControllerRequest::SetDiscovery { .. } => "set_discovery",
3945            PeerControllerRequest::_UnknownMethod {
3946                method_type: fidl::MethodType::OneWay, ..
3947            } => "unknown one-way method",
3948            PeerControllerRequest::_UnknownMethod {
3949                method_type: fidl::MethodType::TwoWay, ..
3950            } => "unknown two-way method",
3951        }
3952    }
3953}
3954
3955#[derive(Debug, Clone)]
3956pub struct PeerControllerControlHandle {
3957    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3958}
3959
3960impl fidl::endpoints::ControlHandle for PeerControllerControlHandle {
3961    fn shutdown(&self) {
3962        self.inner.shutdown()
3963    }
3964
3965    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3966        self.inner.shutdown_with_epitaph(status)
3967    }
3968
3969    fn is_closed(&self) -> bool {
3970        self.inner.channel().is_closed()
3971    }
3972    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3973        self.inner.channel().on_closed()
3974    }
3975
3976    #[cfg(target_os = "fuchsia")]
3977    fn signal_peer(
3978        &self,
3979        clear_mask: zx::Signals,
3980        set_mask: zx::Signals,
3981    ) -> Result<(), zx_status::Status> {
3982        use fidl::Peered;
3983        self.inner.channel().signal_peer(clear_mask, set_mask)
3984    }
3985}
3986
3987impl PeerControllerControlHandle {}
3988
3989#[must_use = "FIDL methods require a response to be sent"]
3990#[derive(Debug)]
3991pub struct PeerControllerGetKnownPeersResponder {
3992    control_handle: std::mem::ManuallyDrop<PeerControllerControlHandle>,
3993    tx_id: u32,
3994}
3995
3996/// Set the the channel to be shutdown (see [`PeerControllerControlHandle::shutdown`])
3997/// if the responder is dropped without sending a response, so that the client
3998/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3999impl std::ops::Drop for PeerControllerGetKnownPeersResponder {
4000    fn drop(&mut self) {
4001        self.control_handle.shutdown();
4002        // Safety: drops once, never accessed again
4003        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4004    }
4005}
4006
4007impl fidl::endpoints::Responder for PeerControllerGetKnownPeersResponder {
4008    type ControlHandle = PeerControllerControlHandle;
4009
4010    fn control_handle(&self) -> &PeerControllerControlHandle {
4011        &self.control_handle
4012    }
4013
4014    fn drop_without_shutdown(mut self) {
4015        // Safety: drops once, never accessed again due to mem::forget
4016        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4017        // Prevent Drop from running (which would shut down the channel)
4018        std::mem::forget(self);
4019    }
4020}
4021
4022impl PeerControllerGetKnownPeersResponder {
4023    /// Sends a response to the FIDL transaction.
4024    ///
4025    /// Sets the channel to shutdown if an error occurs.
4026    pub fn send(
4027        self,
4028        mut result: Result<&PeerControllerGetKnownPeersResponse, Error>,
4029    ) -> Result<(), fidl::Error> {
4030        let _result = self.send_raw(result);
4031        if _result.is_err() {
4032            self.control_handle.shutdown();
4033        }
4034        self.drop_without_shutdown();
4035        _result
4036    }
4037
4038    /// Similar to "send" but does not shutdown the channel if an error occurs.
4039    pub fn send_no_shutdown_on_err(
4040        self,
4041        mut result: Result<&PeerControllerGetKnownPeersResponse, Error>,
4042    ) -> Result<(), fidl::Error> {
4043        let _result = self.send_raw(result);
4044        self.drop_without_shutdown();
4045        _result
4046    }
4047
4048    fn send_raw(
4049        &self,
4050        mut result: Result<&PeerControllerGetKnownPeersResponse, Error>,
4051    ) -> Result<(), fidl::Error> {
4052        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4053            PeerControllerGetKnownPeersResponse,
4054            Error,
4055        >>(
4056            fidl::encoding::FlexibleResult::new(result),
4057            self.tx_id,
4058            0x482cf3745bab65f6,
4059            fidl::encoding::DynamicFlags::FLEXIBLE,
4060        )
4061    }
4062}
4063
4064#[must_use = "FIDL methods require a response to be sent"]
4065#[derive(Debug)]
4066pub struct PeerControllerConnectPeerResponder {
4067    control_handle: std::mem::ManuallyDrop<PeerControllerControlHandle>,
4068    tx_id: u32,
4069}
4070
4071/// Set the the channel to be shutdown (see [`PeerControllerControlHandle::shutdown`])
4072/// if the responder is dropped without sending a response, so that the client
4073/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4074impl std::ops::Drop for PeerControllerConnectPeerResponder {
4075    fn drop(&mut self) {
4076        self.control_handle.shutdown();
4077        // Safety: drops once, never accessed again
4078        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4079    }
4080}
4081
4082impl fidl::endpoints::Responder for PeerControllerConnectPeerResponder {
4083    type ControlHandle = PeerControllerControlHandle;
4084
4085    fn control_handle(&self) -> &PeerControllerControlHandle {
4086        &self.control_handle
4087    }
4088
4089    fn drop_without_shutdown(mut self) {
4090        // Safety: drops once, never accessed again due to mem::forget
4091        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4092        // Prevent Drop from running (which would shut down the channel)
4093        std::mem::forget(self);
4094    }
4095}
4096
4097impl PeerControllerConnectPeerResponder {
4098    /// Sends a response to the FIDL transaction.
4099    ///
4100    /// Sets the channel to shutdown if an error occurs.
4101    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4102        let _result = self.send_raw(result);
4103        if _result.is_err() {
4104            self.control_handle.shutdown();
4105        }
4106        self.drop_without_shutdown();
4107        _result
4108    }
4109
4110    /// Similar to "send" but does not shutdown the channel if an error occurs.
4111    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4112        let _result = self.send_raw(result);
4113        self.drop_without_shutdown();
4114        _result
4115    }
4116
4117    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4118        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4119            fidl::encoding::EmptyStruct,
4120            Error,
4121        >>(
4122            fidl::encoding::FlexibleResult::new(result),
4123            self.tx_id,
4124            0x13fbb990835acf66,
4125            fidl::encoding::DynamicFlags::FLEXIBLE,
4126        )
4127    }
4128}
4129
4130#[must_use = "FIDL methods require a response to be sent"]
4131#[derive(Debug)]
4132pub struct PeerControllerDisconnectPeerResponder {
4133    control_handle: std::mem::ManuallyDrop<PeerControllerControlHandle>,
4134    tx_id: u32,
4135}
4136
4137/// Set the the channel to be shutdown (see [`PeerControllerControlHandle::shutdown`])
4138/// if the responder is dropped without sending a response, so that the client
4139/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4140impl std::ops::Drop for PeerControllerDisconnectPeerResponder {
4141    fn drop(&mut self) {
4142        self.control_handle.shutdown();
4143        // Safety: drops once, never accessed again
4144        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4145    }
4146}
4147
4148impl fidl::endpoints::Responder for PeerControllerDisconnectPeerResponder {
4149    type ControlHandle = PeerControllerControlHandle;
4150
4151    fn control_handle(&self) -> &PeerControllerControlHandle {
4152        &self.control_handle
4153    }
4154
4155    fn drop_without_shutdown(mut self) {
4156        // Safety: drops once, never accessed again due to mem::forget
4157        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4158        // Prevent Drop from running (which would shut down the channel)
4159        std::mem::forget(self);
4160    }
4161}
4162
4163impl PeerControllerDisconnectPeerResponder {
4164    /// Sends a response to the FIDL transaction.
4165    ///
4166    /// Sets the channel to shutdown if an error occurs.
4167    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4168        let _result = self.send_raw(result);
4169        if _result.is_err() {
4170            self.control_handle.shutdown();
4171        }
4172        self.drop_without_shutdown();
4173        _result
4174    }
4175
4176    /// Similar to "send" but does not shutdown the channel if an error occurs.
4177    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4178        let _result = self.send_raw(result);
4179        self.drop_without_shutdown();
4180        _result
4181    }
4182
4183    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4184        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4185            fidl::encoding::EmptyStruct,
4186            Error,
4187        >>(
4188            fidl::encoding::FlexibleResult::new(result),
4189            self.tx_id,
4190            0x5f9992f066c664ad,
4191            fidl::encoding::DynamicFlags::FLEXIBLE,
4192        )
4193    }
4194}
4195
4196#[must_use = "FIDL methods require a response to be sent"]
4197#[derive(Debug)]
4198pub struct PeerControllerPairResponder {
4199    control_handle: std::mem::ManuallyDrop<PeerControllerControlHandle>,
4200    tx_id: u32,
4201}
4202
4203/// Set the the channel to be shutdown (see [`PeerControllerControlHandle::shutdown`])
4204/// if the responder is dropped without sending a response, so that the client
4205/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4206impl std::ops::Drop for PeerControllerPairResponder {
4207    fn drop(&mut self) {
4208        self.control_handle.shutdown();
4209        // Safety: drops once, never accessed again
4210        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4211    }
4212}
4213
4214impl fidl::endpoints::Responder for PeerControllerPairResponder {
4215    type ControlHandle = PeerControllerControlHandle;
4216
4217    fn control_handle(&self) -> &PeerControllerControlHandle {
4218        &self.control_handle
4219    }
4220
4221    fn drop_without_shutdown(mut self) {
4222        // Safety: drops once, never accessed again due to mem::forget
4223        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4224        // Prevent Drop from running (which would shut down the channel)
4225        std::mem::forget(self);
4226    }
4227}
4228
4229impl PeerControllerPairResponder {
4230    /// Sends a response to the FIDL transaction.
4231    ///
4232    /// Sets the channel to shutdown if an error occurs.
4233    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4234        let _result = self.send_raw(result);
4235        if _result.is_err() {
4236            self.control_handle.shutdown();
4237        }
4238        self.drop_without_shutdown();
4239        _result
4240    }
4241
4242    /// Similar to "send" but does not shutdown the channel if an error occurs.
4243    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4244        let _result = self.send_raw(result);
4245        self.drop_without_shutdown();
4246        _result
4247    }
4248
4249    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4250        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4251            fidl::encoding::EmptyStruct,
4252            Error,
4253        >>(
4254            fidl::encoding::FlexibleResult::new(result),
4255            self.tx_id,
4256            0x1991671d4d7eff26,
4257            fidl::encoding::DynamicFlags::FLEXIBLE,
4258        )
4259    }
4260}
4261
4262#[must_use = "FIDL methods require a response to be sent"]
4263#[derive(Debug)]
4264pub struct PeerControllerForgetPeerResponder {
4265    control_handle: std::mem::ManuallyDrop<PeerControllerControlHandle>,
4266    tx_id: u32,
4267}
4268
4269/// Set the the channel to be shutdown (see [`PeerControllerControlHandle::shutdown`])
4270/// if the responder is dropped without sending a response, so that the client
4271/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4272impl std::ops::Drop for PeerControllerForgetPeerResponder {
4273    fn drop(&mut self) {
4274        self.control_handle.shutdown();
4275        // Safety: drops once, never accessed again
4276        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4277    }
4278}
4279
4280impl fidl::endpoints::Responder for PeerControllerForgetPeerResponder {
4281    type ControlHandle = PeerControllerControlHandle;
4282
4283    fn control_handle(&self) -> &PeerControllerControlHandle {
4284        &self.control_handle
4285    }
4286
4287    fn drop_without_shutdown(mut self) {
4288        // Safety: drops once, never accessed again due to mem::forget
4289        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4290        // Prevent Drop from running (which would shut down the channel)
4291        std::mem::forget(self);
4292    }
4293}
4294
4295impl PeerControllerForgetPeerResponder {
4296    /// Sends a response to the FIDL transaction.
4297    ///
4298    /// Sets the channel to shutdown if an error occurs.
4299    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4300        let _result = self.send_raw(result);
4301        if _result.is_err() {
4302            self.control_handle.shutdown();
4303        }
4304        self.drop_without_shutdown();
4305        _result
4306    }
4307
4308    /// Similar to "send" but does not shutdown the channel if an error occurs.
4309    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4310        let _result = self.send_raw(result);
4311        self.drop_without_shutdown();
4312        _result
4313    }
4314
4315    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4316        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4317            fidl::encoding::EmptyStruct,
4318            Error,
4319        >>(
4320            fidl::encoding::FlexibleResult::new(result),
4321            self.tx_id,
4322            0x26011dbbd834f8c6,
4323            fidl::encoding::DynamicFlags::FLEXIBLE,
4324        )
4325    }
4326}
4327
4328#[must_use = "FIDL methods require a response to be sent"]
4329#[derive(Debug)]
4330pub struct PeerControllerSetDiscoveryResponder {
4331    control_handle: std::mem::ManuallyDrop<PeerControllerControlHandle>,
4332    tx_id: u32,
4333}
4334
4335/// Set the the channel to be shutdown (see [`PeerControllerControlHandle::shutdown`])
4336/// if the responder is dropped without sending a response, so that the client
4337/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4338impl std::ops::Drop for PeerControllerSetDiscoveryResponder {
4339    fn drop(&mut self) {
4340        self.control_handle.shutdown();
4341        // Safety: drops once, never accessed again
4342        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4343    }
4344}
4345
4346impl fidl::endpoints::Responder for PeerControllerSetDiscoveryResponder {
4347    type ControlHandle = PeerControllerControlHandle;
4348
4349    fn control_handle(&self) -> &PeerControllerControlHandle {
4350        &self.control_handle
4351    }
4352
4353    fn drop_without_shutdown(mut self) {
4354        // Safety: drops once, never accessed again due to mem::forget
4355        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4356        // Prevent Drop from running (which would shut down the channel)
4357        std::mem::forget(self);
4358    }
4359}
4360
4361impl PeerControllerSetDiscoveryResponder {
4362    /// Sends a response to the FIDL transaction.
4363    ///
4364    /// Sets the channel to shutdown if an error occurs.
4365    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4366        let _result = self.send_raw(result);
4367        if _result.is_err() {
4368            self.control_handle.shutdown();
4369        }
4370        self.drop_without_shutdown();
4371        _result
4372    }
4373
4374    /// Similar to "send" but does not shutdown the channel if an error occurs.
4375    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4376        let _result = self.send_raw(result);
4377        self.drop_without_shutdown();
4378        _result
4379    }
4380
4381    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4382        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4383            fidl::encoding::EmptyStruct,
4384            Error,
4385        >>(
4386            fidl::encoding::FlexibleResult::new(result),
4387            self.tx_id,
4388            0x3269624c9e1d6ab3,
4389            fidl::encoding::DynamicFlags::FLEXIBLE,
4390        )
4391    }
4392}
4393
4394#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4395pub struct PeripheralControllerMarker;
4396
4397impl fidl::endpoints::ProtocolMarker for PeripheralControllerMarker {
4398    type Proxy = PeripheralControllerProxy;
4399    type RequestStream = PeripheralControllerRequestStream;
4400    #[cfg(target_os = "fuchsia")]
4401    type SynchronousProxy = PeripheralControllerSynchronousProxy;
4402
4403    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.affordances.PeripheralController";
4404}
4405impl fidl::endpoints::DiscoverableProtocolMarker for PeripheralControllerMarker {}
4406pub type PeripheralControllerAdvertiseResult = Result<PeripheralControllerAdvertiseResponse, Error>;
4407
4408pub trait PeripheralControllerProxyInterface: Send + Sync {
4409    type AdvertiseResponseFut: std::future::Future<Output = Result<PeripheralControllerAdvertiseResult, fidl::Error>>
4410        + Send;
4411    fn r#advertise(
4412        &self,
4413        payload: &PeripheralControllerAdvertiseRequest,
4414    ) -> Self::AdvertiseResponseFut;
4415}
4416#[derive(Debug)]
4417#[cfg(target_os = "fuchsia")]
4418pub struct PeripheralControllerSynchronousProxy {
4419    client: fidl::client::sync::Client,
4420}
4421
4422#[cfg(target_os = "fuchsia")]
4423impl fidl::endpoints::SynchronousProxy for PeripheralControllerSynchronousProxy {
4424    type Proxy = PeripheralControllerProxy;
4425    type Protocol = PeripheralControllerMarker;
4426
4427    fn from_channel(inner: fidl::Channel) -> Self {
4428        Self::new(inner)
4429    }
4430
4431    fn into_channel(self) -> fidl::Channel {
4432        self.client.into_channel()
4433    }
4434
4435    fn as_channel(&self) -> &fidl::Channel {
4436        self.client.as_channel()
4437    }
4438}
4439
4440#[cfg(target_os = "fuchsia")]
4441impl PeripheralControllerSynchronousProxy {
4442    pub fn new(channel: fidl::Channel) -> Self {
4443        Self { client: fidl::client::sync::Client::new(channel) }
4444    }
4445
4446    pub fn into_channel(self) -> fidl::Channel {
4447        self.client.into_channel()
4448    }
4449
4450    /// Waits until an event arrives and returns it. It is safe for other
4451    /// threads to make concurrent requests while waiting for an event.
4452    pub fn wait_for_event(
4453        &self,
4454        deadline: zx::MonotonicInstant,
4455    ) -> Result<PeripheralControllerEvent, fidl::Error> {
4456        PeripheralControllerEvent::decode(
4457            self.client.wait_for_event::<PeripheralControllerMarker>(deadline)?,
4458        )
4459    }
4460
4461    /// Start advertising.
4462    ///
4463    /// * error Returns `INTERNAL` if the operation failed (check logs).
4464    /// * error Returns `TIMEOUT` if the advertisement timed out without a connection.
4465    /// * error Returns `MISSING_PARAMETERS` if `parameters` or `timeout` is missing.
4466    pub fn r#advertise(
4467        &self,
4468        mut payload: &PeripheralControllerAdvertiseRequest,
4469        ___deadline: zx::MonotonicInstant,
4470    ) -> Result<PeripheralControllerAdvertiseResult, fidl::Error> {
4471        let _response = self.client.send_query::<
4472            PeripheralControllerAdvertiseRequest,
4473            fidl::encoding::FlexibleResultType<PeripheralControllerAdvertiseResponse, Error>,
4474            PeripheralControllerMarker,
4475        >(
4476            payload,
4477            0x59079a81362a66f3,
4478            fidl::encoding::DynamicFlags::FLEXIBLE,
4479            ___deadline,
4480        )?
4481        .into_result::<PeripheralControllerMarker>("advertise")?;
4482        Ok(_response.map(|x| x))
4483    }
4484}
4485
4486#[cfg(target_os = "fuchsia")]
4487impl From<PeripheralControllerSynchronousProxy> for zx::NullableHandle {
4488    fn from(value: PeripheralControllerSynchronousProxy) -> Self {
4489        value.into_channel().into()
4490    }
4491}
4492
4493#[cfg(target_os = "fuchsia")]
4494impl From<fidl::Channel> for PeripheralControllerSynchronousProxy {
4495    fn from(value: fidl::Channel) -> Self {
4496        Self::new(value)
4497    }
4498}
4499
4500#[cfg(target_os = "fuchsia")]
4501impl fidl::endpoints::FromClient for PeripheralControllerSynchronousProxy {
4502    type Protocol = PeripheralControllerMarker;
4503
4504    fn from_client(value: fidl::endpoints::ClientEnd<PeripheralControllerMarker>) -> Self {
4505        Self::new(value.into_channel())
4506    }
4507}
4508
4509#[derive(Debug, Clone)]
4510pub struct PeripheralControllerProxy {
4511    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4512}
4513
4514impl fidl::endpoints::Proxy for PeripheralControllerProxy {
4515    type Protocol = PeripheralControllerMarker;
4516
4517    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4518        Self::new(inner)
4519    }
4520
4521    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4522        self.client.into_channel().map_err(|client| Self { client })
4523    }
4524
4525    fn as_channel(&self) -> &::fidl::AsyncChannel {
4526        self.client.as_channel()
4527    }
4528}
4529
4530impl PeripheralControllerProxy {
4531    /// Create a new Proxy for fuchsia.bluetooth.affordances/PeripheralController.
4532    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4533        let protocol_name =
4534            <PeripheralControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4535        Self { client: fidl::client::Client::new(channel, protocol_name) }
4536    }
4537
4538    /// Get a Stream of events from the remote end of the protocol.
4539    ///
4540    /// # Panics
4541    ///
4542    /// Panics if the event stream was already taken.
4543    pub fn take_event_stream(&self) -> PeripheralControllerEventStream {
4544        PeripheralControllerEventStream { event_receiver: self.client.take_event_receiver() }
4545    }
4546
4547    /// Start advertising.
4548    ///
4549    /// * error Returns `INTERNAL` if the operation failed (check logs).
4550    /// * error Returns `TIMEOUT` if the advertisement timed out without a connection.
4551    /// * error Returns `MISSING_PARAMETERS` if `parameters` or `timeout` is missing.
4552    pub fn r#advertise(
4553        &self,
4554        mut payload: &PeripheralControllerAdvertiseRequest,
4555    ) -> fidl::client::QueryResponseFut<
4556        PeripheralControllerAdvertiseResult,
4557        fidl::encoding::DefaultFuchsiaResourceDialect,
4558    > {
4559        PeripheralControllerProxyInterface::r#advertise(self, payload)
4560    }
4561}
4562
4563impl PeripheralControllerProxyInterface for PeripheralControllerProxy {
4564    type AdvertiseResponseFut = fidl::client::QueryResponseFut<
4565        PeripheralControllerAdvertiseResult,
4566        fidl::encoding::DefaultFuchsiaResourceDialect,
4567    >;
4568    fn r#advertise(
4569        &self,
4570        mut payload: &PeripheralControllerAdvertiseRequest,
4571    ) -> Self::AdvertiseResponseFut {
4572        fn _decode(
4573            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4574        ) -> Result<PeripheralControllerAdvertiseResult, fidl::Error> {
4575            let _response = fidl::client::decode_transaction_body::<
4576                fidl::encoding::FlexibleResultType<PeripheralControllerAdvertiseResponse, Error>,
4577                fidl::encoding::DefaultFuchsiaResourceDialect,
4578                0x59079a81362a66f3,
4579            >(_buf?)?
4580            .into_result::<PeripheralControllerMarker>("advertise")?;
4581            Ok(_response.map(|x| x))
4582        }
4583        self.client.send_query_and_decode::<
4584            PeripheralControllerAdvertiseRequest,
4585            PeripheralControllerAdvertiseResult,
4586        >(
4587            payload,
4588            0x59079a81362a66f3,
4589            fidl::encoding::DynamicFlags::FLEXIBLE,
4590            _decode,
4591        )
4592    }
4593}
4594
4595pub struct PeripheralControllerEventStream {
4596    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4597}
4598
4599impl std::marker::Unpin for PeripheralControllerEventStream {}
4600
4601impl futures::stream::FusedStream for PeripheralControllerEventStream {
4602    fn is_terminated(&self) -> bool {
4603        self.event_receiver.is_terminated()
4604    }
4605}
4606
4607impl futures::Stream for PeripheralControllerEventStream {
4608    type Item = Result<PeripheralControllerEvent, fidl::Error>;
4609
4610    fn poll_next(
4611        mut self: std::pin::Pin<&mut Self>,
4612        cx: &mut std::task::Context<'_>,
4613    ) -> std::task::Poll<Option<Self::Item>> {
4614        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4615            &mut self.event_receiver,
4616            cx
4617        )?) {
4618            Some(buf) => std::task::Poll::Ready(Some(PeripheralControllerEvent::decode(buf))),
4619            None => std::task::Poll::Ready(None),
4620        }
4621    }
4622}
4623
4624#[derive(Debug)]
4625pub enum PeripheralControllerEvent {
4626    #[non_exhaustive]
4627    _UnknownEvent {
4628        /// Ordinal of the event that was sent.
4629        ordinal: u64,
4630    },
4631}
4632
4633impl PeripheralControllerEvent {
4634    /// Decodes a message buffer as a [`PeripheralControllerEvent`].
4635    fn decode(
4636        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4637    ) -> Result<PeripheralControllerEvent, fidl::Error> {
4638        let (bytes, _handles) = buf.split_mut();
4639        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4640        debug_assert_eq!(tx_header.tx_id, 0);
4641        match tx_header.ordinal {
4642            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4643                Ok(PeripheralControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4644            }
4645            _ => Err(fidl::Error::UnknownOrdinal {
4646                ordinal: tx_header.ordinal,
4647                protocol_name:
4648                    <PeripheralControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4649            }),
4650        }
4651    }
4652}
4653
4654/// A Stream of incoming requests for fuchsia.bluetooth.affordances/PeripheralController.
4655pub struct PeripheralControllerRequestStream {
4656    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4657    is_terminated: bool,
4658}
4659
4660impl std::marker::Unpin for PeripheralControllerRequestStream {}
4661
4662impl futures::stream::FusedStream for PeripheralControllerRequestStream {
4663    fn is_terminated(&self) -> bool {
4664        self.is_terminated
4665    }
4666}
4667
4668impl fidl::endpoints::RequestStream for PeripheralControllerRequestStream {
4669    type Protocol = PeripheralControllerMarker;
4670    type ControlHandle = PeripheralControllerControlHandle;
4671
4672    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4673        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4674    }
4675
4676    fn control_handle(&self) -> Self::ControlHandle {
4677        PeripheralControllerControlHandle { inner: self.inner.clone() }
4678    }
4679
4680    fn into_inner(
4681        self,
4682    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4683    {
4684        (self.inner, self.is_terminated)
4685    }
4686
4687    fn from_inner(
4688        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4689        is_terminated: bool,
4690    ) -> Self {
4691        Self { inner, is_terminated }
4692    }
4693}
4694
4695impl futures::Stream for PeripheralControllerRequestStream {
4696    type Item = Result<PeripheralControllerRequest, fidl::Error>;
4697
4698    fn poll_next(
4699        mut self: std::pin::Pin<&mut Self>,
4700        cx: &mut std::task::Context<'_>,
4701    ) -> std::task::Poll<Option<Self::Item>> {
4702        let this = &mut *self;
4703        if this.inner.check_shutdown(cx) {
4704            this.is_terminated = true;
4705            return std::task::Poll::Ready(None);
4706        }
4707        if this.is_terminated {
4708            panic!("polled PeripheralControllerRequestStream after completion");
4709        }
4710        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4711            |bytes, handles| {
4712                match this.inner.channel().read_etc(cx, bytes, handles) {
4713                    std::task::Poll::Ready(Ok(())) => {}
4714                    std::task::Poll::Pending => return std::task::Poll::Pending,
4715                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4716                        this.is_terminated = true;
4717                        return std::task::Poll::Ready(None);
4718                    }
4719                    std::task::Poll::Ready(Err(e)) => {
4720                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4721                            e.into(),
4722                        ))));
4723                    }
4724                }
4725
4726                // A message has been received from the channel
4727                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4728
4729                std::task::Poll::Ready(Some(match header.ordinal {
4730                0x59079a81362a66f3 => {
4731                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4732                    let mut req = fidl::new_empty!(PeripheralControllerAdvertiseRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
4733                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralControllerAdvertiseRequest>(&header, _body_bytes, handles, &mut req)?;
4734                    let control_handle = PeripheralControllerControlHandle {
4735                        inner: this.inner.clone(),
4736                    };
4737                    Ok(PeripheralControllerRequest::Advertise {payload: req,
4738                        responder: PeripheralControllerAdvertiseResponder {
4739                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4740                            tx_id: header.tx_id,
4741                        },
4742                    })
4743                }
4744                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4745                    Ok(PeripheralControllerRequest::_UnknownMethod {
4746                        ordinal: header.ordinal,
4747                        control_handle: PeripheralControllerControlHandle { inner: this.inner.clone() },
4748                        method_type: fidl::MethodType::OneWay,
4749                    })
4750                }
4751                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4752                    this.inner.send_framework_err(
4753                        fidl::encoding::FrameworkErr::UnknownMethod,
4754                        header.tx_id,
4755                        header.ordinal,
4756                        header.dynamic_flags(),
4757                        (bytes, handles),
4758                    )?;
4759                    Ok(PeripheralControllerRequest::_UnknownMethod {
4760                        ordinal: header.ordinal,
4761                        control_handle: PeripheralControllerControlHandle { inner: this.inner.clone() },
4762                        method_type: fidl::MethodType::TwoWay,
4763                    })
4764                }
4765                _ => Err(fidl::Error::UnknownOrdinal {
4766                    ordinal: header.ordinal,
4767                    protocol_name: <PeripheralControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4768                }),
4769            }))
4770            },
4771        )
4772    }
4773}
4774
4775#[derive(Debug)]
4776pub enum PeripheralControllerRequest {
4777    /// Start advertising.
4778    ///
4779    /// * error Returns `INTERNAL` if the operation failed (check logs).
4780    /// * error Returns `TIMEOUT` if the advertisement timed out without a connection.
4781    /// * error Returns `MISSING_PARAMETERS` if `parameters` or `timeout` is missing.
4782    Advertise {
4783        payload: PeripheralControllerAdvertiseRequest,
4784        responder: PeripheralControllerAdvertiseResponder,
4785    },
4786    /// An interaction was received which does not match any known method.
4787    #[non_exhaustive]
4788    _UnknownMethod {
4789        /// Ordinal of the method that was called.
4790        ordinal: u64,
4791        control_handle: PeripheralControllerControlHandle,
4792        method_type: fidl::MethodType,
4793    },
4794}
4795
4796impl PeripheralControllerRequest {
4797    #[allow(irrefutable_let_patterns)]
4798    pub fn into_advertise(
4799        self,
4800    ) -> Option<(PeripheralControllerAdvertiseRequest, PeripheralControllerAdvertiseResponder)>
4801    {
4802        if let PeripheralControllerRequest::Advertise { payload, responder } = self {
4803            Some((payload, responder))
4804        } else {
4805            None
4806        }
4807    }
4808
4809    /// Name of the method defined in FIDL
4810    pub fn method_name(&self) -> &'static str {
4811        match *self {
4812            PeripheralControllerRequest::Advertise { .. } => "advertise",
4813            PeripheralControllerRequest::_UnknownMethod {
4814                method_type: fidl::MethodType::OneWay,
4815                ..
4816            } => "unknown one-way method",
4817            PeripheralControllerRequest::_UnknownMethod {
4818                method_type: fidl::MethodType::TwoWay,
4819                ..
4820            } => "unknown two-way method",
4821        }
4822    }
4823}
4824
4825#[derive(Debug, Clone)]
4826pub struct PeripheralControllerControlHandle {
4827    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4828}
4829
4830impl fidl::endpoints::ControlHandle for PeripheralControllerControlHandle {
4831    fn shutdown(&self) {
4832        self.inner.shutdown()
4833    }
4834
4835    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4836        self.inner.shutdown_with_epitaph(status)
4837    }
4838
4839    fn is_closed(&self) -> bool {
4840        self.inner.channel().is_closed()
4841    }
4842    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4843        self.inner.channel().on_closed()
4844    }
4845
4846    #[cfg(target_os = "fuchsia")]
4847    fn signal_peer(
4848        &self,
4849        clear_mask: zx::Signals,
4850        set_mask: zx::Signals,
4851    ) -> Result<(), zx_status::Status> {
4852        use fidl::Peered;
4853        self.inner.channel().signal_peer(clear_mask, set_mask)
4854    }
4855}
4856
4857impl PeripheralControllerControlHandle {}
4858
4859#[must_use = "FIDL methods require a response to be sent"]
4860#[derive(Debug)]
4861pub struct PeripheralControllerAdvertiseResponder {
4862    control_handle: std::mem::ManuallyDrop<PeripheralControllerControlHandle>,
4863    tx_id: u32,
4864}
4865
4866/// Set the the channel to be shutdown (see [`PeripheralControllerControlHandle::shutdown`])
4867/// if the responder is dropped without sending a response, so that the client
4868/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4869impl std::ops::Drop for PeripheralControllerAdvertiseResponder {
4870    fn drop(&mut self) {
4871        self.control_handle.shutdown();
4872        // Safety: drops once, never accessed again
4873        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4874    }
4875}
4876
4877impl fidl::endpoints::Responder for PeripheralControllerAdvertiseResponder {
4878    type ControlHandle = PeripheralControllerControlHandle;
4879
4880    fn control_handle(&self) -> &PeripheralControllerControlHandle {
4881        &self.control_handle
4882    }
4883
4884    fn drop_without_shutdown(mut self) {
4885        // Safety: drops once, never accessed again due to mem::forget
4886        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4887        // Prevent Drop from running (which would shut down the channel)
4888        std::mem::forget(self);
4889    }
4890}
4891
4892impl PeripheralControllerAdvertiseResponder {
4893    /// Sends a response to the FIDL transaction.
4894    ///
4895    /// Sets the channel to shutdown if an error occurs.
4896    pub fn send(
4897        self,
4898        mut result: Result<&PeripheralControllerAdvertiseResponse, Error>,
4899    ) -> Result<(), fidl::Error> {
4900        let _result = self.send_raw(result);
4901        if _result.is_err() {
4902            self.control_handle.shutdown();
4903        }
4904        self.drop_without_shutdown();
4905        _result
4906    }
4907
4908    /// Similar to "send" but does not shutdown the channel if an error occurs.
4909    pub fn send_no_shutdown_on_err(
4910        self,
4911        mut result: Result<&PeripheralControllerAdvertiseResponse, Error>,
4912    ) -> Result<(), fidl::Error> {
4913        let _result = self.send_raw(result);
4914        self.drop_without_shutdown();
4915        _result
4916    }
4917
4918    fn send_raw(
4919        &self,
4920        mut result: Result<&PeripheralControllerAdvertiseResponse, Error>,
4921    ) -> Result<(), fidl::Error> {
4922        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4923            PeripheralControllerAdvertiseResponse,
4924            Error,
4925        >>(
4926            fidl::encoding::FlexibleResult::new(result),
4927            self.tx_id,
4928            0x59079a81362a66f3,
4929            fidl::encoding::DynamicFlags::FLEXIBLE,
4930        )
4931    }
4932}
4933
4934#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4935pub struct ScanResultListenerMarker;
4936
4937impl fidl::endpoints::ProtocolMarker for ScanResultListenerMarker {
4938    type Proxy = ScanResultListenerProxy;
4939    type RequestStream = ScanResultListenerRequestStream;
4940    #[cfg(target_os = "fuchsia")]
4941    type SynchronousProxy = ScanResultListenerSynchronousProxy;
4942
4943    const DEBUG_NAME: &'static str = "(anonymous) ScanResultListener";
4944}
4945
4946pub trait ScanResultListenerProxyInterface: Send + Sync {
4947    type OnPeersDiscoveredResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4948    fn r#on_peers_discovered(
4949        &self,
4950        payload: &ScanResultListenerOnPeersDiscoveredRequest,
4951    ) -> Self::OnPeersDiscoveredResponseFut;
4952}
4953#[derive(Debug)]
4954#[cfg(target_os = "fuchsia")]
4955pub struct ScanResultListenerSynchronousProxy {
4956    client: fidl::client::sync::Client,
4957}
4958
4959#[cfg(target_os = "fuchsia")]
4960impl fidl::endpoints::SynchronousProxy for ScanResultListenerSynchronousProxy {
4961    type Proxy = ScanResultListenerProxy;
4962    type Protocol = ScanResultListenerMarker;
4963
4964    fn from_channel(inner: fidl::Channel) -> Self {
4965        Self::new(inner)
4966    }
4967
4968    fn into_channel(self) -> fidl::Channel {
4969        self.client.into_channel()
4970    }
4971
4972    fn as_channel(&self) -> &fidl::Channel {
4973        self.client.as_channel()
4974    }
4975}
4976
4977#[cfg(target_os = "fuchsia")]
4978impl ScanResultListenerSynchronousProxy {
4979    pub fn new(channel: fidl::Channel) -> Self {
4980        Self { client: fidl::client::sync::Client::new(channel) }
4981    }
4982
4983    pub fn into_channel(self) -> fidl::Channel {
4984        self.client.into_channel()
4985    }
4986
4987    /// Waits until an event arrives and returns it. It is safe for other
4988    /// threads to make concurrent requests while waiting for an event.
4989    pub fn wait_for_event(
4990        &self,
4991        deadline: zx::MonotonicInstant,
4992    ) -> Result<ScanResultListenerEvent, fidl::Error> {
4993        ScanResultListenerEvent::decode(
4994            self.client.wait_for_event::<ScanResultListenerMarker>(deadline)?,
4995        )
4996    }
4997
4998    /// Called by the server when peers are discovered.
4999    pub fn r#on_peers_discovered(
5000        &self,
5001        mut payload: &ScanResultListenerOnPeersDiscoveredRequest,
5002        ___deadline: zx::MonotonicInstant,
5003    ) -> Result<(), fidl::Error> {
5004        let _response = self.client.send_query::<
5005            ScanResultListenerOnPeersDiscoveredRequest,
5006            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
5007            ScanResultListenerMarker,
5008        >(
5009            payload,
5010            0x111ea99f3f0c8009,
5011            fidl::encoding::DynamicFlags::FLEXIBLE,
5012            ___deadline,
5013        )?
5014        .into_result::<ScanResultListenerMarker>("on_peers_discovered")?;
5015        Ok(_response)
5016    }
5017}
5018
5019#[cfg(target_os = "fuchsia")]
5020impl From<ScanResultListenerSynchronousProxy> for zx::NullableHandle {
5021    fn from(value: ScanResultListenerSynchronousProxy) -> Self {
5022        value.into_channel().into()
5023    }
5024}
5025
5026#[cfg(target_os = "fuchsia")]
5027impl From<fidl::Channel> for ScanResultListenerSynchronousProxy {
5028    fn from(value: fidl::Channel) -> Self {
5029        Self::new(value)
5030    }
5031}
5032
5033#[cfg(target_os = "fuchsia")]
5034impl fidl::endpoints::FromClient for ScanResultListenerSynchronousProxy {
5035    type Protocol = ScanResultListenerMarker;
5036
5037    fn from_client(value: fidl::endpoints::ClientEnd<ScanResultListenerMarker>) -> Self {
5038        Self::new(value.into_channel())
5039    }
5040}
5041
5042#[derive(Debug, Clone)]
5043pub struct ScanResultListenerProxy {
5044    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5045}
5046
5047impl fidl::endpoints::Proxy for ScanResultListenerProxy {
5048    type Protocol = ScanResultListenerMarker;
5049
5050    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5051        Self::new(inner)
5052    }
5053
5054    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5055        self.client.into_channel().map_err(|client| Self { client })
5056    }
5057
5058    fn as_channel(&self) -> &::fidl::AsyncChannel {
5059        self.client.as_channel()
5060    }
5061}
5062
5063impl ScanResultListenerProxy {
5064    /// Create a new Proxy for fuchsia.bluetooth.affordances/ScanResultListener.
5065    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5066        let protocol_name =
5067            <ScanResultListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5068        Self { client: fidl::client::Client::new(channel, protocol_name) }
5069    }
5070
5071    /// Get a Stream of events from the remote end of the protocol.
5072    ///
5073    /// # Panics
5074    ///
5075    /// Panics if the event stream was already taken.
5076    pub fn take_event_stream(&self) -> ScanResultListenerEventStream {
5077        ScanResultListenerEventStream { event_receiver: self.client.take_event_receiver() }
5078    }
5079
5080    /// Called by the server when peers are discovered.
5081    pub fn r#on_peers_discovered(
5082        &self,
5083        mut payload: &ScanResultListenerOnPeersDiscoveredRequest,
5084    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5085        ScanResultListenerProxyInterface::r#on_peers_discovered(self, payload)
5086    }
5087}
5088
5089impl ScanResultListenerProxyInterface for ScanResultListenerProxy {
5090    type OnPeersDiscoveredResponseFut =
5091        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5092    fn r#on_peers_discovered(
5093        &self,
5094        mut payload: &ScanResultListenerOnPeersDiscoveredRequest,
5095    ) -> Self::OnPeersDiscoveredResponseFut {
5096        fn _decode(
5097            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5098        ) -> Result<(), fidl::Error> {
5099            let _response = fidl::client::decode_transaction_body::<
5100                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
5101                fidl::encoding::DefaultFuchsiaResourceDialect,
5102                0x111ea99f3f0c8009,
5103            >(_buf?)?
5104            .into_result::<ScanResultListenerMarker>("on_peers_discovered")?;
5105            Ok(_response)
5106        }
5107        self.client.send_query_and_decode::<ScanResultListenerOnPeersDiscoveredRequest, ()>(
5108            payload,
5109            0x111ea99f3f0c8009,
5110            fidl::encoding::DynamicFlags::FLEXIBLE,
5111            _decode,
5112        )
5113    }
5114}
5115
5116pub struct ScanResultListenerEventStream {
5117    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5118}
5119
5120impl std::marker::Unpin for ScanResultListenerEventStream {}
5121
5122impl futures::stream::FusedStream for ScanResultListenerEventStream {
5123    fn is_terminated(&self) -> bool {
5124        self.event_receiver.is_terminated()
5125    }
5126}
5127
5128impl futures::Stream for ScanResultListenerEventStream {
5129    type Item = Result<ScanResultListenerEvent, fidl::Error>;
5130
5131    fn poll_next(
5132        mut self: std::pin::Pin<&mut Self>,
5133        cx: &mut std::task::Context<'_>,
5134    ) -> std::task::Poll<Option<Self::Item>> {
5135        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5136            &mut self.event_receiver,
5137            cx
5138        )?) {
5139            Some(buf) => std::task::Poll::Ready(Some(ScanResultListenerEvent::decode(buf))),
5140            None => std::task::Poll::Ready(None),
5141        }
5142    }
5143}
5144
5145#[derive(Debug)]
5146pub enum ScanResultListenerEvent {
5147    #[non_exhaustive]
5148    _UnknownEvent {
5149        /// Ordinal of the event that was sent.
5150        ordinal: u64,
5151    },
5152}
5153
5154impl ScanResultListenerEvent {
5155    /// Decodes a message buffer as a [`ScanResultListenerEvent`].
5156    fn decode(
5157        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5158    ) -> Result<ScanResultListenerEvent, fidl::Error> {
5159        let (bytes, _handles) = buf.split_mut();
5160        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5161        debug_assert_eq!(tx_header.tx_id, 0);
5162        match tx_header.ordinal {
5163            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5164                Ok(ScanResultListenerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5165            }
5166            _ => Err(fidl::Error::UnknownOrdinal {
5167                ordinal: tx_header.ordinal,
5168                protocol_name:
5169                    <ScanResultListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5170            }),
5171        }
5172    }
5173}
5174
5175/// A Stream of incoming requests for fuchsia.bluetooth.affordances/ScanResultListener.
5176pub struct ScanResultListenerRequestStream {
5177    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5178    is_terminated: bool,
5179}
5180
5181impl std::marker::Unpin for ScanResultListenerRequestStream {}
5182
5183impl futures::stream::FusedStream for ScanResultListenerRequestStream {
5184    fn is_terminated(&self) -> bool {
5185        self.is_terminated
5186    }
5187}
5188
5189impl fidl::endpoints::RequestStream for ScanResultListenerRequestStream {
5190    type Protocol = ScanResultListenerMarker;
5191    type ControlHandle = ScanResultListenerControlHandle;
5192
5193    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5194        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5195    }
5196
5197    fn control_handle(&self) -> Self::ControlHandle {
5198        ScanResultListenerControlHandle { inner: self.inner.clone() }
5199    }
5200
5201    fn into_inner(
5202        self,
5203    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5204    {
5205        (self.inner, self.is_terminated)
5206    }
5207
5208    fn from_inner(
5209        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5210        is_terminated: bool,
5211    ) -> Self {
5212        Self { inner, is_terminated }
5213    }
5214}
5215
5216impl futures::Stream for ScanResultListenerRequestStream {
5217    type Item = Result<ScanResultListenerRequest, fidl::Error>;
5218
5219    fn poll_next(
5220        mut self: std::pin::Pin<&mut Self>,
5221        cx: &mut std::task::Context<'_>,
5222    ) -> std::task::Poll<Option<Self::Item>> {
5223        let this = &mut *self;
5224        if this.inner.check_shutdown(cx) {
5225            this.is_terminated = true;
5226            return std::task::Poll::Ready(None);
5227        }
5228        if this.is_terminated {
5229            panic!("polled ScanResultListenerRequestStream after completion");
5230        }
5231        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5232            |bytes, handles| {
5233                match this.inner.channel().read_etc(cx, bytes, handles) {
5234                    std::task::Poll::Ready(Ok(())) => {}
5235                    std::task::Poll::Pending => return std::task::Poll::Pending,
5236                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5237                        this.is_terminated = true;
5238                        return std::task::Poll::Ready(None);
5239                    }
5240                    std::task::Poll::Ready(Err(e)) => {
5241                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5242                            e.into(),
5243                        ))));
5244                    }
5245                }
5246
5247                // A message has been received from the channel
5248                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5249
5250                std::task::Poll::Ready(Some(match header.ordinal {
5251                0x111ea99f3f0c8009 => {
5252                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5253                    let mut req = fidl::new_empty!(ScanResultListenerOnPeersDiscoveredRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5254                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScanResultListenerOnPeersDiscoveredRequest>(&header, _body_bytes, handles, &mut req)?;
5255                    let control_handle = ScanResultListenerControlHandle {
5256                        inner: this.inner.clone(),
5257                    };
5258                    Ok(ScanResultListenerRequest::OnPeersDiscovered {payload: req,
5259                        responder: ScanResultListenerOnPeersDiscoveredResponder {
5260                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5261                            tx_id: header.tx_id,
5262                        },
5263                    })
5264                }
5265                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5266                    Ok(ScanResultListenerRequest::_UnknownMethod {
5267                        ordinal: header.ordinal,
5268                        control_handle: ScanResultListenerControlHandle { inner: this.inner.clone() },
5269                        method_type: fidl::MethodType::OneWay,
5270                    })
5271                }
5272                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5273                    this.inner.send_framework_err(
5274                        fidl::encoding::FrameworkErr::UnknownMethod,
5275                        header.tx_id,
5276                        header.ordinal,
5277                        header.dynamic_flags(),
5278                        (bytes, handles),
5279                    )?;
5280                    Ok(ScanResultListenerRequest::_UnknownMethod {
5281                        ordinal: header.ordinal,
5282                        control_handle: ScanResultListenerControlHandle { inner: this.inner.clone() },
5283                        method_type: fidl::MethodType::TwoWay,
5284                    })
5285                }
5286                _ => Err(fidl::Error::UnknownOrdinal {
5287                    ordinal: header.ordinal,
5288                    protocol_name: <ScanResultListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5289                }),
5290            }))
5291            },
5292        )
5293    }
5294}
5295
5296/// Protocol implemented by the client to receive scan results.
5297#[derive(Debug)]
5298pub enum ScanResultListenerRequest {
5299    /// Called by the server when peers are discovered.
5300    OnPeersDiscovered {
5301        payload: ScanResultListenerOnPeersDiscoveredRequest,
5302        responder: ScanResultListenerOnPeersDiscoveredResponder,
5303    },
5304    /// An interaction was received which does not match any known method.
5305    #[non_exhaustive]
5306    _UnknownMethod {
5307        /// Ordinal of the method that was called.
5308        ordinal: u64,
5309        control_handle: ScanResultListenerControlHandle,
5310        method_type: fidl::MethodType,
5311    },
5312}
5313
5314impl ScanResultListenerRequest {
5315    #[allow(irrefutable_let_patterns)]
5316    pub fn into_on_peers_discovered(
5317        self,
5318    ) -> Option<(
5319        ScanResultListenerOnPeersDiscoveredRequest,
5320        ScanResultListenerOnPeersDiscoveredResponder,
5321    )> {
5322        if let ScanResultListenerRequest::OnPeersDiscovered { payload, responder } = self {
5323            Some((payload, responder))
5324        } else {
5325            None
5326        }
5327    }
5328
5329    /// Name of the method defined in FIDL
5330    pub fn method_name(&self) -> &'static str {
5331        match *self {
5332            ScanResultListenerRequest::OnPeersDiscovered { .. } => "on_peers_discovered",
5333            ScanResultListenerRequest::_UnknownMethod {
5334                method_type: fidl::MethodType::OneWay,
5335                ..
5336            } => "unknown one-way method",
5337            ScanResultListenerRequest::_UnknownMethod {
5338                method_type: fidl::MethodType::TwoWay,
5339                ..
5340            } => "unknown two-way method",
5341        }
5342    }
5343}
5344
5345#[derive(Debug, Clone)]
5346pub struct ScanResultListenerControlHandle {
5347    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5348}
5349
5350impl fidl::endpoints::ControlHandle for ScanResultListenerControlHandle {
5351    fn shutdown(&self) {
5352        self.inner.shutdown()
5353    }
5354
5355    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5356        self.inner.shutdown_with_epitaph(status)
5357    }
5358
5359    fn is_closed(&self) -> bool {
5360        self.inner.channel().is_closed()
5361    }
5362    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5363        self.inner.channel().on_closed()
5364    }
5365
5366    #[cfg(target_os = "fuchsia")]
5367    fn signal_peer(
5368        &self,
5369        clear_mask: zx::Signals,
5370        set_mask: zx::Signals,
5371    ) -> Result<(), zx_status::Status> {
5372        use fidl::Peered;
5373        self.inner.channel().signal_peer(clear_mask, set_mask)
5374    }
5375}
5376
5377impl ScanResultListenerControlHandle {}
5378
5379#[must_use = "FIDL methods require a response to be sent"]
5380#[derive(Debug)]
5381pub struct ScanResultListenerOnPeersDiscoveredResponder {
5382    control_handle: std::mem::ManuallyDrop<ScanResultListenerControlHandle>,
5383    tx_id: u32,
5384}
5385
5386/// Set the the channel to be shutdown (see [`ScanResultListenerControlHandle::shutdown`])
5387/// if the responder is dropped without sending a response, so that the client
5388/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5389impl std::ops::Drop for ScanResultListenerOnPeersDiscoveredResponder {
5390    fn drop(&mut self) {
5391        self.control_handle.shutdown();
5392        // Safety: drops once, never accessed again
5393        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5394    }
5395}
5396
5397impl fidl::endpoints::Responder for ScanResultListenerOnPeersDiscoveredResponder {
5398    type ControlHandle = ScanResultListenerControlHandle;
5399
5400    fn control_handle(&self) -> &ScanResultListenerControlHandle {
5401        &self.control_handle
5402    }
5403
5404    fn drop_without_shutdown(mut self) {
5405        // Safety: drops once, never accessed again due to mem::forget
5406        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5407        // Prevent Drop from running (which would shut down the channel)
5408        std::mem::forget(self);
5409    }
5410}
5411
5412impl ScanResultListenerOnPeersDiscoveredResponder {
5413    /// Sends a response to the FIDL transaction.
5414    ///
5415    /// Sets the channel to shutdown if an error occurs.
5416    pub fn send(self) -> Result<(), fidl::Error> {
5417        let _result = self.send_raw();
5418        if _result.is_err() {
5419            self.control_handle.shutdown();
5420        }
5421        self.drop_without_shutdown();
5422        _result
5423    }
5424
5425    /// Similar to "send" but does not shutdown the channel if an error occurs.
5426    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5427        let _result = self.send_raw();
5428        self.drop_without_shutdown();
5429        _result
5430    }
5431
5432    fn send_raw(&self) -> Result<(), fidl::Error> {
5433        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
5434            fidl::encoding::Flexible::new(()),
5435            self.tx_id,
5436            0x111ea99f3f0c8009,
5437            fidl::encoding::DynamicFlags::FLEXIBLE,
5438        )
5439    }
5440}
5441
5442mod internal {
5443    use super::*;
5444
5445    impl CentralControllerStartScanRequest {
5446        #[inline(always)]
5447        fn max_ordinal_present(&self) -> u64 {
5448            if let Some(_) = self.listener {
5449                return 1;
5450            }
5451            0
5452        }
5453    }
5454
5455    impl fidl::encoding::ResourceTypeMarker for CentralControllerStartScanRequest {
5456        type Borrowed<'a> = &'a mut Self;
5457        fn take_or_borrow<'a>(
5458            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5459        ) -> Self::Borrowed<'a> {
5460            value
5461        }
5462    }
5463
5464    unsafe impl fidl::encoding::TypeMarker for CentralControllerStartScanRequest {
5465        type Owned = Self;
5466
5467        #[inline(always)]
5468        fn inline_align(_context: fidl::encoding::Context) -> usize {
5469            8
5470        }
5471
5472        #[inline(always)]
5473        fn inline_size(_context: fidl::encoding::Context) -> usize {
5474            16
5475        }
5476    }
5477
5478    unsafe impl
5479        fidl::encoding::Encode<
5480            CentralControllerStartScanRequest,
5481            fidl::encoding::DefaultFuchsiaResourceDialect,
5482        > for &mut CentralControllerStartScanRequest
5483    {
5484        unsafe fn encode(
5485            self,
5486            encoder: &mut fidl::encoding::Encoder<
5487                '_,
5488                fidl::encoding::DefaultFuchsiaResourceDialect,
5489            >,
5490            offset: usize,
5491            mut depth: fidl::encoding::Depth,
5492        ) -> fidl::Result<()> {
5493            encoder.debug_check_bounds::<CentralControllerStartScanRequest>(offset);
5494            // Vector header
5495            let max_ordinal: u64 = self.max_ordinal_present();
5496            encoder.write_num(max_ordinal, offset);
5497            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5498            // Calling encoder.out_of_line_offset(0) is not allowed.
5499            if max_ordinal == 0 {
5500                return Ok(());
5501            }
5502            depth.increment()?;
5503            let envelope_size = 8;
5504            let bytes_len = max_ordinal as usize * envelope_size;
5505            #[allow(unused_variables)]
5506            let offset = encoder.out_of_line_offset(bytes_len);
5507            let mut _prev_end_offset: usize = 0;
5508            if 1 > max_ordinal {
5509                return Ok(());
5510            }
5511
5512            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5513            // are envelope_size bytes.
5514            let cur_offset: usize = (1 - 1) * envelope_size;
5515
5516            // Zero reserved fields.
5517            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5518
5519            // Safety:
5520            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5521            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5522            //   envelope_size bytes, there is always sufficient room.
5523            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ScanResultListenerMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5524            self.listener.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ScanResultListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
5525            encoder, offset + cur_offset, depth
5526        )?;
5527
5528            _prev_end_offset = cur_offset + envelope_size;
5529
5530            Ok(())
5531        }
5532    }
5533
5534    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5535        for CentralControllerStartScanRequest
5536    {
5537        #[inline(always)]
5538        fn new_empty() -> Self {
5539            Self::default()
5540        }
5541
5542        unsafe fn decode(
5543            &mut self,
5544            decoder: &mut fidl::encoding::Decoder<
5545                '_,
5546                fidl::encoding::DefaultFuchsiaResourceDialect,
5547            >,
5548            offset: usize,
5549            mut depth: fidl::encoding::Depth,
5550        ) -> fidl::Result<()> {
5551            decoder.debug_check_bounds::<Self>(offset);
5552            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5553                None => return Err(fidl::Error::NotNullable),
5554                Some(len) => len,
5555            };
5556            // Calling decoder.out_of_line_offset(0) is not allowed.
5557            if len == 0 {
5558                return Ok(());
5559            };
5560            depth.increment()?;
5561            let envelope_size = 8;
5562            let bytes_len = len * envelope_size;
5563            let offset = decoder.out_of_line_offset(bytes_len)?;
5564            // Decode the envelope for each type.
5565            let mut _next_ordinal_to_read = 0;
5566            let mut next_offset = offset;
5567            let end_offset = offset + bytes_len;
5568            _next_ordinal_to_read += 1;
5569            if next_offset >= end_offset {
5570                return Ok(());
5571            }
5572
5573            // Decode unknown envelopes for gaps in ordinals.
5574            while _next_ordinal_to_read < 1 {
5575                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5576                _next_ordinal_to_read += 1;
5577                next_offset += envelope_size;
5578            }
5579
5580            let next_out_of_line = decoder.next_out_of_line();
5581            let handles_before = decoder.remaining_handles();
5582            if let Some((inlined, num_bytes, num_handles)) =
5583                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5584            {
5585                let member_inline_size = <fidl::encoding::Endpoint<
5586                    fidl::endpoints::ClientEnd<ScanResultListenerMarker>,
5587                > as fidl::encoding::TypeMarker>::inline_size(
5588                    decoder.context
5589                );
5590                if inlined != (member_inline_size <= 4) {
5591                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5592                }
5593                let inner_offset;
5594                let mut inner_depth = depth.clone();
5595                if inlined {
5596                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5597                    inner_offset = next_offset;
5598                } else {
5599                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5600                    inner_depth.increment()?;
5601                }
5602                let val_ref = self.listener.get_or_insert_with(|| {
5603                    fidl::new_empty!(
5604                        fidl::encoding::Endpoint<
5605                            fidl::endpoints::ClientEnd<ScanResultListenerMarker>,
5606                        >,
5607                        fidl::encoding::DefaultFuchsiaResourceDialect
5608                    )
5609                });
5610                fidl::decode!(
5611                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ScanResultListenerMarker>>,
5612                    fidl::encoding::DefaultFuchsiaResourceDialect,
5613                    val_ref,
5614                    decoder,
5615                    inner_offset,
5616                    inner_depth
5617                )?;
5618                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5619                {
5620                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5621                }
5622                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5623                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5624                }
5625            }
5626
5627            next_offset += envelope_size;
5628
5629            // Decode the remaining unknown envelopes.
5630            while next_offset < end_offset {
5631                _next_ordinal_to_read += 1;
5632                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5633                next_offset += envelope_size;
5634            }
5635
5636            Ok(())
5637        }
5638    }
5639}