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, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct HostControllerMarker;
16
17impl fidl::endpoints::ProtocolMarker for HostControllerMarker {
18    type Proxy = HostControllerProxy;
19    type RequestStream = HostControllerRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = HostControllerSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.affordances.HostController";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for HostControllerMarker {}
26pub type HostControllerGetHostsResult = Result<HostControllerGetHostsResponse, Error>;
27pub type HostControllerSetDiscoverabilityResult = Result<(), Error>;
28pub type HostControllerSetLocalNameResult = Result<(), Error>;
29pub type HostControllerStartPairingDelegateResult = Result<(), Error>;
30pub type HostControllerStopPairingDelegateResult = Result<(), Error>;
31pub type HostControllerSetDeviceClassResult = Result<(), Error>;
32
33pub trait HostControllerProxyInterface: Send + Sync {
34    type GetHostsResponseFut: std::future::Future<Output = Result<HostControllerGetHostsResult, fidl::Error>>
35        + Send;
36    fn r#get_hosts(&self) -> Self::GetHostsResponseFut;
37    type SetDiscoverabilityResponseFut: std::future::Future<Output = Result<HostControllerSetDiscoverabilityResult, fidl::Error>>
38        + Send;
39    fn r#set_discoverability(
40        &self,
41        payload: &HostControllerSetDiscoverabilityRequest,
42    ) -> Self::SetDiscoverabilityResponseFut;
43    type SetLocalNameResponseFut: std::future::Future<Output = Result<HostControllerSetLocalNameResult, fidl::Error>>
44        + Send;
45    fn r#set_local_name(
46        &self,
47        payload: &HostControllerSetLocalNameRequest,
48    ) -> Self::SetLocalNameResponseFut;
49    type StartPairingDelegateResponseFut: std::future::Future<Output = Result<HostControllerStartPairingDelegateResult, fidl::Error>>
50        + Send;
51    fn r#start_pairing_delegate(
52        &self,
53        payload: &HostControllerStartPairingDelegateRequest,
54    ) -> Self::StartPairingDelegateResponseFut;
55    type StopPairingDelegateResponseFut: std::future::Future<Output = Result<HostControllerStopPairingDelegateResult, fidl::Error>>
56        + Send;
57    fn r#stop_pairing_delegate(&self) -> Self::StopPairingDelegateResponseFut;
58    type SetDeviceClassResponseFut: std::future::Future<Output = Result<HostControllerSetDeviceClassResult, fidl::Error>>
59        + Send;
60    fn r#set_device_class(
61        &self,
62        payload: &HostControllerSetDeviceClassRequest,
63    ) -> Self::SetDeviceClassResponseFut;
64}
65#[derive(Debug)]
66#[cfg(target_os = "fuchsia")]
67pub struct HostControllerSynchronousProxy {
68    client: fidl::client::sync::Client,
69}
70
71#[cfg(target_os = "fuchsia")]
72impl fidl::endpoints::SynchronousProxy for HostControllerSynchronousProxy {
73    type Proxy = HostControllerProxy;
74    type Protocol = HostControllerMarker;
75
76    fn from_channel(inner: fidl::Channel) -> Self {
77        Self::new(inner)
78    }
79
80    fn into_channel(self) -> fidl::Channel {
81        self.client.into_channel()
82    }
83
84    fn as_channel(&self) -> &fidl::Channel {
85        self.client.as_channel()
86    }
87}
88
89#[cfg(target_os = "fuchsia")]
90impl HostControllerSynchronousProxy {
91    pub fn new(channel: fidl::Channel) -> Self {
92        Self { client: fidl::client::sync::Client::new(channel) }
93    }
94
95    pub fn into_channel(self) -> fidl::Channel {
96        self.client.into_channel()
97    }
98
99    /// Waits until an event arrives and returns it. It is safe for other
100    /// threads to make concurrent requests while waiting for an event.
101    pub fn wait_for_event(
102        &self,
103        deadline: zx::MonotonicInstant,
104    ) -> Result<HostControllerEvent, fidl::Error> {
105        HostControllerEvent::decode(self.client.wait_for_event::<HostControllerMarker>(deadline)?)
106    }
107
108    /// Get all known hosts.
109    ///
110    /// * error Returns `INTERNAL` if the operation failed (check logs).
111    pub fn r#get_hosts(
112        &self,
113        ___deadline: zx::MonotonicInstant,
114    ) -> Result<HostControllerGetHostsResult, fidl::Error> {
115        let _response = self.client.send_query::<
116            fidl::encoding::EmptyPayload,
117            fidl::encoding::FlexibleResultType<HostControllerGetHostsResponse, Error>,
118            HostControllerMarker,
119        >(
120            (),
121            0x167d2522684d453d,
122            fidl::encoding::DynamicFlags::FLEXIBLE,
123            ___deadline,
124        )?
125        .into_result::<HostControllerMarker>("get_hosts")?;
126        Ok(_response.map(|x| x))
127    }
128
129    /// Set discoverability state.
130    ///
131    /// * error Returns `INTERNAL` if the operation failed (check logs).
132    pub fn r#set_discoverability(
133        &self,
134        mut payload: &HostControllerSetDiscoverabilityRequest,
135        ___deadline: zx::MonotonicInstant,
136    ) -> Result<HostControllerSetDiscoverabilityResult, fidl::Error> {
137        let _response = self.client.send_query::<
138            HostControllerSetDiscoverabilityRequest,
139            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
140            HostControllerMarker,
141        >(
142            payload,
143            0x1e977b538b94b08b,
144            fidl::encoding::DynamicFlags::FLEXIBLE,
145            ___deadline,
146        )?
147        .into_result::<HostControllerMarker>("set_discoverability")?;
148        Ok(_response.map(|x| x))
149    }
150
151    /// Set the active host's local name.
152    ///
153    /// + request `name` Name to assign to the host.
154    /// * error Returns `INTERNAL` if the operation failed (check logs).
155    pub fn r#set_local_name(
156        &self,
157        mut payload: &HostControllerSetLocalNameRequest,
158        ___deadline: zx::MonotonicInstant,
159    ) -> Result<HostControllerSetLocalNameResult, fidl::Error> {
160        let _response = self.client.send_query::<
161            HostControllerSetLocalNameRequest,
162            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
163            HostControllerMarker,
164        >(
165            payload,
166            0x357714c7aa252336,
167            fidl::encoding::DynamicFlags::FLEXIBLE,
168            ___deadline,
169        )?
170        .into_result::<HostControllerMarker>("set_local_name")?;
171        Ok(_response.map(|x| x))
172    }
173
174    /// Start a pairing delegate to respond to pairing procedures. Only one pairing delegate can be
175    /// set at a time host-wide. Calling this while a delegate started by this method is already
176    /// active will drop and overwrite the existing delegate. If this is called while a delegate
177    /// started through other means is active, the new delegate will be closed immediately. Closing
178    /// a pairing delegate after it is set aborts all ongoing pairing procedures without accepting
179    /// and unsets the delegate.
180    ///
181    /// If no pairing delegate is set, all pairings will be rejected even if the peer connection was
182    /// initiated by the host.
183    ///
184    /// * error Returns `INTERNAL` if the operation failed (check logs).
185    pub fn r#start_pairing_delegate(
186        &self,
187        mut payload: &HostControllerStartPairingDelegateRequest,
188        ___deadline: zx::MonotonicInstant,
189    ) -> Result<HostControllerStartPairingDelegateResult, fidl::Error> {
190        let _response = self.client.send_query::<
191            HostControllerStartPairingDelegateRequest,
192            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
193            HostControllerMarker,
194        >(
195            payload,
196            0x155c20cb1b9c1ed2,
197            fidl::encoding::DynamicFlags::FLEXIBLE,
198            ___deadline,
199        )?
200        .into_result::<HostControllerMarker>("start_pairing_delegate")?;
201        Ok(_response.map(|x| x))
202    }
203
204    /// Stop a pairing delegate previously started by [`StartPairingDelegate`]. This will abort all
205    /// ongoing pairing procedures without accepting and unsets the delegate.
206    ///
207    /// This method can only stop a delegate started by [`StartPairingDelegate`], and will not stop
208    /// a delegate started through other means.
209    ///
210    /// * error Returns `INTERNAL` if the operation failed (check logs).
211    pub fn r#stop_pairing_delegate(
212        &self,
213        ___deadline: zx::MonotonicInstant,
214    ) -> Result<HostControllerStopPairingDelegateResult, fidl::Error> {
215        let _response = self.client.send_query::<
216            fidl::encoding::EmptyPayload,
217            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
218            HostControllerMarker,
219        >(
220            (),
221            0x5caaee1192a8172c,
222            fidl::encoding::DynamicFlags::FLEXIBLE,
223            ___deadline,
224        )?
225        .into_result::<HostControllerMarker>("stop_pairing_delegate")?;
226        Ok(_response.map(|x| x))
227    }
228
229    /// Set the active host's device class.
230    ///
231    /// * error Returns `INTERNAL` if the operation failed (check logs).
232    pub fn r#set_device_class(
233        &self,
234        mut payload: &HostControllerSetDeviceClassRequest,
235        ___deadline: zx::MonotonicInstant,
236    ) -> Result<HostControllerSetDeviceClassResult, fidl::Error> {
237        let _response = self.client.send_query::<
238            HostControllerSetDeviceClassRequest,
239            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
240            HostControllerMarker,
241        >(
242            payload,
243            0x34dcc9ed479692dc,
244            fidl::encoding::DynamicFlags::FLEXIBLE,
245            ___deadline,
246        )?
247        .into_result::<HostControllerMarker>("set_device_class")?;
248        Ok(_response.map(|x| x))
249    }
250}
251
252#[cfg(target_os = "fuchsia")]
253impl From<HostControllerSynchronousProxy> for zx::NullableHandle {
254    fn from(value: HostControllerSynchronousProxy) -> Self {
255        value.into_channel().into()
256    }
257}
258
259#[cfg(target_os = "fuchsia")]
260impl From<fidl::Channel> for HostControllerSynchronousProxy {
261    fn from(value: fidl::Channel) -> Self {
262        Self::new(value)
263    }
264}
265
266#[cfg(target_os = "fuchsia")]
267impl fidl::endpoints::FromClient for HostControllerSynchronousProxy {
268    type Protocol = HostControllerMarker;
269
270    fn from_client(value: fidl::endpoints::ClientEnd<HostControllerMarker>) -> Self {
271        Self::new(value.into_channel())
272    }
273}
274
275#[derive(Debug, Clone)]
276pub struct HostControllerProxy {
277    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
278}
279
280impl fidl::endpoints::Proxy for HostControllerProxy {
281    type Protocol = HostControllerMarker;
282
283    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
284        Self::new(inner)
285    }
286
287    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
288        self.client.into_channel().map_err(|client| Self { client })
289    }
290
291    fn as_channel(&self) -> &::fidl::AsyncChannel {
292        self.client.as_channel()
293    }
294}
295
296impl HostControllerProxy {
297    /// Create a new Proxy for fuchsia.bluetooth.affordances/HostController.
298    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
299        let protocol_name = <HostControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
300        Self { client: fidl::client::Client::new(channel, protocol_name) }
301    }
302
303    /// Get a Stream of events from the remote end of the protocol.
304    ///
305    /// # Panics
306    ///
307    /// Panics if the event stream was already taken.
308    pub fn take_event_stream(&self) -> HostControllerEventStream {
309        HostControllerEventStream { event_receiver: self.client.take_event_receiver() }
310    }
311
312    /// Get all known hosts.
313    ///
314    /// * error Returns `INTERNAL` if the operation failed (check logs).
315    pub fn r#get_hosts(
316        &self,
317    ) -> fidl::client::QueryResponseFut<
318        HostControllerGetHostsResult,
319        fidl::encoding::DefaultFuchsiaResourceDialect,
320    > {
321        HostControllerProxyInterface::r#get_hosts(self)
322    }
323
324    /// Set discoverability state.
325    ///
326    /// * error Returns `INTERNAL` if the operation failed (check logs).
327    pub fn r#set_discoverability(
328        &self,
329        mut payload: &HostControllerSetDiscoverabilityRequest,
330    ) -> fidl::client::QueryResponseFut<
331        HostControllerSetDiscoverabilityResult,
332        fidl::encoding::DefaultFuchsiaResourceDialect,
333    > {
334        HostControllerProxyInterface::r#set_discoverability(self, payload)
335    }
336
337    /// Set the active host's local name.
338    ///
339    /// + request `name` Name to assign to the host.
340    /// * error Returns `INTERNAL` if the operation failed (check logs).
341    pub fn r#set_local_name(
342        &self,
343        mut payload: &HostControllerSetLocalNameRequest,
344    ) -> fidl::client::QueryResponseFut<
345        HostControllerSetLocalNameResult,
346        fidl::encoding::DefaultFuchsiaResourceDialect,
347    > {
348        HostControllerProxyInterface::r#set_local_name(self, payload)
349    }
350
351    /// Start a pairing delegate to respond to pairing procedures. Only one pairing delegate can be
352    /// set at a time host-wide. Calling this while a delegate started by this method is already
353    /// active will drop and overwrite the existing delegate. If this is called while a delegate
354    /// started through other means is active, the new delegate will be closed immediately. Closing
355    /// a pairing delegate after it is set aborts all ongoing pairing procedures without accepting
356    /// and unsets the delegate.
357    ///
358    /// If no pairing delegate is set, all pairings will be rejected even if the peer connection was
359    /// initiated by the host.
360    ///
361    /// * error Returns `INTERNAL` if the operation failed (check logs).
362    pub fn r#start_pairing_delegate(
363        &self,
364        mut payload: &HostControllerStartPairingDelegateRequest,
365    ) -> fidl::client::QueryResponseFut<
366        HostControllerStartPairingDelegateResult,
367        fidl::encoding::DefaultFuchsiaResourceDialect,
368    > {
369        HostControllerProxyInterface::r#start_pairing_delegate(self, payload)
370    }
371
372    /// Stop a pairing delegate previously started by [`StartPairingDelegate`]. This will abort all
373    /// ongoing pairing procedures without accepting and unsets the delegate.
374    ///
375    /// This method can only stop a delegate started by [`StartPairingDelegate`], and will not stop
376    /// a delegate started through other means.
377    ///
378    /// * error Returns `INTERNAL` if the operation failed (check logs).
379    pub fn r#stop_pairing_delegate(
380        &self,
381    ) -> fidl::client::QueryResponseFut<
382        HostControllerStopPairingDelegateResult,
383        fidl::encoding::DefaultFuchsiaResourceDialect,
384    > {
385        HostControllerProxyInterface::r#stop_pairing_delegate(self)
386    }
387
388    /// Set the active host's device class.
389    ///
390    /// * error Returns `INTERNAL` if the operation failed (check logs).
391    pub fn r#set_device_class(
392        &self,
393        mut payload: &HostControllerSetDeviceClassRequest,
394    ) -> fidl::client::QueryResponseFut<
395        HostControllerSetDeviceClassResult,
396        fidl::encoding::DefaultFuchsiaResourceDialect,
397    > {
398        HostControllerProxyInterface::r#set_device_class(self, payload)
399    }
400}
401
402impl HostControllerProxyInterface for HostControllerProxy {
403    type GetHostsResponseFut = fidl::client::QueryResponseFut<
404        HostControllerGetHostsResult,
405        fidl::encoding::DefaultFuchsiaResourceDialect,
406    >;
407    fn r#get_hosts(&self) -> Self::GetHostsResponseFut {
408        fn _decode(
409            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
410        ) -> Result<HostControllerGetHostsResult, fidl::Error> {
411            let _response = fidl::client::decode_transaction_body::<
412                fidl::encoding::FlexibleResultType<HostControllerGetHostsResponse, Error>,
413                fidl::encoding::DefaultFuchsiaResourceDialect,
414                0x167d2522684d453d,
415            >(_buf?)?
416            .into_result::<HostControllerMarker>("get_hosts")?;
417            Ok(_response.map(|x| x))
418        }
419        self.client
420            .send_query_and_decode::<fidl::encoding::EmptyPayload, HostControllerGetHostsResult>(
421                (),
422                0x167d2522684d453d,
423                fidl::encoding::DynamicFlags::FLEXIBLE,
424                _decode,
425            )
426    }
427
428    type SetDiscoverabilityResponseFut = fidl::client::QueryResponseFut<
429        HostControllerSetDiscoverabilityResult,
430        fidl::encoding::DefaultFuchsiaResourceDialect,
431    >;
432    fn r#set_discoverability(
433        &self,
434        mut payload: &HostControllerSetDiscoverabilityRequest,
435    ) -> Self::SetDiscoverabilityResponseFut {
436        fn _decode(
437            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
438        ) -> Result<HostControllerSetDiscoverabilityResult, fidl::Error> {
439            let _response = fidl::client::decode_transaction_body::<
440                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
441                fidl::encoding::DefaultFuchsiaResourceDialect,
442                0x1e977b538b94b08b,
443            >(_buf?)?
444            .into_result::<HostControllerMarker>("set_discoverability")?;
445            Ok(_response.map(|x| x))
446        }
447        self.client.send_query_and_decode::<
448            HostControllerSetDiscoverabilityRequest,
449            HostControllerSetDiscoverabilityResult,
450        >(
451            payload,
452            0x1e977b538b94b08b,
453            fidl::encoding::DynamicFlags::FLEXIBLE,
454            _decode,
455        )
456    }
457
458    type SetLocalNameResponseFut = fidl::client::QueryResponseFut<
459        HostControllerSetLocalNameResult,
460        fidl::encoding::DefaultFuchsiaResourceDialect,
461    >;
462    fn r#set_local_name(
463        &self,
464        mut payload: &HostControllerSetLocalNameRequest,
465    ) -> Self::SetLocalNameResponseFut {
466        fn _decode(
467            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
468        ) -> Result<HostControllerSetLocalNameResult, fidl::Error> {
469            let _response = fidl::client::decode_transaction_body::<
470                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
471                fidl::encoding::DefaultFuchsiaResourceDialect,
472                0x357714c7aa252336,
473            >(_buf?)?
474            .into_result::<HostControllerMarker>("set_local_name")?;
475            Ok(_response.map(|x| x))
476        }
477        self.client.send_query_and_decode::<
478            HostControllerSetLocalNameRequest,
479            HostControllerSetLocalNameResult,
480        >(
481            payload,
482            0x357714c7aa252336,
483            fidl::encoding::DynamicFlags::FLEXIBLE,
484            _decode,
485        )
486    }
487
488    type StartPairingDelegateResponseFut = fidl::client::QueryResponseFut<
489        HostControllerStartPairingDelegateResult,
490        fidl::encoding::DefaultFuchsiaResourceDialect,
491    >;
492    fn r#start_pairing_delegate(
493        &self,
494        mut payload: &HostControllerStartPairingDelegateRequest,
495    ) -> Self::StartPairingDelegateResponseFut {
496        fn _decode(
497            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
498        ) -> Result<HostControllerStartPairingDelegateResult, fidl::Error> {
499            let _response = fidl::client::decode_transaction_body::<
500                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
501                fidl::encoding::DefaultFuchsiaResourceDialect,
502                0x155c20cb1b9c1ed2,
503            >(_buf?)?
504            .into_result::<HostControllerMarker>("start_pairing_delegate")?;
505            Ok(_response.map(|x| x))
506        }
507        self.client.send_query_and_decode::<
508            HostControllerStartPairingDelegateRequest,
509            HostControllerStartPairingDelegateResult,
510        >(
511            payload,
512            0x155c20cb1b9c1ed2,
513            fidl::encoding::DynamicFlags::FLEXIBLE,
514            _decode,
515        )
516    }
517
518    type StopPairingDelegateResponseFut = fidl::client::QueryResponseFut<
519        HostControllerStopPairingDelegateResult,
520        fidl::encoding::DefaultFuchsiaResourceDialect,
521    >;
522    fn r#stop_pairing_delegate(&self) -> Self::StopPairingDelegateResponseFut {
523        fn _decode(
524            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
525        ) -> Result<HostControllerStopPairingDelegateResult, fidl::Error> {
526            let _response = fidl::client::decode_transaction_body::<
527                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
528                fidl::encoding::DefaultFuchsiaResourceDialect,
529                0x5caaee1192a8172c,
530            >(_buf?)?
531            .into_result::<HostControllerMarker>("stop_pairing_delegate")?;
532            Ok(_response.map(|x| x))
533        }
534        self.client.send_query_and_decode::<
535            fidl::encoding::EmptyPayload,
536            HostControllerStopPairingDelegateResult,
537        >(
538            (),
539            0x5caaee1192a8172c,
540            fidl::encoding::DynamicFlags::FLEXIBLE,
541            _decode,
542        )
543    }
544
545    type SetDeviceClassResponseFut = fidl::client::QueryResponseFut<
546        HostControllerSetDeviceClassResult,
547        fidl::encoding::DefaultFuchsiaResourceDialect,
548    >;
549    fn r#set_device_class(
550        &self,
551        mut payload: &HostControllerSetDeviceClassRequest,
552    ) -> Self::SetDeviceClassResponseFut {
553        fn _decode(
554            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
555        ) -> Result<HostControllerSetDeviceClassResult, fidl::Error> {
556            let _response = fidl::client::decode_transaction_body::<
557                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
558                fidl::encoding::DefaultFuchsiaResourceDialect,
559                0x34dcc9ed479692dc,
560            >(_buf?)?
561            .into_result::<HostControllerMarker>("set_device_class")?;
562            Ok(_response.map(|x| x))
563        }
564        self.client.send_query_and_decode::<
565            HostControllerSetDeviceClassRequest,
566            HostControllerSetDeviceClassResult,
567        >(
568            payload,
569            0x34dcc9ed479692dc,
570            fidl::encoding::DynamicFlags::FLEXIBLE,
571            _decode,
572        )
573    }
574}
575
576pub struct HostControllerEventStream {
577    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
578}
579
580impl std::marker::Unpin for HostControllerEventStream {}
581
582impl futures::stream::FusedStream for HostControllerEventStream {
583    fn is_terminated(&self) -> bool {
584        self.event_receiver.is_terminated()
585    }
586}
587
588impl futures::Stream for HostControllerEventStream {
589    type Item = Result<HostControllerEvent, fidl::Error>;
590
591    fn poll_next(
592        mut self: std::pin::Pin<&mut Self>,
593        cx: &mut std::task::Context<'_>,
594    ) -> std::task::Poll<Option<Self::Item>> {
595        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
596            &mut self.event_receiver,
597            cx
598        )?) {
599            Some(buf) => std::task::Poll::Ready(Some(HostControllerEvent::decode(buf))),
600            None => std::task::Poll::Ready(None),
601        }
602    }
603}
604
605#[derive(Debug)]
606pub enum HostControllerEvent {
607    #[non_exhaustive]
608    _UnknownEvent {
609        /// Ordinal of the event that was sent.
610        ordinal: u64,
611    },
612}
613
614impl HostControllerEvent {
615    /// Decodes a message buffer as a [`HostControllerEvent`].
616    fn decode(
617        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
618    ) -> Result<HostControllerEvent, fidl::Error> {
619        let (bytes, _handles) = buf.split_mut();
620        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
621        debug_assert_eq!(tx_header.tx_id, 0);
622        match tx_header.ordinal {
623            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
624                Ok(HostControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
625            }
626            _ => Err(fidl::Error::UnknownOrdinal {
627                ordinal: tx_header.ordinal,
628                protocol_name:
629                    <HostControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
630            }),
631        }
632    }
633}
634
635/// A Stream of incoming requests for fuchsia.bluetooth.affordances/HostController.
636pub struct HostControllerRequestStream {
637    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
638    is_terminated: bool,
639}
640
641impl std::marker::Unpin for HostControllerRequestStream {}
642
643impl futures::stream::FusedStream for HostControllerRequestStream {
644    fn is_terminated(&self) -> bool {
645        self.is_terminated
646    }
647}
648
649impl fidl::endpoints::RequestStream for HostControllerRequestStream {
650    type Protocol = HostControllerMarker;
651    type ControlHandle = HostControllerControlHandle;
652
653    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
654        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
655    }
656
657    fn control_handle(&self) -> Self::ControlHandle {
658        HostControllerControlHandle { inner: self.inner.clone() }
659    }
660
661    fn into_inner(
662        self,
663    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
664    {
665        (self.inner, self.is_terminated)
666    }
667
668    fn from_inner(
669        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
670        is_terminated: bool,
671    ) -> Self {
672        Self { inner, is_terminated }
673    }
674}
675
676impl futures::Stream for HostControllerRequestStream {
677    type Item = Result<HostControllerRequest, fidl::Error>;
678
679    fn poll_next(
680        mut self: std::pin::Pin<&mut Self>,
681        cx: &mut std::task::Context<'_>,
682    ) -> std::task::Poll<Option<Self::Item>> {
683        let this = &mut *self;
684        if this.inner.check_shutdown(cx) {
685            this.is_terminated = true;
686            return std::task::Poll::Ready(None);
687        }
688        if this.is_terminated {
689            panic!("polled HostControllerRequestStream after completion");
690        }
691        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
692            |bytes, handles| {
693                match this.inner.channel().read_etc(cx, bytes, handles) {
694                    std::task::Poll::Ready(Ok(())) => {}
695                    std::task::Poll::Pending => return std::task::Poll::Pending,
696                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
697                        this.is_terminated = true;
698                        return std::task::Poll::Ready(None);
699                    }
700                    std::task::Poll::Ready(Err(e)) => {
701                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
702                            e.into(),
703                        ))));
704                    }
705                }
706
707                // A message has been received from the channel
708                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
709
710                std::task::Poll::Ready(Some(match header.ordinal {
711                    0x167d2522684d453d => {
712                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
713                        let mut req = fidl::new_empty!(
714                            fidl::encoding::EmptyPayload,
715                            fidl::encoding::DefaultFuchsiaResourceDialect
716                        );
717                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
718                        let control_handle =
719                            HostControllerControlHandle { inner: this.inner.clone() };
720                        Ok(HostControllerRequest::GetHosts {
721                            responder: HostControllerGetHostsResponder {
722                                control_handle: std::mem::ManuallyDrop::new(control_handle),
723                                tx_id: header.tx_id,
724                            },
725                        })
726                    }
727                    0x1e977b538b94b08b => {
728                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
729                        let mut req = fidl::new_empty!(
730                            HostControllerSetDiscoverabilityRequest,
731                            fidl::encoding::DefaultFuchsiaResourceDialect
732                        );
733                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostControllerSetDiscoverabilityRequest>(&header, _body_bytes, handles, &mut req)?;
734                        let control_handle =
735                            HostControllerControlHandle { inner: this.inner.clone() };
736                        Ok(HostControllerRequest::SetDiscoverability {
737                            payload: req,
738                            responder: HostControllerSetDiscoverabilityResponder {
739                                control_handle: std::mem::ManuallyDrop::new(control_handle),
740                                tx_id: header.tx_id,
741                            },
742                        })
743                    }
744                    0x357714c7aa252336 => {
745                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
746                        let mut req = fidl::new_empty!(
747                            HostControllerSetLocalNameRequest,
748                            fidl::encoding::DefaultFuchsiaResourceDialect
749                        );
750                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostControllerSetLocalNameRequest>(&header, _body_bytes, handles, &mut req)?;
751                        let control_handle =
752                            HostControllerControlHandle { inner: this.inner.clone() };
753                        Ok(HostControllerRequest::SetLocalName {
754                            payload: req,
755                            responder: HostControllerSetLocalNameResponder {
756                                control_handle: std::mem::ManuallyDrop::new(control_handle),
757                                tx_id: header.tx_id,
758                            },
759                        })
760                    }
761                    0x155c20cb1b9c1ed2 => {
762                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
763                        let mut req = fidl::new_empty!(
764                            HostControllerStartPairingDelegateRequest,
765                            fidl::encoding::DefaultFuchsiaResourceDialect
766                        );
767                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostControllerStartPairingDelegateRequest>(&header, _body_bytes, handles, &mut req)?;
768                        let control_handle =
769                            HostControllerControlHandle { inner: this.inner.clone() };
770                        Ok(HostControllerRequest::StartPairingDelegate {
771                            payload: req,
772                            responder: HostControllerStartPairingDelegateResponder {
773                                control_handle: std::mem::ManuallyDrop::new(control_handle),
774                                tx_id: header.tx_id,
775                            },
776                        })
777                    }
778                    0x5caaee1192a8172c => {
779                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
780                        let mut req = fidl::new_empty!(
781                            fidl::encoding::EmptyPayload,
782                            fidl::encoding::DefaultFuchsiaResourceDialect
783                        );
784                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
785                        let control_handle =
786                            HostControllerControlHandle { inner: this.inner.clone() };
787                        Ok(HostControllerRequest::StopPairingDelegate {
788                            responder: HostControllerStopPairingDelegateResponder {
789                                control_handle: std::mem::ManuallyDrop::new(control_handle),
790                                tx_id: header.tx_id,
791                            },
792                        })
793                    }
794                    0x34dcc9ed479692dc => {
795                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
796                        let mut req = fidl::new_empty!(
797                            HostControllerSetDeviceClassRequest,
798                            fidl::encoding::DefaultFuchsiaResourceDialect
799                        );
800                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostControllerSetDeviceClassRequest>(&header, _body_bytes, handles, &mut req)?;
801                        let control_handle =
802                            HostControllerControlHandle { inner: this.inner.clone() };
803                        Ok(HostControllerRequest::SetDeviceClass {
804                            payload: req,
805                            responder: HostControllerSetDeviceClassResponder {
806                                control_handle: std::mem::ManuallyDrop::new(control_handle),
807                                tx_id: header.tx_id,
808                            },
809                        })
810                    }
811                    _ if header.tx_id == 0
812                        && header
813                            .dynamic_flags()
814                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
815                    {
816                        Ok(HostControllerRequest::_UnknownMethod {
817                            ordinal: header.ordinal,
818                            control_handle: HostControllerControlHandle {
819                                inner: this.inner.clone(),
820                            },
821                            method_type: fidl::MethodType::OneWay,
822                        })
823                    }
824                    _ if header
825                        .dynamic_flags()
826                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
827                    {
828                        this.inner.send_framework_err(
829                            fidl::encoding::FrameworkErr::UnknownMethod,
830                            header.tx_id,
831                            header.ordinal,
832                            header.dynamic_flags(),
833                            (bytes, handles),
834                        )?;
835                        Ok(HostControllerRequest::_UnknownMethod {
836                            ordinal: header.ordinal,
837                            control_handle: HostControllerControlHandle {
838                                inner: this.inner.clone(),
839                            },
840                            method_type: fidl::MethodType::TwoWay,
841                        })
842                    }
843                    _ => Err(fidl::Error::UnknownOrdinal {
844                        ordinal: header.ordinal,
845                        protocol_name:
846                            <HostControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
847                    }),
848                }))
849            },
850        )
851    }
852}
853
854#[derive(Debug)]
855pub enum HostControllerRequest {
856    /// Get all known hosts.
857    ///
858    /// * error Returns `INTERNAL` if the operation failed (check logs).
859    GetHosts { responder: HostControllerGetHostsResponder },
860    /// Set discoverability state.
861    ///
862    /// * error Returns `INTERNAL` if the operation failed (check logs).
863    SetDiscoverability {
864        payload: HostControllerSetDiscoverabilityRequest,
865        responder: HostControllerSetDiscoverabilityResponder,
866    },
867    /// Set the active host's local name.
868    ///
869    /// + request `name` Name to assign to the host.
870    /// * error Returns `INTERNAL` if the operation failed (check logs).
871    SetLocalName {
872        payload: HostControllerSetLocalNameRequest,
873        responder: HostControllerSetLocalNameResponder,
874    },
875    /// Start a pairing delegate to respond to pairing procedures. Only one pairing delegate can be
876    /// set at a time host-wide. Calling this while a delegate started by this method is already
877    /// active will drop and overwrite the existing delegate. If this is called while a delegate
878    /// started through other means is active, the new delegate will be closed immediately. Closing
879    /// a pairing delegate after it is set aborts all ongoing pairing procedures without accepting
880    /// and unsets the delegate.
881    ///
882    /// If no pairing delegate is set, all pairings will be rejected even if the peer connection was
883    /// initiated by the host.
884    ///
885    /// * error Returns `INTERNAL` if the operation failed (check logs).
886    StartPairingDelegate {
887        payload: HostControllerStartPairingDelegateRequest,
888        responder: HostControllerStartPairingDelegateResponder,
889    },
890    /// Stop a pairing delegate previously started by [`StartPairingDelegate`]. This will abort all
891    /// ongoing pairing procedures without accepting and unsets the delegate.
892    ///
893    /// This method can only stop a delegate started by [`StartPairingDelegate`], and will not stop
894    /// a delegate started through other means.
895    ///
896    /// * error Returns `INTERNAL` if the operation failed (check logs).
897    StopPairingDelegate { responder: HostControllerStopPairingDelegateResponder },
898    /// Set the active host's device class.
899    ///
900    /// * error Returns `INTERNAL` if the operation failed (check logs).
901    SetDeviceClass {
902        payload: HostControllerSetDeviceClassRequest,
903        responder: HostControllerSetDeviceClassResponder,
904    },
905    /// An interaction was received which does not match any known method.
906    #[non_exhaustive]
907    _UnknownMethod {
908        /// Ordinal of the method that was called.
909        ordinal: u64,
910        control_handle: HostControllerControlHandle,
911        method_type: fidl::MethodType,
912    },
913}
914
915impl HostControllerRequest {
916    #[allow(irrefutable_let_patterns)]
917    pub fn into_get_hosts(self) -> Option<(HostControllerGetHostsResponder)> {
918        if let HostControllerRequest::GetHosts { responder } = self {
919            Some((responder))
920        } else {
921            None
922        }
923    }
924
925    #[allow(irrefutable_let_patterns)]
926    pub fn into_set_discoverability(
927        self,
928    ) -> Option<(HostControllerSetDiscoverabilityRequest, HostControllerSetDiscoverabilityResponder)>
929    {
930        if let HostControllerRequest::SetDiscoverability { payload, responder } = self {
931            Some((payload, responder))
932        } else {
933            None
934        }
935    }
936
937    #[allow(irrefutable_let_patterns)]
938    pub fn into_set_local_name(
939        self,
940    ) -> Option<(HostControllerSetLocalNameRequest, HostControllerSetLocalNameResponder)> {
941        if let HostControllerRequest::SetLocalName { payload, responder } = self {
942            Some((payload, responder))
943        } else {
944            None
945        }
946    }
947
948    #[allow(irrefutable_let_patterns)]
949    pub fn into_start_pairing_delegate(
950        self,
951    ) -> Option<(
952        HostControllerStartPairingDelegateRequest,
953        HostControllerStartPairingDelegateResponder,
954    )> {
955        if let HostControllerRequest::StartPairingDelegate { payload, responder } = self {
956            Some((payload, responder))
957        } else {
958            None
959        }
960    }
961
962    #[allow(irrefutable_let_patterns)]
963    pub fn into_stop_pairing_delegate(
964        self,
965    ) -> Option<(HostControllerStopPairingDelegateResponder)> {
966        if let HostControllerRequest::StopPairingDelegate { responder } = self {
967            Some((responder))
968        } else {
969            None
970        }
971    }
972
973    #[allow(irrefutable_let_patterns)]
974    pub fn into_set_device_class(
975        self,
976    ) -> Option<(HostControllerSetDeviceClassRequest, HostControllerSetDeviceClassResponder)> {
977        if let HostControllerRequest::SetDeviceClass { payload, responder } = self {
978            Some((payload, responder))
979        } else {
980            None
981        }
982    }
983
984    /// Name of the method defined in FIDL
985    pub fn method_name(&self) -> &'static str {
986        match *self {
987            HostControllerRequest::GetHosts { .. } => "get_hosts",
988            HostControllerRequest::SetDiscoverability { .. } => "set_discoverability",
989            HostControllerRequest::SetLocalName { .. } => "set_local_name",
990            HostControllerRequest::StartPairingDelegate { .. } => "start_pairing_delegate",
991            HostControllerRequest::StopPairingDelegate { .. } => "stop_pairing_delegate",
992            HostControllerRequest::SetDeviceClass { .. } => "set_device_class",
993            HostControllerRequest::_UnknownMethod {
994                method_type: fidl::MethodType::OneWay, ..
995            } => "unknown one-way method",
996            HostControllerRequest::_UnknownMethod {
997                method_type: fidl::MethodType::TwoWay, ..
998            } => "unknown two-way method",
999        }
1000    }
1001}
1002
1003#[derive(Debug, Clone)]
1004pub struct HostControllerControlHandle {
1005    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1006}
1007
1008impl fidl::endpoints::ControlHandle for HostControllerControlHandle {
1009    fn shutdown(&self) {
1010        self.inner.shutdown()
1011    }
1012
1013    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1014        self.inner.shutdown_with_epitaph(status)
1015    }
1016
1017    fn is_closed(&self) -> bool {
1018        self.inner.channel().is_closed()
1019    }
1020    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1021        self.inner.channel().on_closed()
1022    }
1023
1024    #[cfg(target_os = "fuchsia")]
1025    fn signal_peer(
1026        &self,
1027        clear_mask: zx::Signals,
1028        set_mask: zx::Signals,
1029    ) -> Result<(), zx_status::Status> {
1030        use fidl::Peered;
1031        self.inner.channel().signal_peer(clear_mask, set_mask)
1032    }
1033}
1034
1035impl HostControllerControlHandle {}
1036
1037#[must_use = "FIDL methods require a response to be sent"]
1038#[derive(Debug)]
1039pub struct HostControllerGetHostsResponder {
1040    control_handle: std::mem::ManuallyDrop<HostControllerControlHandle>,
1041    tx_id: u32,
1042}
1043
1044/// Set the the channel to be shutdown (see [`HostControllerControlHandle::shutdown`])
1045/// if the responder is dropped without sending a response, so that the client
1046/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1047impl std::ops::Drop for HostControllerGetHostsResponder {
1048    fn drop(&mut self) {
1049        self.control_handle.shutdown();
1050        // Safety: drops once, never accessed again
1051        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1052    }
1053}
1054
1055impl fidl::endpoints::Responder for HostControllerGetHostsResponder {
1056    type ControlHandle = HostControllerControlHandle;
1057
1058    fn control_handle(&self) -> &HostControllerControlHandle {
1059        &self.control_handle
1060    }
1061
1062    fn drop_without_shutdown(mut self) {
1063        // Safety: drops once, never accessed again due to mem::forget
1064        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1065        // Prevent Drop from running (which would shut down the channel)
1066        std::mem::forget(self);
1067    }
1068}
1069
1070impl HostControllerGetHostsResponder {
1071    /// Sends a response to the FIDL transaction.
1072    ///
1073    /// Sets the channel to shutdown if an error occurs.
1074    pub fn send(
1075        self,
1076        mut result: Result<&HostControllerGetHostsResponse, Error>,
1077    ) -> Result<(), fidl::Error> {
1078        let _result = self.send_raw(result);
1079        if _result.is_err() {
1080            self.control_handle.shutdown();
1081        }
1082        self.drop_without_shutdown();
1083        _result
1084    }
1085
1086    /// Similar to "send" but does not shutdown the channel if an error occurs.
1087    pub fn send_no_shutdown_on_err(
1088        self,
1089        mut result: Result<&HostControllerGetHostsResponse, Error>,
1090    ) -> Result<(), fidl::Error> {
1091        let _result = self.send_raw(result);
1092        self.drop_without_shutdown();
1093        _result
1094    }
1095
1096    fn send_raw(
1097        &self,
1098        mut result: Result<&HostControllerGetHostsResponse, Error>,
1099    ) -> Result<(), fidl::Error> {
1100        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1101            HostControllerGetHostsResponse,
1102            Error,
1103        >>(
1104            fidl::encoding::FlexibleResult::new(result),
1105            self.tx_id,
1106            0x167d2522684d453d,
1107            fidl::encoding::DynamicFlags::FLEXIBLE,
1108        )
1109    }
1110}
1111
1112#[must_use = "FIDL methods require a response to be sent"]
1113#[derive(Debug)]
1114pub struct HostControllerSetDiscoverabilityResponder {
1115    control_handle: std::mem::ManuallyDrop<HostControllerControlHandle>,
1116    tx_id: u32,
1117}
1118
1119/// Set the the channel to be shutdown (see [`HostControllerControlHandle::shutdown`])
1120/// if the responder is dropped without sending a response, so that the client
1121/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1122impl std::ops::Drop for HostControllerSetDiscoverabilityResponder {
1123    fn drop(&mut self) {
1124        self.control_handle.shutdown();
1125        // Safety: drops once, never accessed again
1126        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1127    }
1128}
1129
1130impl fidl::endpoints::Responder for HostControllerSetDiscoverabilityResponder {
1131    type ControlHandle = HostControllerControlHandle;
1132
1133    fn control_handle(&self) -> &HostControllerControlHandle {
1134        &self.control_handle
1135    }
1136
1137    fn drop_without_shutdown(mut self) {
1138        // Safety: drops once, never accessed again due to mem::forget
1139        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1140        // Prevent Drop from running (which would shut down the channel)
1141        std::mem::forget(self);
1142    }
1143}
1144
1145impl HostControllerSetDiscoverabilityResponder {
1146    /// Sends a response to the FIDL transaction.
1147    ///
1148    /// Sets the channel to shutdown if an error occurs.
1149    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1150        let _result = self.send_raw(result);
1151        if _result.is_err() {
1152            self.control_handle.shutdown();
1153        }
1154        self.drop_without_shutdown();
1155        _result
1156    }
1157
1158    /// Similar to "send" but does not shutdown the channel if an error occurs.
1159    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1160        let _result = self.send_raw(result);
1161        self.drop_without_shutdown();
1162        _result
1163    }
1164
1165    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1166        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1167            fidl::encoding::EmptyStruct,
1168            Error,
1169        >>(
1170            fidl::encoding::FlexibleResult::new(result),
1171            self.tx_id,
1172            0x1e977b538b94b08b,
1173            fidl::encoding::DynamicFlags::FLEXIBLE,
1174        )
1175    }
1176}
1177
1178#[must_use = "FIDL methods require a response to be sent"]
1179#[derive(Debug)]
1180pub struct HostControllerSetLocalNameResponder {
1181    control_handle: std::mem::ManuallyDrop<HostControllerControlHandle>,
1182    tx_id: u32,
1183}
1184
1185/// Set the the channel to be shutdown (see [`HostControllerControlHandle::shutdown`])
1186/// if the responder is dropped without sending a response, so that the client
1187/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1188impl std::ops::Drop for HostControllerSetLocalNameResponder {
1189    fn drop(&mut self) {
1190        self.control_handle.shutdown();
1191        // Safety: drops once, never accessed again
1192        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1193    }
1194}
1195
1196impl fidl::endpoints::Responder for HostControllerSetLocalNameResponder {
1197    type ControlHandle = HostControllerControlHandle;
1198
1199    fn control_handle(&self) -> &HostControllerControlHandle {
1200        &self.control_handle
1201    }
1202
1203    fn drop_without_shutdown(mut self) {
1204        // Safety: drops once, never accessed again due to mem::forget
1205        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1206        // Prevent Drop from running (which would shut down the channel)
1207        std::mem::forget(self);
1208    }
1209}
1210
1211impl HostControllerSetLocalNameResponder {
1212    /// Sends a response to the FIDL transaction.
1213    ///
1214    /// Sets the channel to shutdown if an error occurs.
1215    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1216        let _result = self.send_raw(result);
1217        if _result.is_err() {
1218            self.control_handle.shutdown();
1219        }
1220        self.drop_without_shutdown();
1221        _result
1222    }
1223
1224    /// Similar to "send" but does not shutdown the channel if an error occurs.
1225    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1226        let _result = self.send_raw(result);
1227        self.drop_without_shutdown();
1228        _result
1229    }
1230
1231    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1232        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1233            fidl::encoding::EmptyStruct,
1234            Error,
1235        >>(
1236            fidl::encoding::FlexibleResult::new(result),
1237            self.tx_id,
1238            0x357714c7aa252336,
1239            fidl::encoding::DynamicFlags::FLEXIBLE,
1240        )
1241    }
1242}
1243
1244#[must_use = "FIDL methods require a response to be sent"]
1245#[derive(Debug)]
1246pub struct HostControllerStartPairingDelegateResponder {
1247    control_handle: std::mem::ManuallyDrop<HostControllerControlHandle>,
1248    tx_id: u32,
1249}
1250
1251/// Set the the channel to be shutdown (see [`HostControllerControlHandle::shutdown`])
1252/// if the responder is dropped without sending a response, so that the client
1253/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1254impl std::ops::Drop for HostControllerStartPairingDelegateResponder {
1255    fn drop(&mut self) {
1256        self.control_handle.shutdown();
1257        // Safety: drops once, never accessed again
1258        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1259    }
1260}
1261
1262impl fidl::endpoints::Responder for HostControllerStartPairingDelegateResponder {
1263    type ControlHandle = HostControllerControlHandle;
1264
1265    fn control_handle(&self) -> &HostControllerControlHandle {
1266        &self.control_handle
1267    }
1268
1269    fn drop_without_shutdown(mut self) {
1270        // Safety: drops once, never accessed again due to mem::forget
1271        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1272        // Prevent Drop from running (which would shut down the channel)
1273        std::mem::forget(self);
1274    }
1275}
1276
1277impl HostControllerStartPairingDelegateResponder {
1278    /// Sends a response to the FIDL transaction.
1279    ///
1280    /// Sets the channel to shutdown if an error occurs.
1281    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1282        let _result = self.send_raw(result);
1283        if _result.is_err() {
1284            self.control_handle.shutdown();
1285        }
1286        self.drop_without_shutdown();
1287        _result
1288    }
1289
1290    /// Similar to "send" but does not shutdown the channel if an error occurs.
1291    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1292        let _result = self.send_raw(result);
1293        self.drop_without_shutdown();
1294        _result
1295    }
1296
1297    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1298        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1299            fidl::encoding::EmptyStruct,
1300            Error,
1301        >>(
1302            fidl::encoding::FlexibleResult::new(result),
1303            self.tx_id,
1304            0x155c20cb1b9c1ed2,
1305            fidl::encoding::DynamicFlags::FLEXIBLE,
1306        )
1307    }
1308}
1309
1310#[must_use = "FIDL methods require a response to be sent"]
1311#[derive(Debug)]
1312pub struct HostControllerStopPairingDelegateResponder {
1313    control_handle: std::mem::ManuallyDrop<HostControllerControlHandle>,
1314    tx_id: u32,
1315}
1316
1317/// Set the the channel to be shutdown (see [`HostControllerControlHandle::shutdown`])
1318/// if the responder is dropped without sending a response, so that the client
1319/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1320impl std::ops::Drop for HostControllerStopPairingDelegateResponder {
1321    fn drop(&mut self) {
1322        self.control_handle.shutdown();
1323        // Safety: drops once, never accessed again
1324        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1325    }
1326}
1327
1328impl fidl::endpoints::Responder for HostControllerStopPairingDelegateResponder {
1329    type ControlHandle = HostControllerControlHandle;
1330
1331    fn control_handle(&self) -> &HostControllerControlHandle {
1332        &self.control_handle
1333    }
1334
1335    fn drop_without_shutdown(mut self) {
1336        // Safety: drops once, never accessed again due to mem::forget
1337        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1338        // Prevent Drop from running (which would shut down the channel)
1339        std::mem::forget(self);
1340    }
1341}
1342
1343impl HostControllerStopPairingDelegateResponder {
1344    /// Sends a response to the FIDL transaction.
1345    ///
1346    /// Sets the channel to shutdown if an error occurs.
1347    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1348        let _result = self.send_raw(result);
1349        if _result.is_err() {
1350            self.control_handle.shutdown();
1351        }
1352        self.drop_without_shutdown();
1353        _result
1354    }
1355
1356    /// Similar to "send" but does not shutdown the channel if an error occurs.
1357    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1358        let _result = self.send_raw(result);
1359        self.drop_without_shutdown();
1360        _result
1361    }
1362
1363    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1364        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1365            fidl::encoding::EmptyStruct,
1366            Error,
1367        >>(
1368            fidl::encoding::FlexibleResult::new(result),
1369            self.tx_id,
1370            0x5caaee1192a8172c,
1371            fidl::encoding::DynamicFlags::FLEXIBLE,
1372        )
1373    }
1374}
1375
1376#[must_use = "FIDL methods require a response to be sent"]
1377#[derive(Debug)]
1378pub struct HostControllerSetDeviceClassResponder {
1379    control_handle: std::mem::ManuallyDrop<HostControllerControlHandle>,
1380    tx_id: u32,
1381}
1382
1383/// Set the the channel to be shutdown (see [`HostControllerControlHandle::shutdown`])
1384/// if the responder is dropped without sending a response, so that the client
1385/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1386impl std::ops::Drop for HostControllerSetDeviceClassResponder {
1387    fn drop(&mut self) {
1388        self.control_handle.shutdown();
1389        // Safety: drops once, never accessed again
1390        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1391    }
1392}
1393
1394impl fidl::endpoints::Responder for HostControllerSetDeviceClassResponder {
1395    type ControlHandle = HostControllerControlHandle;
1396
1397    fn control_handle(&self) -> &HostControllerControlHandle {
1398        &self.control_handle
1399    }
1400
1401    fn drop_without_shutdown(mut self) {
1402        // Safety: drops once, never accessed again due to mem::forget
1403        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1404        // Prevent Drop from running (which would shut down the channel)
1405        std::mem::forget(self);
1406    }
1407}
1408
1409impl HostControllerSetDeviceClassResponder {
1410    /// Sends a response to the FIDL transaction.
1411    ///
1412    /// Sets the channel to shutdown if an error occurs.
1413    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1414        let _result = self.send_raw(result);
1415        if _result.is_err() {
1416            self.control_handle.shutdown();
1417        }
1418        self.drop_without_shutdown();
1419        _result
1420    }
1421
1422    /// Similar to "send" but does not shutdown the channel if an error occurs.
1423    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1424        let _result = self.send_raw(result);
1425        self.drop_without_shutdown();
1426        _result
1427    }
1428
1429    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1430        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1431            fidl::encoding::EmptyStruct,
1432            Error,
1433        >>(
1434            fidl::encoding::FlexibleResult::new(result),
1435            self.tx_id,
1436            0x34dcc9ed479692dc,
1437            fidl::encoding::DynamicFlags::FLEXIBLE,
1438        )
1439    }
1440}
1441
1442#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1443pub struct PeerControllerMarker;
1444
1445impl fidl::endpoints::ProtocolMarker for PeerControllerMarker {
1446    type Proxy = PeerControllerProxy;
1447    type RequestStream = PeerControllerRequestStream;
1448    #[cfg(target_os = "fuchsia")]
1449    type SynchronousProxy = PeerControllerSynchronousProxy;
1450
1451    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.affordances.PeerController";
1452}
1453impl fidl::endpoints::DiscoverableProtocolMarker for PeerControllerMarker {}
1454pub type PeerControllerGetKnownPeersResult = Result<PeerControllerGetKnownPeersResponse, Error>;
1455pub type PeerControllerConnectPeerResult = Result<(), Error>;
1456pub type PeerControllerDisconnectPeerResult = Result<(), Error>;
1457pub type PeerControllerPairResult = Result<(), Error>;
1458pub type PeerControllerForgetPeerResult = Result<(), Error>;
1459pub type PeerControllerSetDiscoveryResult = Result<(), Error>;
1460
1461pub trait PeerControllerProxyInterface: Send + Sync {
1462    type GetKnownPeersResponseFut: std::future::Future<Output = Result<PeerControllerGetKnownPeersResult, fidl::Error>>
1463        + Send;
1464    fn r#get_known_peers(&self) -> Self::GetKnownPeersResponseFut;
1465    type ConnectPeerResponseFut: std::future::Future<Output = Result<PeerControllerConnectPeerResult, fidl::Error>>
1466        + Send;
1467    fn r#connect_peer(&self, payload: &PeerSelector) -> Self::ConnectPeerResponseFut;
1468    type DisconnectPeerResponseFut: std::future::Future<Output = Result<PeerControllerDisconnectPeerResult, fidl::Error>>
1469        + Send;
1470    fn r#disconnect_peer(&self, payload: &PeerSelector) -> Self::DisconnectPeerResponseFut;
1471    type PairResponseFut: std::future::Future<Output = Result<PeerControllerPairResult, fidl::Error>>
1472        + Send;
1473    fn r#pair(&self, payload: &PeerControllerPairRequest) -> Self::PairResponseFut;
1474    type ForgetPeerResponseFut: std::future::Future<Output = Result<PeerControllerForgetPeerResult, fidl::Error>>
1475        + Send;
1476    fn r#forget_peer(&self, payload: &PeerSelector) -> Self::ForgetPeerResponseFut;
1477    type SetDiscoveryResponseFut: std::future::Future<Output = Result<PeerControllerSetDiscoveryResult, fidl::Error>>
1478        + Send;
1479    fn r#set_discovery(
1480        &self,
1481        payload: &PeerControllerSetDiscoveryRequest,
1482    ) -> Self::SetDiscoveryResponseFut;
1483}
1484#[derive(Debug)]
1485#[cfg(target_os = "fuchsia")]
1486pub struct PeerControllerSynchronousProxy {
1487    client: fidl::client::sync::Client,
1488}
1489
1490#[cfg(target_os = "fuchsia")]
1491impl fidl::endpoints::SynchronousProxy for PeerControllerSynchronousProxy {
1492    type Proxy = PeerControllerProxy;
1493    type Protocol = PeerControllerMarker;
1494
1495    fn from_channel(inner: fidl::Channel) -> Self {
1496        Self::new(inner)
1497    }
1498
1499    fn into_channel(self) -> fidl::Channel {
1500        self.client.into_channel()
1501    }
1502
1503    fn as_channel(&self) -> &fidl::Channel {
1504        self.client.as_channel()
1505    }
1506}
1507
1508#[cfg(target_os = "fuchsia")]
1509impl PeerControllerSynchronousProxy {
1510    pub fn new(channel: fidl::Channel) -> Self {
1511        Self { client: fidl::client::sync::Client::new(channel) }
1512    }
1513
1514    pub fn into_channel(self) -> fidl::Channel {
1515        self.client.into_channel()
1516    }
1517
1518    /// Waits until an event arrives and returns it. It is safe for other
1519    /// threads to make concurrent requests while waiting for an event.
1520    pub fn wait_for_event(
1521        &self,
1522        deadline: zx::MonotonicInstant,
1523    ) -> Result<PeerControllerEvent, fidl::Error> {
1524        PeerControllerEvent::decode(self.client.wait_for_event::<PeerControllerMarker>(deadline)?)
1525    }
1526
1527    /// Get a list of discovered peers.
1528    ///
1529    /// * error Returns `INTERNAL` if the operation failed (check logs).
1530    pub fn r#get_known_peers(
1531        &self,
1532        ___deadline: zx::MonotonicInstant,
1533    ) -> Result<PeerControllerGetKnownPeersResult, fidl::Error> {
1534        let _response = self.client.send_query::<
1535            fidl::encoding::EmptyPayload,
1536            fidl::encoding::FlexibleResultType<PeerControllerGetKnownPeersResponse, Error>,
1537            PeerControllerMarker,
1538        >(
1539            (),
1540            0x482cf3745bab65f6,
1541            fidl::encoding::DynamicFlags::FLEXIBLE,
1542            ___deadline,
1543        )?
1544        .into_result::<PeerControllerMarker>("get_known_peers")?;
1545        Ok(_response.map(|x| x))
1546    }
1547
1548    /// Connect to a peer.
1549    ///
1550    /// * error Returns `INTERNAL` if the operation failed (check logs).
1551    pub fn r#connect_peer(
1552        &self,
1553        mut payload: &PeerSelector,
1554        ___deadline: zx::MonotonicInstant,
1555    ) -> Result<PeerControllerConnectPeerResult, fidl::Error> {
1556        let _response = self.client.send_query::<
1557            PeerSelector,
1558            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1559            PeerControllerMarker,
1560        >(
1561            payload,
1562            0x13fbb990835acf66,
1563            fidl::encoding::DynamicFlags::FLEXIBLE,
1564            ___deadline,
1565        )?
1566        .into_result::<PeerControllerMarker>("connect_peer")?;
1567        Ok(_response.map(|x| x))
1568    }
1569
1570    /// Disconnect all logical links (BR/EDR & LE) to a peer.
1571    ///
1572    /// * error Returns `INTERNAL` if the operation failed (check logs).
1573    pub fn r#disconnect_peer(
1574        &self,
1575        mut payload: &PeerSelector,
1576        ___deadline: zx::MonotonicInstant,
1577    ) -> Result<PeerControllerDisconnectPeerResult, fidl::Error> {
1578        let _response = self.client.send_query::<
1579            PeerSelector,
1580            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1581            PeerControllerMarker,
1582        >(
1583            payload,
1584            0x5f9992f066c664ad,
1585            fidl::encoding::DynamicFlags::FLEXIBLE,
1586            ___deadline,
1587        )?
1588        .into_result::<PeerControllerMarker>("disconnect_peer")?;
1589        Ok(_response.map(|x| x))
1590    }
1591
1592    /// Initiate pairing with a peer.
1593    ///
1594    /// * error Returns `INTERNAL` if the operation failed (check logs).
1595    pub fn r#pair(
1596        &self,
1597        mut payload: &PeerControllerPairRequest,
1598        ___deadline: zx::MonotonicInstant,
1599    ) -> Result<PeerControllerPairResult, fidl::Error> {
1600        let _response = self.client.send_query::<
1601            PeerControllerPairRequest,
1602            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1603            PeerControllerMarker,
1604        >(
1605            payload,
1606            0x1991671d4d7eff26,
1607            fidl::encoding::DynamicFlags::FLEXIBLE,
1608            ___deadline,
1609        )?
1610        .into_result::<PeerControllerMarker>("pair")?;
1611        Ok(_response.map(|x| x))
1612    }
1613
1614    /// Forget a peer and all its bonding information.
1615    ///
1616    /// * error Returns `INTERNAL` if the operation failed (check logs).
1617    pub fn r#forget_peer(
1618        &self,
1619        mut payload: &PeerSelector,
1620        ___deadline: zx::MonotonicInstant,
1621    ) -> Result<PeerControllerForgetPeerResult, fidl::Error> {
1622        let _response = self.client.send_query::<
1623            PeerSelector,
1624            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1625            PeerControllerMarker,
1626        >(
1627            payload,
1628            0x26011dbbd834f8c6,
1629            fidl::encoding::DynamicFlags::FLEXIBLE,
1630            ___deadline,
1631        )?
1632        .into_result::<PeerControllerMarker>("forget_peer")?;
1633        Ok(_response.map(|x| x))
1634    }
1635
1636    /// Set discovery state.
1637    ///
1638    /// * error Returns `INTERNAL` if the operation failed (check logs).
1639    pub fn r#set_discovery(
1640        &self,
1641        mut payload: &PeerControllerSetDiscoveryRequest,
1642        ___deadline: zx::MonotonicInstant,
1643    ) -> Result<PeerControllerSetDiscoveryResult, fidl::Error> {
1644        let _response = self.client.send_query::<
1645            PeerControllerSetDiscoveryRequest,
1646            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1647            PeerControllerMarker,
1648        >(
1649            payload,
1650            0x3269624c9e1d6ab3,
1651            fidl::encoding::DynamicFlags::FLEXIBLE,
1652            ___deadline,
1653        )?
1654        .into_result::<PeerControllerMarker>("set_discovery")?;
1655        Ok(_response.map(|x| x))
1656    }
1657}
1658
1659#[cfg(target_os = "fuchsia")]
1660impl From<PeerControllerSynchronousProxy> for zx::NullableHandle {
1661    fn from(value: PeerControllerSynchronousProxy) -> Self {
1662        value.into_channel().into()
1663    }
1664}
1665
1666#[cfg(target_os = "fuchsia")]
1667impl From<fidl::Channel> for PeerControllerSynchronousProxy {
1668    fn from(value: fidl::Channel) -> Self {
1669        Self::new(value)
1670    }
1671}
1672
1673#[cfg(target_os = "fuchsia")]
1674impl fidl::endpoints::FromClient for PeerControllerSynchronousProxy {
1675    type Protocol = PeerControllerMarker;
1676
1677    fn from_client(value: fidl::endpoints::ClientEnd<PeerControllerMarker>) -> Self {
1678        Self::new(value.into_channel())
1679    }
1680}
1681
1682#[derive(Debug, Clone)]
1683pub struct PeerControllerProxy {
1684    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1685}
1686
1687impl fidl::endpoints::Proxy for PeerControllerProxy {
1688    type Protocol = PeerControllerMarker;
1689
1690    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1691        Self::new(inner)
1692    }
1693
1694    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1695        self.client.into_channel().map_err(|client| Self { client })
1696    }
1697
1698    fn as_channel(&self) -> &::fidl::AsyncChannel {
1699        self.client.as_channel()
1700    }
1701}
1702
1703impl PeerControllerProxy {
1704    /// Create a new Proxy for fuchsia.bluetooth.affordances/PeerController.
1705    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1706        let protocol_name = <PeerControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1707        Self { client: fidl::client::Client::new(channel, protocol_name) }
1708    }
1709
1710    /// Get a Stream of events from the remote end of the protocol.
1711    ///
1712    /// # Panics
1713    ///
1714    /// Panics if the event stream was already taken.
1715    pub fn take_event_stream(&self) -> PeerControllerEventStream {
1716        PeerControllerEventStream { event_receiver: self.client.take_event_receiver() }
1717    }
1718
1719    /// Get a list of discovered peers.
1720    ///
1721    /// * error Returns `INTERNAL` if the operation failed (check logs).
1722    pub fn r#get_known_peers(
1723        &self,
1724    ) -> fidl::client::QueryResponseFut<
1725        PeerControllerGetKnownPeersResult,
1726        fidl::encoding::DefaultFuchsiaResourceDialect,
1727    > {
1728        PeerControllerProxyInterface::r#get_known_peers(self)
1729    }
1730
1731    /// Connect to a peer.
1732    ///
1733    /// * error Returns `INTERNAL` if the operation failed (check logs).
1734    pub fn r#connect_peer(
1735        &self,
1736        mut payload: &PeerSelector,
1737    ) -> fidl::client::QueryResponseFut<
1738        PeerControllerConnectPeerResult,
1739        fidl::encoding::DefaultFuchsiaResourceDialect,
1740    > {
1741        PeerControllerProxyInterface::r#connect_peer(self, payload)
1742    }
1743
1744    /// Disconnect all logical links (BR/EDR & LE) to a peer.
1745    ///
1746    /// * error Returns `INTERNAL` if the operation failed (check logs).
1747    pub fn r#disconnect_peer(
1748        &self,
1749        mut payload: &PeerSelector,
1750    ) -> fidl::client::QueryResponseFut<
1751        PeerControllerDisconnectPeerResult,
1752        fidl::encoding::DefaultFuchsiaResourceDialect,
1753    > {
1754        PeerControllerProxyInterface::r#disconnect_peer(self, payload)
1755    }
1756
1757    /// Initiate pairing with a peer.
1758    ///
1759    /// * error Returns `INTERNAL` if the operation failed (check logs).
1760    pub fn r#pair(
1761        &self,
1762        mut payload: &PeerControllerPairRequest,
1763    ) -> fidl::client::QueryResponseFut<
1764        PeerControllerPairResult,
1765        fidl::encoding::DefaultFuchsiaResourceDialect,
1766    > {
1767        PeerControllerProxyInterface::r#pair(self, payload)
1768    }
1769
1770    /// Forget a peer and all its bonding information.
1771    ///
1772    /// * error Returns `INTERNAL` if the operation failed (check logs).
1773    pub fn r#forget_peer(
1774        &self,
1775        mut payload: &PeerSelector,
1776    ) -> fidl::client::QueryResponseFut<
1777        PeerControllerForgetPeerResult,
1778        fidl::encoding::DefaultFuchsiaResourceDialect,
1779    > {
1780        PeerControllerProxyInterface::r#forget_peer(self, payload)
1781    }
1782
1783    /// Set discovery state.
1784    ///
1785    /// * error Returns `INTERNAL` if the operation failed (check logs).
1786    pub fn r#set_discovery(
1787        &self,
1788        mut payload: &PeerControllerSetDiscoveryRequest,
1789    ) -> fidl::client::QueryResponseFut<
1790        PeerControllerSetDiscoveryResult,
1791        fidl::encoding::DefaultFuchsiaResourceDialect,
1792    > {
1793        PeerControllerProxyInterface::r#set_discovery(self, payload)
1794    }
1795}
1796
1797impl PeerControllerProxyInterface for PeerControllerProxy {
1798    type GetKnownPeersResponseFut = fidl::client::QueryResponseFut<
1799        PeerControllerGetKnownPeersResult,
1800        fidl::encoding::DefaultFuchsiaResourceDialect,
1801    >;
1802    fn r#get_known_peers(&self) -> Self::GetKnownPeersResponseFut {
1803        fn _decode(
1804            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1805        ) -> Result<PeerControllerGetKnownPeersResult, fidl::Error> {
1806            let _response = fidl::client::decode_transaction_body::<
1807                fidl::encoding::FlexibleResultType<PeerControllerGetKnownPeersResponse, Error>,
1808                fidl::encoding::DefaultFuchsiaResourceDialect,
1809                0x482cf3745bab65f6,
1810            >(_buf?)?
1811            .into_result::<PeerControllerMarker>("get_known_peers")?;
1812            Ok(_response.map(|x| x))
1813        }
1814        self.client.send_query_and_decode::<
1815            fidl::encoding::EmptyPayload,
1816            PeerControllerGetKnownPeersResult,
1817        >(
1818            (),
1819            0x482cf3745bab65f6,
1820            fidl::encoding::DynamicFlags::FLEXIBLE,
1821            _decode,
1822        )
1823    }
1824
1825    type ConnectPeerResponseFut = fidl::client::QueryResponseFut<
1826        PeerControllerConnectPeerResult,
1827        fidl::encoding::DefaultFuchsiaResourceDialect,
1828    >;
1829    fn r#connect_peer(&self, mut payload: &PeerSelector) -> Self::ConnectPeerResponseFut {
1830        fn _decode(
1831            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1832        ) -> Result<PeerControllerConnectPeerResult, fidl::Error> {
1833            let _response = fidl::client::decode_transaction_body::<
1834                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1835                fidl::encoding::DefaultFuchsiaResourceDialect,
1836                0x13fbb990835acf66,
1837            >(_buf?)?
1838            .into_result::<PeerControllerMarker>("connect_peer")?;
1839            Ok(_response.map(|x| x))
1840        }
1841        self.client.send_query_and_decode::<PeerSelector, PeerControllerConnectPeerResult>(
1842            payload,
1843            0x13fbb990835acf66,
1844            fidl::encoding::DynamicFlags::FLEXIBLE,
1845            _decode,
1846        )
1847    }
1848
1849    type DisconnectPeerResponseFut = fidl::client::QueryResponseFut<
1850        PeerControllerDisconnectPeerResult,
1851        fidl::encoding::DefaultFuchsiaResourceDialect,
1852    >;
1853    fn r#disconnect_peer(&self, mut payload: &PeerSelector) -> Self::DisconnectPeerResponseFut {
1854        fn _decode(
1855            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1856        ) -> Result<PeerControllerDisconnectPeerResult, fidl::Error> {
1857            let _response = fidl::client::decode_transaction_body::<
1858                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1859                fidl::encoding::DefaultFuchsiaResourceDialect,
1860                0x5f9992f066c664ad,
1861            >(_buf?)?
1862            .into_result::<PeerControllerMarker>("disconnect_peer")?;
1863            Ok(_response.map(|x| x))
1864        }
1865        self.client.send_query_and_decode::<PeerSelector, PeerControllerDisconnectPeerResult>(
1866            payload,
1867            0x5f9992f066c664ad,
1868            fidl::encoding::DynamicFlags::FLEXIBLE,
1869            _decode,
1870        )
1871    }
1872
1873    type PairResponseFut = fidl::client::QueryResponseFut<
1874        PeerControllerPairResult,
1875        fidl::encoding::DefaultFuchsiaResourceDialect,
1876    >;
1877    fn r#pair(&self, mut payload: &PeerControllerPairRequest) -> Self::PairResponseFut {
1878        fn _decode(
1879            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1880        ) -> Result<PeerControllerPairResult, fidl::Error> {
1881            let _response = fidl::client::decode_transaction_body::<
1882                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1883                fidl::encoding::DefaultFuchsiaResourceDialect,
1884                0x1991671d4d7eff26,
1885            >(_buf?)?
1886            .into_result::<PeerControllerMarker>("pair")?;
1887            Ok(_response.map(|x| x))
1888        }
1889        self.client.send_query_and_decode::<PeerControllerPairRequest, PeerControllerPairResult>(
1890            payload,
1891            0x1991671d4d7eff26,
1892            fidl::encoding::DynamicFlags::FLEXIBLE,
1893            _decode,
1894        )
1895    }
1896
1897    type ForgetPeerResponseFut = fidl::client::QueryResponseFut<
1898        PeerControllerForgetPeerResult,
1899        fidl::encoding::DefaultFuchsiaResourceDialect,
1900    >;
1901    fn r#forget_peer(&self, mut payload: &PeerSelector) -> Self::ForgetPeerResponseFut {
1902        fn _decode(
1903            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1904        ) -> Result<PeerControllerForgetPeerResult, fidl::Error> {
1905            let _response = fidl::client::decode_transaction_body::<
1906                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1907                fidl::encoding::DefaultFuchsiaResourceDialect,
1908                0x26011dbbd834f8c6,
1909            >(_buf?)?
1910            .into_result::<PeerControllerMarker>("forget_peer")?;
1911            Ok(_response.map(|x| x))
1912        }
1913        self.client.send_query_and_decode::<PeerSelector, PeerControllerForgetPeerResult>(
1914            payload,
1915            0x26011dbbd834f8c6,
1916            fidl::encoding::DynamicFlags::FLEXIBLE,
1917            _decode,
1918        )
1919    }
1920
1921    type SetDiscoveryResponseFut = fidl::client::QueryResponseFut<
1922        PeerControllerSetDiscoveryResult,
1923        fidl::encoding::DefaultFuchsiaResourceDialect,
1924    >;
1925    fn r#set_discovery(
1926        &self,
1927        mut payload: &PeerControllerSetDiscoveryRequest,
1928    ) -> Self::SetDiscoveryResponseFut {
1929        fn _decode(
1930            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1931        ) -> Result<PeerControllerSetDiscoveryResult, fidl::Error> {
1932            let _response = fidl::client::decode_transaction_body::<
1933                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1934                fidl::encoding::DefaultFuchsiaResourceDialect,
1935                0x3269624c9e1d6ab3,
1936            >(_buf?)?
1937            .into_result::<PeerControllerMarker>("set_discovery")?;
1938            Ok(_response.map(|x| x))
1939        }
1940        self.client.send_query_and_decode::<
1941            PeerControllerSetDiscoveryRequest,
1942            PeerControllerSetDiscoveryResult,
1943        >(
1944            payload,
1945            0x3269624c9e1d6ab3,
1946            fidl::encoding::DynamicFlags::FLEXIBLE,
1947            _decode,
1948        )
1949    }
1950}
1951
1952pub struct PeerControllerEventStream {
1953    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1954}
1955
1956impl std::marker::Unpin for PeerControllerEventStream {}
1957
1958impl futures::stream::FusedStream for PeerControllerEventStream {
1959    fn is_terminated(&self) -> bool {
1960        self.event_receiver.is_terminated()
1961    }
1962}
1963
1964impl futures::Stream for PeerControllerEventStream {
1965    type Item = Result<PeerControllerEvent, fidl::Error>;
1966
1967    fn poll_next(
1968        mut self: std::pin::Pin<&mut Self>,
1969        cx: &mut std::task::Context<'_>,
1970    ) -> std::task::Poll<Option<Self::Item>> {
1971        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1972            &mut self.event_receiver,
1973            cx
1974        )?) {
1975            Some(buf) => std::task::Poll::Ready(Some(PeerControllerEvent::decode(buf))),
1976            None => std::task::Poll::Ready(None),
1977        }
1978    }
1979}
1980
1981#[derive(Debug)]
1982pub enum PeerControllerEvent {
1983    #[non_exhaustive]
1984    _UnknownEvent {
1985        /// Ordinal of the event that was sent.
1986        ordinal: u64,
1987    },
1988}
1989
1990impl PeerControllerEvent {
1991    /// Decodes a message buffer as a [`PeerControllerEvent`].
1992    fn decode(
1993        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1994    ) -> Result<PeerControllerEvent, fidl::Error> {
1995        let (bytes, _handles) = buf.split_mut();
1996        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1997        debug_assert_eq!(tx_header.tx_id, 0);
1998        match tx_header.ordinal {
1999            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2000                Ok(PeerControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2001            }
2002            _ => Err(fidl::Error::UnknownOrdinal {
2003                ordinal: tx_header.ordinal,
2004                protocol_name:
2005                    <PeerControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2006            }),
2007        }
2008    }
2009}
2010
2011/// A Stream of incoming requests for fuchsia.bluetooth.affordances/PeerController.
2012pub struct PeerControllerRequestStream {
2013    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2014    is_terminated: bool,
2015}
2016
2017impl std::marker::Unpin for PeerControllerRequestStream {}
2018
2019impl futures::stream::FusedStream for PeerControllerRequestStream {
2020    fn is_terminated(&self) -> bool {
2021        self.is_terminated
2022    }
2023}
2024
2025impl fidl::endpoints::RequestStream for PeerControllerRequestStream {
2026    type Protocol = PeerControllerMarker;
2027    type ControlHandle = PeerControllerControlHandle;
2028
2029    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2030        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2031    }
2032
2033    fn control_handle(&self) -> Self::ControlHandle {
2034        PeerControllerControlHandle { inner: self.inner.clone() }
2035    }
2036
2037    fn into_inner(
2038        self,
2039    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2040    {
2041        (self.inner, self.is_terminated)
2042    }
2043
2044    fn from_inner(
2045        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2046        is_terminated: bool,
2047    ) -> Self {
2048        Self { inner, is_terminated }
2049    }
2050}
2051
2052impl futures::Stream for PeerControllerRequestStream {
2053    type Item = Result<PeerControllerRequest, fidl::Error>;
2054
2055    fn poll_next(
2056        mut self: std::pin::Pin<&mut Self>,
2057        cx: &mut std::task::Context<'_>,
2058    ) -> std::task::Poll<Option<Self::Item>> {
2059        let this = &mut *self;
2060        if this.inner.check_shutdown(cx) {
2061            this.is_terminated = true;
2062            return std::task::Poll::Ready(None);
2063        }
2064        if this.is_terminated {
2065            panic!("polled PeerControllerRequestStream after completion");
2066        }
2067        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2068            |bytes, handles| {
2069                match this.inner.channel().read_etc(cx, bytes, handles) {
2070                    std::task::Poll::Ready(Ok(())) => {}
2071                    std::task::Poll::Pending => return std::task::Poll::Pending,
2072                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2073                        this.is_terminated = true;
2074                        return std::task::Poll::Ready(None);
2075                    }
2076                    std::task::Poll::Ready(Err(e)) => {
2077                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2078                            e.into(),
2079                        ))));
2080                    }
2081                }
2082
2083                // A message has been received from the channel
2084                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2085
2086                std::task::Poll::Ready(Some(match header.ordinal {
2087                    0x482cf3745bab65f6 => {
2088                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2089                        let mut req = fidl::new_empty!(
2090                            fidl::encoding::EmptyPayload,
2091                            fidl::encoding::DefaultFuchsiaResourceDialect
2092                        );
2093                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2094                        let control_handle =
2095                            PeerControllerControlHandle { inner: this.inner.clone() };
2096                        Ok(PeerControllerRequest::GetKnownPeers {
2097                            responder: PeerControllerGetKnownPeersResponder {
2098                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2099                                tx_id: header.tx_id,
2100                            },
2101                        })
2102                    }
2103                    0x13fbb990835acf66 => {
2104                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2105                        let mut req = fidl::new_empty!(
2106                            PeerSelector,
2107                            fidl::encoding::DefaultFuchsiaResourceDialect
2108                        );
2109                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerSelector>(&header, _body_bytes, handles, &mut req)?;
2110                        let control_handle =
2111                            PeerControllerControlHandle { inner: this.inner.clone() };
2112                        Ok(PeerControllerRequest::ConnectPeer {
2113                            payload: req,
2114                            responder: PeerControllerConnectPeerResponder {
2115                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2116                                tx_id: header.tx_id,
2117                            },
2118                        })
2119                    }
2120                    0x5f9992f066c664ad => {
2121                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2122                        let mut req = fidl::new_empty!(
2123                            PeerSelector,
2124                            fidl::encoding::DefaultFuchsiaResourceDialect
2125                        );
2126                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerSelector>(&header, _body_bytes, handles, &mut req)?;
2127                        let control_handle =
2128                            PeerControllerControlHandle { inner: this.inner.clone() };
2129                        Ok(PeerControllerRequest::DisconnectPeer {
2130                            payload: req,
2131                            responder: PeerControllerDisconnectPeerResponder {
2132                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2133                                tx_id: header.tx_id,
2134                            },
2135                        })
2136                    }
2137                    0x1991671d4d7eff26 => {
2138                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2139                        let mut req = fidl::new_empty!(
2140                            PeerControllerPairRequest,
2141                            fidl::encoding::DefaultFuchsiaResourceDialect
2142                        );
2143                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerControllerPairRequest>(&header, _body_bytes, handles, &mut req)?;
2144                        let control_handle =
2145                            PeerControllerControlHandle { inner: this.inner.clone() };
2146                        Ok(PeerControllerRequest::Pair {
2147                            payload: req,
2148                            responder: PeerControllerPairResponder {
2149                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2150                                tx_id: header.tx_id,
2151                            },
2152                        })
2153                    }
2154                    0x26011dbbd834f8c6 => {
2155                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2156                        let mut req = fidl::new_empty!(
2157                            PeerSelector,
2158                            fidl::encoding::DefaultFuchsiaResourceDialect
2159                        );
2160                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerSelector>(&header, _body_bytes, handles, &mut req)?;
2161                        let control_handle =
2162                            PeerControllerControlHandle { inner: this.inner.clone() };
2163                        Ok(PeerControllerRequest::ForgetPeer {
2164                            payload: req,
2165                            responder: PeerControllerForgetPeerResponder {
2166                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2167                                tx_id: header.tx_id,
2168                            },
2169                        })
2170                    }
2171                    0x3269624c9e1d6ab3 => {
2172                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2173                        let mut req = fidl::new_empty!(
2174                            PeerControllerSetDiscoveryRequest,
2175                            fidl::encoding::DefaultFuchsiaResourceDialect
2176                        );
2177                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerControllerSetDiscoveryRequest>(&header, _body_bytes, handles, &mut req)?;
2178                        let control_handle =
2179                            PeerControllerControlHandle { inner: this.inner.clone() };
2180                        Ok(PeerControllerRequest::SetDiscovery {
2181                            payload: req,
2182                            responder: PeerControllerSetDiscoveryResponder {
2183                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2184                                tx_id: header.tx_id,
2185                            },
2186                        })
2187                    }
2188                    _ if header.tx_id == 0
2189                        && header
2190                            .dynamic_flags()
2191                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2192                    {
2193                        Ok(PeerControllerRequest::_UnknownMethod {
2194                            ordinal: header.ordinal,
2195                            control_handle: PeerControllerControlHandle {
2196                                inner: this.inner.clone(),
2197                            },
2198                            method_type: fidl::MethodType::OneWay,
2199                        })
2200                    }
2201                    _ if header
2202                        .dynamic_flags()
2203                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2204                    {
2205                        this.inner.send_framework_err(
2206                            fidl::encoding::FrameworkErr::UnknownMethod,
2207                            header.tx_id,
2208                            header.ordinal,
2209                            header.dynamic_flags(),
2210                            (bytes, handles),
2211                        )?;
2212                        Ok(PeerControllerRequest::_UnknownMethod {
2213                            ordinal: header.ordinal,
2214                            control_handle: PeerControllerControlHandle {
2215                                inner: this.inner.clone(),
2216                            },
2217                            method_type: fidl::MethodType::TwoWay,
2218                        })
2219                    }
2220                    _ => Err(fidl::Error::UnknownOrdinal {
2221                        ordinal: header.ordinal,
2222                        protocol_name:
2223                            <PeerControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2224                    }),
2225                }))
2226            },
2227        )
2228    }
2229}
2230
2231#[derive(Debug)]
2232pub enum PeerControllerRequest {
2233    /// Get a list of discovered peers.
2234    ///
2235    /// * error Returns `INTERNAL` if the operation failed (check logs).
2236    GetKnownPeers { responder: PeerControllerGetKnownPeersResponder },
2237    /// Connect to a peer.
2238    ///
2239    /// * error Returns `INTERNAL` if the operation failed (check logs).
2240    ConnectPeer { payload: PeerSelector, responder: PeerControllerConnectPeerResponder },
2241    /// Disconnect all logical links (BR/EDR & LE) to a peer.
2242    ///
2243    /// * error Returns `INTERNAL` if the operation failed (check logs).
2244    DisconnectPeer { payload: PeerSelector, responder: PeerControllerDisconnectPeerResponder },
2245    /// Initiate pairing with a peer.
2246    ///
2247    /// * error Returns `INTERNAL` if the operation failed (check logs).
2248    Pair { payload: PeerControllerPairRequest, responder: PeerControllerPairResponder },
2249    /// Forget a peer and all its bonding information.
2250    ///
2251    /// * error Returns `INTERNAL` if the operation failed (check logs).
2252    ForgetPeer { payload: PeerSelector, responder: PeerControllerForgetPeerResponder },
2253    /// Set discovery state.
2254    ///
2255    /// * error Returns `INTERNAL` if the operation failed (check logs).
2256    SetDiscovery {
2257        payload: PeerControllerSetDiscoveryRequest,
2258        responder: PeerControllerSetDiscoveryResponder,
2259    },
2260    /// An interaction was received which does not match any known method.
2261    #[non_exhaustive]
2262    _UnknownMethod {
2263        /// Ordinal of the method that was called.
2264        ordinal: u64,
2265        control_handle: PeerControllerControlHandle,
2266        method_type: fidl::MethodType,
2267    },
2268}
2269
2270impl PeerControllerRequest {
2271    #[allow(irrefutable_let_patterns)]
2272    pub fn into_get_known_peers(self) -> Option<(PeerControllerGetKnownPeersResponder)> {
2273        if let PeerControllerRequest::GetKnownPeers { responder } = self {
2274            Some((responder))
2275        } else {
2276            None
2277        }
2278    }
2279
2280    #[allow(irrefutable_let_patterns)]
2281    pub fn into_connect_peer(self) -> Option<(PeerSelector, PeerControllerConnectPeerResponder)> {
2282        if let PeerControllerRequest::ConnectPeer { payload, responder } = self {
2283            Some((payload, responder))
2284        } else {
2285            None
2286        }
2287    }
2288
2289    #[allow(irrefutable_let_patterns)]
2290    pub fn into_disconnect_peer(
2291        self,
2292    ) -> Option<(PeerSelector, PeerControllerDisconnectPeerResponder)> {
2293        if let PeerControllerRequest::DisconnectPeer { payload, responder } = self {
2294            Some((payload, responder))
2295        } else {
2296            None
2297        }
2298    }
2299
2300    #[allow(irrefutable_let_patterns)]
2301    pub fn into_pair(self) -> Option<(PeerControllerPairRequest, PeerControllerPairResponder)> {
2302        if let PeerControllerRequest::Pair { payload, responder } = self {
2303            Some((payload, responder))
2304        } else {
2305            None
2306        }
2307    }
2308
2309    #[allow(irrefutable_let_patterns)]
2310    pub fn into_forget_peer(self) -> Option<(PeerSelector, PeerControllerForgetPeerResponder)> {
2311        if let PeerControllerRequest::ForgetPeer { payload, responder } = self {
2312            Some((payload, responder))
2313        } else {
2314            None
2315        }
2316    }
2317
2318    #[allow(irrefutable_let_patterns)]
2319    pub fn into_set_discovery(
2320        self,
2321    ) -> Option<(PeerControllerSetDiscoveryRequest, PeerControllerSetDiscoveryResponder)> {
2322        if let PeerControllerRequest::SetDiscovery { payload, responder } = self {
2323            Some((payload, responder))
2324        } else {
2325            None
2326        }
2327    }
2328
2329    /// Name of the method defined in FIDL
2330    pub fn method_name(&self) -> &'static str {
2331        match *self {
2332            PeerControllerRequest::GetKnownPeers { .. } => "get_known_peers",
2333            PeerControllerRequest::ConnectPeer { .. } => "connect_peer",
2334            PeerControllerRequest::DisconnectPeer { .. } => "disconnect_peer",
2335            PeerControllerRequest::Pair { .. } => "pair",
2336            PeerControllerRequest::ForgetPeer { .. } => "forget_peer",
2337            PeerControllerRequest::SetDiscovery { .. } => "set_discovery",
2338            PeerControllerRequest::_UnknownMethod {
2339                method_type: fidl::MethodType::OneWay, ..
2340            } => "unknown one-way method",
2341            PeerControllerRequest::_UnknownMethod {
2342                method_type: fidl::MethodType::TwoWay, ..
2343            } => "unknown two-way method",
2344        }
2345    }
2346}
2347
2348#[derive(Debug, Clone)]
2349pub struct PeerControllerControlHandle {
2350    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2351}
2352
2353impl fidl::endpoints::ControlHandle for PeerControllerControlHandle {
2354    fn shutdown(&self) {
2355        self.inner.shutdown()
2356    }
2357
2358    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2359        self.inner.shutdown_with_epitaph(status)
2360    }
2361
2362    fn is_closed(&self) -> bool {
2363        self.inner.channel().is_closed()
2364    }
2365    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2366        self.inner.channel().on_closed()
2367    }
2368
2369    #[cfg(target_os = "fuchsia")]
2370    fn signal_peer(
2371        &self,
2372        clear_mask: zx::Signals,
2373        set_mask: zx::Signals,
2374    ) -> Result<(), zx_status::Status> {
2375        use fidl::Peered;
2376        self.inner.channel().signal_peer(clear_mask, set_mask)
2377    }
2378}
2379
2380impl PeerControllerControlHandle {}
2381
2382#[must_use = "FIDL methods require a response to be sent"]
2383#[derive(Debug)]
2384pub struct PeerControllerGetKnownPeersResponder {
2385    control_handle: std::mem::ManuallyDrop<PeerControllerControlHandle>,
2386    tx_id: u32,
2387}
2388
2389/// Set the the channel to be shutdown (see [`PeerControllerControlHandle::shutdown`])
2390/// if the responder is dropped without sending a response, so that the client
2391/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2392impl std::ops::Drop for PeerControllerGetKnownPeersResponder {
2393    fn drop(&mut self) {
2394        self.control_handle.shutdown();
2395        // Safety: drops once, never accessed again
2396        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2397    }
2398}
2399
2400impl fidl::endpoints::Responder for PeerControllerGetKnownPeersResponder {
2401    type ControlHandle = PeerControllerControlHandle;
2402
2403    fn control_handle(&self) -> &PeerControllerControlHandle {
2404        &self.control_handle
2405    }
2406
2407    fn drop_without_shutdown(mut self) {
2408        // Safety: drops once, never accessed again due to mem::forget
2409        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2410        // Prevent Drop from running (which would shut down the channel)
2411        std::mem::forget(self);
2412    }
2413}
2414
2415impl PeerControllerGetKnownPeersResponder {
2416    /// Sends a response to the FIDL transaction.
2417    ///
2418    /// Sets the channel to shutdown if an error occurs.
2419    pub fn send(
2420        self,
2421        mut result: Result<&PeerControllerGetKnownPeersResponse, Error>,
2422    ) -> Result<(), fidl::Error> {
2423        let _result = self.send_raw(result);
2424        if _result.is_err() {
2425            self.control_handle.shutdown();
2426        }
2427        self.drop_without_shutdown();
2428        _result
2429    }
2430
2431    /// Similar to "send" but does not shutdown the channel if an error occurs.
2432    pub fn send_no_shutdown_on_err(
2433        self,
2434        mut result: Result<&PeerControllerGetKnownPeersResponse, Error>,
2435    ) -> Result<(), fidl::Error> {
2436        let _result = self.send_raw(result);
2437        self.drop_without_shutdown();
2438        _result
2439    }
2440
2441    fn send_raw(
2442        &self,
2443        mut result: Result<&PeerControllerGetKnownPeersResponse, Error>,
2444    ) -> Result<(), fidl::Error> {
2445        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2446            PeerControllerGetKnownPeersResponse,
2447            Error,
2448        >>(
2449            fidl::encoding::FlexibleResult::new(result),
2450            self.tx_id,
2451            0x482cf3745bab65f6,
2452            fidl::encoding::DynamicFlags::FLEXIBLE,
2453        )
2454    }
2455}
2456
2457#[must_use = "FIDL methods require a response to be sent"]
2458#[derive(Debug)]
2459pub struct PeerControllerConnectPeerResponder {
2460    control_handle: std::mem::ManuallyDrop<PeerControllerControlHandle>,
2461    tx_id: u32,
2462}
2463
2464/// Set the the channel to be shutdown (see [`PeerControllerControlHandle::shutdown`])
2465/// if the responder is dropped without sending a response, so that the client
2466/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2467impl std::ops::Drop for PeerControllerConnectPeerResponder {
2468    fn drop(&mut self) {
2469        self.control_handle.shutdown();
2470        // Safety: drops once, never accessed again
2471        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2472    }
2473}
2474
2475impl fidl::endpoints::Responder for PeerControllerConnectPeerResponder {
2476    type ControlHandle = PeerControllerControlHandle;
2477
2478    fn control_handle(&self) -> &PeerControllerControlHandle {
2479        &self.control_handle
2480    }
2481
2482    fn drop_without_shutdown(mut self) {
2483        // Safety: drops once, never accessed again due to mem::forget
2484        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2485        // Prevent Drop from running (which would shut down the channel)
2486        std::mem::forget(self);
2487    }
2488}
2489
2490impl PeerControllerConnectPeerResponder {
2491    /// Sends a response to the FIDL transaction.
2492    ///
2493    /// Sets the channel to shutdown if an error occurs.
2494    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2495        let _result = self.send_raw(result);
2496        if _result.is_err() {
2497            self.control_handle.shutdown();
2498        }
2499        self.drop_without_shutdown();
2500        _result
2501    }
2502
2503    /// Similar to "send" but does not shutdown the channel if an error occurs.
2504    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2505        let _result = self.send_raw(result);
2506        self.drop_without_shutdown();
2507        _result
2508    }
2509
2510    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2511        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2512            fidl::encoding::EmptyStruct,
2513            Error,
2514        >>(
2515            fidl::encoding::FlexibleResult::new(result),
2516            self.tx_id,
2517            0x13fbb990835acf66,
2518            fidl::encoding::DynamicFlags::FLEXIBLE,
2519        )
2520    }
2521}
2522
2523#[must_use = "FIDL methods require a response to be sent"]
2524#[derive(Debug)]
2525pub struct PeerControllerDisconnectPeerResponder {
2526    control_handle: std::mem::ManuallyDrop<PeerControllerControlHandle>,
2527    tx_id: u32,
2528}
2529
2530/// Set the the channel to be shutdown (see [`PeerControllerControlHandle::shutdown`])
2531/// if the responder is dropped without sending a response, so that the client
2532/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2533impl std::ops::Drop for PeerControllerDisconnectPeerResponder {
2534    fn drop(&mut self) {
2535        self.control_handle.shutdown();
2536        // Safety: drops once, never accessed again
2537        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2538    }
2539}
2540
2541impl fidl::endpoints::Responder for PeerControllerDisconnectPeerResponder {
2542    type ControlHandle = PeerControllerControlHandle;
2543
2544    fn control_handle(&self) -> &PeerControllerControlHandle {
2545        &self.control_handle
2546    }
2547
2548    fn drop_without_shutdown(mut self) {
2549        // Safety: drops once, never accessed again due to mem::forget
2550        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2551        // Prevent Drop from running (which would shut down the channel)
2552        std::mem::forget(self);
2553    }
2554}
2555
2556impl PeerControllerDisconnectPeerResponder {
2557    /// Sends a response to the FIDL transaction.
2558    ///
2559    /// Sets the channel to shutdown if an error occurs.
2560    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2561        let _result = self.send_raw(result);
2562        if _result.is_err() {
2563            self.control_handle.shutdown();
2564        }
2565        self.drop_without_shutdown();
2566        _result
2567    }
2568
2569    /// Similar to "send" but does not shutdown the channel if an error occurs.
2570    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2571        let _result = self.send_raw(result);
2572        self.drop_without_shutdown();
2573        _result
2574    }
2575
2576    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2577        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2578            fidl::encoding::EmptyStruct,
2579            Error,
2580        >>(
2581            fidl::encoding::FlexibleResult::new(result),
2582            self.tx_id,
2583            0x5f9992f066c664ad,
2584            fidl::encoding::DynamicFlags::FLEXIBLE,
2585        )
2586    }
2587}
2588
2589#[must_use = "FIDL methods require a response to be sent"]
2590#[derive(Debug)]
2591pub struct PeerControllerPairResponder {
2592    control_handle: std::mem::ManuallyDrop<PeerControllerControlHandle>,
2593    tx_id: u32,
2594}
2595
2596/// Set the the channel to be shutdown (see [`PeerControllerControlHandle::shutdown`])
2597/// if the responder is dropped without sending a response, so that the client
2598/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2599impl std::ops::Drop for PeerControllerPairResponder {
2600    fn drop(&mut self) {
2601        self.control_handle.shutdown();
2602        // Safety: drops once, never accessed again
2603        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2604    }
2605}
2606
2607impl fidl::endpoints::Responder for PeerControllerPairResponder {
2608    type ControlHandle = PeerControllerControlHandle;
2609
2610    fn control_handle(&self) -> &PeerControllerControlHandle {
2611        &self.control_handle
2612    }
2613
2614    fn drop_without_shutdown(mut self) {
2615        // Safety: drops once, never accessed again due to mem::forget
2616        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2617        // Prevent Drop from running (which would shut down the channel)
2618        std::mem::forget(self);
2619    }
2620}
2621
2622impl PeerControllerPairResponder {
2623    /// Sends a response to the FIDL transaction.
2624    ///
2625    /// Sets the channel to shutdown if an error occurs.
2626    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2627        let _result = self.send_raw(result);
2628        if _result.is_err() {
2629            self.control_handle.shutdown();
2630        }
2631        self.drop_without_shutdown();
2632        _result
2633    }
2634
2635    /// Similar to "send" but does not shutdown the channel if an error occurs.
2636    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2637        let _result = self.send_raw(result);
2638        self.drop_without_shutdown();
2639        _result
2640    }
2641
2642    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2643        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2644            fidl::encoding::EmptyStruct,
2645            Error,
2646        >>(
2647            fidl::encoding::FlexibleResult::new(result),
2648            self.tx_id,
2649            0x1991671d4d7eff26,
2650            fidl::encoding::DynamicFlags::FLEXIBLE,
2651        )
2652    }
2653}
2654
2655#[must_use = "FIDL methods require a response to be sent"]
2656#[derive(Debug)]
2657pub struct PeerControllerForgetPeerResponder {
2658    control_handle: std::mem::ManuallyDrop<PeerControllerControlHandle>,
2659    tx_id: u32,
2660}
2661
2662/// Set the the channel to be shutdown (see [`PeerControllerControlHandle::shutdown`])
2663/// if the responder is dropped without sending a response, so that the client
2664/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2665impl std::ops::Drop for PeerControllerForgetPeerResponder {
2666    fn drop(&mut self) {
2667        self.control_handle.shutdown();
2668        // Safety: drops once, never accessed again
2669        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2670    }
2671}
2672
2673impl fidl::endpoints::Responder for PeerControllerForgetPeerResponder {
2674    type ControlHandle = PeerControllerControlHandle;
2675
2676    fn control_handle(&self) -> &PeerControllerControlHandle {
2677        &self.control_handle
2678    }
2679
2680    fn drop_without_shutdown(mut self) {
2681        // Safety: drops once, never accessed again due to mem::forget
2682        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2683        // Prevent Drop from running (which would shut down the channel)
2684        std::mem::forget(self);
2685    }
2686}
2687
2688impl PeerControllerForgetPeerResponder {
2689    /// Sends a response to the FIDL transaction.
2690    ///
2691    /// Sets the channel to shutdown if an error occurs.
2692    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2693        let _result = self.send_raw(result);
2694        if _result.is_err() {
2695            self.control_handle.shutdown();
2696        }
2697        self.drop_without_shutdown();
2698        _result
2699    }
2700
2701    /// Similar to "send" but does not shutdown the channel if an error occurs.
2702    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2703        let _result = self.send_raw(result);
2704        self.drop_without_shutdown();
2705        _result
2706    }
2707
2708    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2709        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2710            fidl::encoding::EmptyStruct,
2711            Error,
2712        >>(
2713            fidl::encoding::FlexibleResult::new(result),
2714            self.tx_id,
2715            0x26011dbbd834f8c6,
2716            fidl::encoding::DynamicFlags::FLEXIBLE,
2717        )
2718    }
2719}
2720
2721#[must_use = "FIDL methods require a response to be sent"]
2722#[derive(Debug)]
2723pub struct PeerControllerSetDiscoveryResponder {
2724    control_handle: std::mem::ManuallyDrop<PeerControllerControlHandle>,
2725    tx_id: u32,
2726}
2727
2728/// Set the the channel to be shutdown (see [`PeerControllerControlHandle::shutdown`])
2729/// if the responder is dropped without sending a response, so that the client
2730/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2731impl std::ops::Drop for PeerControllerSetDiscoveryResponder {
2732    fn drop(&mut self) {
2733        self.control_handle.shutdown();
2734        // Safety: drops once, never accessed again
2735        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2736    }
2737}
2738
2739impl fidl::endpoints::Responder for PeerControllerSetDiscoveryResponder {
2740    type ControlHandle = PeerControllerControlHandle;
2741
2742    fn control_handle(&self) -> &PeerControllerControlHandle {
2743        &self.control_handle
2744    }
2745
2746    fn drop_without_shutdown(mut self) {
2747        // Safety: drops once, never accessed again due to mem::forget
2748        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2749        // Prevent Drop from running (which would shut down the channel)
2750        std::mem::forget(self);
2751    }
2752}
2753
2754impl PeerControllerSetDiscoveryResponder {
2755    /// Sends a response to the FIDL transaction.
2756    ///
2757    /// Sets the channel to shutdown if an error occurs.
2758    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2759        let _result = self.send_raw(result);
2760        if _result.is_err() {
2761            self.control_handle.shutdown();
2762        }
2763        self.drop_without_shutdown();
2764        _result
2765    }
2766
2767    /// Similar to "send" but does not shutdown the channel if an error occurs.
2768    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2769        let _result = self.send_raw(result);
2770        self.drop_without_shutdown();
2771        _result
2772    }
2773
2774    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2775        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2776            fidl::encoding::EmptyStruct,
2777            Error,
2778        >>(
2779            fidl::encoding::FlexibleResult::new(result),
2780            self.tx_id,
2781            0x3269624c9e1d6ab3,
2782            fidl::encoding::DynamicFlags::FLEXIBLE,
2783        )
2784    }
2785}
2786
2787#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2788pub struct PeripheralControllerMarker;
2789
2790impl fidl::endpoints::ProtocolMarker for PeripheralControllerMarker {
2791    type Proxy = PeripheralControllerProxy;
2792    type RequestStream = PeripheralControllerRequestStream;
2793    #[cfg(target_os = "fuchsia")]
2794    type SynchronousProxy = PeripheralControllerSynchronousProxy;
2795
2796    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.affordances.PeripheralController";
2797}
2798impl fidl::endpoints::DiscoverableProtocolMarker for PeripheralControllerMarker {}
2799pub type PeripheralControllerAdvertiseResult = Result<PeripheralControllerAdvertiseResponse, Error>;
2800
2801pub trait PeripheralControllerProxyInterface: Send + Sync {
2802    type AdvertiseResponseFut: std::future::Future<Output = Result<PeripheralControllerAdvertiseResult, fidl::Error>>
2803        + Send;
2804    fn r#advertise(
2805        &self,
2806        payload: &PeripheralControllerAdvertiseRequest,
2807    ) -> Self::AdvertiseResponseFut;
2808}
2809#[derive(Debug)]
2810#[cfg(target_os = "fuchsia")]
2811pub struct PeripheralControllerSynchronousProxy {
2812    client: fidl::client::sync::Client,
2813}
2814
2815#[cfg(target_os = "fuchsia")]
2816impl fidl::endpoints::SynchronousProxy for PeripheralControllerSynchronousProxy {
2817    type Proxy = PeripheralControllerProxy;
2818    type Protocol = PeripheralControllerMarker;
2819
2820    fn from_channel(inner: fidl::Channel) -> Self {
2821        Self::new(inner)
2822    }
2823
2824    fn into_channel(self) -> fidl::Channel {
2825        self.client.into_channel()
2826    }
2827
2828    fn as_channel(&self) -> &fidl::Channel {
2829        self.client.as_channel()
2830    }
2831}
2832
2833#[cfg(target_os = "fuchsia")]
2834impl PeripheralControllerSynchronousProxy {
2835    pub fn new(channel: fidl::Channel) -> Self {
2836        Self { client: fidl::client::sync::Client::new(channel) }
2837    }
2838
2839    pub fn into_channel(self) -> fidl::Channel {
2840        self.client.into_channel()
2841    }
2842
2843    /// Waits until an event arrives and returns it. It is safe for other
2844    /// threads to make concurrent requests while waiting for an event.
2845    pub fn wait_for_event(
2846        &self,
2847        deadline: zx::MonotonicInstant,
2848    ) -> Result<PeripheralControllerEvent, fidl::Error> {
2849        PeripheralControllerEvent::decode(
2850            self.client.wait_for_event::<PeripheralControllerMarker>(deadline)?,
2851        )
2852    }
2853
2854    /// Start advertising.
2855    ///
2856    /// * error Returns `INTERNAL` if the operation failed (check logs).
2857    /// * error Returns `TIMEOUT` if the advertisement timed out without a connection.
2858    pub fn r#advertise(
2859        &self,
2860        mut payload: &PeripheralControllerAdvertiseRequest,
2861        ___deadline: zx::MonotonicInstant,
2862    ) -> Result<PeripheralControllerAdvertiseResult, fidl::Error> {
2863        let _response = self.client.send_query::<
2864            PeripheralControllerAdvertiseRequest,
2865            fidl::encoding::FlexibleResultType<PeripheralControllerAdvertiseResponse, Error>,
2866            PeripheralControllerMarker,
2867        >(
2868            payload,
2869            0x59079a81362a66f3,
2870            fidl::encoding::DynamicFlags::FLEXIBLE,
2871            ___deadline,
2872        )?
2873        .into_result::<PeripheralControllerMarker>("advertise")?;
2874        Ok(_response.map(|x| x))
2875    }
2876}
2877
2878#[cfg(target_os = "fuchsia")]
2879impl From<PeripheralControllerSynchronousProxy> for zx::NullableHandle {
2880    fn from(value: PeripheralControllerSynchronousProxy) -> Self {
2881        value.into_channel().into()
2882    }
2883}
2884
2885#[cfg(target_os = "fuchsia")]
2886impl From<fidl::Channel> for PeripheralControllerSynchronousProxy {
2887    fn from(value: fidl::Channel) -> Self {
2888        Self::new(value)
2889    }
2890}
2891
2892#[cfg(target_os = "fuchsia")]
2893impl fidl::endpoints::FromClient for PeripheralControllerSynchronousProxy {
2894    type Protocol = PeripheralControllerMarker;
2895
2896    fn from_client(value: fidl::endpoints::ClientEnd<PeripheralControllerMarker>) -> Self {
2897        Self::new(value.into_channel())
2898    }
2899}
2900
2901#[derive(Debug, Clone)]
2902pub struct PeripheralControllerProxy {
2903    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2904}
2905
2906impl fidl::endpoints::Proxy for PeripheralControllerProxy {
2907    type Protocol = PeripheralControllerMarker;
2908
2909    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2910        Self::new(inner)
2911    }
2912
2913    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2914        self.client.into_channel().map_err(|client| Self { client })
2915    }
2916
2917    fn as_channel(&self) -> &::fidl::AsyncChannel {
2918        self.client.as_channel()
2919    }
2920}
2921
2922impl PeripheralControllerProxy {
2923    /// Create a new Proxy for fuchsia.bluetooth.affordances/PeripheralController.
2924    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2925        let protocol_name =
2926            <PeripheralControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2927        Self { client: fidl::client::Client::new(channel, protocol_name) }
2928    }
2929
2930    /// Get a Stream of events from the remote end of the protocol.
2931    ///
2932    /// # Panics
2933    ///
2934    /// Panics if the event stream was already taken.
2935    pub fn take_event_stream(&self) -> PeripheralControllerEventStream {
2936        PeripheralControllerEventStream { event_receiver: self.client.take_event_receiver() }
2937    }
2938
2939    /// Start advertising.
2940    ///
2941    /// * error Returns `INTERNAL` if the operation failed (check logs).
2942    /// * error Returns `TIMEOUT` if the advertisement timed out without a connection.
2943    pub fn r#advertise(
2944        &self,
2945        mut payload: &PeripheralControllerAdvertiseRequest,
2946    ) -> fidl::client::QueryResponseFut<
2947        PeripheralControllerAdvertiseResult,
2948        fidl::encoding::DefaultFuchsiaResourceDialect,
2949    > {
2950        PeripheralControllerProxyInterface::r#advertise(self, payload)
2951    }
2952}
2953
2954impl PeripheralControllerProxyInterface for PeripheralControllerProxy {
2955    type AdvertiseResponseFut = fidl::client::QueryResponseFut<
2956        PeripheralControllerAdvertiseResult,
2957        fidl::encoding::DefaultFuchsiaResourceDialect,
2958    >;
2959    fn r#advertise(
2960        &self,
2961        mut payload: &PeripheralControllerAdvertiseRequest,
2962    ) -> Self::AdvertiseResponseFut {
2963        fn _decode(
2964            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2965        ) -> Result<PeripheralControllerAdvertiseResult, fidl::Error> {
2966            let _response = fidl::client::decode_transaction_body::<
2967                fidl::encoding::FlexibleResultType<PeripheralControllerAdvertiseResponse, Error>,
2968                fidl::encoding::DefaultFuchsiaResourceDialect,
2969                0x59079a81362a66f3,
2970            >(_buf?)?
2971            .into_result::<PeripheralControllerMarker>("advertise")?;
2972            Ok(_response.map(|x| x))
2973        }
2974        self.client.send_query_and_decode::<
2975            PeripheralControllerAdvertiseRequest,
2976            PeripheralControllerAdvertiseResult,
2977        >(
2978            payload,
2979            0x59079a81362a66f3,
2980            fidl::encoding::DynamicFlags::FLEXIBLE,
2981            _decode,
2982        )
2983    }
2984}
2985
2986pub struct PeripheralControllerEventStream {
2987    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2988}
2989
2990impl std::marker::Unpin for PeripheralControllerEventStream {}
2991
2992impl futures::stream::FusedStream for PeripheralControllerEventStream {
2993    fn is_terminated(&self) -> bool {
2994        self.event_receiver.is_terminated()
2995    }
2996}
2997
2998impl futures::Stream for PeripheralControllerEventStream {
2999    type Item = Result<PeripheralControllerEvent, fidl::Error>;
3000
3001    fn poll_next(
3002        mut self: std::pin::Pin<&mut Self>,
3003        cx: &mut std::task::Context<'_>,
3004    ) -> std::task::Poll<Option<Self::Item>> {
3005        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3006            &mut self.event_receiver,
3007            cx
3008        )?) {
3009            Some(buf) => std::task::Poll::Ready(Some(PeripheralControllerEvent::decode(buf))),
3010            None => std::task::Poll::Ready(None),
3011        }
3012    }
3013}
3014
3015#[derive(Debug)]
3016pub enum PeripheralControllerEvent {
3017    #[non_exhaustive]
3018    _UnknownEvent {
3019        /// Ordinal of the event that was sent.
3020        ordinal: u64,
3021    },
3022}
3023
3024impl PeripheralControllerEvent {
3025    /// Decodes a message buffer as a [`PeripheralControllerEvent`].
3026    fn decode(
3027        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3028    ) -> Result<PeripheralControllerEvent, fidl::Error> {
3029        let (bytes, _handles) = buf.split_mut();
3030        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3031        debug_assert_eq!(tx_header.tx_id, 0);
3032        match tx_header.ordinal {
3033            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3034                Ok(PeripheralControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3035            }
3036            _ => Err(fidl::Error::UnknownOrdinal {
3037                ordinal: tx_header.ordinal,
3038                protocol_name:
3039                    <PeripheralControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3040            }),
3041        }
3042    }
3043}
3044
3045/// A Stream of incoming requests for fuchsia.bluetooth.affordances/PeripheralController.
3046pub struct PeripheralControllerRequestStream {
3047    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3048    is_terminated: bool,
3049}
3050
3051impl std::marker::Unpin for PeripheralControllerRequestStream {}
3052
3053impl futures::stream::FusedStream for PeripheralControllerRequestStream {
3054    fn is_terminated(&self) -> bool {
3055        self.is_terminated
3056    }
3057}
3058
3059impl fidl::endpoints::RequestStream for PeripheralControllerRequestStream {
3060    type Protocol = PeripheralControllerMarker;
3061    type ControlHandle = PeripheralControllerControlHandle;
3062
3063    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3064        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3065    }
3066
3067    fn control_handle(&self) -> Self::ControlHandle {
3068        PeripheralControllerControlHandle { inner: self.inner.clone() }
3069    }
3070
3071    fn into_inner(
3072        self,
3073    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3074    {
3075        (self.inner, self.is_terminated)
3076    }
3077
3078    fn from_inner(
3079        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3080        is_terminated: bool,
3081    ) -> Self {
3082        Self { inner, is_terminated }
3083    }
3084}
3085
3086impl futures::Stream for PeripheralControllerRequestStream {
3087    type Item = Result<PeripheralControllerRequest, fidl::Error>;
3088
3089    fn poll_next(
3090        mut self: std::pin::Pin<&mut Self>,
3091        cx: &mut std::task::Context<'_>,
3092    ) -> std::task::Poll<Option<Self::Item>> {
3093        let this = &mut *self;
3094        if this.inner.check_shutdown(cx) {
3095            this.is_terminated = true;
3096            return std::task::Poll::Ready(None);
3097        }
3098        if this.is_terminated {
3099            panic!("polled PeripheralControllerRequestStream after completion");
3100        }
3101        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3102            |bytes, handles| {
3103                match this.inner.channel().read_etc(cx, bytes, handles) {
3104                    std::task::Poll::Ready(Ok(())) => {}
3105                    std::task::Poll::Pending => return std::task::Poll::Pending,
3106                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3107                        this.is_terminated = true;
3108                        return std::task::Poll::Ready(None);
3109                    }
3110                    std::task::Poll::Ready(Err(e)) => {
3111                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3112                            e.into(),
3113                        ))));
3114                    }
3115                }
3116
3117                // A message has been received from the channel
3118                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3119
3120                std::task::Poll::Ready(Some(match header.ordinal {
3121                0x59079a81362a66f3 => {
3122                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3123                    let mut req = fidl::new_empty!(PeripheralControllerAdvertiseRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
3124                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralControllerAdvertiseRequest>(&header, _body_bytes, handles, &mut req)?;
3125                    let control_handle = PeripheralControllerControlHandle {
3126                        inner: this.inner.clone(),
3127                    };
3128                    Ok(PeripheralControllerRequest::Advertise {payload: req,
3129                        responder: PeripheralControllerAdvertiseResponder {
3130                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3131                            tx_id: header.tx_id,
3132                        },
3133                    })
3134                }
3135                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3136                    Ok(PeripheralControllerRequest::_UnknownMethod {
3137                        ordinal: header.ordinal,
3138                        control_handle: PeripheralControllerControlHandle { inner: this.inner.clone() },
3139                        method_type: fidl::MethodType::OneWay,
3140                    })
3141                }
3142                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3143                    this.inner.send_framework_err(
3144                        fidl::encoding::FrameworkErr::UnknownMethod,
3145                        header.tx_id,
3146                        header.ordinal,
3147                        header.dynamic_flags(),
3148                        (bytes, handles),
3149                    )?;
3150                    Ok(PeripheralControllerRequest::_UnknownMethod {
3151                        ordinal: header.ordinal,
3152                        control_handle: PeripheralControllerControlHandle { inner: this.inner.clone() },
3153                        method_type: fidl::MethodType::TwoWay,
3154                    })
3155                }
3156                _ => Err(fidl::Error::UnknownOrdinal {
3157                    ordinal: header.ordinal,
3158                    protocol_name: <PeripheralControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3159                }),
3160            }))
3161            },
3162        )
3163    }
3164}
3165
3166#[derive(Debug)]
3167pub enum PeripheralControllerRequest {
3168    /// Start advertising.
3169    ///
3170    /// * error Returns `INTERNAL` if the operation failed (check logs).
3171    /// * error Returns `TIMEOUT` if the advertisement timed out without a connection.
3172    Advertise {
3173        payload: PeripheralControllerAdvertiseRequest,
3174        responder: PeripheralControllerAdvertiseResponder,
3175    },
3176    /// An interaction was received which does not match any known method.
3177    #[non_exhaustive]
3178    _UnknownMethod {
3179        /// Ordinal of the method that was called.
3180        ordinal: u64,
3181        control_handle: PeripheralControllerControlHandle,
3182        method_type: fidl::MethodType,
3183    },
3184}
3185
3186impl PeripheralControllerRequest {
3187    #[allow(irrefutable_let_patterns)]
3188    pub fn into_advertise(
3189        self,
3190    ) -> Option<(PeripheralControllerAdvertiseRequest, PeripheralControllerAdvertiseResponder)>
3191    {
3192        if let PeripheralControllerRequest::Advertise { payload, responder } = self {
3193            Some((payload, responder))
3194        } else {
3195            None
3196        }
3197    }
3198
3199    /// Name of the method defined in FIDL
3200    pub fn method_name(&self) -> &'static str {
3201        match *self {
3202            PeripheralControllerRequest::Advertise { .. } => "advertise",
3203            PeripheralControllerRequest::_UnknownMethod {
3204                method_type: fidl::MethodType::OneWay,
3205                ..
3206            } => "unknown one-way method",
3207            PeripheralControllerRequest::_UnknownMethod {
3208                method_type: fidl::MethodType::TwoWay,
3209                ..
3210            } => "unknown two-way method",
3211        }
3212    }
3213}
3214
3215#[derive(Debug, Clone)]
3216pub struct PeripheralControllerControlHandle {
3217    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3218}
3219
3220impl fidl::endpoints::ControlHandle for PeripheralControllerControlHandle {
3221    fn shutdown(&self) {
3222        self.inner.shutdown()
3223    }
3224
3225    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3226        self.inner.shutdown_with_epitaph(status)
3227    }
3228
3229    fn is_closed(&self) -> bool {
3230        self.inner.channel().is_closed()
3231    }
3232    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3233        self.inner.channel().on_closed()
3234    }
3235
3236    #[cfg(target_os = "fuchsia")]
3237    fn signal_peer(
3238        &self,
3239        clear_mask: zx::Signals,
3240        set_mask: zx::Signals,
3241    ) -> Result<(), zx_status::Status> {
3242        use fidl::Peered;
3243        self.inner.channel().signal_peer(clear_mask, set_mask)
3244    }
3245}
3246
3247impl PeripheralControllerControlHandle {}
3248
3249#[must_use = "FIDL methods require a response to be sent"]
3250#[derive(Debug)]
3251pub struct PeripheralControllerAdvertiseResponder {
3252    control_handle: std::mem::ManuallyDrop<PeripheralControllerControlHandle>,
3253    tx_id: u32,
3254}
3255
3256/// Set the the channel to be shutdown (see [`PeripheralControllerControlHandle::shutdown`])
3257/// if the responder is dropped without sending a response, so that the client
3258/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3259impl std::ops::Drop for PeripheralControllerAdvertiseResponder {
3260    fn drop(&mut self) {
3261        self.control_handle.shutdown();
3262        // Safety: drops once, never accessed again
3263        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3264    }
3265}
3266
3267impl fidl::endpoints::Responder for PeripheralControllerAdvertiseResponder {
3268    type ControlHandle = PeripheralControllerControlHandle;
3269
3270    fn control_handle(&self) -> &PeripheralControllerControlHandle {
3271        &self.control_handle
3272    }
3273
3274    fn drop_without_shutdown(mut self) {
3275        // Safety: drops once, never accessed again due to mem::forget
3276        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3277        // Prevent Drop from running (which would shut down the channel)
3278        std::mem::forget(self);
3279    }
3280}
3281
3282impl PeripheralControllerAdvertiseResponder {
3283    /// Sends a response to the FIDL transaction.
3284    ///
3285    /// Sets the channel to shutdown if an error occurs.
3286    pub fn send(
3287        self,
3288        mut result: Result<&PeripheralControllerAdvertiseResponse, Error>,
3289    ) -> Result<(), fidl::Error> {
3290        let _result = self.send_raw(result);
3291        if _result.is_err() {
3292            self.control_handle.shutdown();
3293        }
3294        self.drop_without_shutdown();
3295        _result
3296    }
3297
3298    /// Similar to "send" but does not shutdown the channel if an error occurs.
3299    pub fn send_no_shutdown_on_err(
3300        self,
3301        mut result: Result<&PeripheralControllerAdvertiseResponse, Error>,
3302    ) -> Result<(), fidl::Error> {
3303        let _result = self.send_raw(result);
3304        self.drop_without_shutdown();
3305        _result
3306    }
3307
3308    fn send_raw(
3309        &self,
3310        mut result: Result<&PeripheralControllerAdvertiseResponse, Error>,
3311    ) -> Result<(), fidl::Error> {
3312        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3313            PeripheralControllerAdvertiseResponse,
3314            Error,
3315        >>(
3316            fidl::encoding::FlexibleResult::new(result),
3317            self.tx_id,
3318            0x59079a81362a66f3,
3319            fidl::encoding::DynamicFlags::FLEXIBLE,
3320        )
3321    }
3322}
3323
3324mod internal {
3325    use super::*;
3326}