fidl_fuchsia_bluetooth_sys/
fidl_fuchsia_bluetooth_sys.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_sys__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct AccessMakeDiscoverableRequest {
16    pub token: fidl::endpoints::ServerEnd<ProcedureTokenMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for AccessMakeDiscoverableRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct AccessSetPairingDelegateRequest {
26    pub input: InputCapability,
27    pub output: OutputCapability,
28    pub delegate: fidl::endpoints::ClientEnd<PairingDelegateMarker>,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
32    for AccessSetPairingDelegateRequest
33{
34}
35
36#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
37pub struct AccessStartDiscoveryRequest {
38    pub token: fidl::endpoints::ServerEnd<ProcedureTokenMarker>,
39}
40
41impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
42    for AccessStartDiscoveryRequest
43{
44}
45
46#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
47pub struct PairingSetDelegateRequest {
48    pub input: InputCapability,
49    pub output: OutputCapability,
50    pub delegate: fidl::endpoints::ClientEnd<PairingDelegate2Marker>,
51}
52
53impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PairingSetDelegateRequest {}
54
55#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
56pub struct PairingSetPairingDelegateRequest {
57    pub input: InputCapability,
58    pub output: OutputCapability,
59    pub delegate: fidl::endpoints::ClientEnd<PairingDelegateMarker>,
60}
61
62impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
63    for PairingSetPairingDelegateRequest
64{
65}
66
67#[derive(Debug, Default, PartialEq)]
68pub struct AccessSetConnectionPolicyRequest {
69    /// Suppress all new connections over the BR/EDR transport. The active host will disable
70    /// page scan while the `ProcedureToken` is held open.
71    /// NOTE: The system will remain non-connectable until all [`fuchsia.bluetooth.sys/Access`]
72    /// clients drop their tokens.
73    pub suppress_bredr_connections: Option<fidl::endpoints::ServerEnd<ProcedureTokenMarker>>,
74    #[doc(hidden)]
75    pub __source_breaking: fidl::marker::SourceBreaking,
76}
77
78impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
79    for AccessSetConnectionPolicyRequest
80{
81}
82
83#[derive(Debug, Default, PartialEq)]
84pub struct PairingDelegate2StartRequestRequest {
85    /// Peer making the request.
86    pub peer: Option<Peer>,
87    /// Properties of the pairing.
88    pub info: Option<PairingProperties>,
89    /// Protocol used to complete the pairing process.
90    pub request: Option<fidl::endpoints::ClientEnd<PairingRequestMarker>>,
91    #[doc(hidden)]
92    pub __source_breaking: fidl::marker::SourceBreaking,
93}
94
95impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
96    for PairingDelegate2StartRequestRequest
97{
98}
99
100#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
101pub struct AccessMarker;
102
103impl fidl::endpoints::ProtocolMarker for AccessMarker {
104    type Proxy = AccessProxy;
105    type RequestStream = AccessRequestStream;
106    #[cfg(target_os = "fuchsia")]
107    type SynchronousProxy = AccessSynchronousProxy;
108
109    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.sys.Access";
110}
111impl fidl::endpoints::DiscoverableProtocolMarker for AccessMarker {}
112pub type AccessMakeDiscoverableResult = Result<(), Error>;
113pub type AccessSetConnectionPolicyResult = Result<(), Error>;
114pub type AccessStartDiscoveryResult = Result<(), Error>;
115pub type AccessConnectResult = Result<(), Error>;
116pub type AccessDisconnectResult = Result<(), Error>;
117pub type AccessPairResult = Result<(), Error>;
118pub type AccessForgetResult = Result<(), Error>;
119
120pub trait AccessProxyInterface: Send + Sync {
121    fn r#set_pairing_delegate(
122        &self,
123        input: InputCapability,
124        output: OutputCapability,
125        delegate: fidl::endpoints::ClientEnd<PairingDelegateMarker>,
126    ) -> Result<(), fidl::Error>;
127    fn r#set_local_name(&self, name: &str) -> Result<(), fidl::Error>;
128    fn r#set_device_class(
129        &self,
130        device_class: &fidl_fuchsia_bluetooth::DeviceClass,
131    ) -> Result<(), fidl::Error>;
132    type MakeDiscoverableResponseFut: std::future::Future<Output = Result<AccessMakeDiscoverableResult, fidl::Error>>
133        + Send;
134    fn r#make_discoverable(
135        &self,
136        token: fidl::endpoints::ServerEnd<ProcedureTokenMarker>,
137    ) -> Self::MakeDiscoverableResponseFut;
138    type SetConnectionPolicyResponseFut: std::future::Future<Output = Result<AccessSetConnectionPolicyResult, fidl::Error>>
139        + Send;
140    fn r#set_connection_policy(
141        &self,
142        payload: AccessSetConnectionPolicyRequest,
143    ) -> Self::SetConnectionPolicyResponseFut;
144    type StartDiscoveryResponseFut: std::future::Future<Output = Result<AccessStartDiscoveryResult, fidl::Error>>
145        + Send;
146    fn r#start_discovery(
147        &self,
148        token: fidl::endpoints::ServerEnd<ProcedureTokenMarker>,
149    ) -> Self::StartDiscoveryResponseFut;
150    type WatchPeersResponseFut: std::future::Future<
151            Output = Result<(Vec<Peer>, Vec<fidl_fuchsia_bluetooth::PeerId>), fidl::Error>,
152        > + Send;
153    fn r#watch_peers(&self) -> Self::WatchPeersResponseFut;
154    type ConnectResponseFut: std::future::Future<Output = Result<AccessConnectResult, fidl::Error>>
155        + Send;
156    fn r#connect(&self, id: &fidl_fuchsia_bluetooth::PeerId) -> Self::ConnectResponseFut;
157    type DisconnectResponseFut: std::future::Future<Output = Result<AccessDisconnectResult, fidl::Error>>
158        + Send;
159    fn r#disconnect(&self, id: &fidl_fuchsia_bluetooth::PeerId) -> Self::DisconnectResponseFut;
160    type PairResponseFut: std::future::Future<Output = Result<AccessPairResult, fidl::Error>> + Send;
161    fn r#pair(
162        &self,
163        id: &fidl_fuchsia_bluetooth::PeerId,
164        options: &PairingOptions,
165    ) -> Self::PairResponseFut;
166    type ForgetResponseFut: std::future::Future<Output = Result<AccessForgetResult, fidl::Error>>
167        + Send;
168    fn r#forget(&self, id: &fidl_fuchsia_bluetooth::PeerId) -> Self::ForgetResponseFut;
169}
170#[derive(Debug)]
171#[cfg(target_os = "fuchsia")]
172pub struct AccessSynchronousProxy {
173    client: fidl::client::sync::Client,
174}
175
176#[cfg(target_os = "fuchsia")]
177impl fidl::endpoints::SynchronousProxy for AccessSynchronousProxy {
178    type Proxy = AccessProxy;
179    type Protocol = AccessMarker;
180
181    fn from_channel(inner: fidl::Channel) -> Self {
182        Self::new(inner)
183    }
184
185    fn into_channel(self) -> fidl::Channel {
186        self.client.into_channel()
187    }
188
189    fn as_channel(&self) -> &fidl::Channel {
190        self.client.as_channel()
191    }
192}
193
194#[cfg(target_os = "fuchsia")]
195impl AccessSynchronousProxy {
196    pub fn new(channel: fidl::Channel) -> Self {
197        let protocol_name = <AccessMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
198        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
199    }
200
201    pub fn into_channel(self) -> fidl::Channel {
202        self.client.into_channel()
203    }
204
205    /// Waits until an event arrives and returns it. It is safe for other
206    /// threads to make concurrent requests while waiting for an event.
207    pub fn wait_for_event(
208        &self,
209        deadline: zx::MonotonicInstant,
210    ) -> Result<AccessEvent, fidl::Error> {
211        AccessEvent::decode(self.client.wait_for_event(deadline)?)
212    }
213
214    /// Assign a PairingDelegate to respond to drive pairing procedures. The delegate will be
215    /// configured to use the provided I/O capabilities to determine the pairing method.
216    ///
217    /// Only one PairingDelegate can be registered at a time. Closing a PairingDelegate aborts all
218    /// on-going pairing procedures associated with a delegate and closes the PairingDelegate
219    /// previously assigned for this Access instance.
220    ///
221    /// + request `input` Bluetooth input capability
222    /// + request `output` Bluetooth output capability
223    /// + request `delegate` The client end of a PairingDelegate channel.
224    /// # Deprecation - This method is folded into the fuchsia.bluetooth.sys/Pairing protocol. See
225    ///   https://fxbug.dev/42180744 for more details on the migration.
226    pub fn r#set_pairing_delegate(
227        &self,
228        mut input: InputCapability,
229        mut output: OutputCapability,
230        mut delegate: fidl::endpoints::ClientEnd<PairingDelegateMarker>,
231    ) -> Result<(), fidl::Error> {
232        self.client.send::<AccessSetPairingDelegateRequest>(
233            (input, output, delegate),
234            0x4af398e1f4cdb40b,
235            fidl::encoding::DynamicFlags::empty(),
236        )
237    }
238
239    /// Assign a local name for the Bluetooth system. This name will be visible to nearby peers
240    /// when the system is in discoverable mode and during name discovery procedures.
241    ///
242    /// + request `name` The complete local name to assign to the system.
243    pub fn r#set_local_name(&self, mut name: &str) -> Result<(), fidl::Error> {
244        self.client.send::<AccessSetLocalNameRequest>(
245            (name,),
246            0x7d12cd2d902206eb,
247            fidl::encoding::DynamicFlags::empty(),
248        )
249    }
250
251    /// Set the local device class that will be visible to nearby peers when the system is in
252    /// discoverable mode.
253    ///
254    /// + request `device_class` The device class to assign to the system.
255    pub fn r#set_device_class(
256        &self,
257        mut device_class: &fidl_fuchsia_bluetooth::DeviceClass,
258    ) -> Result<(), fidl::Error> {
259        self.client.send::<AccessSetDeviceClassRequest>(
260            (device_class,),
261            0x58dd8f65f589035d,
262            fidl::encoding::DynamicFlags::empty(),
263        )
264    }
265
266    /// Put the system into the "General Discoverable" mode on the BR/EDR transport. The active
267    /// host will respond to general inquiry (by regularly entering the inquiry scan mode).
268    ///
269    /// + request `token` [`fuchsia.bluetooth.sys/ProcedureToken`] that will remain valid while a
270    ///   discoverable mode session is active. NOTE: The system may remain discoverable until all
271    ///   [`fuchsia.bluetooth.sys/Access`] clients drop their tokens.
272    /// * error Reports Error.FAILED if inquiry mode cannot be entered.
273    pub fn r#make_discoverable(
274        &self,
275        mut token: fidl::endpoints::ServerEnd<ProcedureTokenMarker>,
276        ___deadline: zx::MonotonicInstant,
277    ) -> Result<AccessMakeDiscoverableResult, fidl::Error> {
278        let _response = self.client.send_query::<
279            AccessMakeDiscoverableRequest,
280            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
281        >(
282            (token,),
283            0x747cadf609c96fb1,
284            fidl::encoding::DynamicFlags::empty(),
285            ___deadline,
286        )?;
287        Ok(_response.map(|x| x))
288    }
289
290    /// Set the BR/EDR and LE connection policy for the active host.
291    ///
292    /// * error Reports Error.FAILED if the requested connection policy couldn't be applied.
293    pub fn r#set_connection_policy(
294        &self,
295        mut payload: AccessSetConnectionPolicyRequest,
296        ___deadline: zx::MonotonicInstant,
297    ) -> Result<AccessSetConnectionPolicyResult, fidl::Error> {
298        let _response = self.client.send_query::<
299            AccessSetConnectionPolicyRequest,
300            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
301        >(
302            &mut payload,
303            0x8e8c7354932fb5a,
304            fidl::encoding::DynamicFlags::empty(),
305            ___deadline,
306        )?;
307        Ok(_response.map(|x| x))
308    }
309
310    /// Start a general discovery procedure. All general discoverable BR/EDR, LE,
311    /// and BR/EDR/LE devices will appear in the peer list, which can be observed by calling
312    /// [`fuchsia.bluetooth.sys/Access.WatchPeers`].
313    ///
314    /// + request `token` [`fuchsia.bluetooth.sys/ProcedureToken`] that will remain valid while
315    ///   discovery is in progress. NOTE: The radio will continue performing discovery until all
316    ///   [`fuchsia.bluetooth.sys/Access`] drop their tokens.
317    /// * error Reports Error.FAILED if discovery on either transport cannot be initiated.
318    pub fn r#start_discovery(
319        &self,
320        mut token: fidl::endpoints::ServerEnd<ProcedureTokenMarker>,
321        ___deadline: zx::MonotonicInstant,
322    ) -> Result<AccessStartDiscoveryResult, fidl::Error> {
323        let _response = self.client.send_query::<
324            AccessStartDiscoveryRequest,
325            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
326        >(
327            (token,),
328            0x6907100d9b99439,
329            fidl::encoding::DynamicFlags::empty(),
330            ___deadline,
331        )?;
332        Ok(_response.map(|x| x))
333    }
334
335    /// Returns a list of all peers (connectable Bluetooth devices) known to the system. The first
336    /// call results in a snapshot of all known peers to be sent immediately in the `updated` return
337    /// paremeter. Subsequent calls receive a response only when one or more entries have been
338    /// added, modified, or removed from the entries reported since the most recent call.
339    ///
340    /// - response `updated` Peers that were added or updated since the last call to WatchPeers().
341    /// - response `removed` Ids of peers that were removed since the last call to WatchPeers().
342    pub fn r#watch_peers(
343        &self,
344        ___deadline: zx::MonotonicInstant,
345    ) -> Result<(Vec<Peer>, Vec<fidl_fuchsia_bluetooth::PeerId>), fidl::Error> {
346        let _response =
347            self.client.send_query::<fidl::encoding::EmptyPayload, AccessWatchPeersResponse>(
348                (),
349                0x1921fe1ed8e6eb7c,
350                fidl::encoding::DynamicFlags::empty(),
351                ___deadline,
352            )?;
353        Ok((_response.updated, _response.removed))
354    }
355
356    /// Initiate a connection to the peer with the given `id`. This method connects both BR/EDR and
357    /// LE transports depending on the technologies that the peer is known to support.
358    ///
359    /// + request `id` The id of the peer to connect.
360    /// * error Reports `Error.FAILED` if a connection to the peer cannot be initiated.
361    /// * error Reports `Error.PEER_NOT_FOUND` if `id` is not recognized.
362    pub fn r#connect(
363        &self,
364        mut id: &fidl_fuchsia_bluetooth::PeerId,
365        ___deadline: zx::MonotonicInstant,
366    ) -> Result<AccessConnectResult, fidl::Error> {
367        let _response = self.client.send_query::<AccessConnectRequest, fidl::encoding::ResultType<
368            fidl::encoding::EmptyStruct,
369            Error,
370        >>(
371            (id,),
372            0x1734199789fe7667,
373            fidl::encoding::DynamicFlags::empty(),
374            ___deadline,
375        )?;
376        Ok(_response.map(|x| x))
377    }
378
379    /// Disconnect all logical links to the peer with the given `id`. This includes LE and
380    /// BR/EDR links that have been initiated using all Access and fuchsia.bluetooth.le protocol
381    /// instances.
382    ///
383    /// + request `id` The id of the peer to disconnect.
384    /// * error Reports `Error.PEER_NOT_FOUND` if `id` is not recognized.
385    pub fn r#disconnect(
386        &self,
387        mut id: &fidl_fuchsia_bluetooth::PeerId,
388        ___deadline: zx::MonotonicInstant,
389    ) -> Result<AccessDisconnectResult, fidl::Error> {
390        let _response = self.client.send_query::<
391            AccessDisconnectRequest,
392            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
393        >(
394            (id,),
395            0x3a4e06d0c6185a5,
396            fidl::encoding::DynamicFlags::empty(),
397            ___deadline,
398        )?;
399        Ok(_response.map(|x| x))
400    }
401
402    /// Initiate a pairing to the remote `id` with the given `options`.
403    /// This call completes only once the pairing procedure has completed or aborted.
404    /// Returns an error if no connected peer with `id` is found or the pairing procedure fails.
405    /// If the named peer is already paired, this returns immediately with a success value - unless
406    /// the pairing is over LE and the PairingOptions.le_security_level is more secure than the
407    /// current security level, in which case we will attempt to raise security to the requested
408    /// level.
409    ///
410    /// Pairing will take place over whichever transport is indicated by `options.transport`. If
411    /// that transport isn't currently connected, the pairing will fail with `Error.PEER_NOT_FOUND`.
412    /// Currently, if DUAL_MODE is requested, we will attempt to pair over the LE transport.
413    ///
414    /// + request `id` The id of the peer to initiate pairing with
415    /// + request `options` The configuration options to use for this pairing request
416    /// * error Reports `Error.PEER_NOT_FOUND` if `id` is not recognized, or the peer is not
417    ///   connected on the requested transport.
418    /// * error Reports `Error.INVALID_ARGUMENTS` if ill-formed options are passed
419    /// * error Reports `Error.FAILED` if an error occurs during pairing
420    pub fn r#pair(
421        &self,
422        mut id: &fidl_fuchsia_bluetooth::PeerId,
423        mut options: &PairingOptions,
424        ___deadline: zx::MonotonicInstant,
425    ) -> Result<AccessPairResult, fidl::Error> {
426        let _response = self.client.send_query::<AccessPairRequest, fidl::encoding::ResultType<
427            fidl::encoding::EmptyStruct,
428            Error,
429        >>(
430            (id, options),
431            0x1d08ea19db327779,
432            fidl::encoding::DynamicFlags::empty(),
433            ___deadline,
434        )?;
435        Ok(_response.map(|x| x))
436    }
437
438    /// Removes all bonding information and disconnects any existing links with the peer with the
439    /// given `id`.
440    ///
441    /// + request `id` The id of the peer to forget.
442    /// * error Reports `Error.PEER_NOT_FOUND` if `id` is not recognized.
443    pub fn r#forget(
444        &self,
445        mut id: &fidl_fuchsia_bluetooth::PeerId,
446        ___deadline: zx::MonotonicInstant,
447    ) -> Result<AccessForgetResult, fidl::Error> {
448        let _response = self.client.send_query::<AccessForgetRequest, fidl::encoding::ResultType<
449            fidl::encoding::EmptyStruct,
450            Error,
451        >>(
452            (id,),
453            0x1fd8e27202854c0,
454            fidl::encoding::DynamicFlags::empty(),
455            ___deadline,
456        )?;
457        Ok(_response.map(|x| x))
458    }
459}
460
461#[cfg(target_os = "fuchsia")]
462impl From<AccessSynchronousProxy> for zx::Handle {
463    fn from(value: AccessSynchronousProxy) -> Self {
464        value.into_channel().into()
465    }
466}
467
468#[cfg(target_os = "fuchsia")]
469impl From<fidl::Channel> for AccessSynchronousProxy {
470    fn from(value: fidl::Channel) -> Self {
471        Self::new(value)
472    }
473}
474
475#[derive(Debug, Clone)]
476pub struct AccessProxy {
477    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
478}
479
480impl fidl::endpoints::Proxy for AccessProxy {
481    type Protocol = AccessMarker;
482
483    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
484        Self::new(inner)
485    }
486
487    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
488        self.client.into_channel().map_err(|client| Self { client })
489    }
490
491    fn as_channel(&self) -> &::fidl::AsyncChannel {
492        self.client.as_channel()
493    }
494}
495
496impl AccessProxy {
497    /// Create a new Proxy for fuchsia.bluetooth.sys/Access.
498    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
499        let protocol_name = <AccessMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
500        Self { client: fidl::client::Client::new(channel, protocol_name) }
501    }
502
503    /// Get a Stream of events from the remote end of the protocol.
504    ///
505    /// # Panics
506    ///
507    /// Panics if the event stream was already taken.
508    pub fn take_event_stream(&self) -> AccessEventStream {
509        AccessEventStream { event_receiver: self.client.take_event_receiver() }
510    }
511
512    /// Assign a PairingDelegate to respond to drive pairing procedures. The delegate will be
513    /// configured to use the provided I/O capabilities to determine the pairing method.
514    ///
515    /// Only one PairingDelegate can be registered at a time. Closing a PairingDelegate aborts all
516    /// on-going pairing procedures associated with a delegate and closes the PairingDelegate
517    /// previously assigned for this Access instance.
518    ///
519    /// + request `input` Bluetooth input capability
520    /// + request `output` Bluetooth output capability
521    /// + request `delegate` The client end of a PairingDelegate channel.
522    /// # Deprecation - This method is folded into the fuchsia.bluetooth.sys/Pairing protocol. See
523    ///   https://fxbug.dev/42180744 for more details on the migration.
524    pub fn r#set_pairing_delegate(
525        &self,
526        mut input: InputCapability,
527        mut output: OutputCapability,
528        mut delegate: fidl::endpoints::ClientEnd<PairingDelegateMarker>,
529    ) -> Result<(), fidl::Error> {
530        AccessProxyInterface::r#set_pairing_delegate(self, input, output, delegate)
531    }
532
533    /// Assign a local name for the Bluetooth system. This name will be visible to nearby peers
534    /// when the system is in discoverable mode and during name discovery procedures.
535    ///
536    /// + request `name` The complete local name to assign to the system.
537    pub fn r#set_local_name(&self, mut name: &str) -> Result<(), fidl::Error> {
538        AccessProxyInterface::r#set_local_name(self, name)
539    }
540
541    /// Set the local device class that will be visible to nearby peers when the system is in
542    /// discoverable mode.
543    ///
544    /// + request `device_class` The device class to assign to the system.
545    pub fn r#set_device_class(
546        &self,
547        mut device_class: &fidl_fuchsia_bluetooth::DeviceClass,
548    ) -> Result<(), fidl::Error> {
549        AccessProxyInterface::r#set_device_class(self, device_class)
550    }
551
552    /// Put the system into the "General Discoverable" mode on the BR/EDR transport. The active
553    /// host will respond to general inquiry (by regularly entering the inquiry scan mode).
554    ///
555    /// + request `token` [`fuchsia.bluetooth.sys/ProcedureToken`] that will remain valid while a
556    ///   discoverable mode session is active. NOTE: The system may remain discoverable until all
557    ///   [`fuchsia.bluetooth.sys/Access`] clients drop their tokens.
558    /// * error Reports Error.FAILED if inquiry mode cannot be entered.
559    pub fn r#make_discoverable(
560        &self,
561        mut token: fidl::endpoints::ServerEnd<ProcedureTokenMarker>,
562    ) -> fidl::client::QueryResponseFut<
563        AccessMakeDiscoverableResult,
564        fidl::encoding::DefaultFuchsiaResourceDialect,
565    > {
566        AccessProxyInterface::r#make_discoverable(self, token)
567    }
568
569    /// Set the BR/EDR and LE connection policy for the active host.
570    ///
571    /// * error Reports Error.FAILED if the requested connection policy couldn't be applied.
572    pub fn r#set_connection_policy(
573        &self,
574        mut payload: AccessSetConnectionPolicyRequest,
575    ) -> fidl::client::QueryResponseFut<
576        AccessSetConnectionPolicyResult,
577        fidl::encoding::DefaultFuchsiaResourceDialect,
578    > {
579        AccessProxyInterface::r#set_connection_policy(self, payload)
580    }
581
582    /// Start a general discovery procedure. All general discoverable BR/EDR, LE,
583    /// and BR/EDR/LE devices will appear in the peer list, which can be observed by calling
584    /// [`fuchsia.bluetooth.sys/Access.WatchPeers`].
585    ///
586    /// + request `token` [`fuchsia.bluetooth.sys/ProcedureToken`] that will remain valid while
587    ///   discovery is in progress. NOTE: The radio will continue performing discovery until all
588    ///   [`fuchsia.bluetooth.sys/Access`] drop their tokens.
589    /// * error Reports Error.FAILED if discovery on either transport cannot be initiated.
590    pub fn r#start_discovery(
591        &self,
592        mut token: fidl::endpoints::ServerEnd<ProcedureTokenMarker>,
593    ) -> fidl::client::QueryResponseFut<
594        AccessStartDiscoveryResult,
595        fidl::encoding::DefaultFuchsiaResourceDialect,
596    > {
597        AccessProxyInterface::r#start_discovery(self, token)
598    }
599
600    /// Returns a list of all peers (connectable Bluetooth devices) known to the system. The first
601    /// call results in a snapshot of all known peers to be sent immediately in the `updated` return
602    /// paremeter. Subsequent calls receive a response only when one or more entries have been
603    /// added, modified, or removed from the entries reported since the most recent call.
604    ///
605    /// - response `updated` Peers that were added or updated since the last call to WatchPeers().
606    /// - response `removed` Ids of peers that were removed since the last call to WatchPeers().
607    pub fn r#watch_peers(
608        &self,
609    ) -> fidl::client::QueryResponseFut<
610        (Vec<Peer>, Vec<fidl_fuchsia_bluetooth::PeerId>),
611        fidl::encoding::DefaultFuchsiaResourceDialect,
612    > {
613        AccessProxyInterface::r#watch_peers(self)
614    }
615
616    /// Initiate a connection to the peer with the given `id`. This method connects both BR/EDR and
617    /// LE transports depending on the technologies that the peer is known to support.
618    ///
619    /// + request `id` The id of the peer to connect.
620    /// * error Reports `Error.FAILED` if a connection to the peer cannot be initiated.
621    /// * error Reports `Error.PEER_NOT_FOUND` if `id` is not recognized.
622    pub fn r#connect(
623        &self,
624        mut id: &fidl_fuchsia_bluetooth::PeerId,
625    ) -> fidl::client::QueryResponseFut<
626        AccessConnectResult,
627        fidl::encoding::DefaultFuchsiaResourceDialect,
628    > {
629        AccessProxyInterface::r#connect(self, id)
630    }
631
632    /// Disconnect all logical links to the peer with the given `id`. This includes LE and
633    /// BR/EDR links that have been initiated using all Access and fuchsia.bluetooth.le protocol
634    /// instances.
635    ///
636    /// + request `id` The id of the peer to disconnect.
637    /// * error Reports `Error.PEER_NOT_FOUND` if `id` is not recognized.
638    pub fn r#disconnect(
639        &self,
640        mut id: &fidl_fuchsia_bluetooth::PeerId,
641    ) -> fidl::client::QueryResponseFut<
642        AccessDisconnectResult,
643        fidl::encoding::DefaultFuchsiaResourceDialect,
644    > {
645        AccessProxyInterface::r#disconnect(self, id)
646    }
647
648    /// Initiate a pairing to the remote `id` with the given `options`.
649    /// This call completes only once the pairing procedure has completed or aborted.
650    /// Returns an error if no connected peer with `id` is found or the pairing procedure fails.
651    /// If the named peer is already paired, this returns immediately with a success value - unless
652    /// the pairing is over LE and the PairingOptions.le_security_level is more secure than the
653    /// current security level, in which case we will attempt to raise security to the requested
654    /// level.
655    ///
656    /// Pairing will take place over whichever transport is indicated by `options.transport`. If
657    /// that transport isn't currently connected, the pairing will fail with `Error.PEER_NOT_FOUND`.
658    /// Currently, if DUAL_MODE is requested, we will attempt to pair over the LE transport.
659    ///
660    /// + request `id` The id of the peer to initiate pairing with
661    /// + request `options` The configuration options to use for this pairing request
662    /// * error Reports `Error.PEER_NOT_FOUND` if `id` is not recognized, or the peer is not
663    ///   connected on the requested transport.
664    /// * error Reports `Error.INVALID_ARGUMENTS` if ill-formed options are passed
665    /// * error Reports `Error.FAILED` if an error occurs during pairing
666    pub fn r#pair(
667        &self,
668        mut id: &fidl_fuchsia_bluetooth::PeerId,
669        mut options: &PairingOptions,
670    ) -> fidl::client::QueryResponseFut<
671        AccessPairResult,
672        fidl::encoding::DefaultFuchsiaResourceDialect,
673    > {
674        AccessProxyInterface::r#pair(self, id, options)
675    }
676
677    /// Removes all bonding information and disconnects any existing links with the peer with the
678    /// given `id`.
679    ///
680    /// + request `id` The id of the peer to forget.
681    /// * error Reports `Error.PEER_NOT_FOUND` if `id` is not recognized.
682    pub fn r#forget(
683        &self,
684        mut id: &fidl_fuchsia_bluetooth::PeerId,
685    ) -> fidl::client::QueryResponseFut<
686        AccessForgetResult,
687        fidl::encoding::DefaultFuchsiaResourceDialect,
688    > {
689        AccessProxyInterface::r#forget(self, id)
690    }
691}
692
693impl AccessProxyInterface for AccessProxy {
694    fn r#set_pairing_delegate(
695        &self,
696        mut input: InputCapability,
697        mut output: OutputCapability,
698        mut delegate: fidl::endpoints::ClientEnd<PairingDelegateMarker>,
699    ) -> Result<(), fidl::Error> {
700        self.client.send::<AccessSetPairingDelegateRequest>(
701            (input, output, delegate),
702            0x4af398e1f4cdb40b,
703            fidl::encoding::DynamicFlags::empty(),
704        )
705    }
706
707    fn r#set_local_name(&self, mut name: &str) -> Result<(), fidl::Error> {
708        self.client.send::<AccessSetLocalNameRequest>(
709            (name,),
710            0x7d12cd2d902206eb,
711            fidl::encoding::DynamicFlags::empty(),
712        )
713    }
714
715    fn r#set_device_class(
716        &self,
717        mut device_class: &fidl_fuchsia_bluetooth::DeviceClass,
718    ) -> Result<(), fidl::Error> {
719        self.client.send::<AccessSetDeviceClassRequest>(
720            (device_class,),
721            0x58dd8f65f589035d,
722            fidl::encoding::DynamicFlags::empty(),
723        )
724    }
725
726    type MakeDiscoverableResponseFut = fidl::client::QueryResponseFut<
727        AccessMakeDiscoverableResult,
728        fidl::encoding::DefaultFuchsiaResourceDialect,
729    >;
730    fn r#make_discoverable(
731        &self,
732        mut token: fidl::endpoints::ServerEnd<ProcedureTokenMarker>,
733    ) -> Self::MakeDiscoverableResponseFut {
734        fn _decode(
735            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
736        ) -> Result<AccessMakeDiscoverableResult, fidl::Error> {
737            let _response = fidl::client::decode_transaction_body::<
738                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
739                fidl::encoding::DefaultFuchsiaResourceDialect,
740                0x747cadf609c96fb1,
741            >(_buf?)?;
742            Ok(_response.map(|x| x))
743        }
744        self.client
745            .send_query_and_decode::<AccessMakeDiscoverableRequest, AccessMakeDiscoverableResult>(
746                (token,),
747                0x747cadf609c96fb1,
748                fidl::encoding::DynamicFlags::empty(),
749                _decode,
750            )
751    }
752
753    type SetConnectionPolicyResponseFut = fidl::client::QueryResponseFut<
754        AccessSetConnectionPolicyResult,
755        fidl::encoding::DefaultFuchsiaResourceDialect,
756    >;
757    fn r#set_connection_policy(
758        &self,
759        mut payload: AccessSetConnectionPolicyRequest,
760    ) -> Self::SetConnectionPolicyResponseFut {
761        fn _decode(
762            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
763        ) -> Result<AccessSetConnectionPolicyResult, fidl::Error> {
764            let _response = fidl::client::decode_transaction_body::<
765                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
766                fidl::encoding::DefaultFuchsiaResourceDialect,
767                0x8e8c7354932fb5a,
768            >(_buf?)?;
769            Ok(_response.map(|x| x))
770        }
771        self.client.send_query_and_decode::<
772            AccessSetConnectionPolicyRequest,
773            AccessSetConnectionPolicyResult,
774        >(
775            &mut payload,
776            0x8e8c7354932fb5a,
777            fidl::encoding::DynamicFlags::empty(),
778            _decode,
779        )
780    }
781
782    type StartDiscoveryResponseFut = fidl::client::QueryResponseFut<
783        AccessStartDiscoveryResult,
784        fidl::encoding::DefaultFuchsiaResourceDialect,
785    >;
786    fn r#start_discovery(
787        &self,
788        mut token: fidl::endpoints::ServerEnd<ProcedureTokenMarker>,
789    ) -> Self::StartDiscoveryResponseFut {
790        fn _decode(
791            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
792        ) -> Result<AccessStartDiscoveryResult, fidl::Error> {
793            let _response = fidl::client::decode_transaction_body::<
794                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
795                fidl::encoding::DefaultFuchsiaResourceDialect,
796                0x6907100d9b99439,
797            >(_buf?)?;
798            Ok(_response.map(|x| x))
799        }
800        self.client
801            .send_query_and_decode::<AccessStartDiscoveryRequest, AccessStartDiscoveryResult>(
802                (token,),
803                0x6907100d9b99439,
804                fidl::encoding::DynamicFlags::empty(),
805                _decode,
806            )
807    }
808
809    type WatchPeersResponseFut = fidl::client::QueryResponseFut<
810        (Vec<Peer>, Vec<fidl_fuchsia_bluetooth::PeerId>),
811        fidl::encoding::DefaultFuchsiaResourceDialect,
812    >;
813    fn r#watch_peers(&self) -> Self::WatchPeersResponseFut {
814        fn _decode(
815            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
816        ) -> Result<(Vec<Peer>, Vec<fidl_fuchsia_bluetooth::PeerId>), fidl::Error> {
817            let _response = fidl::client::decode_transaction_body::<
818                AccessWatchPeersResponse,
819                fidl::encoding::DefaultFuchsiaResourceDialect,
820                0x1921fe1ed8e6eb7c,
821            >(_buf?)?;
822            Ok((_response.updated, _response.removed))
823        }
824        self.client.send_query_and_decode::<
825            fidl::encoding::EmptyPayload,
826            (Vec<Peer>, Vec<fidl_fuchsia_bluetooth::PeerId>),
827        >(
828            (),
829            0x1921fe1ed8e6eb7c,
830            fidl::encoding::DynamicFlags::empty(),
831            _decode,
832        )
833    }
834
835    type ConnectResponseFut = fidl::client::QueryResponseFut<
836        AccessConnectResult,
837        fidl::encoding::DefaultFuchsiaResourceDialect,
838    >;
839    fn r#connect(&self, mut id: &fidl_fuchsia_bluetooth::PeerId) -> Self::ConnectResponseFut {
840        fn _decode(
841            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
842        ) -> Result<AccessConnectResult, fidl::Error> {
843            let _response = fidl::client::decode_transaction_body::<
844                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
845                fidl::encoding::DefaultFuchsiaResourceDialect,
846                0x1734199789fe7667,
847            >(_buf?)?;
848            Ok(_response.map(|x| x))
849        }
850        self.client.send_query_and_decode::<AccessConnectRequest, AccessConnectResult>(
851            (id,),
852            0x1734199789fe7667,
853            fidl::encoding::DynamicFlags::empty(),
854            _decode,
855        )
856    }
857
858    type DisconnectResponseFut = fidl::client::QueryResponseFut<
859        AccessDisconnectResult,
860        fidl::encoding::DefaultFuchsiaResourceDialect,
861    >;
862    fn r#disconnect(&self, mut id: &fidl_fuchsia_bluetooth::PeerId) -> Self::DisconnectResponseFut {
863        fn _decode(
864            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
865        ) -> Result<AccessDisconnectResult, fidl::Error> {
866            let _response = fidl::client::decode_transaction_body::<
867                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
868                fidl::encoding::DefaultFuchsiaResourceDialect,
869                0x3a4e06d0c6185a5,
870            >(_buf?)?;
871            Ok(_response.map(|x| x))
872        }
873        self.client.send_query_and_decode::<AccessDisconnectRequest, AccessDisconnectResult>(
874            (id,),
875            0x3a4e06d0c6185a5,
876            fidl::encoding::DynamicFlags::empty(),
877            _decode,
878        )
879    }
880
881    type PairResponseFut = fidl::client::QueryResponseFut<
882        AccessPairResult,
883        fidl::encoding::DefaultFuchsiaResourceDialect,
884    >;
885    fn r#pair(
886        &self,
887        mut id: &fidl_fuchsia_bluetooth::PeerId,
888        mut options: &PairingOptions,
889    ) -> Self::PairResponseFut {
890        fn _decode(
891            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
892        ) -> Result<AccessPairResult, fidl::Error> {
893            let _response = fidl::client::decode_transaction_body::<
894                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
895                fidl::encoding::DefaultFuchsiaResourceDialect,
896                0x1d08ea19db327779,
897            >(_buf?)?;
898            Ok(_response.map(|x| x))
899        }
900        self.client.send_query_and_decode::<AccessPairRequest, AccessPairResult>(
901            (id, options),
902            0x1d08ea19db327779,
903            fidl::encoding::DynamicFlags::empty(),
904            _decode,
905        )
906    }
907
908    type ForgetResponseFut = fidl::client::QueryResponseFut<
909        AccessForgetResult,
910        fidl::encoding::DefaultFuchsiaResourceDialect,
911    >;
912    fn r#forget(&self, mut id: &fidl_fuchsia_bluetooth::PeerId) -> Self::ForgetResponseFut {
913        fn _decode(
914            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
915        ) -> Result<AccessForgetResult, fidl::Error> {
916            let _response = fidl::client::decode_transaction_body::<
917                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
918                fidl::encoding::DefaultFuchsiaResourceDialect,
919                0x1fd8e27202854c0,
920            >(_buf?)?;
921            Ok(_response.map(|x| x))
922        }
923        self.client.send_query_and_decode::<AccessForgetRequest, AccessForgetResult>(
924            (id,),
925            0x1fd8e27202854c0,
926            fidl::encoding::DynamicFlags::empty(),
927            _decode,
928        )
929    }
930}
931
932pub struct AccessEventStream {
933    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
934}
935
936impl std::marker::Unpin for AccessEventStream {}
937
938impl futures::stream::FusedStream for AccessEventStream {
939    fn is_terminated(&self) -> bool {
940        self.event_receiver.is_terminated()
941    }
942}
943
944impl futures::Stream for AccessEventStream {
945    type Item = Result<AccessEvent, fidl::Error>;
946
947    fn poll_next(
948        mut self: std::pin::Pin<&mut Self>,
949        cx: &mut std::task::Context<'_>,
950    ) -> std::task::Poll<Option<Self::Item>> {
951        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
952            &mut self.event_receiver,
953            cx
954        )?) {
955            Some(buf) => std::task::Poll::Ready(Some(AccessEvent::decode(buf))),
956            None => std::task::Poll::Ready(None),
957        }
958    }
959}
960
961#[derive(Debug)]
962pub enum AccessEvent {}
963
964impl AccessEvent {
965    /// Decodes a message buffer as a [`AccessEvent`].
966    fn decode(
967        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
968    ) -> Result<AccessEvent, fidl::Error> {
969        let (bytes, _handles) = buf.split_mut();
970        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
971        debug_assert_eq!(tx_header.tx_id, 0);
972        match tx_header.ordinal {
973            _ => Err(fidl::Error::UnknownOrdinal {
974                ordinal: tx_header.ordinal,
975                protocol_name: <AccessMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
976            }),
977        }
978    }
979}
980
981/// A Stream of incoming requests for fuchsia.bluetooth.sys/Access.
982pub struct AccessRequestStream {
983    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
984    is_terminated: bool,
985}
986
987impl std::marker::Unpin for AccessRequestStream {}
988
989impl futures::stream::FusedStream for AccessRequestStream {
990    fn is_terminated(&self) -> bool {
991        self.is_terminated
992    }
993}
994
995impl fidl::endpoints::RequestStream for AccessRequestStream {
996    type Protocol = AccessMarker;
997    type ControlHandle = AccessControlHandle;
998
999    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1000        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1001    }
1002
1003    fn control_handle(&self) -> Self::ControlHandle {
1004        AccessControlHandle { inner: self.inner.clone() }
1005    }
1006
1007    fn into_inner(
1008        self,
1009    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1010    {
1011        (self.inner, self.is_terminated)
1012    }
1013
1014    fn from_inner(
1015        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1016        is_terminated: bool,
1017    ) -> Self {
1018        Self { inner, is_terminated }
1019    }
1020}
1021
1022impl futures::Stream for AccessRequestStream {
1023    type Item = Result<AccessRequest, fidl::Error>;
1024
1025    fn poll_next(
1026        mut self: std::pin::Pin<&mut Self>,
1027        cx: &mut std::task::Context<'_>,
1028    ) -> std::task::Poll<Option<Self::Item>> {
1029        let this = &mut *self;
1030        if this.inner.check_shutdown(cx) {
1031            this.is_terminated = true;
1032            return std::task::Poll::Ready(None);
1033        }
1034        if this.is_terminated {
1035            panic!("polled AccessRequestStream after completion");
1036        }
1037        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1038            |bytes, handles| {
1039                match this.inner.channel().read_etc(cx, bytes, handles) {
1040                    std::task::Poll::Ready(Ok(())) => {}
1041                    std::task::Poll::Pending => return std::task::Poll::Pending,
1042                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1043                        this.is_terminated = true;
1044                        return std::task::Poll::Ready(None);
1045                    }
1046                    std::task::Poll::Ready(Err(e)) => {
1047                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1048                            e.into(),
1049                        ))))
1050                    }
1051                }
1052
1053                // A message has been received from the channel
1054                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1055
1056                std::task::Poll::Ready(Some(match header.ordinal {
1057                    0x4af398e1f4cdb40b => {
1058                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1059                        let mut req = fidl::new_empty!(
1060                            AccessSetPairingDelegateRequest,
1061                            fidl::encoding::DefaultFuchsiaResourceDialect
1062                        );
1063                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AccessSetPairingDelegateRequest>(&header, _body_bytes, handles, &mut req)?;
1064                        let control_handle = AccessControlHandle { inner: this.inner.clone() };
1065                        Ok(AccessRequest::SetPairingDelegate {
1066                            input: req.input,
1067                            output: req.output,
1068                            delegate: req.delegate,
1069
1070                            control_handle,
1071                        })
1072                    }
1073                    0x7d12cd2d902206eb => {
1074                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1075                        let mut req = fidl::new_empty!(
1076                            AccessSetLocalNameRequest,
1077                            fidl::encoding::DefaultFuchsiaResourceDialect
1078                        );
1079                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AccessSetLocalNameRequest>(&header, _body_bytes, handles, &mut req)?;
1080                        let control_handle = AccessControlHandle { inner: this.inner.clone() };
1081                        Ok(AccessRequest::SetLocalName { name: req.name, control_handle })
1082                    }
1083                    0x58dd8f65f589035d => {
1084                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1085                        let mut req = fidl::new_empty!(
1086                            AccessSetDeviceClassRequest,
1087                            fidl::encoding::DefaultFuchsiaResourceDialect
1088                        );
1089                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AccessSetDeviceClassRequest>(&header, _body_bytes, handles, &mut req)?;
1090                        let control_handle = AccessControlHandle { inner: this.inner.clone() };
1091                        Ok(AccessRequest::SetDeviceClass {
1092                            device_class: req.device_class,
1093
1094                            control_handle,
1095                        })
1096                    }
1097                    0x747cadf609c96fb1 => {
1098                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1099                        let mut req = fidl::new_empty!(
1100                            AccessMakeDiscoverableRequest,
1101                            fidl::encoding::DefaultFuchsiaResourceDialect
1102                        );
1103                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AccessMakeDiscoverableRequest>(&header, _body_bytes, handles, &mut req)?;
1104                        let control_handle = AccessControlHandle { inner: this.inner.clone() };
1105                        Ok(AccessRequest::MakeDiscoverable {
1106                            token: req.token,
1107
1108                            responder: AccessMakeDiscoverableResponder {
1109                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1110                                tx_id: header.tx_id,
1111                            },
1112                        })
1113                    }
1114                    0x8e8c7354932fb5a => {
1115                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1116                        let mut req = fidl::new_empty!(
1117                            AccessSetConnectionPolicyRequest,
1118                            fidl::encoding::DefaultFuchsiaResourceDialect
1119                        );
1120                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AccessSetConnectionPolicyRequest>(&header, _body_bytes, handles, &mut req)?;
1121                        let control_handle = AccessControlHandle { inner: this.inner.clone() };
1122                        Ok(AccessRequest::SetConnectionPolicy {
1123                            payload: req,
1124                            responder: AccessSetConnectionPolicyResponder {
1125                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1126                                tx_id: header.tx_id,
1127                            },
1128                        })
1129                    }
1130                    0x6907100d9b99439 => {
1131                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1132                        let mut req = fidl::new_empty!(
1133                            AccessStartDiscoveryRequest,
1134                            fidl::encoding::DefaultFuchsiaResourceDialect
1135                        );
1136                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AccessStartDiscoveryRequest>(&header, _body_bytes, handles, &mut req)?;
1137                        let control_handle = AccessControlHandle { inner: this.inner.clone() };
1138                        Ok(AccessRequest::StartDiscovery {
1139                            token: req.token,
1140
1141                            responder: AccessStartDiscoveryResponder {
1142                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1143                                tx_id: header.tx_id,
1144                            },
1145                        })
1146                    }
1147                    0x1921fe1ed8e6eb7c => {
1148                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1149                        let mut req = fidl::new_empty!(
1150                            fidl::encoding::EmptyPayload,
1151                            fidl::encoding::DefaultFuchsiaResourceDialect
1152                        );
1153                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1154                        let control_handle = AccessControlHandle { inner: this.inner.clone() };
1155                        Ok(AccessRequest::WatchPeers {
1156                            responder: AccessWatchPeersResponder {
1157                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1158                                tx_id: header.tx_id,
1159                            },
1160                        })
1161                    }
1162                    0x1734199789fe7667 => {
1163                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1164                        let mut req = fidl::new_empty!(
1165                            AccessConnectRequest,
1166                            fidl::encoding::DefaultFuchsiaResourceDialect
1167                        );
1168                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AccessConnectRequest>(&header, _body_bytes, handles, &mut req)?;
1169                        let control_handle = AccessControlHandle { inner: this.inner.clone() };
1170                        Ok(AccessRequest::Connect {
1171                            id: req.id,
1172
1173                            responder: AccessConnectResponder {
1174                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1175                                tx_id: header.tx_id,
1176                            },
1177                        })
1178                    }
1179                    0x3a4e06d0c6185a5 => {
1180                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1181                        let mut req = fidl::new_empty!(
1182                            AccessDisconnectRequest,
1183                            fidl::encoding::DefaultFuchsiaResourceDialect
1184                        );
1185                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AccessDisconnectRequest>(&header, _body_bytes, handles, &mut req)?;
1186                        let control_handle = AccessControlHandle { inner: this.inner.clone() };
1187                        Ok(AccessRequest::Disconnect {
1188                            id: req.id,
1189
1190                            responder: AccessDisconnectResponder {
1191                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1192                                tx_id: header.tx_id,
1193                            },
1194                        })
1195                    }
1196                    0x1d08ea19db327779 => {
1197                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1198                        let mut req = fidl::new_empty!(
1199                            AccessPairRequest,
1200                            fidl::encoding::DefaultFuchsiaResourceDialect
1201                        );
1202                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AccessPairRequest>(&header, _body_bytes, handles, &mut req)?;
1203                        let control_handle = AccessControlHandle { inner: this.inner.clone() };
1204                        Ok(AccessRequest::Pair {
1205                            id: req.id,
1206                            options: req.options,
1207
1208                            responder: AccessPairResponder {
1209                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1210                                tx_id: header.tx_id,
1211                            },
1212                        })
1213                    }
1214                    0x1fd8e27202854c0 => {
1215                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1216                        let mut req = fidl::new_empty!(
1217                            AccessForgetRequest,
1218                            fidl::encoding::DefaultFuchsiaResourceDialect
1219                        );
1220                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AccessForgetRequest>(&header, _body_bytes, handles, &mut req)?;
1221                        let control_handle = AccessControlHandle { inner: this.inner.clone() };
1222                        Ok(AccessRequest::Forget {
1223                            id: req.id,
1224
1225                            responder: AccessForgetResponder {
1226                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1227                                tx_id: header.tx_id,
1228                            },
1229                        })
1230                    }
1231                    _ => Err(fidl::Error::UnknownOrdinal {
1232                        ordinal: header.ordinal,
1233                        protocol_name:
1234                            <AccessMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1235                    }),
1236                }))
1237            },
1238        )
1239    }
1240}
1241
1242/// Protocol that abstracts the operational modes and procedures defined in the Bluetooth Generic
1243/// Access Profile (see Core Specification v5.1, Vol 3, Part C).
1244///
1245/// The procedures under this protocol apply to the system as a whole. The Bluetooth controller that
1246/// plays an active role in these procedures can be managed using the HostWatcher protocol.
1247///
1248/// The procedures initiated by an Access protocol instance are terminated when the underlying
1249/// channel is closed.
1250#[derive(Debug)]
1251pub enum AccessRequest {
1252    /// Assign a PairingDelegate to respond to drive pairing procedures. The delegate will be
1253    /// configured to use the provided I/O capabilities to determine the pairing method.
1254    ///
1255    /// Only one PairingDelegate can be registered at a time. Closing a PairingDelegate aborts all
1256    /// on-going pairing procedures associated with a delegate and closes the PairingDelegate
1257    /// previously assigned for this Access instance.
1258    ///
1259    /// + request `input` Bluetooth input capability
1260    /// + request `output` Bluetooth output capability
1261    /// + request `delegate` The client end of a PairingDelegate channel.
1262    /// # Deprecation - This method is folded into the fuchsia.bluetooth.sys/Pairing protocol. See
1263    ///   https://fxbug.dev/42180744 for more details on the migration.
1264    SetPairingDelegate {
1265        input: InputCapability,
1266        output: OutputCapability,
1267        delegate: fidl::endpoints::ClientEnd<PairingDelegateMarker>,
1268        control_handle: AccessControlHandle,
1269    },
1270    /// Assign a local name for the Bluetooth system. This name will be visible to nearby peers
1271    /// when the system is in discoverable mode and during name discovery procedures.
1272    ///
1273    /// + request `name` The complete local name to assign to the system.
1274    SetLocalName { name: String, control_handle: AccessControlHandle },
1275    /// Set the local device class that will be visible to nearby peers when the system is in
1276    /// discoverable mode.
1277    ///
1278    /// + request `device_class` The device class to assign to the system.
1279    SetDeviceClass {
1280        device_class: fidl_fuchsia_bluetooth::DeviceClass,
1281        control_handle: AccessControlHandle,
1282    },
1283    /// Put the system into the "General Discoverable" mode on the BR/EDR transport. The active
1284    /// host will respond to general inquiry (by regularly entering the inquiry scan mode).
1285    ///
1286    /// + request `token` [`fuchsia.bluetooth.sys/ProcedureToken`] that will remain valid while a
1287    ///   discoverable mode session is active. NOTE: The system may remain discoverable until all
1288    ///   [`fuchsia.bluetooth.sys/Access`] clients drop their tokens.
1289    /// * error Reports Error.FAILED if inquiry mode cannot be entered.
1290    MakeDiscoverable {
1291        token: fidl::endpoints::ServerEnd<ProcedureTokenMarker>,
1292        responder: AccessMakeDiscoverableResponder,
1293    },
1294    /// Set the BR/EDR and LE connection policy for the active host.
1295    ///
1296    /// * error Reports Error.FAILED if the requested connection policy couldn't be applied.
1297    SetConnectionPolicy {
1298        payload: AccessSetConnectionPolicyRequest,
1299        responder: AccessSetConnectionPolicyResponder,
1300    },
1301    /// Start a general discovery procedure. All general discoverable BR/EDR, LE,
1302    /// and BR/EDR/LE devices will appear in the peer list, which can be observed by calling
1303    /// [`fuchsia.bluetooth.sys/Access.WatchPeers`].
1304    ///
1305    /// + request `token` [`fuchsia.bluetooth.sys/ProcedureToken`] that will remain valid while
1306    ///   discovery is in progress. NOTE: The radio will continue performing discovery until all
1307    ///   [`fuchsia.bluetooth.sys/Access`] drop their tokens.
1308    /// * error Reports Error.FAILED if discovery on either transport cannot be initiated.
1309    StartDiscovery {
1310        token: fidl::endpoints::ServerEnd<ProcedureTokenMarker>,
1311        responder: AccessStartDiscoveryResponder,
1312    },
1313    /// Returns a list of all peers (connectable Bluetooth devices) known to the system. The first
1314    /// call results in a snapshot of all known peers to be sent immediately in the `updated` return
1315    /// paremeter. Subsequent calls receive a response only when one or more entries have been
1316    /// added, modified, or removed from the entries reported since the most recent call.
1317    ///
1318    /// - response `updated` Peers that were added or updated since the last call to WatchPeers().
1319    /// - response `removed` Ids of peers that were removed since the last call to WatchPeers().
1320    WatchPeers { responder: AccessWatchPeersResponder },
1321    /// Initiate a connection to the peer with the given `id`. This method connects both BR/EDR and
1322    /// LE transports depending on the technologies that the peer is known to support.
1323    ///
1324    /// + request `id` The id of the peer to connect.
1325    /// * error Reports `Error.FAILED` if a connection to the peer cannot be initiated.
1326    /// * error Reports `Error.PEER_NOT_FOUND` if `id` is not recognized.
1327    Connect { id: fidl_fuchsia_bluetooth::PeerId, responder: AccessConnectResponder },
1328    /// Disconnect all logical links to the peer with the given `id`. This includes LE and
1329    /// BR/EDR links that have been initiated using all Access and fuchsia.bluetooth.le protocol
1330    /// instances.
1331    ///
1332    /// + request `id` The id of the peer to disconnect.
1333    /// * error Reports `Error.PEER_NOT_FOUND` if `id` is not recognized.
1334    Disconnect { id: fidl_fuchsia_bluetooth::PeerId, responder: AccessDisconnectResponder },
1335    /// Initiate a pairing to the remote `id` with the given `options`.
1336    /// This call completes only once the pairing procedure has completed or aborted.
1337    /// Returns an error if no connected peer with `id` is found or the pairing procedure fails.
1338    /// If the named peer is already paired, this returns immediately with a success value - unless
1339    /// the pairing is over LE and the PairingOptions.le_security_level is more secure than the
1340    /// current security level, in which case we will attempt to raise security to the requested
1341    /// level.
1342    ///
1343    /// Pairing will take place over whichever transport is indicated by `options.transport`. If
1344    /// that transport isn't currently connected, the pairing will fail with `Error.PEER_NOT_FOUND`.
1345    /// Currently, if DUAL_MODE is requested, we will attempt to pair over the LE transport.
1346    ///
1347    /// + request `id` The id of the peer to initiate pairing with
1348    /// + request `options` The configuration options to use for this pairing request
1349    /// * error Reports `Error.PEER_NOT_FOUND` if `id` is not recognized, or the peer is not
1350    ///   connected on the requested transport.
1351    /// * error Reports `Error.INVALID_ARGUMENTS` if ill-formed options are passed
1352    /// * error Reports `Error.FAILED` if an error occurs during pairing
1353    Pair {
1354        id: fidl_fuchsia_bluetooth::PeerId,
1355        options: PairingOptions,
1356        responder: AccessPairResponder,
1357    },
1358    /// Removes all bonding information and disconnects any existing links with the peer with the
1359    /// given `id`.
1360    ///
1361    /// + request `id` The id of the peer to forget.
1362    /// * error Reports `Error.PEER_NOT_FOUND` if `id` is not recognized.
1363    Forget { id: fidl_fuchsia_bluetooth::PeerId, responder: AccessForgetResponder },
1364}
1365
1366impl AccessRequest {
1367    #[allow(irrefutable_let_patterns)]
1368    pub fn into_set_pairing_delegate(
1369        self,
1370    ) -> Option<(
1371        InputCapability,
1372        OutputCapability,
1373        fidl::endpoints::ClientEnd<PairingDelegateMarker>,
1374        AccessControlHandle,
1375    )> {
1376        if let AccessRequest::SetPairingDelegate { input, output, delegate, control_handle } = self
1377        {
1378            Some((input, output, delegate, control_handle))
1379        } else {
1380            None
1381        }
1382    }
1383
1384    #[allow(irrefutable_let_patterns)]
1385    pub fn into_set_local_name(self) -> Option<(String, AccessControlHandle)> {
1386        if let AccessRequest::SetLocalName { name, control_handle } = self {
1387            Some((name, control_handle))
1388        } else {
1389            None
1390        }
1391    }
1392
1393    #[allow(irrefutable_let_patterns)]
1394    pub fn into_set_device_class(
1395        self,
1396    ) -> Option<(fidl_fuchsia_bluetooth::DeviceClass, AccessControlHandle)> {
1397        if let AccessRequest::SetDeviceClass { device_class, control_handle } = self {
1398            Some((device_class, control_handle))
1399        } else {
1400            None
1401        }
1402    }
1403
1404    #[allow(irrefutable_let_patterns)]
1405    pub fn into_make_discoverable(
1406        self,
1407    ) -> Option<(fidl::endpoints::ServerEnd<ProcedureTokenMarker>, AccessMakeDiscoverableResponder)>
1408    {
1409        if let AccessRequest::MakeDiscoverable { token, responder } = self {
1410            Some((token, responder))
1411        } else {
1412            None
1413        }
1414    }
1415
1416    #[allow(irrefutable_let_patterns)]
1417    pub fn into_set_connection_policy(
1418        self,
1419    ) -> Option<(AccessSetConnectionPolicyRequest, AccessSetConnectionPolicyResponder)> {
1420        if let AccessRequest::SetConnectionPolicy { payload, responder } = self {
1421            Some((payload, responder))
1422        } else {
1423            None
1424        }
1425    }
1426
1427    #[allow(irrefutable_let_patterns)]
1428    pub fn into_start_discovery(
1429        self,
1430    ) -> Option<(fidl::endpoints::ServerEnd<ProcedureTokenMarker>, AccessStartDiscoveryResponder)>
1431    {
1432        if let AccessRequest::StartDiscovery { token, responder } = self {
1433            Some((token, responder))
1434        } else {
1435            None
1436        }
1437    }
1438
1439    #[allow(irrefutable_let_patterns)]
1440    pub fn into_watch_peers(self) -> Option<(AccessWatchPeersResponder)> {
1441        if let AccessRequest::WatchPeers { responder } = self {
1442            Some((responder))
1443        } else {
1444            None
1445        }
1446    }
1447
1448    #[allow(irrefutable_let_patterns)]
1449    pub fn into_connect(self) -> Option<(fidl_fuchsia_bluetooth::PeerId, AccessConnectResponder)> {
1450        if let AccessRequest::Connect { id, responder } = self {
1451            Some((id, responder))
1452        } else {
1453            None
1454        }
1455    }
1456
1457    #[allow(irrefutable_let_patterns)]
1458    pub fn into_disconnect(
1459        self,
1460    ) -> Option<(fidl_fuchsia_bluetooth::PeerId, AccessDisconnectResponder)> {
1461        if let AccessRequest::Disconnect { id, responder } = self {
1462            Some((id, responder))
1463        } else {
1464            None
1465        }
1466    }
1467
1468    #[allow(irrefutable_let_patterns)]
1469    pub fn into_pair(
1470        self,
1471    ) -> Option<(fidl_fuchsia_bluetooth::PeerId, PairingOptions, AccessPairResponder)> {
1472        if let AccessRequest::Pair { id, options, responder } = self {
1473            Some((id, options, responder))
1474        } else {
1475            None
1476        }
1477    }
1478
1479    #[allow(irrefutable_let_patterns)]
1480    pub fn into_forget(self) -> Option<(fidl_fuchsia_bluetooth::PeerId, AccessForgetResponder)> {
1481        if let AccessRequest::Forget { id, responder } = self {
1482            Some((id, responder))
1483        } else {
1484            None
1485        }
1486    }
1487
1488    /// Name of the method defined in FIDL
1489    pub fn method_name(&self) -> &'static str {
1490        match *self {
1491            AccessRequest::SetPairingDelegate { .. } => "set_pairing_delegate",
1492            AccessRequest::SetLocalName { .. } => "set_local_name",
1493            AccessRequest::SetDeviceClass { .. } => "set_device_class",
1494            AccessRequest::MakeDiscoverable { .. } => "make_discoverable",
1495            AccessRequest::SetConnectionPolicy { .. } => "set_connection_policy",
1496            AccessRequest::StartDiscovery { .. } => "start_discovery",
1497            AccessRequest::WatchPeers { .. } => "watch_peers",
1498            AccessRequest::Connect { .. } => "connect",
1499            AccessRequest::Disconnect { .. } => "disconnect",
1500            AccessRequest::Pair { .. } => "pair",
1501            AccessRequest::Forget { .. } => "forget",
1502        }
1503    }
1504}
1505
1506#[derive(Debug, Clone)]
1507pub struct AccessControlHandle {
1508    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1509}
1510
1511impl fidl::endpoints::ControlHandle for AccessControlHandle {
1512    fn shutdown(&self) {
1513        self.inner.shutdown()
1514    }
1515    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1516        self.inner.shutdown_with_epitaph(status)
1517    }
1518
1519    fn is_closed(&self) -> bool {
1520        self.inner.channel().is_closed()
1521    }
1522    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1523        self.inner.channel().on_closed()
1524    }
1525
1526    #[cfg(target_os = "fuchsia")]
1527    fn signal_peer(
1528        &self,
1529        clear_mask: zx::Signals,
1530        set_mask: zx::Signals,
1531    ) -> Result<(), zx_status::Status> {
1532        use fidl::Peered;
1533        self.inner.channel().signal_peer(clear_mask, set_mask)
1534    }
1535}
1536
1537impl AccessControlHandle {}
1538
1539#[must_use = "FIDL methods require a response to be sent"]
1540#[derive(Debug)]
1541pub struct AccessMakeDiscoverableResponder {
1542    control_handle: std::mem::ManuallyDrop<AccessControlHandle>,
1543    tx_id: u32,
1544}
1545
1546/// Set the the channel to be shutdown (see [`AccessControlHandle::shutdown`])
1547/// if the responder is dropped without sending a response, so that the client
1548/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1549impl std::ops::Drop for AccessMakeDiscoverableResponder {
1550    fn drop(&mut self) {
1551        self.control_handle.shutdown();
1552        // Safety: drops once, never accessed again
1553        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1554    }
1555}
1556
1557impl fidl::endpoints::Responder for AccessMakeDiscoverableResponder {
1558    type ControlHandle = AccessControlHandle;
1559
1560    fn control_handle(&self) -> &AccessControlHandle {
1561        &self.control_handle
1562    }
1563
1564    fn drop_without_shutdown(mut self) {
1565        // Safety: drops once, never accessed again due to mem::forget
1566        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1567        // Prevent Drop from running (which would shut down the channel)
1568        std::mem::forget(self);
1569    }
1570}
1571
1572impl AccessMakeDiscoverableResponder {
1573    /// Sends a response to the FIDL transaction.
1574    ///
1575    /// Sets the channel to shutdown if an error occurs.
1576    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1577        let _result = self.send_raw(result);
1578        if _result.is_err() {
1579            self.control_handle.shutdown();
1580        }
1581        self.drop_without_shutdown();
1582        _result
1583    }
1584
1585    /// Similar to "send" but does not shutdown the channel if an error occurs.
1586    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1587        let _result = self.send_raw(result);
1588        self.drop_without_shutdown();
1589        _result
1590    }
1591
1592    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1593        self.control_handle
1594            .inner
1595            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
1596                result,
1597                self.tx_id,
1598                0x747cadf609c96fb1,
1599                fidl::encoding::DynamicFlags::empty(),
1600            )
1601    }
1602}
1603
1604#[must_use = "FIDL methods require a response to be sent"]
1605#[derive(Debug)]
1606pub struct AccessSetConnectionPolicyResponder {
1607    control_handle: std::mem::ManuallyDrop<AccessControlHandle>,
1608    tx_id: u32,
1609}
1610
1611/// Set the the channel to be shutdown (see [`AccessControlHandle::shutdown`])
1612/// if the responder is dropped without sending a response, so that the client
1613/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1614impl std::ops::Drop for AccessSetConnectionPolicyResponder {
1615    fn drop(&mut self) {
1616        self.control_handle.shutdown();
1617        // Safety: drops once, never accessed again
1618        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1619    }
1620}
1621
1622impl fidl::endpoints::Responder for AccessSetConnectionPolicyResponder {
1623    type ControlHandle = AccessControlHandle;
1624
1625    fn control_handle(&self) -> &AccessControlHandle {
1626        &self.control_handle
1627    }
1628
1629    fn drop_without_shutdown(mut self) {
1630        // Safety: drops once, never accessed again due to mem::forget
1631        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1632        // Prevent Drop from running (which would shut down the channel)
1633        std::mem::forget(self);
1634    }
1635}
1636
1637impl AccessSetConnectionPolicyResponder {
1638    /// Sends a response to the FIDL transaction.
1639    ///
1640    /// Sets the channel to shutdown if an error occurs.
1641    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1642        let _result = self.send_raw(result);
1643        if _result.is_err() {
1644            self.control_handle.shutdown();
1645        }
1646        self.drop_without_shutdown();
1647        _result
1648    }
1649
1650    /// Similar to "send" but does not shutdown the channel if an error occurs.
1651    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1652        let _result = self.send_raw(result);
1653        self.drop_without_shutdown();
1654        _result
1655    }
1656
1657    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1658        self.control_handle
1659            .inner
1660            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
1661                result,
1662                self.tx_id,
1663                0x8e8c7354932fb5a,
1664                fidl::encoding::DynamicFlags::empty(),
1665            )
1666    }
1667}
1668
1669#[must_use = "FIDL methods require a response to be sent"]
1670#[derive(Debug)]
1671pub struct AccessStartDiscoveryResponder {
1672    control_handle: std::mem::ManuallyDrop<AccessControlHandle>,
1673    tx_id: u32,
1674}
1675
1676/// Set the the channel to be shutdown (see [`AccessControlHandle::shutdown`])
1677/// if the responder is dropped without sending a response, so that the client
1678/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1679impl std::ops::Drop for AccessStartDiscoveryResponder {
1680    fn drop(&mut self) {
1681        self.control_handle.shutdown();
1682        // Safety: drops once, never accessed again
1683        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1684    }
1685}
1686
1687impl fidl::endpoints::Responder for AccessStartDiscoveryResponder {
1688    type ControlHandle = AccessControlHandle;
1689
1690    fn control_handle(&self) -> &AccessControlHandle {
1691        &self.control_handle
1692    }
1693
1694    fn drop_without_shutdown(mut self) {
1695        // Safety: drops once, never accessed again due to mem::forget
1696        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1697        // Prevent Drop from running (which would shut down the channel)
1698        std::mem::forget(self);
1699    }
1700}
1701
1702impl AccessStartDiscoveryResponder {
1703    /// Sends a response to the FIDL transaction.
1704    ///
1705    /// Sets the channel to shutdown if an error occurs.
1706    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1707        let _result = self.send_raw(result);
1708        if _result.is_err() {
1709            self.control_handle.shutdown();
1710        }
1711        self.drop_without_shutdown();
1712        _result
1713    }
1714
1715    /// Similar to "send" but does not shutdown the channel if an error occurs.
1716    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1717        let _result = self.send_raw(result);
1718        self.drop_without_shutdown();
1719        _result
1720    }
1721
1722    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1723        self.control_handle
1724            .inner
1725            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
1726                result,
1727                self.tx_id,
1728                0x6907100d9b99439,
1729                fidl::encoding::DynamicFlags::empty(),
1730            )
1731    }
1732}
1733
1734#[must_use = "FIDL methods require a response to be sent"]
1735#[derive(Debug)]
1736pub struct AccessWatchPeersResponder {
1737    control_handle: std::mem::ManuallyDrop<AccessControlHandle>,
1738    tx_id: u32,
1739}
1740
1741/// Set the the channel to be shutdown (see [`AccessControlHandle::shutdown`])
1742/// if the responder is dropped without sending a response, so that the client
1743/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1744impl std::ops::Drop for AccessWatchPeersResponder {
1745    fn drop(&mut self) {
1746        self.control_handle.shutdown();
1747        // Safety: drops once, never accessed again
1748        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1749    }
1750}
1751
1752impl fidl::endpoints::Responder for AccessWatchPeersResponder {
1753    type ControlHandle = AccessControlHandle;
1754
1755    fn control_handle(&self) -> &AccessControlHandle {
1756        &self.control_handle
1757    }
1758
1759    fn drop_without_shutdown(mut self) {
1760        // Safety: drops once, never accessed again due to mem::forget
1761        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1762        // Prevent Drop from running (which would shut down the channel)
1763        std::mem::forget(self);
1764    }
1765}
1766
1767impl AccessWatchPeersResponder {
1768    /// Sends a response to the FIDL transaction.
1769    ///
1770    /// Sets the channel to shutdown if an error occurs.
1771    pub fn send(
1772        self,
1773        mut updated: &[Peer],
1774        mut removed: &[fidl_fuchsia_bluetooth::PeerId],
1775    ) -> Result<(), fidl::Error> {
1776        let _result = self.send_raw(updated, removed);
1777        if _result.is_err() {
1778            self.control_handle.shutdown();
1779        }
1780        self.drop_without_shutdown();
1781        _result
1782    }
1783
1784    /// Similar to "send" but does not shutdown the channel if an error occurs.
1785    pub fn send_no_shutdown_on_err(
1786        self,
1787        mut updated: &[Peer],
1788        mut removed: &[fidl_fuchsia_bluetooth::PeerId],
1789    ) -> Result<(), fidl::Error> {
1790        let _result = self.send_raw(updated, removed);
1791        self.drop_without_shutdown();
1792        _result
1793    }
1794
1795    fn send_raw(
1796        &self,
1797        mut updated: &[Peer],
1798        mut removed: &[fidl_fuchsia_bluetooth::PeerId],
1799    ) -> Result<(), fidl::Error> {
1800        self.control_handle.inner.send::<AccessWatchPeersResponse>(
1801            (updated, removed),
1802            self.tx_id,
1803            0x1921fe1ed8e6eb7c,
1804            fidl::encoding::DynamicFlags::empty(),
1805        )
1806    }
1807}
1808
1809#[must_use = "FIDL methods require a response to be sent"]
1810#[derive(Debug)]
1811pub struct AccessConnectResponder {
1812    control_handle: std::mem::ManuallyDrop<AccessControlHandle>,
1813    tx_id: u32,
1814}
1815
1816/// Set the the channel to be shutdown (see [`AccessControlHandle::shutdown`])
1817/// if the responder is dropped without sending a response, so that the client
1818/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1819impl std::ops::Drop for AccessConnectResponder {
1820    fn drop(&mut self) {
1821        self.control_handle.shutdown();
1822        // Safety: drops once, never accessed again
1823        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1824    }
1825}
1826
1827impl fidl::endpoints::Responder for AccessConnectResponder {
1828    type ControlHandle = AccessControlHandle;
1829
1830    fn control_handle(&self) -> &AccessControlHandle {
1831        &self.control_handle
1832    }
1833
1834    fn drop_without_shutdown(mut self) {
1835        // Safety: drops once, never accessed again due to mem::forget
1836        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1837        // Prevent Drop from running (which would shut down the channel)
1838        std::mem::forget(self);
1839    }
1840}
1841
1842impl AccessConnectResponder {
1843    /// Sends a response to the FIDL transaction.
1844    ///
1845    /// Sets the channel to shutdown if an error occurs.
1846    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1847        let _result = self.send_raw(result);
1848        if _result.is_err() {
1849            self.control_handle.shutdown();
1850        }
1851        self.drop_without_shutdown();
1852        _result
1853    }
1854
1855    /// Similar to "send" but does not shutdown the channel if an error occurs.
1856    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1857        let _result = self.send_raw(result);
1858        self.drop_without_shutdown();
1859        _result
1860    }
1861
1862    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1863        self.control_handle
1864            .inner
1865            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
1866                result,
1867                self.tx_id,
1868                0x1734199789fe7667,
1869                fidl::encoding::DynamicFlags::empty(),
1870            )
1871    }
1872}
1873
1874#[must_use = "FIDL methods require a response to be sent"]
1875#[derive(Debug)]
1876pub struct AccessDisconnectResponder {
1877    control_handle: std::mem::ManuallyDrop<AccessControlHandle>,
1878    tx_id: u32,
1879}
1880
1881/// Set the the channel to be shutdown (see [`AccessControlHandle::shutdown`])
1882/// if the responder is dropped without sending a response, so that the client
1883/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1884impl std::ops::Drop for AccessDisconnectResponder {
1885    fn drop(&mut self) {
1886        self.control_handle.shutdown();
1887        // Safety: drops once, never accessed again
1888        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1889    }
1890}
1891
1892impl fidl::endpoints::Responder for AccessDisconnectResponder {
1893    type ControlHandle = AccessControlHandle;
1894
1895    fn control_handle(&self) -> &AccessControlHandle {
1896        &self.control_handle
1897    }
1898
1899    fn drop_without_shutdown(mut self) {
1900        // Safety: drops once, never accessed again due to mem::forget
1901        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1902        // Prevent Drop from running (which would shut down the channel)
1903        std::mem::forget(self);
1904    }
1905}
1906
1907impl AccessDisconnectResponder {
1908    /// Sends a response to the FIDL transaction.
1909    ///
1910    /// Sets the channel to shutdown if an error occurs.
1911    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1912        let _result = self.send_raw(result);
1913        if _result.is_err() {
1914            self.control_handle.shutdown();
1915        }
1916        self.drop_without_shutdown();
1917        _result
1918    }
1919
1920    /// Similar to "send" but does not shutdown the channel if an error occurs.
1921    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1922        let _result = self.send_raw(result);
1923        self.drop_without_shutdown();
1924        _result
1925    }
1926
1927    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1928        self.control_handle
1929            .inner
1930            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
1931                result,
1932                self.tx_id,
1933                0x3a4e06d0c6185a5,
1934                fidl::encoding::DynamicFlags::empty(),
1935            )
1936    }
1937}
1938
1939#[must_use = "FIDL methods require a response to be sent"]
1940#[derive(Debug)]
1941pub struct AccessPairResponder {
1942    control_handle: std::mem::ManuallyDrop<AccessControlHandle>,
1943    tx_id: u32,
1944}
1945
1946/// Set the the channel to be shutdown (see [`AccessControlHandle::shutdown`])
1947/// if the responder is dropped without sending a response, so that the client
1948/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1949impl std::ops::Drop for AccessPairResponder {
1950    fn drop(&mut self) {
1951        self.control_handle.shutdown();
1952        // Safety: drops once, never accessed again
1953        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1954    }
1955}
1956
1957impl fidl::endpoints::Responder for AccessPairResponder {
1958    type ControlHandle = AccessControlHandle;
1959
1960    fn control_handle(&self) -> &AccessControlHandle {
1961        &self.control_handle
1962    }
1963
1964    fn drop_without_shutdown(mut self) {
1965        // Safety: drops once, never accessed again due to mem::forget
1966        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1967        // Prevent Drop from running (which would shut down the channel)
1968        std::mem::forget(self);
1969    }
1970}
1971
1972impl AccessPairResponder {
1973    /// Sends a response to the FIDL transaction.
1974    ///
1975    /// Sets the channel to shutdown if an error occurs.
1976    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1977        let _result = self.send_raw(result);
1978        if _result.is_err() {
1979            self.control_handle.shutdown();
1980        }
1981        self.drop_without_shutdown();
1982        _result
1983    }
1984
1985    /// Similar to "send" but does not shutdown the channel if an error occurs.
1986    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1987        let _result = self.send_raw(result);
1988        self.drop_without_shutdown();
1989        _result
1990    }
1991
1992    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1993        self.control_handle
1994            .inner
1995            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
1996                result,
1997                self.tx_id,
1998                0x1d08ea19db327779,
1999                fidl::encoding::DynamicFlags::empty(),
2000            )
2001    }
2002}
2003
2004#[must_use = "FIDL methods require a response to be sent"]
2005#[derive(Debug)]
2006pub struct AccessForgetResponder {
2007    control_handle: std::mem::ManuallyDrop<AccessControlHandle>,
2008    tx_id: u32,
2009}
2010
2011/// Set the the channel to be shutdown (see [`AccessControlHandle::shutdown`])
2012/// if the responder is dropped without sending a response, so that the client
2013/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2014impl std::ops::Drop for AccessForgetResponder {
2015    fn drop(&mut self) {
2016        self.control_handle.shutdown();
2017        // Safety: drops once, never accessed again
2018        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2019    }
2020}
2021
2022impl fidl::endpoints::Responder for AccessForgetResponder {
2023    type ControlHandle = AccessControlHandle;
2024
2025    fn control_handle(&self) -> &AccessControlHandle {
2026        &self.control_handle
2027    }
2028
2029    fn drop_without_shutdown(mut self) {
2030        // Safety: drops once, never accessed again due to mem::forget
2031        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2032        // Prevent Drop from running (which would shut down the channel)
2033        std::mem::forget(self);
2034    }
2035}
2036
2037impl AccessForgetResponder {
2038    /// Sends a response to the FIDL transaction.
2039    ///
2040    /// Sets the channel to shutdown if an error occurs.
2041    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2042        let _result = self.send_raw(result);
2043        if _result.is_err() {
2044            self.control_handle.shutdown();
2045        }
2046        self.drop_without_shutdown();
2047        _result
2048    }
2049
2050    /// Similar to "send" but does not shutdown the channel if an error occurs.
2051    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2052        let _result = self.send_raw(result);
2053        self.drop_without_shutdown();
2054        _result
2055    }
2056
2057    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2058        self.control_handle
2059            .inner
2060            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
2061                result,
2062                self.tx_id,
2063                0x1fd8e27202854c0,
2064                fidl::encoding::DynamicFlags::empty(),
2065            )
2066    }
2067}
2068
2069#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2070pub struct AddressLookupMarker;
2071
2072impl fidl::endpoints::ProtocolMarker for AddressLookupMarker {
2073    type Proxy = AddressLookupProxy;
2074    type RequestStream = AddressLookupRequestStream;
2075    #[cfg(target_os = "fuchsia")]
2076    type SynchronousProxy = AddressLookupSynchronousProxy;
2077
2078    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.sys.AddressLookup";
2079}
2080impl fidl::endpoints::DiscoverableProtocolMarker for AddressLookupMarker {}
2081pub type AddressLookupLookupResult = Result<fidl_fuchsia_bluetooth::Address, LookupError>;
2082
2083pub trait AddressLookupProxyInterface: Send + Sync {
2084    type LookupResponseFut: std::future::Future<Output = Result<AddressLookupLookupResult, fidl::Error>>
2085        + Send;
2086    fn r#lookup(&self, payload: &AddressLookupLookupRequest) -> Self::LookupResponseFut;
2087}
2088#[derive(Debug)]
2089#[cfg(target_os = "fuchsia")]
2090pub struct AddressLookupSynchronousProxy {
2091    client: fidl::client::sync::Client,
2092}
2093
2094#[cfg(target_os = "fuchsia")]
2095impl fidl::endpoints::SynchronousProxy for AddressLookupSynchronousProxy {
2096    type Proxy = AddressLookupProxy;
2097    type Protocol = AddressLookupMarker;
2098
2099    fn from_channel(inner: fidl::Channel) -> Self {
2100        Self::new(inner)
2101    }
2102
2103    fn into_channel(self) -> fidl::Channel {
2104        self.client.into_channel()
2105    }
2106
2107    fn as_channel(&self) -> &fidl::Channel {
2108        self.client.as_channel()
2109    }
2110}
2111
2112#[cfg(target_os = "fuchsia")]
2113impl AddressLookupSynchronousProxy {
2114    pub fn new(channel: fidl::Channel) -> Self {
2115        let protocol_name = <AddressLookupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2116        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2117    }
2118
2119    pub fn into_channel(self) -> fidl::Channel {
2120        self.client.into_channel()
2121    }
2122
2123    /// Waits until an event arrives and returns it. It is safe for other
2124    /// threads to make concurrent requests while waiting for an event.
2125    pub fn wait_for_event(
2126        &self,
2127        deadline: zx::MonotonicInstant,
2128    ) -> Result<AddressLookupEvent, fidl::Error> {
2129        AddressLookupEvent::decode(self.client.wait_for_event(deadline)?)
2130    }
2131
2132    pub fn r#lookup(
2133        &self,
2134        mut payload: &AddressLookupLookupRequest,
2135        ___deadline: zx::MonotonicInstant,
2136    ) -> Result<AddressLookupLookupResult, fidl::Error> {
2137        let _response = self.client.send_query::<
2138            AddressLookupLookupRequest,
2139            fidl::encoding::FlexibleResultType<AddressLookupLookupResponse, LookupError>,
2140        >(
2141            payload,
2142            0x65d2ae252ec22587,
2143            fidl::encoding::DynamicFlags::FLEXIBLE,
2144            ___deadline,
2145        )?
2146        .into_result::<AddressLookupMarker>("lookup")?;
2147        Ok(_response.map(|x| x.bd_addr))
2148    }
2149}
2150
2151#[cfg(target_os = "fuchsia")]
2152impl From<AddressLookupSynchronousProxy> for zx::Handle {
2153    fn from(value: AddressLookupSynchronousProxy) -> Self {
2154        value.into_channel().into()
2155    }
2156}
2157
2158#[cfg(target_os = "fuchsia")]
2159impl From<fidl::Channel> for AddressLookupSynchronousProxy {
2160    fn from(value: fidl::Channel) -> Self {
2161        Self::new(value)
2162    }
2163}
2164
2165#[derive(Debug, Clone)]
2166pub struct AddressLookupProxy {
2167    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2168}
2169
2170impl fidl::endpoints::Proxy for AddressLookupProxy {
2171    type Protocol = AddressLookupMarker;
2172
2173    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2174        Self::new(inner)
2175    }
2176
2177    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2178        self.client.into_channel().map_err(|client| Self { client })
2179    }
2180
2181    fn as_channel(&self) -> &::fidl::AsyncChannel {
2182        self.client.as_channel()
2183    }
2184}
2185
2186impl AddressLookupProxy {
2187    /// Create a new Proxy for fuchsia.bluetooth.sys/AddressLookup.
2188    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2189        let protocol_name = <AddressLookupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2190        Self { client: fidl::client::Client::new(channel, protocol_name) }
2191    }
2192
2193    /// Get a Stream of events from the remote end of the protocol.
2194    ///
2195    /// # Panics
2196    ///
2197    /// Panics if the event stream was already taken.
2198    pub fn take_event_stream(&self) -> AddressLookupEventStream {
2199        AddressLookupEventStream { event_receiver: self.client.take_event_receiver() }
2200    }
2201
2202    pub fn r#lookup(
2203        &self,
2204        mut payload: &AddressLookupLookupRequest,
2205    ) -> fidl::client::QueryResponseFut<
2206        AddressLookupLookupResult,
2207        fidl::encoding::DefaultFuchsiaResourceDialect,
2208    > {
2209        AddressLookupProxyInterface::r#lookup(self, payload)
2210    }
2211}
2212
2213impl AddressLookupProxyInterface for AddressLookupProxy {
2214    type LookupResponseFut = fidl::client::QueryResponseFut<
2215        AddressLookupLookupResult,
2216        fidl::encoding::DefaultFuchsiaResourceDialect,
2217    >;
2218    fn r#lookup(&self, mut payload: &AddressLookupLookupRequest) -> Self::LookupResponseFut {
2219        fn _decode(
2220            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2221        ) -> Result<AddressLookupLookupResult, fidl::Error> {
2222            let _response = fidl::client::decode_transaction_body::<
2223                fidl::encoding::FlexibleResultType<AddressLookupLookupResponse, LookupError>,
2224                fidl::encoding::DefaultFuchsiaResourceDialect,
2225                0x65d2ae252ec22587,
2226            >(_buf?)?
2227            .into_result::<AddressLookupMarker>("lookup")?;
2228            Ok(_response.map(|x| x.bd_addr))
2229        }
2230        self.client.send_query_and_decode::<AddressLookupLookupRequest, AddressLookupLookupResult>(
2231            payload,
2232            0x65d2ae252ec22587,
2233            fidl::encoding::DynamicFlags::FLEXIBLE,
2234            _decode,
2235        )
2236    }
2237}
2238
2239pub struct AddressLookupEventStream {
2240    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2241}
2242
2243impl std::marker::Unpin for AddressLookupEventStream {}
2244
2245impl futures::stream::FusedStream for AddressLookupEventStream {
2246    fn is_terminated(&self) -> bool {
2247        self.event_receiver.is_terminated()
2248    }
2249}
2250
2251impl futures::Stream for AddressLookupEventStream {
2252    type Item = Result<AddressLookupEvent, fidl::Error>;
2253
2254    fn poll_next(
2255        mut self: std::pin::Pin<&mut Self>,
2256        cx: &mut std::task::Context<'_>,
2257    ) -> std::task::Poll<Option<Self::Item>> {
2258        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2259            &mut self.event_receiver,
2260            cx
2261        )?) {
2262            Some(buf) => std::task::Poll::Ready(Some(AddressLookupEvent::decode(buf))),
2263            None => std::task::Poll::Ready(None),
2264        }
2265    }
2266}
2267
2268#[derive(Debug)]
2269pub enum AddressLookupEvent {
2270    #[non_exhaustive]
2271    _UnknownEvent {
2272        /// Ordinal of the event that was sent.
2273        ordinal: u64,
2274    },
2275}
2276
2277impl AddressLookupEvent {
2278    /// Decodes a message buffer as a [`AddressLookupEvent`].
2279    fn decode(
2280        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2281    ) -> Result<AddressLookupEvent, fidl::Error> {
2282        let (bytes, _handles) = buf.split_mut();
2283        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2284        debug_assert_eq!(tx_header.tx_id, 0);
2285        match tx_header.ordinal {
2286            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2287                Ok(AddressLookupEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2288            }
2289            _ => Err(fidl::Error::UnknownOrdinal {
2290                ordinal: tx_header.ordinal,
2291                protocol_name: <AddressLookupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2292            }),
2293        }
2294    }
2295}
2296
2297/// A Stream of incoming requests for fuchsia.bluetooth.sys/AddressLookup.
2298pub struct AddressLookupRequestStream {
2299    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2300    is_terminated: bool,
2301}
2302
2303impl std::marker::Unpin for AddressLookupRequestStream {}
2304
2305impl futures::stream::FusedStream for AddressLookupRequestStream {
2306    fn is_terminated(&self) -> bool {
2307        self.is_terminated
2308    }
2309}
2310
2311impl fidl::endpoints::RequestStream for AddressLookupRequestStream {
2312    type Protocol = AddressLookupMarker;
2313    type ControlHandle = AddressLookupControlHandle;
2314
2315    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2316        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2317    }
2318
2319    fn control_handle(&self) -> Self::ControlHandle {
2320        AddressLookupControlHandle { inner: self.inner.clone() }
2321    }
2322
2323    fn into_inner(
2324        self,
2325    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2326    {
2327        (self.inner, self.is_terminated)
2328    }
2329
2330    fn from_inner(
2331        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2332        is_terminated: bool,
2333    ) -> Self {
2334        Self { inner, is_terminated }
2335    }
2336}
2337
2338impl futures::Stream for AddressLookupRequestStream {
2339    type Item = Result<AddressLookupRequest, fidl::Error>;
2340
2341    fn poll_next(
2342        mut self: std::pin::Pin<&mut Self>,
2343        cx: &mut std::task::Context<'_>,
2344    ) -> std::task::Poll<Option<Self::Item>> {
2345        let this = &mut *self;
2346        if this.inner.check_shutdown(cx) {
2347            this.is_terminated = true;
2348            return std::task::Poll::Ready(None);
2349        }
2350        if this.is_terminated {
2351            panic!("polled AddressLookupRequestStream after completion");
2352        }
2353        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2354            |bytes, handles| {
2355                match this.inner.channel().read_etc(cx, bytes, handles) {
2356                    std::task::Poll::Ready(Ok(())) => {}
2357                    std::task::Poll::Pending => return std::task::Poll::Pending,
2358                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2359                        this.is_terminated = true;
2360                        return std::task::Poll::Ready(None);
2361                    }
2362                    std::task::Poll::Ready(Err(e)) => {
2363                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2364                            e.into(),
2365                        ))))
2366                    }
2367                }
2368
2369                // A message has been received from the channel
2370                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2371
2372                std::task::Poll::Ready(Some(match header.ordinal {
2373                    0x65d2ae252ec22587 => {
2374                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2375                        let mut req = fidl::new_empty!(
2376                            AddressLookupLookupRequest,
2377                            fidl::encoding::DefaultFuchsiaResourceDialect
2378                        );
2379                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AddressLookupLookupRequest>(&header, _body_bytes, handles, &mut req)?;
2380                        let control_handle =
2381                            AddressLookupControlHandle { inner: this.inner.clone() };
2382                        Ok(AddressLookupRequest::Lookup {
2383                            payload: req,
2384                            responder: AddressLookupLookupResponder {
2385                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2386                                tx_id: header.tx_id,
2387                            },
2388                        })
2389                    }
2390                    _ if header.tx_id == 0
2391                        && header
2392                            .dynamic_flags()
2393                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2394                    {
2395                        Ok(AddressLookupRequest::_UnknownMethod {
2396                            ordinal: header.ordinal,
2397                            control_handle: AddressLookupControlHandle {
2398                                inner: this.inner.clone(),
2399                            },
2400                            method_type: fidl::MethodType::OneWay,
2401                        })
2402                    }
2403                    _ if header
2404                        .dynamic_flags()
2405                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2406                    {
2407                        this.inner.send_framework_err(
2408                            fidl::encoding::FrameworkErr::UnknownMethod,
2409                            header.tx_id,
2410                            header.ordinal,
2411                            header.dynamic_flags(),
2412                            (bytes, handles),
2413                        )?;
2414                        Ok(AddressLookupRequest::_UnknownMethod {
2415                            ordinal: header.ordinal,
2416                            control_handle: AddressLookupControlHandle {
2417                                inner: this.inner.clone(),
2418                            },
2419                            method_type: fidl::MethodType::TwoWay,
2420                        })
2421                    }
2422                    _ => Err(fidl::Error::UnknownOrdinal {
2423                        ordinal: header.ordinal,
2424                        protocol_name:
2425                            <AddressLookupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2426                    }),
2427                }))
2428            },
2429        )
2430    }
2431}
2432
2433/// Protocol used for finding a peer's bluetooth address.
2434#[derive(Debug)]
2435pub enum AddressLookupRequest {
2436    Lookup {
2437        payload: AddressLookupLookupRequest,
2438        responder: AddressLookupLookupResponder,
2439    },
2440    /// An interaction was received which does not match any known method.
2441    #[non_exhaustive]
2442    _UnknownMethod {
2443        /// Ordinal of the method that was called.
2444        ordinal: u64,
2445        control_handle: AddressLookupControlHandle,
2446        method_type: fidl::MethodType,
2447    },
2448}
2449
2450impl AddressLookupRequest {
2451    #[allow(irrefutable_let_patterns)]
2452    pub fn into_lookup(self) -> Option<(AddressLookupLookupRequest, AddressLookupLookupResponder)> {
2453        if let AddressLookupRequest::Lookup { payload, responder } = self {
2454            Some((payload, responder))
2455        } else {
2456            None
2457        }
2458    }
2459
2460    /// Name of the method defined in FIDL
2461    pub fn method_name(&self) -> &'static str {
2462        match *self {
2463            AddressLookupRequest::Lookup { .. } => "lookup",
2464            AddressLookupRequest::_UnknownMethod {
2465                method_type: fidl::MethodType::OneWay, ..
2466            } => "unknown one-way method",
2467            AddressLookupRequest::_UnknownMethod {
2468                method_type: fidl::MethodType::TwoWay, ..
2469            } => "unknown two-way method",
2470        }
2471    }
2472}
2473
2474#[derive(Debug, Clone)]
2475pub struct AddressLookupControlHandle {
2476    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2477}
2478
2479impl fidl::endpoints::ControlHandle for AddressLookupControlHandle {
2480    fn shutdown(&self) {
2481        self.inner.shutdown()
2482    }
2483    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2484        self.inner.shutdown_with_epitaph(status)
2485    }
2486
2487    fn is_closed(&self) -> bool {
2488        self.inner.channel().is_closed()
2489    }
2490    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2491        self.inner.channel().on_closed()
2492    }
2493
2494    #[cfg(target_os = "fuchsia")]
2495    fn signal_peer(
2496        &self,
2497        clear_mask: zx::Signals,
2498        set_mask: zx::Signals,
2499    ) -> Result<(), zx_status::Status> {
2500        use fidl::Peered;
2501        self.inner.channel().signal_peer(clear_mask, set_mask)
2502    }
2503}
2504
2505impl AddressLookupControlHandle {}
2506
2507#[must_use = "FIDL methods require a response to be sent"]
2508#[derive(Debug)]
2509pub struct AddressLookupLookupResponder {
2510    control_handle: std::mem::ManuallyDrop<AddressLookupControlHandle>,
2511    tx_id: u32,
2512}
2513
2514/// Set the the channel to be shutdown (see [`AddressLookupControlHandle::shutdown`])
2515/// if the responder is dropped without sending a response, so that the client
2516/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2517impl std::ops::Drop for AddressLookupLookupResponder {
2518    fn drop(&mut self) {
2519        self.control_handle.shutdown();
2520        // Safety: drops once, never accessed again
2521        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2522    }
2523}
2524
2525impl fidl::endpoints::Responder for AddressLookupLookupResponder {
2526    type ControlHandle = AddressLookupControlHandle;
2527
2528    fn control_handle(&self) -> &AddressLookupControlHandle {
2529        &self.control_handle
2530    }
2531
2532    fn drop_without_shutdown(mut self) {
2533        // Safety: drops once, never accessed again due to mem::forget
2534        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2535        // Prevent Drop from running (which would shut down the channel)
2536        std::mem::forget(self);
2537    }
2538}
2539
2540impl AddressLookupLookupResponder {
2541    /// Sends a response to the FIDL transaction.
2542    ///
2543    /// Sets the channel to shutdown if an error occurs.
2544    pub fn send(
2545        self,
2546        mut result: Result<&fidl_fuchsia_bluetooth::Address, LookupError>,
2547    ) -> Result<(), fidl::Error> {
2548        let _result = self.send_raw(result);
2549        if _result.is_err() {
2550            self.control_handle.shutdown();
2551        }
2552        self.drop_without_shutdown();
2553        _result
2554    }
2555
2556    /// Similar to "send" but does not shutdown the channel if an error occurs.
2557    pub fn send_no_shutdown_on_err(
2558        self,
2559        mut result: Result<&fidl_fuchsia_bluetooth::Address, LookupError>,
2560    ) -> Result<(), fidl::Error> {
2561        let _result = self.send_raw(result);
2562        self.drop_without_shutdown();
2563        _result
2564    }
2565
2566    fn send_raw(
2567        &self,
2568        mut result: Result<&fidl_fuchsia_bluetooth::Address, LookupError>,
2569    ) -> Result<(), fidl::Error> {
2570        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2571            AddressLookupLookupResponse,
2572            LookupError,
2573        >>(
2574            fidl::encoding::FlexibleResult::new(result.map(|bd_addr| (bd_addr,))),
2575            self.tx_id,
2576            0x65d2ae252ec22587,
2577            fidl::encoding::DynamicFlags::FLEXIBLE,
2578        )
2579    }
2580}
2581
2582#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2583pub struct BootstrapMarker;
2584
2585impl fidl::endpoints::ProtocolMarker for BootstrapMarker {
2586    type Proxy = BootstrapProxy;
2587    type RequestStream = BootstrapRequestStream;
2588    #[cfg(target_os = "fuchsia")]
2589    type SynchronousProxy = BootstrapSynchronousProxy;
2590
2591    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.sys.Bootstrap";
2592}
2593impl fidl::endpoints::DiscoverableProtocolMarker for BootstrapMarker {}
2594pub type BootstrapCommitResult = Result<(), BootstrapError>;
2595
2596pub trait BootstrapProxyInterface: Send + Sync {
2597    fn r#add_identities(&self, identities: &[Identity]) -> Result<(), fidl::Error>;
2598    type CommitResponseFut: std::future::Future<Output = Result<BootstrapCommitResult, fidl::Error>>
2599        + Send;
2600    fn r#commit(&self) -> Self::CommitResponseFut;
2601}
2602#[derive(Debug)]
2603#[cfg(target_os = "fuchsia")]
2604pub struct BootstrapSynchronousProxy {
2605    client: fidl::client::sync::Client,
2606}
2607
2608#[cfg(target_os = "fuchsia")]
2609impl fidl::endpoints::SynchronousProxy for BootstrapSynchronousProxy {
2610    type Proxy = BootstrapProxy;
2611    type Protocol = BootstrapMarker;
2612
2613    fn from_channel(inner: fidl::Channel) -> Self {
2614        Self::new(inner)
2615    }
2616
2617    fn into_channel(self) -> fidl::Channel {
2618        self.client.into_channel()
2619    }
2620
2621    fn as_channel(&self) -> &fidl::Channel {
2622        self.client.as_channel()
2623    }
2624}
2625
2626#[cfg(target_os = "fuchsia")]
2627impl BootstrapSynchronousProxy {
2628    pub fn new(channel: fidl::Channel) -> Self {
2629        let protocol_name = <BootstrapMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2630        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2631    }
2632
2633    pub fn into_channel(self) -> fidl::Channel {
2634        self.client.into_channel()
2635    }
2636
2637    /// Waits until an event arrives and returns it. It is safe for other
2638    /// threads to make concurrent requests while waiting for an event.
2639    pub fn wait_for_event(
2640        &self,
2641        deadline: zx::MonotonicInstant,
2642    ) -> Result<BootstrapEvent, fidl::Error> {
2643        BootstrapEvent::decode(self.client.wait_for_event(deadline)?)
2644    }
2645
2646    /// Adds identities to be added to the unpopulated Bluetooth stack.
2647    ///
2648    /// Repeated calls will append identities.
2649    pub fn r#add_identities(&self, mut identities: &[Identity]) -> Result<(), fidl::Error> {
2650        self.client.send::<BootstrapAddIdentitiesRequest>(
2651            (identities,),
2652            0x92d7c849de29bb0,
2653            fidl::encoding::DynamicFlags::empty(),
2654        )
2655    }
2656
2657    /// Writes all added bootstrapping data to the Bluetooth core stack. The server will close the
2658    /// channel regardless of success. Returns without error if successful and the stack will be
2659    /// considered initialized even if no bootstrapping data was written. Returns
2660    /// INVALID_HOST_IDENTITY if any host or bonded peer data is insufficient or inconsistent, with
2661    /// no effect (the client may retry by obtaining another protocol handle).
2662    pub fn r#commit(
2663        &self,
2664        ___deadline: zx::MonotonicInstant,
2665    ) -> Result<BootstrapCommitResult, fidl::Error> {
2666        let _response = self.client.send_query::<
2667            fidl::encoding::EmptyPayload,
2668            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, BootstrapError>,
2669        >(
2670            (),
2671            0x5288006c9c7db6b7,
2672            fidl::encoding::DynamicFlags::empty(),
2673            ___deadline,
2674        )?;
2675        Ok(_response.map(|x| x))
2676    }
2677}
2678
2679#[cfg(target_os = "fuchsia")]
2680impl From<BootstrapSynchronousProxy> for zx::Handle {
2681    fn from(value: BootstrapSynchronousProxy) -> Self {
2682        value.into_channel().into()
2683    }
2684}
2685
2686#[cfg(target_os = "fuchsia")]
2687impl From<fidl::Channel> for BootstrapSynchronousProxy {
2688    fn from(value: fidl::Channel) -> Self {
2689        Self::new(value)
2690    }
2691}
2692
2693#[derive(Debug, Clone)]
2694pub struct BootstrapProxy {
2695    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2696}
2697
2698impl fidl::endpoints::Proxy for BootstrapProxy {
2699    type Protocol = BootstrapMarker;
2700
2701    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2702        Self::new(inner)
2703    }
2704
2705    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2706        self.client.into_channel().map_err(|client| Self { client })
2707    }
2708
2709    fn as_channel(&self) -> &::fidl::AsyncChannel {
2710        self.client.as_channel()
2711    }
2712}
2713
2714impl BootstrapProxy {
2715    /// Create a new Proxy for fuchsia.bluetooth.sys/Bootstrap.
2716    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2717        let protocol_name = <BootstrapMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2718        Self { client: fidl::client::Client::new(channel, protocol_name) }
2719    }
2720
2721    /// Get a Stream of events from the remote end of the protocol.
2722    ///
2723    /// # Panics
2724    ///
2725    /// Panics if the event stream was already taken.
2726    pub fn take_event_stream(&self) -> BootstrapEventStream {
2727        BootstrapEventStream { event_receiver: self.client.take_event_receiver() }
2728    }
2729
2730    /// Adds identities to be added to the unpopulated Bluetooth stack.
2731    ///
2732    /// Repeated calls will append identities.
2733    pub fn r#add_identities(&self, mut identities: &[Identity]) -> Result<(), fidl::Error> {
2734        BootstrapProxyInterface::r#add_identities(self, identities)
2735    }
2736
2737    /// Writes all added bootstrapping data to the Bluetooth core stack. The server will close the
2738    /// channel regardless of success. Returns without error if successful and the stack will be
2739    /// considered initialized even if no bootstrapping data was written. Returns
2740    /// INVALID_HOST_IDENTITY if any host or bonded peer data is insufficient or inconsistent, with
2741    /// no effect (the client may retry by obtaining another protocol handle).
2742    pub fn r#commit(
2743        &self,
2744    ) -> fidl::client::QueryResponseFut<
2745        BootstrapCommitResult,
2746        fidl::encoding::DefaultFuchsiaResourceDialect,
2747    > {
2748        BootstrapProxyInterface::r#commit(self)
2749    }
2750}
2751
2752impl BootstrapProxyInterface for BootstrapProxy {
2753    fn r#add_identities(&self, mut identities: &[Identity]) -> Result<(), fidl::Error> {
2754        self.client.send::<BootstrapAddIdentitiesRequest>(
2755            (identities,),
2756            0x92d7c849de29bb0,
2757            fidl::encoding::DynamicFlags::empty(),
2758        )
2759    }
2760
2761    type CommitResponseFut = fidl::client::QueryResponseFut<
2762        BootstrapCommitResult,
2763        fidl::encoding::DefaultFuchsiaResourceDialect,
2764    >;
2765    fn r#commit(&self) -> Self::CommitResponseFut {
2766        fn _decode(
2767            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2768        ) -> Result<BootstrapCommitResult, fidl::Error> {
2769            let _response = fidl::client::decode_transaction_body::<
2770                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, BootstrapError>,
2771                fidl::encoding::DefaultFuchsiaResourceDialect,
2772                0x5288006c9c7db6b7,
2773            >(_buf?)?;
2774            Ok(_response.map(|x| x))
2775        }
2776        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, BootstrapCommitResult>(
2777            (),
2778            0x5288006c9c7db6b7,
2779            fidl::encoding::DynamicFlags::empty(),
2780            _decode,
2781        )
2782    }
2783}
2784
2785pub struct BootstrapEventStream {
2786    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2787}
2788
2789impl std::marker::Unpin for BootstrapEventStream {}
2790
2791impl futures::stream::FusedStream for BootstrapEventStream {
2792    fn is_terminated(&self) -> bool {
2793        self.event_receiver.is_terminated()
2794    }
2795}
2796
2797impl futures::Stream for BootstrapEventStream {
2798    type Item = Result<BootstrapEvent, fidl::Error>;
2799
2800    fn poll_next(
2801        mut self: std::pin::Pin<&mut Self>,
2802        cx: &mut std::task::Context<'_>,
2803    ) -> std::task::Poll<Option<Self::Item>> {
2804        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2805            &mut self.event_receiver,
2806            cx
2807        )?) {
2808            Some(buf) => std::task::Poll::Ready(Some(BootstrapEvent::decode(buf))),
2809            None => std::task::Poll::Ready(None),
2810        }
2811    }
2812}
2813
2814#[derive(Debug)]
2815pub enum BootstrapEvent {}
2816
2817impl BootstrapEvent {
2818    /// Decodes a message buffer as a [`BootstrapEvent`].
2819    fn decode(
2820        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2821    ) -> Result<BootstrapEvent, fidl::Error> {
2822        let (bytes, _handles) = buf.split_mut();
2823        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2824        debug_assert_eq!(tx_header.tx_id, 0);
2825        match tx_header.ordinal {
2826            _ => Err(fidl::Error::UnknownOrdinal {
2827                ordinal: tx_header.ordinal,
2828                protocol_name: <BootstrapMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2829            }),
2830        }
2831    }
2832}
2833
2834/// A Stream of incoming requests for fuchsia.bluetooth.sys/Bootstrap.
2835pub struct BootstrapRequestStream {
2836    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2837    is_terminated: bool,
2838}
2839
2840impl std::marker::Unpin for BootstrapRequestStream {}
2841
2842impl futures::stream::FusedStream for BootstrapRequestStream {
2843    fn is_terminated(&self) -> bool {
2844        self.is_terminated
2845    }
2846}
2847
2848impl fidl::endpoints::RequestStream for BootstrapRequestStream {
2849    type Protocol = BootstrapMarker;
2850    type ControlHandle = BootstrapControlHandle;
2851
2852    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2853        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2854    }
2855
2856    fn control_handle(&self) -> Self::ControlHandle {
2857        BootstrapControlHandle { inner: self.inner.clone() }
2858    }
2859
2860    fn into_inner(
2861        self,
2862    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2863    {
2864        (self.inner, self.is_terminated)
2865    }
2866
2867    fn from_inner(
2868        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2869        is_terminated: bool,
2870    ) -> Self {
2871        Self { inner, is_terminated }
2872    }
2873}
2874
2875impl futures::Stream for BootstrapRequestStream {
2876    type Item = Result<BootstrapRequest, fidl::Error>;
2877
2878    fn poll_next(
2879        mut self: std::pin::Pin<&mut Self>,
2880        cx: &mut std::task::Context<'_>,
2881    ) -> std::task::Poll<Option<Self::Item>> {
2882        let this = &mut *self;
2883        if this.inner.check_shutdown(cx) {
2884            this.is_terminated = true;
2885            return std::task::Poll::Ready(None);
2886        }
2887        if this.is_terminated {
2888            panic!("polled BootstrapRequestStream after completion");
2889        }
2890        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2891            |bytes, handles| {
2892                match this.inner.channel().read_etc(cx, bytes, handles) {
2893                    std::task::Poll::Ready(Ok(())) => {}
2894                    std::task::Poll::Pending => return std::task::Poll::Pending,
2895                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2896                        this.is_terminated = true;
2897                        return std::task::Poll::Ready(None);
2898                    }
2899                    std::task::Poll::Ready(Err(e)) => {
2900                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2901                            e.into(),
2902                        ))))
2903                    }
2904                }
2905
2906                // A message has been received from the channel
2907                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2908
2909                std::task::Poll::Ready(Some(match header.ordinal {
2910                    0x92d7c849de29bb0 => {
2911                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2912                        let mut req = fidl::new_empty!(
2913                            BootstrapAddIdentitiesRequest,
2914                            fidl::encoding::DefaultFuchsiaResourceDialect
2915                        );
2916                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BootstrapAddIdentitiesRequest>(&header, _body_bytes, handles, &mut req)?;
2917                        let control_handle = BootstrapControlHandle { inner: this.inner.clone() };
2918                        Ok(BootstrapRequest::AddIdentities {
2919                            identities: req.identities,
2920
2921                            control_handle,
2922                        })
2923                    }
2924                    0x5288006c9c7db6b7 => {
2925                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2926                        let mut req = fidl::new_empty!(
2927                            fidl::encoding::EmptyPayload,
2928                            fidl::encoding::DefaultFuchsiaResourceDialect
2929                        );
2930                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2931                        let control_handle = BootstrapControlHandle { inner: this.inner.clone() };
2932                        Ok(BootstrapRequest::Commit {
2933                            responder: BootstrapCommitResponder {
2934                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2935                                tx_id: header.tx_id,
2936                            },
2937                        })
2938                    }
2939                    _ => Err(fidl::Error::UnknownOrdinal {
2940                        ordinal: header.ordinal,
2941                        protocol_name:
2942                            <BootstrapMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2943                    }),
2944                }))
2945            },
2946        )
2947    }
2948}
2949
2950/// Protocol used to initialize persistent core Bluetooth data. This protocol populates data that
2951/// determine the identity of this device as perceived by other Bluetooth devices.
2952///
2953/// This protocol can be obtained only before the core Bluetooth host subsystem has generated its
2954/// own identity. Once initial data is committed, this capability becomes unavailable and remains
2955/// unavailable even if new Bluetooth adapters are attached.
2956///
2957/// Due to the privacy and bonding secrets involved, as well as the capability to make this device
2958/// assume the Bluetooth identity of another device, this protocol should only be exposed to
2959/// privileged components that can vouchsafe the origin of the data.
2960#[derive(Debug)]
2961pub enum BootstrapRequest {
2962    /// Adds identities to be added to the unpopulated Bluetooth stack.
2963    ///
2964    /// Repeated calls will append identities.
2965    AddIdentities { identities: Vec<Identity>, control_handle: BootstrapControlHandle },
2966    /// Writes all added bootstrapping data to the Bluetooth core stack. The server will close the
2967    /// channel regardless of success. Returns without error if successful and the stack will be
2968    /// considered initialized even if no bootstrapping data was written. Returns
2969    /// INVALID_HOST_IDENTITY if any host or bonded peer data is insufficient or inconsistent, with
2970    /// no effect (the client may retry by obtaining another protocol handle).
2971    Commit { responder: BootstrapCommitResponder },
2972}
2973
2974impl BootstrapRequest {
2975    #[allow(irrefutable_let_patterns)]
2976    pub fn into_add_identities(self) -> Option<(Vec<Identity>, BootstrapControlHandle)> {
2977        if let BootstrapRequest::AddIdentities { identities, control_handle } = self {
2978            Some((identities, control_handle))
2979        } else {
2980            None
2981        }
2982    }
2983
2984    #[allow(irrefutable_let_patterns)]
2985    pub fn into_commit(self) -> Option<(BootstrapCommitResponder)> {
2986        if let BootstrapRequest::Commit { responder } = self {
2987            Some((responder))
2988        } else {
2989            None
2990        }
2991    }
2992
2993    /// Name of the method defined in FIDL
2994    pub fn method_name(&self) -> &'static str {
2995        match *self {
2996            BootstrapRequest::AddIdentities { .. } => "add_identities",
2997            BootstrapRequest::Commit { .. } => "commit",
2998        }
2999    }
3000}
3001
3002#[derive(Debug, Clone)]
3003pub struct BootstrapControlHandle {
3004    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3005}
3006
3007impl fidl::endpoints::ControlHandle for BootstrapControlHandle {
3008    fn shutdown(&self) {
3009        self.inner.shutdown()
3010    }
3011    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3012        self.inner.shutdown_with_epitaph(status)
3013    }
3014
3015    fn is_closed(&self) -> bool {
3016        self.inner.channel().is_closed()
3017    }
3018    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3019        self.inner.channel().on_closed()
3020    }
3021
3022    #[cfg(target_os = "fuchsia")]
3023    fn signal_peer(
3024        &self,
3025        clear_mask: zx::Signals,
3026        set_mask: zx::Signals,
3027    ) -> Result<(), zx_status::Status> {
3028        use fidl::Peered;
3029        self.inner.channel().signal_peer(clear_mask, set_mask)
3030    }
3031}
3032
3033impl BootstrapControlHandle {}
3034
3035#[must_use = "FIDL methods require a response to be sent"]
3036#[derive(Debug)]
3037pub struct BootstrapCommitResponder {
3038    control_handle: std::mem::ManuallyDrop<BootstrapControlHandle>,
3039    tx_id: u32,
3040}
3041
3042/// Set the the channel to be shutdown (see [`BootstrapControlHandle::shutdown`])
3043/// if the responder is dropped without sending a response, so that the client
3044/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3045impl std::ops::Drop for BootstrapCommitResponder {
3046    fn drop(&mut self) {
3047        self.control_handle.shutdown();
3048        // Safety: drops once, never accessed again
3049        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3050    }
3051}
3052
3053impl fidl::endpoints::Responder for BootstrapCommitResponder {
3054    type ControlHandle = BootstrapControlHandle;
3055
3056    fn control_handle(&self) -> &BootstrapControlHandle {
3057        &self.control_handle
3058    }
3059
3060    fn drop_without_shutdown(mut self) {
3061        // Safety: drops once, never accessed again due to mem::forget
3062        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3063        // Prevent Drop from running (which would shut down the channel)
3064        std::mem::forget(self);
3065    }
3066}
3067
3068impl BootstrapCommitResponder {
3069    /// Sends a response to the FIDL transaction.
3070    ///
3071    /// Sets the channel to shutdown if an error occurs.
3072    pub fn send(self, mut result: Result<(), BootstrapError>) -> Result<(), fidl::Error> {
3073        let _result = self.send_raw(result);
3074        if _result.is_err() {
3075            self.control_handle.shutdown();
3076        }
3077        self.drop_without_shutdown();
3078        _result
3079    }
3080
3081    /// Similar to "send" but does not shutdown the channel if an error occurs.
3082    pub fn send_no_shutdown_on_err(
3083        self,
3084        mut result: Result<(), BootstrapError>,
3085    ) -> Result<(), fidl::Error> {
3086        let _result = self.send_raw(result);
3087        self.drop_without_shutdown();
3088        _result
3089    }
3090
3091    fn send_raw(&self, mut result: Result<(), BootstrapError>) -> Result<(), fidl::Error> {
3092        self.control_handle.inner.send::<fidl::encoding::ResultType<
3093            fidl::encoding::EmptyStruct,
3094            BootstrapError,
3095        >>(
3096            result,
3097            self.tx_id,
3098            0x5288006c9c7db6b7,
3099            fidl::encoding::DynamicFlags::empty(),
3100        )
3101    }
3102}
3103
3104#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3105pub struct ConfigurationMarker;
3106
3107impl fidl::endpoints::ProtocolMarker for ConfigurationMarker {
3108    type Proxy = ConfigurationProxy;
3109    type RequestStream = ConfigurationRequestStream;
3110    #[cfg(target_os = "fuchsia")]
3111    type SynchronousProxy = ConfigurationSynchronousProxy;
3112
3113    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.sys.Configuration";
3114}
3115impl fidl::endpoints::DiscoverableProtocolMarker for ConfigurationMarker {}
3116
3117pub trait ConfigurationProxyInterface: Send + Sync {
3118    type UpdateResponseFut: std::future::Future<Output = Result<Settings, fidl::Error>> + Send;
3119    fn r#update(&self, settings: &Settings) -> Self::UpdateResponseFut;
3120}
3121#[derive(Debug)]
3122#[cfg(target_os = "fuchsia")]
3123pub struct ConfigurationSynchronousProxy {
3124    client: fidl::client::sync::Client,
3125}
3126
3127#[cfg(target_os = "fuchsia")]
3128impl fidl::endpoints::SynchronousProxy for ConfigurationSynchronousProxy {
3129    type Proxy = ConfigurationProxy;
3130    type Protocol = ConfigurationMarker;
3131
3132    fn from_channel(inner: fidl::Channel) -> Self {
3133        Self::new(inner)
3134    }
3135
3136    fn into_channel(self) -> fidl::Channel {
3137        self.client.into_channel()
3138    }
3139
3140    fn as_channel(&self) -> &fidl::Channel {
3141        self.client.as_channel()
3142    }
3143}
3144
3145#[cfg(target_os = "fuchsia")]
3146impl ConfigurationSynchronousProxy {
3147    pub fn new(channel: fidl::Channel) -> Self {
3148        let protocol_name = <ConfigurationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3149        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3150    }
3151
3152    pub fn into_channel(self) -> fidl::Channel {
3153        self.client.into_channel()
3154    }
3155
3156    /// Waits until an event arrives and returns it. It is safe for other
3157    /// threads to make concurrent requests while waiting for an event.
3158    pub fn wait_for_event(
3159        &self,
3160        deadline: zx::MonotonicInstant,
3161    ) -> Result<ConfigurationEvent, fidl::Error> {
3162        ConfigurationEvent::decode(self.client.wait_for_event(deadline)?)
3163    }
3164
3165    /// Applies the fields present in `settings` to all bt-host drivers known to the system. Any
3166    /// fields not present in `settings` will remain unchanged.
3167    ///
3168    /// + request `settings` The new settings for active bt-host drivers - only modified settings
3169    ///   need be present.
3170    /// - response `result` A fully-populated table with the resultant settings after the new
3171    ///   settings are applied.
3172    pub fn r#update(
3173        &self,
3174        mut settings: &Settings,
3175        ___deadline: zx::MonotonicInstant,
3176    ) -> Result<Settings, fidl::Error> {
3177        let _response =
3178            self.client.send_query::<ConfigurationUpdateRequest, ConfigurationUpdateResponse>(
3179                (settings,),
3180                0x27e9cfb72e7c6d01,
3181                fidl::encoding::DynamicFlags::empty(),
3182                ___deadline,
3183            )?;
3184        Ok(_response.result)
3185    }
3186}
3187
3188#[cfg(target_os = "fuchsia")]
3189impl From<ConfigurationSynchronousProxy> for zx::Handle {
3190    fn from(value: ConfigurationSynchronousProxy) -> Self {
3191        value.into_channel().into()
3192    }
3193}
3194
3195#[cfg(target_os = "fuchsia")]
3196impl From<fidl::Channel> for ConfigurationSynchronousProxy {
3197    fn from(value: fidl::Channel) -> Self {
3198        Self::new(value)
3199    }
3200}
3201
3202#[derive(Debug, Clone)]
3203pub struct ConfigurationProxy {
3204    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3205}
3206
3207impl fidl::endpoints::Proxy for ConfigurationProxy {
3208    type Protocol = ConfigurationMarker;
3209
3210    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3211        Self::new(inner)
3212    }
3213
3214    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3215        self.client.into_channel().map_err(|client| Self { client })
3216    }
3217
3218    fn as_channel(&self) -> &::fidl::AsyncChannel {
3219        self.client.as_channel()
3220    }
3221}
3222
3223impl ConfigurationProxy {
3224    /// Create a new Proxy for fuchsia.bluetooth.sys/Configuration.
3225    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3226        let protocol_name = <ConfigurationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3227        Self { client: fidl::client::Client::new(channel, protocol_name) }
3228    }
3229
3230    /// Get a Stream of events from the remote end of the protocol.
3231    ///
3232    /// # Panics
3233    ///
3234    /// Panics if the event stream was already taken.
3235    pub fn take_event_stream(&self) -> ConfigurationEventStream {
3236        ConfigurationEventStream { event_receiver: self.client.take_event_receiver() }
3237    }
3238
3239    /// Applies the fields present in `settings` to all bt-host drivers known to the system. Any
3240    /// fields not present in `settings` will remain unchanged.
3241    ///
3242    /// + request `settings` The new settings for active bt-host drivers - only modified settings
3243    ///   need be present.
3244    /// - response `result` A fully-populated table with the resultant settings after the new
3245    ///   settings are applied.
3246    pub fn r#update(
3247        &self,
3248        mut settings: &Settings,
3249    ) -> fidl::client::QueryResponseFut<Settings, fidl::encoding::DefaultFuchsiaResourceDialect>
3250    {
3251        ConfigurationProxyInterface::r#update(self, settings)
3252    }
3253}
3254
3255impl ConfigurationProxyInterface for ConfigurationProxy {
3256    type UpdateResponseFut =
3257        fidl::client::QueryResponseFut<Settings, fidl::encoding::DefaultFuchsiaResourceDialect>;
3258    fn r#update(&self, mut settings: &Settings) -> Self::UpdateResponseFut {
3259        fn _decode(
3260            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3261        ) -> Result<Settings, fidl::Error> {
3262            let _response = fidl::client::decode_transaction_body::<
3263                ConfigurationUpdateResponse,
3264                fidl::encoding::DefaultFuchsiaResourceDialect,
3265                0x27e9cfb72e7c6d01,
3266            >(_buf?)?;
3267            Ok(_response.result)
3268        }
3269        self.client.send_query_and_decode::<ConfigurationUpdateRequest, Settings>(
3270            (settings,),
3271            0x27e9cfb72e7c6d01,
3272            fidl::encoding::DynamicFlags::empty(),
3273            _decode,
3274        )
3275    }
3276}
3277
3278pub struct ConfigurationEventStream {
3279    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3280}
3281
3282impl std::marker::Unpin for ConfigurationEventStream {}
3283
3284impl futures::stream::FusedStream for ConfigurationEventStream {
3285    fn is_terminated(&self) -> bool {
3286        self.event_receiver.is_terminated()
3287    }
3288}
3289
3290impl futures::Stream for ConfigurationEventStream {
3291    type Item = Result<ConfigurationEvent, fidl::Error>;
3292
3293    fn poll_next(
3294        mut self: std::pin::Pin<&mut Self>,
3295        cx: &mut std::task::Context<'_>,
3296    ) -> std::task::Poll<Option<Self::Item>> {
3297        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3298            &mut self.event_receiver,
3299            cx
3300        )?) {
3301            Some(buf) => std::task::Poll::Ready(Some(ConfigurationEvent::decode(buf))),
3302            None => std::task::Poll::Ready(None),
3303        }
3304    }
3305}
3306
3307#[derive(Debug)]
3308pub enum ConfigurationEvent {}
3309
3310impl ConfigurationEvent {
3311    /// Decodes a message buffer as a [`ConfigurationEvent`].
3312    fn decode(
3313        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3314    ) -> Result<ConfigurationEvent, fidl::Error> {
3315        let (bytes, _handles) = buf.split_mut();
3316        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3317        debug_assert_eq!(tx_header.tx_id, 0);
3318        match tx_header.ordinal {
3319            _ => Err(fidl::Error::UnknownOrdinal {
3320                ordinal: tx_header.ordinal,
3321                protocol_name: <ConfigurationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3322            }),
3323        }
3324    }
3325}
3326
3327/// A Stream of incoming requests for fuchsia.bluetooth.sys/Configuration.
3328pub struct ConfigurationRequestStream {
3329    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3330    is_terminated: bool,
3331}
3332
3333impl std::marker::Unpin for ConfigurationRequestStream {}
3334
3335impl futures::stream::FusedStream for ConfigurationRequestStream {
3336    fn is_terminated(&self) -> bool {
3337        self.is_terminated
3338    }
3339}
3340
3341impl fidl::endpoints::RequestStream for ConfigurationRequestStream {
3342    type Protocol = ConfigurationMarker;
3343    type ControlHandle = ConfigurationControlHandle;
3344
3345    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3346        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3347    }
3348
3349    fn control_handle(&self) -> Self::ControlHandle {
3350        ConfigurationControlHandle { inner: self.inner.clone() }
3351    }
3352
3353    fn into_inner(
3354        self,
3355    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3356    {
3357        (self.inner, self.is_terminated)
3358    }
3359
3360    fn from_inner(
3361        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3362        is_terminated: bool,
3363    ) -> Self {
3364        Self { inner, is_terminated }
3365    }
3366}
3367
3368impl futures::Stream for ConfigurationRequestStream {
3369    type Item = Result<ConfigurationRequest, fidl::Error>;
3370
3371    fn poll_next(
3372        mut self: std::pin::Pin<&mut Self>,
3373        cx: &mut std::task::Context<'_>,
3374    ) -> std::task::Poll<Option<Self::Item>> {
3375        let this = &mut *self;
3376        if this.inner.check_shutdown(cx) {
3377            this.is_terminated = true;
3378            return std::task::Poll::Ready(None);
3379        }
3380        if this.is_terminated {
3381            panic!("polled ConfigurationRequestStream after completion");
3382        }
3383        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3384            |bytes, handles| {
3385                match this.inner.channel().read_etc(cx, bytes, handles) {
3386                    std::task::Poll::Ready(Ok(())) => {}
3387                    std::task::Poll::Pending => return std::task::Poll::Pending,
3388                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3389                        this.is_terminated = true;
3390                        return std::task::Poll::Ready(None);
3391                    }
3392                    std::task::Poll::Ready(Err(e)) => {
3393                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3394                            e.into(),
3395                        ))))
3396                    }
3397                }
3398
3399                // A message has been received from the channel
3400                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3401
3402                std::task::Poll::Ready(Some(match header.ordinal {
3403                    0x27e9cfb72e7c6d01 => {
3404                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3405                        let mut req = fidl::new_empty!(
3406                            ConfigurationUpdateRequest,
3407                            fidl::encoding::DefaultFuchsiaResourceDialect
3408                        );
3409                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConfigurationUpdateRequest>(&header, _body_bytes, handles, &mut req)?;
3410                        let control_handle =
3411                            ConfigurationControlHandle { inner: this.inner.clone() };
3412                        Ok(ConfigurationRequest::Update {
3413                            settings: req.settings,
3414
3415                            responder: ConfigurationUpdateResponder {
3416                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3417                                tx_id: header.tx_id,
3418                            },
3419                        })
3420                    }
3421                    _ => Err(fidl::Error::UnknownOrdinal {
3422                        ordinal: header.ordinal,
3423                        protocol_name:
3424                            <ConfigurationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3425                    }),
3426                }))
3427            },
3428        )
3429    }
3430}
3431
3432/// Protocol to configure parameters and features for the core Bluetooth system. These settings
3433/// apply to all bt-host drivers known to the system.
3434///
3435/// This protocol should only be exposed to highly privileged components (e.g. Bluetooth developer
3436/// tools in a testing/qualification environment).
3437#[derive(Debug)]
3438pub enum ConfigurationRequest {
3439    /// Applies the fields present in `settings` to all bt-host drivers known to the system. Any
3440    /// fields not present in `settings` will remain unchanged.
3441    ///
3442    /// + request `settings` The new settings for active bt-host drivers - only modified settings
3443    ///   need be present.
3444    /// - response `result` A fully-populated table with the resultant settings after the new
3445    ///   settings are applied.
3446    Update { settings: Settings, responder: ConfigurationUpdateResponder },
3447}
3448
3449impl ConfigurationRequest {
3450    #[allow(irrefutable_let_patterns)]
3451    pub fn into_update(self) -> Option<(Settings, ConfigurationUpdateResponder)> {
3452        if let ConfigurationRequest::Update { settings, responder } = self {
3453            Some((settings, responder))
3454        } else {
3455            None
3456        }
3457    }
3458
3459    /// Name of the method defined in FIDL
3460    pub fn method_name(&self) -> &'static str {
3461        match *self {
3462            ConfigurationRequest::Update { .. } => "update",
3463        }
3464    }
3465}
3466
3467#[derive(Debug, Clone)]
3468pub struct ConfigurationControlHandle {
3469    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3470}
3471
3472impl fidl::endpoints::ControlHandle for ConfigurationControlHandle {
3473    fn shutdown(&self) {
3474        self.inner.shutdown()
3475    }
3476    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3477        self.inner.shutdown_with_epitaph(status)
3478    }
3479
3480    fn is_closed(&self) -> bool {
3481        self.inner.channel().is_closed()
3482    }
3483    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3484        self.inner.channel().on_closed()
3485    }
3486
3487    #[cfg(target_os = "fuchsia")]
3488    fn signal_peer(
3489        &self,
3490        clear_mask: zx::Signals,
3491        set_mask: zx::Signals,
3492    ) -> Result<(), zx_status::Status> {
3493        use fidl::Peered;
3494        self.inner.channel().signal_peer(clear_mask, set_mask)
3495    }
3496}
3497
3498impl ConfigurationControlHandle {}
3499
3500#[must_use = "FIDL methods require a response to be sent"]
3501#[derive(Debug)]
3502pub struct ConfigurationUpdateResponder {
3503    control_handle: std::mem::ManuallyDrop<ConfigurationControlHandle>,
3504    tx_id: u32,
3505}
3506
3507/// Set the the channel to be shutdown (see [`ConfigurationControlHandle::shutdown`])
3508/// if the responder is dropped without sending a response, so that the client
3509/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3510impl std::ops::Drop for ConfigurationUpdateResponder {
3511    fn drop(&mut self) {
3512        self.control_handle.shutdown();
3513        // Safety: drops once, never accessed again
3514        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3515    }
3516}
3517
3518impl fidl::endpoints::Responder for ConfigurationUpdateResponder {
3519    type ControlHandle = ConfigurationControlHandle;
3520
3521    fn control_handle(&self) -> &ConfigurationControlHandle {
3522        &self.control_handle
3523    }
3524
3525    fn drop_without_shutdown(mut self) {
3526        // Safety: drops once, never accessed again due to mem::forget
3527        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3528        // Prevent Drop from running (which would shut down the channel)
3529        std::mem::forget(self);
3530    }
3531}
3532
3533impl ConfigurationUpdateResponder {
3534    /// Sends a response to the FIDL transaction.
3535    ///
3536    /// Sets the channel to shutdown if an error occurs.
3537    pub fn send(self, mut result: &Settings) -> Result<(), fidl::Error> {
3538        let _result = self.send_raw(result);
3539        if _result.is_err() {
3540            self.control_handle.shutdown();
3541        }
3542        self.drop_without_shutdown();
3543        _result
3544    }
3545
3546    /// Similar to "send" but does not shutdown the channel if an error occurs.
3547    pub fn send_no_shutdown_on_err(self, mut result: &Settings) -> Result<(), fidl::Error> {
3548        let _result = self.send_raw(result);
3549        self.drop_without_shutdown();
3550        _result
3551    }
3552
3553    fn send_raw(&self, mut result: &Settings) -> Result<(), fidl::Error> {
3554        self.control_handle.inner.send::<ConfigurationUpdateResponse>(
3555            (result,),
3556            self.tx_id,
3557            0x27e9cfb72e7c6d01,
3558            fidl::encoding::DynamicFlags::empty(),
3559        )
3560    }
3561}
3562
3563#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3564pub struct HostWatcherMarker;
3565
3566impl fidl::endpoints::ProtocolMarker for HostWatcherMarker {
3567    type Proxy = HostWatcherProxy;
3568    type RequestStream = HostWatcherRequestStream;
3569    #[cfg(target_os = "fuchsia")]
3570    type SynchronousProxy = HostWatcherSynchronousProxy;
3571
3572    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.sys.HostWatcher";
3573}
3574impl fidl::endpoints::DiscoverableProtocolMarker for HostWatcherMarker {}
3575pub type HostWatcherSetActiveResult = Result<(), i32>;
3576
3577pub trait HostWatcherProxyInterface: Send + Sync {
3578    type WatchResponseFut: std::future::Future<Output = Result<Vec<HostInfo>, fidl::Error>> + Send;
3579    fn r#watch(&self) -> Self::WatchResponseFut;
3580    type SetActiveResponseFut: std::future::Future<Output = Result<HostWatcherSetActiveResult, fidl::Error>>
3581        + Send;
3582    fn r#set_active(&self, id: &fidl_fuchsia_bluetooth::HostId) -> Self::SetActiveResponseFut;
3583}
3584#[derive(Debug)]
3585#[cfg(target_os = "fuchsia")]
3586pub struct HostWatcherSynchronousProxy {
3587    client: fidl::client::sync::Client,
3588}
3589
3590#[cfg(target_os = "fuchsia")]
3591impl fidl::endpoints::SynchronousProxy for HostWatcherSynchronousProxy {
3592    type Proxy = HostWatcherProxy;
3593    type Protocol = HostWatcherMarker;
3594
3595    fn from_channel(inner: fidl::Channel) -> Self {
3596        Self::new(inner)
3597    }
3598
3599    fn into_channel(self) -> fidl::Channel {
3600        self.client.into_channel()
3601    }
3602
3603    fn as_channel(&self) -> &fidl::Channel {
3604        self.client.as_channel()
3605    }
3606}
3607
3608#[cfg(target_os = "fuchsia")]
3609impl HostWatcherSynchronousProxy {
3610    pub fn new(channel: fidl::Channel) -> Self {
3611        let protocol_name = <HostWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3612        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3613    }
3614
3615    pub fn into_channel(self) -> fidl::Channel {
3616        self.client.into_channel()
3617    }
3618
3619    /// Waits until an event arrives and returns it. It is safe for other
3620    /// threads to make concurrent requests while waiting for an event.
3621    pub fn wait_for_event(
3622        &self,
3623        deadline: zx::MonotonicInstant,
3624    ) -> Result<HostWatcherEvent, fidl::Error> {
3625        HostWatcherEvent::decode(self.client.wait_for_event(deadline)?)
3626    }
3627
3628    /// Obtain a list of all available Bluetooth controllers and their state. A response is sent
3629    /// only if this list has changed since the last time the client has sent this message.
3630    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<HostInfo>, fidl::Error> {
3631        let _response =
3632            self.client.send_query::<fidl::encoding::EmptyPayload, HostWatcherWatchResponse>(
3633                (),
3634                0x4e2c2972a5b16f9c,
3635                fidl::encoding::DynamicFlags::empty(),
3636                ___deadline,
3637            )?;
3638        Ok(_response.hosts)
3639    }
3640
3641    /// Designates the host with the given `id` as active. All Bluetooth procedures will be routed
3642    /// over this host. Any previously assigned active host will be disabled and all of its pending
3643    /// procedures will be terminated.
3644    ///
3645    /// * error This can fail if a host with `id` was not found.
3646    pub fn r#set_active(
3647        &self,
3648        mut id: &fidl_fuchsia_bluetooth::HostId,
3649        ___deadline: zx::MonotonicInstant,
3650    ) -> Result<HostWatcherSetActiveResult, fidl::Error> {
3651        let _response = self.client.send_query::<
3652            HostWatcherSetActiveRequest,
3653            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3654        >(
3655            (id,),
3656            0x83f311ecaf0ddf3,
3657            fidl::encoding::DynamicFlags::empty(),
3658            ___deadline,
3659        )?;
3660        Ok(_response.map(|x| x))
3661    }
3662}
3663
3664#[cfg(target_os = "fuchsia")]
3665impl From<HostWatcherSynchronousProxy> for zx::Handle {
3666    fn from(value: HostWatcherSynchronousProxy) -> Self {
3667        value.into_channel().into()
3668    }
3669}
3670
3671#[cfg(target_os = "fuchsia")]
3672impl From<fidl::Channel> for HostWatcherSynchronousProxy {
3673    fn from(value: fidl::Channel) -> Self {
3674        Self::new(value)
3675    }
3676}
3677
3678#[derive(Debug, Clone)]
3679pub struct HostWatcherProxy {
3680    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3681}
3682
3683impl fidl::endpoints::Proxy for HostWatcherProxy {
3684    type Protocol = HostWatcherMarker;
3685
3686    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3687        Self::new(inner)
3688    }
3689
3690    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3691        self.client.into_channel().map_err(|client| Self { client })
3692    }
3693
3694    fn as_channel(&self) -> &::fidl::AsyncChannel {
3695        self.client.as_channel()
3696    }
3697}
3698
3699impl HostWatcherProxy {
3700    /// Create a new Proxy for fuchsia.bluetooth.sys/HostWatcher.
3701    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3702        let protocol_name = <HostWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3703        Self { client: fidl::client::Client::new(channel, protocol_name) }
3704    }
3705
3706    /// Get a Stream of events from the remote end of the protocol.
3707    ///
3708    /// # Panics
3709    ///
3710    /// Panics if the event stream was already taken.
3711    pub fn take_event_stream(&self) -> HostWatcherEventStream {
3712        HostWatcherEventStream { event_receiver: self.client.take_event_receiver() }
3713    }
3714
3715    /// Obtain a list of all available Bluetooth controllers and their state. A response is sent
3716    /// only if this list has changed since the last time the client has sent this message.
3717    pub fn r#watch(
3718        &self,
3719    ) -> fidl::client::QueryResponseFut<Vec<HostInfo>, fidl::encoding::DefaultFuchsiaResourceDialect>
3720    {
3721        HostWatcherProxyInterface::r#watch(self)
3722    }
3723
3724    /// Designates the host with the given `id` as active. All Bluetooth procedures will be routed
3725    /// over this host. Any previously assigned active host will be disabled and all of its pending
3726    /// procedures will be terminated.
3727    ///
3728    /// * error This can fail if a host with `id` was not found.
3729    pub fn r#set_active(
3730        &self,
3731        mut id: &fidl_fuchsia_bluetooth::HostId,
3732    ) -> fidl::client::QueryResponseFut<
3733        HostWatcherSetActiveResult,
3734        fidl::encoding::DefaultFuchsiaResourceDialect,
3735    > {
3736        HostWatcherProxyInterface::r#set_active(self, id)
3737    }
3738}
3739
3740impl HostWatcherProxyInterface for HostWatcherProxy {
3741    type WatchResponseFut = fidl::client::QueryResponseFut<
3742        Vec<HostInfo>,
3743        fidl::encoding::DefaultFuchsiaResourceDialect,
3744    >;
3745    fn r#watch(&self) -> Self::WatchResponseFut {
3746        fn _decode(
3747            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3748        ) -> Result<Vec<HostInfo>, fidl::Error> {
3749            let _response = fidl::client::decode_transaction_body::<
3750                HostWatcherWatchResponse,
3751                fidl::encoding::DefaultFuchsiaResourceDialect,
3752                0x4e2c2972a5b16f9c,
3753            >(_buf?)?;
3754            Ok(_response.hosts)
3755        }
3756        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<HostInfo>>(
3757            (),
3758            0x4e2c2972a5b16f9c,
3759            fidl::encoding::DynamicFlags::empty(),
3760            _decode,
3761        )
3762    }
3763
3764    type SetActiveResponseFut = fidl::client::QueryResponseFut<
3765        HostWatcherSetActiveResult,
3766        fidl::encoding::DefaultFuchsiaResourceDialect,
3767    >;
3768    fn r#set_active(&self, mut id: &fidl_fuchsia_bluetooth::HostId) -> Self::SetActiveResponseFut {
3769        fn _decode(
3770            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3771        ) -> Result<HostWatcherSetActiveResult, fidl::Error> {
3772            let _response = fidl::client::decode_transaction_body::<
3773                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3774                fidl::encoding::DefaultFuchsiaResourceDialect,
3775                0x83f311ecaf0ddf3,
3776            >(_buf?)?;
3777            Ok(_response.map(|x| x))
3778        }
3779        self.client
3780            .send_query_and_decode::<HostWatcherSetActiveRequest, HostWatcherSetActiveResult>(
3781                (id,),
3782                0x83f311ecaf0ddf3,
3783                fidl::encoding::DynamicFlags::empty(),
3784                _decode,
3785            )
3786    }
3787}
3788
3789pub struct HostWatcherEventStream {
3790    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3791}
3792
3793impl std::marker::Unpin for HostWatcherEventStream {}
3794
3795impl futures::stream::FusedStream for HostWatcherEventStream {
3796    fn is_terminated(&self) -> bool {
3797        self.event_receiver.is_terminated()
3798    }
3799}
3800
3801impl futures::Stream for HostWatcherEventStream {
3802    type Item = Result<HostWatcherEvent, fidl::Error>;
3803
3804    fn poll_next(
3805        mut self: std::pin::Pin<&mut Self>,
3806        cx: &mut std::task::Context<'_>,
3807    ) -> std::task::Poll<Option<Self::Item>> {
3808        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3809            &mut self.event_receiver,
3810            cx
3811        )?) {
3812            Some(buf) => std::task::Poll::Ready(Some(HostWatcherEvent::decode(buf))),
3813            None => std::task::Poll::Ready(None),
3814        }
3815    }
3816}
3817
3818#[derive(Debug)]
3819pub enum HostWatcherEvent {}
3820
3821impl HostWatcherEvent {
3822    /// Decodes a message buffer as a [`HostWatcherEvent`].
3823    fn decode(
3824        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3825    ) -> Result<HostWatcherEvent, fidl::Error> {
3826        let (bytes, _handles) = buf.split_mut();
3827        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3828        debug_assert_eq!(tx_header.tx_id, 0);
3829        match tx_header.ordinal {
3830            _ => Err(fidl::Error::UnknownOrdinal {
3831                ordinal: tx_header.ordinal,
3832                protocol_name: <HostWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3833            }),
3834        }
3835    }
3836}
3837
3838/// A Stream of incoming requests for fuchsia.bluetooth.sys/HostWatcher.
3839pub struct HostWatcherRequestStream {
3840    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3841    is_terminated: bool,
3842}
3843
3844impl std::marker::Unpin for HostWatcherRequestStream {}
3845
3846impl futures::stream::FusedStream for HostWatcherRequestStream {
3847    fn is_terminated(&self) -> bool {
3848        self.is_terminated
3849    }
3850}
3851
3852impl fidl::endpoints::RequestStream for HostWatcherRequestStream {
3853    type Protocol = HostWatcherMarker;
3854    type ControlHandle = HostWatcherControlHandle;
3855
3856    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3857        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3858    }
3859
3860    fn control_handle(&self) -> Self::ControlHandle {
3861        HostWatcherControlHandle { inner: self.inner.clone() }
3862    }
3863
3864    fn into_inner(
3865        self,
3866    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3867    {
3868        (self.inner, self.is_terminated)
3869    }
3870
3871    fn from_inner(
3872        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3873        is_terminated: bool,
3874    ) -> Self {
3875        Self { inner, is_terminated }
3876    }
3877}
3878
3879impl futures::Stream for HostWatcherRequestStream {
3880    type Item = Result<HostWatcherRequest, fidl::Error>;
3881
3882    fn poll_next(
3883        mut self: std::pin::Pin<&mut Self>,
3884        cx: &mut std::task::Context<'_>,
3885    ) -> std::task::Poll<Option<Self::Item>> {
3886        let this = &mut *self;
3887        if this.inner.check_shutdown(cx) {
3888            this.is_terminated = true;
3889            return std::task::Poll::Ready(None);
3890        }
3891        if this.is_terminated {
3892            panic!("polled HostWatcherRequestStream after completion");
3893        }
3894        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3895            |bytes, handles| {
3896                match this.inner.channel().read_etc(cx, bytes, handles) {
3897                    std::task::Poll::Ready(Ok(())) => {}
3898                    std::task::Poll::Pending => return std::task::Poll::Pending,
3899                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3900                        this.is_terminated = true;
3901                        return std::task::Poll::Ready(None);
3902                    }
3903                    std::task::Poll::Ready(Err(e)) => {
3904                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3905                            e.into(),
3906                        ))))
3907                    }
3908                }
3909
3910                // A message has been received from the channel
3911                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3912
3913                std::task::Poll::Ready(Some(match header.ordinal {
3914                    0x4e2c2972a5b16f9c => {
3915                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3916                        let mut req = fidl::new_empty!(
3917                            fidl::encoding::EmptyPayload,
3918                            fidl::encoding::DefaultFuchsiaResourceDialect
3919                        );
3920                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3921                        let control_handle = HostWatcherControlHandle { inner: this.inner.clone() };
3922                        Ok(HostWatcherRequest::Watch {
3923                            responder: HostWatcherWatchResponder {
3924                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3925                                tx_id: header.tx_id,
3926                            },
3927                        })
3928                    }
3929                    0x83f311ecaf0ddf3 => {
3930                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3931                        let mut req = fidl::new_empty!(
3932                            HostWatcherSetActiveRequest,
3933                            fidl::encoding::DefaultFuchsiaResourceDialect
3934                        );
3935                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HostWatcherSetActiveRequest>(&header, _body_bytes, handles, &mut req)?;
3936                        let control_handle = HostWatcherControlHandle { inner: this.inner.clone() };
3937                        Ok(HostWatcherRequest::SetActive {
3938                            id: req.id,
3939
3940                            responder: HostWatcherSetActiveResponder {
3941                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3942                                tx_id: header.tx_id,
3943                            },
3944                        })
3945                    }
3946                    _ => Err(fidl::Error::UnknownOrdinal {
3947                        ordinal: header.ordinal,
3948                        protocol_name:
3949                            <HostWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3950                    }),
3951                }))
3952            },
3953        )
3954    }
3955}
3956
3957/// Protocol used to observe and manage the Bluetooth controllers on the system.
3958#[derive(Debug)]
3959pub enum HostWatcherRequest {
3960    /// Obtain a list of all available Bluetooth controllers and their state. A response is sent
3961    /// only if this list has changed since the last time the client has sent this message.
3962    Watch { responder: HostWatcherWatchResponder },
3963    /// Designates the host with the given `id` as active. All Bluetooth procedures will be routed
3964    /// over this host. Any previously assigned active host will be disabled and all of its pending
3965    /// procedures will be terminated.
3966    ///
3967    /// * error This can fail if a host with `id` was not found.
3968    SetActive { id: fidl_fuchsia_bluetooth::HostId, responder: HostWatcherSetActiveResponder },
3969}
3970
3971impl HostWatcherRequest {
3972    #[allow(irrefutable_let_patterns)]
3973    pub fn into_watch(self) -> Option<(HostWatcherWatchResponder)> {
3974        if let HostWatcherRequest::Watch { responder } = self {
3975            Some((responder))
3976        } else {
3977            None
3978        }
3979    }
3980
3981    #[allow(irrefutable_let_patterns)]
3982    pub fn into_set_active(
3983        self,
3984    ) -> Option<(fidl_fuchsia_bluetooth::HostId, HostWatcherSetActiveResponder)> {
3985        if let HostWatcherRequest::SetActive { id, responder } = self {
3986            Some((id, responder))
3987        } else {
3988            None
3989        }
3990    }
3991
3992    /// Name of the method defined in FIDL
3993    pub fn method_name(&self) -> &'static str {
3994        match *self {
3995            HostWatcherRequest::Watch { .. } => "watch",
3996            HostWatcherRequest::SetActive { .. } => "set_active",
3997        }
3998    }
3999}
4000
4001#[derive(Debug, Clone)]
4002pub struct HostWatcherControlHandle {
4003    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4004}
4005
4006impl fidl::endpoints::ControlHandle for HostWatcherControlHandle {
4007    fn shutdown(&self) {
4008        self.inner.shutdown()
4009    }
4010    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4011        self.inner.shutdown_with_epitaph(status)
4012    }
4013
4014    fn is_closed(&self) -> bool {
4015        self.inner.channel().is_closed()
4016    }
4017    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4018        self.inner.channel().on_closed()
4019    }
4020
4021    #[cfg(target_os = "fuchsia")]
4022    fn signal_peer(
4023        &self,
4024        clear_mask: zx::Signals,
4025        set_mask: zx::Signals,
4026    ) -> Result<(), zx_status::Status> {
4027        use fidl::Peered;
4028        self.inner.channel().signal_peer(clear_mask, set_mask)
4029    }
4030}
4031
4032impl HostWatcherControlHandle {}
4033
4034#[must_use = "FIDL methods require a response to be sent"]
4035#[derive(Debug)]
4036pub struct HostWatcherWatchResponder {
4037    control_handle: std::mem::ManuallyDrop<HostWatcherControlHandle>,
4038    tx_id: u32,
4039}
4040
4041/// Set the the channel to be shutdown (see [`HostWatcherControlHandle::shutdown`])
4042/// if the responder is dropped without sending a response, so that the client
4043/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4044impl std::ops::Drop for HostWatcherWatchResponder {
4045    fn drop(&mut self) {
4046        self.control_handle.shutdown();
4047        // Safety: drops once, never accessed again
4048        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4049    }
4050}
4051
4052impl fidl::endpoints::Responder for HostWatcherWatchResponder {
4053    type ControlHandle = HostWatcherControlHandle;
4054
4055    fn control_handle(&self) -> &HostWatcherControlHandle {
4056        &self.control_handle
4057    }
4058
4059    fn drop_without_shutdown(mut self) {
4060        // Safety: drops once, never accessed again due to mem::forget
4061        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4062        // Prevent Drop from running (which would shut down the channel)
4063        std::mem::forget(self);
4064    }
4065}
4066
4067impl HostWatcherWatchResponder {
4068    /// Sends a response to the FIDL transaction.
4069    ///
4070    /// Sets the channel to shutdown if an error occurs.
4071    pub fn send(self, mut hosts: &[HostInfo]) -> Result<(), fidl::Error> {
4072        let _result = self.send_raw(hosts);
4073        if _result.is_err() {
4074            self.control_handle.shutdown();
4075        }
4076        self.drop_without_shutdown();
4077        _result
4078    }
4079
4080    /// Similar to "send" but does not shutdown the channel if an error occurs.
4081    pub fn send_no_shutdown_on_err(self, mut hosts: &[HostInfo]) -> Result<(), fidl::Error> {
4082        let _result = self.send_raw(hosts);
4083        self.drop_without_shutdown();
4084        _result
4085    }
4086
4087    fn send_raw(&self, mut hosts: &[HostInfo]) -> Result<(), fidl::Error> {
4088        self.control_handle.inner.send::<HostWatcherWatchResponse>(
4089            (hosts,),
4090            self.tx_id,
4091            0x4e2c2972a5b16f9c,
4092            fidl::encoding::DynamicFlags::empty(),
4093        )
4094    }
4095}
4096
4097#[must_use = "FIDL methods require a response to be sent"]
4098#[derive(Debug)]
4099pub struct HostWatcherSetActiveResponder {
4100    control_handle: std::mem::ManuallyDrop<HostWatcherControlHandle>,
4101    tx_id: u32,
4102}
4103
4104/// Set the the channel to be shutdown (see [`HostWatcherControlHandle::shutdown`])
4105/// if the responder is dropped without sending a response, so that the client
4106/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4107impl std::ops::Drop for HostWatcherSetActiveResponder {
4108    fn drop(&mut self) {
4109        self.control_handle.shutdown();
4110        // Safety: drops once, never accessed again
4111        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4112    }
4113}
4114
4115impl fidl::endpoints::Responder for HostWatcherSetActiveResponder {
4116    type ControlHandle = HostWatcherControlHandle;
4117
4118    fn control_handle(&self) -> &HostWatcherControlHandle {
4119        &self.control_handle
4120    }
4121
4122    fn drop_without_shutdown(mut self) {
4123        // Safety: drops once, never accessed again due to mem::forget
4124        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4125        // Prevent Drop from running (which would shut down the channel)
4126        std::mem::forget(self);
4127    }
4128}
4129
4130impl HostWatcherSetActiveResponder {
4131    /// Sends a response to the FIDL transaction.
4132    ///
4133    /// Sets the channel to shutdown if an error occurs.
4134    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4135        let _result = self.send_raw(result);
4136        if _result.is_err() {
4137            self.control_handle.shutdown();
4138        }
4139        self.drop_without_shutdown();
4140        _result
4141    }
4142
4143    /// Similar to "send" but does not shutdown the channel if an error occurs.
4144    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4145        let _result = self.send_raw(result);
4146        self.drop_without_shutdown();
4147        _result
4148    }
4149
4150    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4151        self.control_handle
4152            .inner
4153            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4154                result,
4155                self.tx_id,
4156                0x83f311ecaf0ddf3,
4157                fidl::encoding::DynamicFlags::empty(),
4158            )
4159    }
4160}
4161
4162#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4163pub struct PairingMarker;
4164
4165impl fidl::endpoints::ProtocolMarker for PairingMarker {
4166    type Proxy = PairingProxy;
4167    type RequestStream = PairingRequestStream;
4168    #[cfg(target_os = "fuchsia")]
4169    type SynchronousProxy = PairingSynchronousProxy;
4170
4171    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.sys.Pairing";
4172}
4173impl fidl::endpoints::DiscoverableProtocolMarker for PairingMarker {}
4174
4175pub trait PairingProxyInterface: Send + Sync {
4176    fn r#set_pairing_delegate(
4177        &self,
4178        input: InputCapability,
4179        output: OutputCapability,
4180        delegate: fidl::endpoints::ClientEnd<PairingDelegateMarker>,
4181    ) -> Result<(), fidl::Error>;
4182    fn r#set_delegate(
4183        &self,
4184        input: InputCapability,
4185        output: OutputCapability,
4186        delegate: fidl::endpoints::ClientEnd<PairingDelegate2Marker>,
4187    ) -> Result<(), fidl::Error>;
4188}
4189#[derive(Debug)]
4190#[cfg(target_os = "fuchsia")]
4191pub struct PairingSynchronousProxy {
4192    client: fidl::client::sync::Client,
4193}
4194
4195#[cfg(target_os = "fuchsia")]
4196impl fidl::endpoints::SynchronousProxy for PairingSynchronousProxy {
4197    type Proxy = PairingProxy;
4198    type Protocol = PairingMarker;
4199
4200    fn from_channel(inner: fidl::Channel) -> Self {
4201        Self::new(inner)
4202    }
4203
4204    fn into_channel(self) -> fidl::Channel {
4205        self.client.into_channel()
4206    }
4207
4208    fn as_channel(&self) -> &fidl::Channel {
4209        self.client.as_channel()
4210    }
4211}
4212
4213#[cfg(target_os = "fuchsia")]
4214impl PairingSynchronousProxy {
4215    pub fn new(channel: fidl::Channel) -> Self {
4216        let protocol_name = <PairingMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4217        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4218    }
4219
4220    pub fn into_channel(self) -> fidl::Channel {
4221        self.client.into_channel()
4222    }
4223
4224    /// Waits until an event arrives and returns it. It is safe for other
4225    /// threads to make concurrent requests while waiting for an event.
4226    pub fn wait_for_event(
4227        &self,
4228        deadline: zx::MonotonicInstant,
4229    ) -> Result<PairingEvent, fidl::Error> {
4230        PairingEvent::decode(self.client.wait_for_event(deadline)?)
4231    }
4232
4233    /// Assign a PairingDelegate to respond to pairing procedures. The provided I/O capabilities
4234    /// will be used to determine the pairing methods used.
4235    ///
4236    /// Only one PairingDelegate can be set at a time system-wide - if this is called
4237    /// while another delegate is set, the new delegate will be closed immediately.
4238    /// Closing a PairingDelegate after it is set aborts all ongoing pairing procedures
4239    /// without accepting and unsets the delegate.
4240    ///
4241    /// If no PairingDelegate is set, all pairings will be rejected even if the
4242    /// peer connection was initiated by the local device.
4243    ///
4244    /// + request `input` Bluetooth input capability, see `InputCapability`
4245    /// + request `output` Bluetooth output capability, see `OutputCapability`
4246    /// + request `delegate` PairingDelegate which will receive pairing requests
4247    pub fn r#set_pairing_delegate(
4248        &self,
4249        mut input: InputCapability,
4250        mut output: OutputCapability,
4251        mut delegate: fidl::endpoints::ClientEnd<PairingDelegateMarker>,
4252    ) -> Result<(), fidl::Error> {
4253        self.client.send::<PairingSetPairingDelegateRequest>(
4254            (input, output, delegate),
4255            0x19721a12cb80212c,
4256            fidl::encoding::DynamicFlags::empty(),
4257        )
4258    }
4259
4260    /// Assign a PairingDelegate2 to handle pairing procedures.  The provided
4261    /// I/O capabilities will be used to determine the methods used.
4262    ///
4263    /// Only one of PairingDelegate or PairingDelegate2 can be set at a time
4264    /// system-wide.  If this is called while another delegate is set, the new
4265    /// delegate will be closed immediately.
4266    ///
4267    /// Closing a PairingDelegate2 unsets the pairing delegate. Ongoing
4268    /// PairingRequests can still be completed, but new requests will act as if
4269    /// no delegate is set.
4270    ///
4271    /// If no delegate is set, all pairings will be rejected even if the
4272    /// peer connection was initiated by the local device.
4273    ///
4274    /// + request `input` Bluetooth input capability, see `InputCapability`
4275    /// + request `output` Bluetooth output capability, see `OutputCapability`
4276    /// + request `delegate` PairingDelegate2 which will receive pairing requests
4277    pub fn r#set_delegate(
4278        &self,
4279        mut input: InputCapability,
4280        mut output: OutputCapability,
4281        mut delegate: fidl::endpoints::ClientEnd<PairingDelegate2Marker>,
4282    ) -> Result<(), fidl::Error> {
4283        self.client.send::<PairingSetDelegateRequest>(
4284            (input, output, delegate),
4285            0x1da0568d2582a9a5,
4286            fidl::encoding::DynamicFlags::empty(),
4287        )
4288    }
4289}
4290
4291#[cfg(target_os = "fuchsia")]
4292impl From<PairingSynchronousProxy> for zx::Handle {
4293    fn from(value: PairingSynchronousProxy) -> Self {
4294        value.into_channel().into()
4295    }
4296}
4297
4298#[cfg(target_os = "fuchsia")]
4299impl From<fidl::Channel> for PairingSynchronousProxy {
4300    fn from(value: fidl::Channel) -> Self {
4301        Self::new(value)
4302    }
4303}
4304
4305#[derive(Debug, Clone)]
4306pub struct PairingProxy {
4307    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4308}
4309
4310impl fidl::endpoints::Proxy for PairingProxy {
4311    type Protocol = PairingMarker;
4312
4313    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4314        Self::new(inner)
4315    }
4316
4317    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4318        self.client.into_channel().map_err(|client| Self { client })
4319    }
4320
4321    fn as_channel(&self) -> &::fidl::AsyncChannel {
4322        self.client.as_channel()
4323    }
4324}
4325
4326impl PairingProxy {
4327    /// Create a new Proxy for fuchsia.bluetooth.sys/Pairing.
4328    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4329        let protocol_name = <PairingMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4330        Self { client: fidl::client::Client::new(channel, protocol_name) }
4331    }
4332
4333    /// Get a Stream of events from the remote end of the protocol.
4334    ///
4335    /// # Panics
4336    ///
4337    /// Panics if the event stream was already taken.
4338    pub fn take_event_stream(&self) -> PairingEventStream {
4339        PairingEventStream { event_receiver: self.client.take_event_receiver() }
4340    }
4341
4342    /// Assign a PairingDelegate to respond to pairing procedures. The provided I/O capabilities
4343    /// will be used to determine the pairing methods used.
4344    ///
4345    /// Only one PairingDelegate can be set at a time system-wide - if this is called
4346    /// while another delegate is set, the new delegate will be closed immediately.
4347    /// Closing a PairingDelegate after it is set aborts all ongoing pairing procedures
4348    /// without accepting and unsets the delegate.
4349    ///
4350    /// If no PairingDelegate is set, all pairings will be rejected even if the
4351    /// peer connection was initiated by the local device.
4352    ///
4353    /// + request `input` Bluetooth input capability, see `InputCapability`
4354    /// + request `output` Bluetooth output capability, see `OutputCapability`
4355    /// + request `delegate` PairingDelegate which will receive pairing requests
4356    pub fn r#set_pairing_delegate(
4357        &self,
4358        mut input: InputCapability,
4359        mut output: OutputCapability,
4360        mut delegate: fidl::endpoints::ClientEnd<PairingDelegateMarker>,
4361    ) -> Result<(), fidl::Error> {
4362        PairingProxyInterface::r#set_pairing_delegate(self, input, output, delegate)
4363    }
4364
4365    /// Assign a PairingDelegate2 to handle pairing procedures.  The provided
4366    /// I/O capabilities will be used to determine the methods used.
4367    ///
4368    /// Only one of PairingDelegate or PairingDelegate2 can be set at a time
4369    /// system-wide.  If this is called while another delegate is set, the new
4370    /// delegate will be closed immediately.
4371    ///
4372    /// Closing a PairingDelegate2 unsets the pairing delegate. Ongoing
4373    /// PairingRequests can still be completed, but new requests will act as if
4374    /// no delegate is set.
4375    ///
4376    /// If no delegate is set, all pairings will be rejected even if the
4377    /// peer connection was initiated by the local device.
4378    ///
4379    /// + request `input` Bluetooth input capability, see `InputCapability`
4380    /// + request `output` Bluetooth output capability, see `OutputCapability`
4381    /// + request `delegate` PairingDelegate2 which will receive pairing requests
4382    pub fn r#set_delegate(
4383        &self,
4384        mut input: InputCapability,
4385        mut output: OutputCapability,
4386        mut delegate: fidl::endpoints::ClientEnd<PairingDelegate2Marker>,
4387    ) -> Result<(), fidl::Error> {
4388        PairingProxyInterface::r#set_delegate(self, input, output, delegate)
4389    }
4390}
4391
4392impl PairingProxyInterface for PairingProxy {
4393    fn r#set_pairing_delegate(
4394        &self,
4395        mut input: InputCapability,
4396        mut output: OutputCapability,
4397        mut delegate: fidl::endpoints::ClientEnd<PairingDelegateMarker>,
4398    ) -> Result<(), fidl::Error> {
4399        self.client.send::<PairingSetPairingDelegateRequest>(
4400            (input, output, delegate),
4401            0x19721a12cb80212c,
4402            fidl::encoding::DynamicFlags::empty(),
4403        )
4404    }
4405
4406    fn r#set_delegate(
4407        &self,
4408        mut input: InputCapability,
4409        mut output: OutputCapability,
4410        mut delegate: fidl::endpoints::ClientEnd<PairingDelegate2Marker>,
4411    ) -> Result<(), fidl::Error> {
4412        self.client.send::<PairingSetDelegateRequest>(
4413            (input, output, delegate),
4414            0x1da0568d2582a9a5,
4415            fidl::encoding::DynamicFlags::empty(),
4416        )
4417    }
4418}
4419
4420pub struct PairingEventStream {
4421    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4422}
4423
4424impl std::marker::Unpin for PairingEventStream {}
4425
4426impl futures::stream::FusedStream for PairingEventStream {
4427    fn is_terminated(&self) -> bool {
4428        self.event_receiver.is_terminated()
4429    }
4430}
4431
4432impl futures::Stream for PairingEventStream {
4433    type Item = Result<PairingEvent, fidl::Error>;
4434
4435    fn poll_next(
4436        mut self: std::pin::Pin<&mut Self>,
4437        cx: &mut std::task::Context<'_>,
4438    ) -> std::task::Poll<Option<Self::Item>> {
4439        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4440            &mut self.event_receiver,
4441            cx
4442        )?) {
4443            Some(buf) => std::task::Poll::Ready(Some(PairingEvent::decode(buf))),
4444            None => std::task::Poll::Ready(None),
4445        }
4446    }
4447}
4448
4449#[derive(Debug)]
4450pub enum PairingEvent {}
4451
4452impl PairingEvent {
4453    /// Decodes a message buffer as a [`PairingEvent`].
4454    fn decode(
4455        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4456    ) -> Result<PairingEvent, fidl::Error> {
4457        let (bytes, _handles) = buf.split_mut();
4458        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4459        debug_assert_eq!(tx_header.tx_id, 0);
4460        match tx_header.ordinal {
4461            _ => Err(fidl::Error::UnknownOrdinal {
4462                ordinal: tx_header.ordinal,
4463                protocol_name: <PairingMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4464            }),
4465        }
4466    }
4467}
4468
4469/// A Stream of incoming requests for fuchsia.bluetooth.sys/Pairing.
4470pub struct PairingRequestStream {
4471    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4472    is_terminated: bool,
4473}
4474
4475impl std::marker::Unpin for PairingRequestStream {}
4476
4477impl futures::stream::FusedStream for PairingRequestStream {
4478    fn is_terminated(&self) -> bool {
4479        self.is_terminated
4480    }
4481}
4482
4483impl fidl::endpoints::RequestStream for PairingRequestStream {
4484    type Protocol = PairingMarker;
4485    type ControlHandle = PairingControlHandle;
4486
4487    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4488        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4489    }
4490
4491    fn control_handle(&self) -> Self::ControlHandle {
4492        PairingControlHandle { inner: self.inner.clone() }
4493    }
4494
4495    fn into_inner(
4496        self,
4497    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4498    {
4499        (self.inner, self.is_terminated)
4500    }
4501
4502    fn from_inner(
4503        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4504        is_terminated: bool,
4505    ) -> Self {
4506        Self { inner, is_terminated }
4507    }
4508}
4509
4510impl futures::Stream for PairingRequestStream {
4511    type Item = Result<PairingRequest, fidl::Error>;
4512
4513    fn poll_next(
4514        mut self: std::pin::Pin<&mut Self>,
4515        cx: &mut std::task::Context<'_>,
4516    ) -> std::task::Poll<Option<Self::Item>> {
4517        let this = &mut *self;
4518        if this.inner.check_shutdown(cx) {
4519            this.is_terminated = true;
4520            return std::task::Poll::Ready(None);
4521        }
4522        if this.is_terminated {
4523            panic!("polled PairingRequestStream after completion");
4524        }
4525        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4526            |bytes, handles| {
4527                match this.inner.channel().read_etc(cx, bytes, handles) {
4528                    std::task::Poll::Ready(Ok(())) => {}
4529                    std::task::Poll::Pending => return std::task::Poll::Pending,
4530                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4531                        this.is_terminated = true;
4532                        return std::task::Poll::Ready(None);
4533                    }
4534                    std::task::Poll::Ready(Err(e)) => {
4535                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4536                            e.into(),
4537                        ))))
4538                    }
4539                }
4540
4541                // A message has been received from the channel
4542                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4543
4544                std::task::Poll::Ready(Some(match header.ordinal {
4545                    0x19721a12cb80212c => {
4546                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4547                        let mut req = fidl::new_empty!(
4548                            PairingSetPairingDelegateRequest,
4549                            fidl::encoding::DefaultFuchsiaResourceDialect
4550                        );
4551                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PairingSetPairingDelegateRequest>(&header, _body_bytes, handles, &mut req)?;
4552                        let control_handle = PairingControlHandle { inner: this.inner.clone() };
4553                        Ok(PairingRequest::SetPairingDelegate {
4554                            input: req.input,
4555                            output: req.output,
4556                            delegate: req.delegate,
4557
4558                            control_handle,
4559                        })
4560                    }
4561                    0x1da0568d2582a9a5 => {
4562                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4563                        let mut req = fidl::new_empty!(
4564                            PairingSetDelegateRequest,
4565                            fidl::encoding::DefaultFuchsiaResourceDialect
4566                        );
4567                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PairingSetDelegateRequest>(&header, _body_bytes, handles, &mut req)?;
4568                        let control_handle = PairingControlHandle { inner: this.inner.clone() };
4569                        Ok(PairingRequest::SetDelegate {
4570                            input: req.input,
4571                            output: req.output,
4572                            delegate: req.delegate,
4573
4574                            control_handle,
4575                        })
4576                    }
4577                    _ => Err(fidl::Error::UnknownOrdinal {
4578                        ordinal: header.ordinal,
4579                        protocol_name:
4580                            <PairingMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4581                    }),
4582                }))
4583            },
4584        )
4585    }
4586}
4587
4588/// Allows system clients to enable Bluetooth pairing.
4589#[derive(Debug)]
4590pub enum PairingRequest {
4591    /// Assign a PairingDelegate to respond to pairing procedures. The provided I/O capabilities
4592    /// will be used to determine the pairing methods used.
4593    ///
4594    /// Only one PairingDelegate can be set at a time system-wide - if this is called
4595    /// while another delegate is set, the new delegate will be closed immediately.
4596    /// Closing a PairingDelegate after it is set aborts all ongoing pairing procedures
4597    /// without accepting and unsets the delegate.
4598    ///
4599    /// If no PairingDelegate is set, all pairings will be rejected even if the
4600    /// peer connection was initiated by the local device.
4601    ///
4602    /// + request `input` Bluetooth input capability, see `InputCapability`
4603    /// + request `output` Bluetooth output capability, see `OutputCapability`
4604    /// + request `delegate` PairingDelegate which will receive pairing requests
4605    SetPairingDelegate {
4606        input: InputCapability,
4607        output: OutputCapability,
4608        delegate: fidl::endpoints::ClientEnd<PairingDelegateMarker>,
4609        control_handle: PairingControlHandle,
4610    },
4611    /// Assign a PairingDelegate2 to handle pairing procedures.  The provided
4612    /// I/O capabilities will be used to determine the methods used.
4613    ///
4614    /// Only one of PairingDelegate or PairingDelegate2 can be set at a time
4615    /// system-wide.  If this is called while another delegate is set, the new
4616    /// delegate will be closed immediately.
4617    ///
4618    /// Closing a PairingDelegate2 unsets the pairing delegate. Ongoing
4619    /// PairingRequests can still be completed, but new requests will act as if
4620    /// no delegate is set.
4621    ///
4622    /// If no delegate is set, all pairings will be rejected even if the
4623    /// peer connection was initiated by the local device.
4624    ///
4625    /// + request `input` Bluetooth input capability, see `InputCapability`
4626    /// + request `output` Bluetooth output capability, see `OutputCapability`
4627    /// + request `delegate` PairingDelegate2 which will receive pairing requests
4628    SetDelegate {
4629        input: InputCapability,
4630        output: OutputCapability,
4631        delegate: fidl::endpoints::ClientEnd<PairingDelegate2Marker>,
4632        control_handle: PairingControlHandle,
4633    },
4634}
4635
4636impl PairingRequest {
4637    #[allow(irrefutable_let_patterns)]
4638    pub fn into_set_pairing_delegate(
4639        self,
4640    ) -> Option<(
4641        InputCapability,
4642        OutputCapability,
4643        fidl::endpoints::ClientEnd<PairingDelegateMarker>,
4644        PairingControlHandle,
4645    )> {
4646        if let PairingRequest::SetPairingDelegate { input, output, delegate, control_handle } = self
4647        {
4648            Some((input, output, delegate, control_handle))
4649        } else {
4650            None
4651        }
4652    }
4653
4654    #[allow(irrefutable_let_patterns)]
4655    pub fn into_set_delegate(
4656        self,
4657    ) -> Option<(
4658        InputCapability,
4659        OutputCapability,
4660        fidl::endpoints::ClientEnd<PairingDelegate2Marker>,
4661        PairingControlHandle,
4662    )> {
4663        if let PairingRequest::SetDelegate { input, output, delegate, control_handle } = self {
4664            Some((input, output, delegate, control_handle))
4665        } else {
4666            None
4667        }
4668    }
4669
4670    /// Name of the method defined in FIDL
4671    pub fn method_name(&self) -> &'static str {
4672        match *self {
4673            PairingRequest::SetPairingDelegate { .. } => "set_pairing_delegate",
4674            PairingRequest::SetDelegate { .. } => "set_delegate",
4675        }
4676    }
4677}
4678
4679#[derive(Debug, Clone)]
4680pub struct PairingControlHandle {
4681    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4682}
4683
4684impl fidl::endpoints::ControlHandle for PairingControlHandle {
4685    fn shutdown(&self) {
4686        self.inner.shutdown()
4687    }
4688    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4689        self.inner.shutdown_with_epitaph(status)
4690    }
4691
4692    fn is_closed(&self) -> bool {
4693        self.inner.channel().is_closed()
4694    }
4695    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4696        self.inner.channel().on_closed()
4697    }
4698
4699    #[cfg(target_os = "fuchsia")]
4700    fn signal_peer(
4701        &self,
4702        clear_mask: zx::Signals,
4703        set_mask: zx::Signals,
4704    ) -> Result<(), zx_status::Status> {
4705        use fidl::Peered;
4706        self.inner.channel().signal_peer(clear_mask, set_mask)
4707    }
4708}
4709
4710impl PairingControlHandle {}
4711
4712#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4713pub struct PairingDelegateMarker;
4714
4715impl fidl::endpoints::ProtocolMarker for PairingDelegateMarker {
4716    type Proxy = PairingDelegateProxy;
4717    type RequestStream = PairingDelegateRequestStream;
4718    #[cfg(target_os = "fuchsia")]
4719    type SynchronousProxy = PairingDelegateSynchronousProxy;
4720
4721    const DEBUG_NAME: &'static str = "(anonymous) PairingDelegate";
4722}
4723
4724pub trait PairingDelegateProxyInterface: Send + Sync {
4725    type OnPairingRequestResponseFut: std::future::Future<Output = Result<(bool, u32), fidl::Error>>
4726        + Send;
4727    fn r#on_pairing_request(
4728        &self,
4729        peer: &Peer,
4730        method: PairingMethod,
4731        displayed_passkey: u32,
4732    ) -> Self::OnPairingRequestResponseFut;
4733    fn r#on_pairing_complete(
4734        &self,
4735        id: &fidl_fuchsia_bluetooth::PeerId,
4736        success: bool,
4737    ) -> Result<(), fidl::Error>;
4738    fn r#on_remote_keypress(
4739        &self,
4740        id: &fidl_fuchsia_bluetooth::PeerId,
4741        keypress: PairingKeypress,
4742    ) -> Result<(), fidl::Error>;
4743}
4744#[derive(Debug)]
4745#[cfg(target_os = "fuchsia")]
4746pub struct PairingDelegateSynchronousProxy {
4747    client: fidl::client::sync::Client,
4748}
4749
4750#[cfg(target_os = "fuchsia")]
4751impl fidl::endpoints::SynchronousProxy for PairingDelegateSynchronousProxy {
4752    type Proxy = PairingDelegateProxy;
4753    type Protocol = PairingDelegateMarker;
4754
4755    fn from_channel(inner: fidl::Channel) -> Self {
4756        Self::new(inner)
4757    }
4758
4759    fn into_channel(self) -> fidl::Channel {
4760        self.client.into_channel()
4761    }
4762
4763    fn as_channel(&self) -> &fidl::Channel {
4764        self.client.as_channel()
4765    }
4766}
4767
4768#[cfg(target_os = "fuchsia")]
4769impl PairingDelegateSynchronousProxy {
4770    pub fn new(channel: fidl::Channel) -> Self {
4771        let protocol_name = <PairingDelegateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4772        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4773    }
4774
4775    pub fn into_channel(self) -> fidl::Channel {
4776        self.client.into_channel()
4777    }
4778
4779    /// Waits until an event arrives and returns it. It is safe for other
4780    /// threads to make concurrent requests while waiting for an event.
4781    pub fn wait_for_event(
4782        &self,
4783        deadline: zx::MonotonicInstant,
4784    ) -> Result<PairingDelegateEvent, fidl::Error> {
4785        PairingDelegateEvent::decode(self.client.wait_for_event(deadline)?)
4786    }
4787
4788    /// Called to confirm a pairing. The pairing process will be continued if
4789    /// `accept` response is true and rejected otherwise.
4790    /// If the pairing method requires a passkey it must be included as well.
4791    /// Pairing methods that do not require a passkey ignore the `entered_passkey`
4792    /// repsonse.
4793    ///
4794    /// The pairing can fail (usually by timeout or peer disconnect) before the
4795    /// response is received. The OnPairingComplete method will be called when this
4796    /// occurs.  Any response sent in this case will be ignored.
4797    ///
4798    /// + request `peer` information about the peer being paired
4799    /// + request `method` method of pairing active. See `PairingMethod`
4800    /// + request `displayed_passkey` a passkey to display to the user if
4801    ///   PASSKEY_DISPLAY or PASSKEY_COMPARISON is being used. Meaningless
4802    ///   otherwise.
4803    /// - response `accept` true if the pairing is accepted
4804    /// - response `entered_passkey` passkey entered by the user. Ignored unless
4805    ///   method is PASSKEY_ENTRY.
4806    pub fn r#on_pairing_request(
4807        &self,
4808        mut peer: &Peer,
4809        mut method: PairingMethod,
4810        mut displayed_passkey: u32,
4811        ___deadline: zx::MonotonicInstant,
4812    ) -> Result<(bool, u32), fidl::Error> {
4813        let _response = self.client.send_query::<
4814            PairingDelegateOnPairingRequestRequest,
4815            PairingDelegateOnPairingRequestResponse,
4816        >(
4817            (peer, method, displayed_passkey,),
4818            0x5c483a8f97b226b3,
4819            fidl::encoding::DynamicFlags::empty(),
4820            ___deadline,
4821        )?;
4822        Ok((_response.accept, _response.entered_passkey))
4823    }
4824
4825    /// Called when the pairing procedure for a peer has been completed.
4826    /// This can be due to successful completion or an error (e.g. due to cancellation
4827    /// by the peer, a timeout, or disconnection).
4828    /// * request `id` The Bluetooth peer ID of the peer which was being paired.
4829    /// * request `success` true if the pairing succeeded, otherwise false.
4830    pub fn r#on_pairing_complete(
4831        &self,
4832        mut id: &fidl_fuchsia_bluetooth::PeerId,
4833        mut success: bool,
4834    ) -> Result<(), fidl::Error> {
4835        self.client.send::<PairingDelegateOnPairingCompleteRequest>(
4836            (id, success),
4837            0x5ad8fc9864eba757,
4838            fidl::encoding::DynamicFlags::empty(),
4839        )
4840    }
4841
4842    /// Called to notify keypresses from the peer device during pairing using
4843    /// `PairingMethod.PASSKEY_DISPLAY`.
4844    ///
4845    /// This event is used to provide key press events to the delegate for a responsive user
4846    /// experience as the user types the passkey on the peer device. This event will be called
4847    /// once for each keypress.
4848    ///
4849    /// This event will only be called between when an OnPairingRequest has been sent for
4850    /// `id` and when OnPairingComplete is sent.
4851    ///
4852    /// Note: many devices do not send these events
4853    /// * request `id` The peer id of the peer that sent the keypress event.
4854    /// * request `keypress` The type of event which was received.
4855    pub fn r#on_remote_keypress(
4856        &self,
4857        mut id: &fidl_fuchsia_bluetooth::PeerId,
4858        mut keypress: PairingKeypress,
4859    ) -> Result<(), fidl::Error> {
4860        self.client.send::<PairingDelegateOnRemoteKeypressRequest>(
4861            (id, keypress),
4862            0x4e341e41c604c724,
4863            fidl::encoding::DynamicFlags::empty(),
4864        )
4865    }
4866}
4867
4868#[cfg(target_os = "fuchsia")]
4869impl From<PairingDelegateSynchronousProxy> for zx::Handle {
4870    fn from(value: PairingDelegateSynchronousProxy) -> Self {
4871        value.into_channel().into()
4872    }
4873}
4874
4875#[cfg(target_os = "fuchsia")]
4876impl From<fidl::Channel> for PairingDelegateSynchronousProxy {
4877    fn from(value: fidl::Channel) -> Self {
4878        Self::new(value)
4879    }
4880}
4881
4882#[derive(Debug, Clone)]
4883pub struct PairingDelegateProxy {
4884    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4885}
4886
4887impl fidl::endpoints::Proxy for PairingDelegateProxy {
4888    type Protocol = PairingDelegateMarker;
4889
4890    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4891        Self::new(inner)
4892    }
4893
4894    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4895        self.client.into_channel().map_err(|client| Self { client })
4896    }
4897
4898    fn as_channel(&self) -> &::fidl::AsyncChannel {
4899        self.client.as_channel()
4900    }
4901}
4902
4903impl PairingDelegateProxy {
4904    /// Create a new Proxy for fuchsia.bluetooth.sys/PairingDelegate.
4905    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4906        let protocol_name = <PairingDelegateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4907        Self { client: fidl::client::Client::new(channel, protocol_name) }
4908    }
4909
4910    /// Get a Stream of events from the remote end of the protocol.
4911    ///
4912    /// # Panics
4913    ///
4914    /// Panics if the event stream was already taken.
4915    pub fn take_event_stream(&self) -> PairingDelegateEventStream {
4916        PairingDelegateEventStream { event_receiver: self.client.take_event_receiver() }
4917    }
4918
4919    /// Called to confirm a pairing. The pairing process will be continued if
4920    /// `accept` response is true and rejected otherwise.
4921    /// If the pairing method requires a passkey it must be included as well.
4922    /// Pairing methods that do not require a passkey ignore the `entered_passkey`
4923    /// repsonse.
4924    ///
4925    /// The pairing can fail (usually by timeout or peer disconnect) before the
4926    /// response is received. The OnPairingComplete method will be called when this
4927    /// occurs.  Any response sent in this case will be ignored.
4928    ///
4929    /// + request `peer` information about the peer being paired
4930    /// + request `method` method of pairing active. See `PairingMethod`
4931    /// + request `displayed_passkey` a passkey to display to the user if
4932    ///   PASSKEY_DISPLAY or PASSKEY_COMPARISON is being used. Meaningless
4933    ///   otherwise.
4934    /// - response `accept` true if the pairing is accepted
4935    /// - response `entered_passkey` passkey entered by the user. Ignored unless
4936    ///   method is PASSKEY_ENTRY.
4937    pub fn r#on_pairing_request(
4938        &self,
4939        mut peer: &Peer,
4940        mut method: PairingMethod,
4941        mut displayed_passkey: u32,
4942    ) -> fidl::client::QueryResponseFut<(bool, u32), fidl::encoding::DefaultFuchsiaResourceDialect>
4943    {
4944        PairingDelegateProxyInterface::r#on_pairing_request(self, peer, method, displayed_passkey)
4945    }
4946
4947    /// Called when the pairing procedure for a peer has been completed.
4948    /// This can be due to successful completion or an error (e.g. due to cancellation
4949    /// by the peer, a timeout, or disconnection).
4950    /// * request `id` The Bluetooth peer ID of the peer which was being paired.
4951    /// * request `success` true if the pairing succeeded, otherwise false.
4952    pub fn r#on_pairing_complete(
4953        &self,
4954        mut id: &fidl_fuchsia_bluetooth::PeerId,
4955        mut success: bool,
4956    ) -> Result<(), fidl::Error> {
4957        PairingDelegateProxyInterface::r#on_pairing_complete(self, id, success)
4958    }
4959
4960    /// Called to notify keypresses from the peer device during pairing using
4961    /// `PairingMethod.PASSKEY_DISPLAY`.
4962    ///
4963    /// This event is used to provide key press events to the delegate for a responsive user
4964    /// experience as the user types the passkey on the peer device. This event will be called
4965    /// once for each keypress.
4966    ///
4967    /// This event will only be called between when an OnPairingRequest has been sent for
4968    /// `id` and when OnPairingComplete is sent.
4969    ///
4970    /// Note: many devices do not send these events
4971    /// * request `id` The peer id of the peer that sent the keypress event.
4972    /// * request `keypress` The type of event which was received.
4973    pub fn r#on_remote_keypress(
4974        &self,
4975        mut id: &fidl_fuchsia_bluetooth::PeerId,
4976        mut keypress: PairingKeypress,
4977    ) -> Result<(), fidl::Error> {
4978        PairingDelegateProxyInterface::r#on_remote_keypress(self, id, keypress)
4979    }
4980}
4981
4982impl PairingDelegateProxyInterface for PairingDelegateProxy {
4983    type OnPairingRequestResponseFut =
4984        fidl::client::QueryResponseFut<(bool, u32), fidl::encoding::DefaultFuchsiaResourceDialect>;
4985    fn r#on_pairing_request(
4986        &self,
4987        mut peer: &Peer,
4988        mut method: PairingMethod,
4989        mut displayed_passkey: u32,
4990    ) -> Self::OnPairingRequestResponseFut {
4991        fn _decode(
4992            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4993        ) -> Result<(bool, u32), fidl::Error> {
4994            let _response = fidl::client::decode_transaction_body::<
4995                PairingDelegateOnPairingRequestResponse,
4996                fidl::encoding::DefaultFuchsiaResourceDialect,
4997                0x5c483a8f97b226b3,
4998            >(_buf?)?;
4999            Ok((_response.accept, _response.entered_passkey))
5000        }
5001        self.client.send_query_and_decode::<PairingDelegateOnPairingRequestRequest, (bool, u32)>(
5002            (peer, method, displayed_passkey),
5003            0x5c483a8f97b226b3,
5004            fidl::encoding::DynamicFlags::empty(),
5005            _decode,
5006        )
5007    }
5008
5009    fn r#on_pairing_complete(
5010        &self,
5011        mut id: &fidl_fuchsia_bluetooth::PeerId,
5012        mut success: bool,
5013    ) -> Result<(), fidl::Error> {
5014        self.client.send::<PairingDelegateOnPairingCompleteRequest>(
5015            (id, success),
5016            0x5ad8fc9864eba757,
5017            fidl::encoding::DynamicFlags::empty(),
5018        )
5019    }
5020
5021    fn r#on_remote_keypress(
5022        &self,
5023        mut id: &fidl_fuchsia_bluetooth::PeerId,
5024        mut keypress: PairingKeypress,
5025    ) -> Result<(), fidl::Error> {
5026        self.client.send::<PairingDelegateOnRemoteKeypressRequest>(
5027            (id, keypress),
5028            0x4e341e41c604c724,
5029            fidl::encoding::DynamicFlags::empty(),
5030        )
5031    }
5032}
5033
5034pub struct PairingDelegateEventStream {
5035    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5036}
5037
5038impl std::marker::Unpin for PairingDelegateEventStream {}
5039
5040impl futures::stream::FusedStream for PairingDelegateEventStream {
5041    fn is_terminated(&self) -> bool {
5042        self.event_receiver.is_terminated()
5043    }
5044}
5045
5046impl futures::Stream for PairingDelegateEventStream {
5047    type Item = Result<PairingDelegateEvent, fidl::Error>;
5048
5049    fn poll_next(
5050        mut self: std::pin::Pin<&mut Self>,
5051        cx: &mut std::task::Context<'_>,
5052    ) -> std::task::Poll<Option<Self::Item>> {
5053        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5054            &mut self.event_receiver,
5055            cx
5056        )?) {
5057            Some(buf) => std::task::Poll::Ready(Some(PairingDelegateEvent::decode(buf))),
5058            None => std::task::Poll::Ready(None),
5059        }
5060    }
5061}
5062
5063#[derive(Debug)]
5064pub enum PairingDelegateEvent {
5065    OnLocalKeypress { id: fidl_fuchsia_bluetooth::PeerId, keypress: PairingKeypress },
5066}
5067
5068impl PairingDelegateEvent {
5069    #[allow(irrefutable_let_patterns)]
5070    pub fn into_on_local_keypress(
5071        self,
5072    ) -> Option<(fidl_fuchsia_bluetooth::PeerId, PairingKeypress)> {
5073        if let PairingDelegateEvent::OnLocalKeypress { id, keypress } = self {
5074            Some((id, keypress))
5075        } else {
5076            None
5077        }
5078    }
5079
5080    /// Decodes a message buffer as a [`PairingDelegateEvent`].
5081    fn decode(
5082        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5083    ) -> Result<PairingDelegateEvent, fidl::Error> {
5084        let (bytes, _handles) = buf.split_mut();
5085        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5086        debug_assert_eq!(tx_header.tx_id, 0);
5087        match tx_header.ordinal {
5088            0x1a764c0428878889 => {
5089                let mut out = fidl::new_empty!(
5090                    PairingDelegateOnLocalKeypressRequest,
5091                    fidl::encoding::DefaultFuchsiaResourceDialect
5092                );
5093                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PairingDelegateOnLocalKeypressRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
5094                Ok((PairingDelegateEvent::OnLocalKeypress { id: out.id, keypress: out.keypress }))
5095            }
5096            _ => Err(fidl::Error::UnknownOrdinal {
5097                ordinal: tx_header.ordinal,
5098                protocol_name:
5099                    <PairingDelegateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5100            }),
5101        }
5102    }
5103}
5104
5105/// A Stream of incoming requests for fuchsia.bluetooth.sys/PairingDelegate.
5106pub struct PairingDelegateRequestStream {
5107    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5108    is_terminated: bool,
5109}
5110
5111impl std::marker::Unpin for PairingDelegateRequestStream {}
5112
5113impl futures::stream::FusedStream for PairingDelegateRequestStream {
5114    fn is_terminated(&self) -> bool {
5115        self.is_terminated
5116    }
5117}
5118
5119impl fidl::endpoints::RequestStream for PairingDelegateRequestStream {
5120    type Protocol = PairingDelegateMarker;
5121    type ControlHandle = PairingDelegateControlHandle;
5122
5123    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5124        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5125    }
5126
5127    fn control_handle(&self) -> Self::ControlHandle {
5128        PairingDelegateControlHandle { inner: self.inner.clone() }
5129    }
5130
5131    fn into_inner(
5132        self,
5133    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5134    {
5135        (self.inner, self.is_terminated)
5136    }
5137
5138    fn from_inner(
5139        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5140        is_terminated: bool,
5141    ) -> Self {
5142        Self { inner, is_terminated }
5143    }
5144}
5145
5146impl futures::Stream for PairingDelegateRequestStream {
5147    type Item = Result<PairingDelegateRequest, fidl::Error>;
5148
5149    fn poll_next(
5150        mut self: std::pin::Pin<&mut Self>,
5151        cx: &mut std::task::Context<'_>,
5152    ) -> std::task::Poll<Option<Self::Item>> {
5153        let this = &mut *self;
5154        if this.inner.check_shutdown(cx) {
5155            this.is_terminated = true;
5156            return std::task::Poll::Ready(None);
5157        }
5158        if this.is_terminated {
5159            panic!("polled PairingDelegateRequestStream after completion");
5160        }
5161        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5162            |bytes, handles| {
5163                match this.inner.channel().read_etc(cx, bytes, handles) {
5164                    std::task::Poll::Ready(Ok(())) => {}
5165                    std::task::Poll::Pending => return std::task::Poll::Pending,
5166                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5167                        this.is_terminated = true;
5168                        return std::task::Poll::Ready(None);
5169                    }
5170                    std::task::Poll::Ready(Err(e)) => {
5171                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5172                            e.into(),
5173                        ))))
5174                    }
5175                }
5176
5177                // A message has been received from the channel
5178                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5179
5180                std::task::Poll::Ready(Some(match header.ordinal {
5181                    0x5c483a8f97b226b3 => {
5182                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5183                        let mut req = fidl::new_empty!(
5184                            PairingDelegateOnPairingRequestRequest,
5185                            fidl::encoding::DefaultFuchsiaResourceDialect
5186                        );
5187                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PairingDelegateOnPairingRequestRequest>(&header, _body_bytes, handles, &mut req)?;
5188                        let control_handle =
5189                            PairingDelegateControlHandle { inner: this.inner.clone() };
5190                        Ok(PairingDelegateRequest::OnPairingRequest {
5191                            peer: req.peer,
5192                            method: req.method,
5193                            displayed_passkey: req.displayed_passkey,
5194
5195                            responder: PairingDelegateOnPairingRequestResponder {
5196                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5197                                tx_id: header.tx_id,
5198                            },
5199                        })
5200                    }
5201                    0x5ad8fc9864eba757 => {
5202                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5203                        let mut req = fidl::new_empty!(
5204                            PairingDelegateOnPairingCompleteRequest,
5205                            fidl::encoding::DefaultFuchsiaResourceDialect
5206                        );
5207                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PairingDelegateOnPairingCompleteRequest>(&header, _body_bytes, handles, &mut req)?;
5208                        let control_handle =
5209                            PairingDelegateControlHandle { inner: this.inner.clone() };
5210                        Ok(PairingDelegateRequest::OnPairingComplete {
5211                            id: req.id,
5212                            success: req.success,
5213
5214                            control_handle,
5215                        })
5216                    }
5217                    0x4e341e41c604c724 => {
5218                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5219                        let mut req = fidl::new_empty!(
5220                            PairingDelegateOnRemoteKeypressRequest,
5221                            fidl::encoding::DefaultFuchsiaResourceDialect
5222                        );
5223                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PairingDelegateOnRemoteKeypressRequest>(&header, _body_bytes, handles, &mut req)?;
5224                        let control_handle =
5225                            PairingDelegateControlHandle { inner: this.inner.clone() };
5226                        Ok(PairingDelegateRequest::OnRemoteKeypress {
5227                            id: req.id,
5228                            keypress: req.keypress,
5229
5230                            control_handle,
5231                        })
5232                    }
5233                    _ => Err(fidl::Error::UnknownOrdinal {
5234                        ordinal: header.ordinal,
5235                        protocol_name:
5236                            <PairingDelegateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5237                    }),
5238                }))
5239            },
5240        )
5241    }
5242}
5243
5244/// A Bluetooth Pairing Delegate is responsible for confirming or denying
5245/// pairing requests received from Bluetooth peers that connect or are
5246/// being connected to the local device.
5247///
5248/// Any new pairing will result in a call to `PairingDelegate.OnPairingRequest`,
5249/// including pairings where the InputCapability and OutputCapability are set
5250/// to none. The delegate is expected to have enough context to derive whether
5251/// to accept or deny the pairing.
5252///
5253/// Only one delegate is allowed to be set per system at a time. See
5254/// `fuchsia.bluetooth.sys.Pairing` for how to set the pairing delegate.
5255#[derive(Debug)]
5256pub enum PairingDelegateRequest {
5257    /// Called to confirm a pairing. The pairing process will be continued if
5258    /// `accept` response is true and rejected otherwise.
5259    /// If the pairing method requires a passkey it must be included as well.
5260    /// Pairing methods that do not require a passkey ignore the `entered_passkey`
5261    /// repsonse.
5262    ///
5263    /// The pairing can fail (usually by timeout or peer disconnect) before the
5264    /// response is received. The OnPairingComplete method will be called when this
5265    /// occurs.  Any response sent in this case will be ignored.
5266    ///
5267    /// + request `peer` information about the peer being paired
5268    /// + request `method` method of pairing active. See `PairingMethod`
5269    /// + request `displayed_passkey` a passkey to display to the user if
5270    ///   PASSKEY_DISPLAY or PASSKEY_COMPARISON is being used. Meaningless
5271    ///   otherwise.
5272    /// - response `accept` true if the pairing is accepted
5273    /// - response `entered_passkey` passkey entered by the user. Ignored unless
5274    ///   method is PASSKEY_ENTRY.
5275    OnPairingRequest {
5276        peer: Peer,
5277        method: PairingMethod,
5278        displayed_passkey: u32,
5279        responder: PairingDelegateOnPairingRequestResponder,
5280    },
5281    /// Called when the pairing procedure for a peer has been completed.
5282    /// This can be due to successful completion or an error (e.g. due to cancellation
5283    /// by the peer, a timeout, or disconnection).
5284    /// * request `id` The Bluetooth peer ID of the peer which was being paired.
5285    /// * request `success` true if the pairing succeeded, otherwise false.
5286    OnPairingComplete {
5287        id: fidl_fuchsia_bluetooth::PeerId,
5288        success: bool,
5289        control_handle: PairingDelegateControlHandle,
5290    },
5291    /// Called to notify keypresses from the peer device during pairing using
5292    /// `PairingMethod.PASSKEY_DISPLAY`.
5293    ///
5294    /// This event is used to provide key press events to the delegate for a responsive user
5295    /// experience as the user types the passkey on the peer device. This event will be called
5296    /// once for each keypress.
5297    ///
5298    /// This event will only be called between when an OnPairingRequest has been sent for
5299    /// `id` and when OnPairingComplete is sent.
5300    ///
5301    /// Note: many devices do not send these events
5302    /// * request `id` The peer id of the peer that sent the keypress event.
5303    /// * request `keypress` The type of event which was received.
5304    OnRemoteKeypress {
5305        id: fidl_fuchsia_bluetooth::PeerId,
5306        keypress: PairingKeypress,
5307        control_handle: PairingDelegateControlHandle,
5308    },
5309}
5310
5311impl PairingDelegateRequest {
5312    #[allow(irrefutable_let_patterns)]
5313    pub fn into_on_pairing_request(
5314        self,
5315    ) -> Option<(Peer, PairingMethod, u32, PairingDelegateOnPairingRequestResponder)> {
5316        if let PairingDelegateRequest::OnPairingRequest {
5317            peer,
5318            method,
5319            displayed_passkey,
5320            responder,
5321        } = self
5322        {
5323            Some((peer, method, displayed_passkey, responder))
5324        } else {
5325            None
5326        }
5327    }
5328
5329    #[allow(irrefutable_let_patterns)]
5330    pub fn into_on_pairing_complete(
5331        self,
5332    ) -> Option<(fidl_fuchsia_bluetooth::PeerId, bool, PairingDelegateControlHandle)> {
5333        if let PairingDelegateRequest::OnPairingComplete { id, success, control_handle } = self {
5334            Some((id, success, control_handle))
5335        } else {
5336            None
5337        }
5338    }
5339
5340    #[allow(irrefutable_let_patterns)]
5341    pub fn into_on_remote_keypress(
5342        self,
5343    ) -> Option<(fidl_fuchsia_bluetooth::PeerId, PairingKeypress, PairingDelegateControlHandle)>
5344    {
5345        if let PairingDelegateRequest::OnRemoteKeypress { id, keypress, control_handle } = self {
5346            Some((id, keypress, control_handle))
5347        } else {
5348            None
5349        }
5350    }
5351
5352    /// Name of the method defined in FIDL
5353    pub fn method_name(&self) -> &'static str {
5354        match *self {
5355            PairingDelegateRequest::OnPairingRequest { .. } => "on_pairing_request",
5356            PairingDelegateRequest::OnPairingComplete { .. } => "on_pairing_complete",
5357            PairingDelegateRequest::OnRemoteKeypress { .. } => "on_remote_keypress",
5358        }
5359    }
5360}
5361
5362#[derive(Debug, Clone)]
5363pub struct PairingDelegateControlHandle {
5364    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5365}
5366
5367impl fidl::endpoints::ControlHandle for PairingDelegateControlHandle {
5368    fn shutdown(&self) {
5369        self.inner.shutdown()
5370    }
5371    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5372        self.inner.shutdown_with_epitaph(status)
5373    }
5374
5375    fn is_closed(&self) -> bool {
5376        self.inner.channel().is_closed()
5377    }
5378    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5379        self.inner.channel().on_closed()
5380    }
5381
5382    #[cfg(target_os = "fuchsia")]
5383    fn signal_peer(
5384        &self,
5385        clear_mask: zx::Signals,
5386        set_mask: zx::Signals,
5387    ) -> Result<(), zx_status::Status> {
5388        use fidl::Peered;
5389        self.inner.channel().signal_peer(clear_mask, set_mask)
5390    }
5391}
5392
5393impl PairingDelegateControlHandle {
5394    pub fn send_on_local_keypress(
5395        &self,
5396        mut id: &fidl_fuchsia_bluetooth::PeerId,
5397        mut keypress: PairingKeypress,
5398    ) -> Result<(), fidl::Error> {
5399        self.inner.send::<PairingDelegateOnLocalKeypressRequest>(
5400            (id, keypress),
5401            0,
5402            0x1a764c0428878889,
5403            fidl::encoding::DynamicFlags::empty(),
5404        )
5405    }
5406}
5407
5408#[must_use = "FIDL methods require a response to be sent"]
5409#[derive(Debug)]
5410pub struct PairingDelegateOnPairingRequestResponder {
5411    control_handle: std::mem::ManuallyDrop<PairingDelegateControlHandle>,
5412    tx_id: u32,
5413}
5414
5415/// Set the the channel to be shutdown (see [`PairingDelegateControlHandle::shutdown`])
5416/// if the responder is dropped without sending a response, so that the client
5417/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5418impl std::ops::Drop for PairingDelegateOnPairingRequestResponder {
5419    fn drop(&mut self) {
5420        self.control_handle.shutdown();
5421        // Safety: drops once, never accessed again
5422        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5423    }
5424}
5425
5426impl fidl::endpoints::Responder for PairingDelegateOnPairingRequestResponder {
5427    type ControlHandle = PairingDelegateControlHandle;
5428
5429    fn control_handle(&self) -> &PairingDelegateControlHandle {
5430        &self.control_handle
5431    }
5432
5433    fn drop_without_shutdown(mut self) {
5434        // Safety: drops once, never accessed again due to mem::forget
5435        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5436        // Prevent Drop from running (which would shut down the channel)
5437        std::mem::forget(self);
5438    }
5439}
5440
5441impl PairingDelegateOnPairingRequestResponder {
5442    /// Sends a response to the FIDL transaction.
5443    ///
5444    /// Sets the channel to shutdown if an error occurs.
5445    pub fn send(self, mut accept: bool, mut entered_passkey: u32) -> Result<(), fidl::Error> {
5446        let _result = self.send_raw(accept, entered_passkey);
5447        if _result.is_err() {
5448            self.control_handle.shutdown();
5449        }
5450        self.drop_without_shutdown();
5451        _result
5452    }
5453
5454    /// Similar to "send" but does not shutdown the channel if an error occurs.
5455    pub fn send_no_shutdown_on_err(
5456        self,
5457        mut accept: bool,
5458        mut entered_passkey: u32,
5459    ) -> Result<(), fidl::Error> {
5460        let _result = self.send_raw(accept, entered_passkey);
5461        self.drop_without_shutdown();
5462        _result
5463    }
5464
5465    fn send_raw(&self, mut accept: bool, mut entered_passkey: u32) -> Result<(), fidl::Error> {
5466        self.control_handle.inner.send::<PairingDelegateOnPairingRequestResponse>(
5467            (accept, entered_passkey),
5468            self.tx_id,
5469            0x5c483a8f97b226b3,
5470            fidl::encoding::DynamicFlags::empty(),
5471        )
5472    }
5473}
5474
5475#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5476pub struct PairingDelegate2Marker;
5477
5478impl fidl::endpoints::ProtocolMarker for PairingDelegate2Marker {
5479    type Proxy = PairingDelegate2Proxy;
5480    type RequestStream = PairingDelegate2RequestStream;
5481    #[cfg(target_os = "fuchsia")]
5482    type SynchronousProxy = PairingDelegate2SynchronousProxy;
5483
5484    const DEBUG_NAME: &'static str = "(anonymous) PairingDelegate2";
5485}
5486
5487pub trait PairingDelegate2ProxyInterface: Send + Sync {
5488    fn r#start_request(
5489        &self,
5490        payload: PairingDelegate2StartRequestRequest,
5491    ) -> Result<(), fidl::Error>;
5492    fn r#request_complete(
5493        &self,
5494        id: &fidl_fuchsia_bluetooth::PeerId,
5495        success: bool,
5496    ) -> Result<(), fidl::Error>;
5497}
5498#[derive(Debug)]
5499#[cfg(target_os = "fuchsia")]
5500pub struct PairingDelegate2SynchronousProxy {
5501    client: fidl::client::sync::Client,
5502}
5503
5504#[cfg(target_os = "fuchsia")]
5505impl fidl::endpoints::SynchronousProxy for PairingDelegate2SynchronousProxy {
5506    type Proxy = PairingDelegate2Proxy;
5507    type Protocol = PairingDelegate2Marker;
5508
5509    fn from_channel(inner: fidl::Channel) -> Self {
5510        Self::new(inner)
5511    }
5512
5513    fn into_channel(self) -> fidl::Channel {
5514        self.client.into_channel()
5515    }
5516
5517    fn as_channel(&self) -> &fidl::Channel {
5518        self.client.as_channel()
5519    }
5520}
5521
5522#[cfg(target_os = "fuchsia")]
5523impl PairingDelegate2SynchronousProxy {
5524    pub fn new(channel: fidl::Channel) -> Self {
5525        let protocol_name = <PairingDelegate2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5526        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5527    }
5528
5529    pub fn into_channel(self) -> fidl::Channel {
5530        self.client.into_channel()
5531    }
5532
5533    /// Waits until an event arrives and returns it. It is safe for other
5534    /// threads to make concurrent requests while waiting for an event.
5535    pub fn wait_for_event(
5536        &self,
5537        deadline: zx::MonotonicInstant,
5538    ) -> Result<PairingDelegate2Event, fidl::Error> {
5539        PairingDelegate2Event::decode(self.client.wait_for_event(deadline)?)
5540    }
5541
5542    /// Called when a pairing with `peer` is started. The pairing process is
5543    /// continued using the PairingRequest protocol.
5544    ///
5545    /// The properties of the pairing are provided in `info` which indicates
5546    /// what type of interaction is intended locally.
5547    ///
5548    /// Multiple requests can be active at one time for different peers, and
5549    /// requests can outlive this protocol.  Dropping the request protocol will
5550    /// automatically reject the pairing.
5551    ///
5552    /// All fields will always be present.
5553    pub fn r#start_request(
5554        &self,
5555        mut payload: PairingDelegate2StartRequestRequest,
5556    ) -> Result<(), fidl::Error> {
5557        self.client.send::<PairingDelegate2StartRequestRequest>(
5558            &mut payload,
5559            0x2a5ab8092a961a01,
5560            fidl::encoding::DynamicFlags::empty(),
5561        )
5562    }
5563
5564    /// Called when the pairing procedure for a peer has been completed.  This
5565    /// can be due to successful completion or an error (e.g. due to
5566    /// cancellation by the peer, a timeout, or disconnection).
5567    ///
5568    /// + request `id` The Bluetooth peer ID of the peer which was being paired
5569    /// + request `success` true if the pairing succeeded, otherwise false
5570    pub fn r#request_complete(
5571        &self,
5572        mut id: &fidl_fuchsia_bluetooth::PeerId,
5573        mut success: bool,
5574    ) -> Result<(), fidl::Error> {
5575        self.client.send::<PairingDelegate2RequestCompleteRequest>(
5576            (id, success),
5577            0x4b63b44d5dbca192,
5578            fidl::encoding::DynamicFlags::empty(),
5579        )
5580    }
5581}
5582
5583#[cfg(target_os = "fuchsia")]
5584impl From<PairingDelegate2SynchronousProxy> for zx::Handle {
5585    fn from(value: PairingDelegate2SynchronousProxy) -> Self {
5586        value.into_channel().into()
5587    }
5588}
5589
5590#[cfg(target_os = "fuchsia")]
5591impl From<fidl::Channel> for PairingDelegate2SynchronousProxy {
5592    fn from(value: fidl::Channel) -> Self {
5593        Self::new(value)
5594    }
5595}
5596
5597#[derive(Debug, Clone)]
5598pub struct PairingDelegate2Proxy {
5599    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5600}
5601
5602impl fidl::endpoints::Proxy for PairingDelegate2Proxy {
5603    type Protocol = PairingDelegate2Marker;
5604
5605    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5606        Self::new(inner)
5607    }
5608
5609    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5610        self.client.into_channel().map_err(|client| Self { client })
5611    }
5612
5613    fn as_channel(&self) -> &::fidl::AsyncChannel {
5614        self.client.as_channel()
5615    }
5616}
5617
5618impl PairingDelegate2Proxy {
5619    /// Create a new Proxy for fuchsia.bluetooth.sys/PairingDelegate2.
5620    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5621        let protocol_name = <PairingDelegate2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5622        Self { client: fidl::client::Client::new(channel, protocol_name) }
5623    }
5624
5625    /// Get a Stream of events from the remote end of the protocol.
5626    ///
5627    /// # Panics
5628    ///
5629    /// Panics if the event stream was already taken.
5630    pub fn take_event_stream(&self) -> PairingDelegate2EventStream {
5631        PairingDelegate2EventStream { event_receiver: self.client.take_event_receiver() }
5632    }
5633
5634    /// Called when a pairing with `peer` is started. The pairing process is
5635    /// continued using the PairingRequest protocol.
5636    ///
5637    /// The properties of the pairing are provided in `info` which indicates
5638    /// what type of interaction is intended locally.
5639    ///
5640    /// Multiple requests can be active at one time for different peers, and
5641    /// requests can outlive this protocol.  Dropping the request protocol will
5642    /// automatically reject the pairing.
5643    ///
5644    /// All fields will always be present.
5645    pub fn r#start_request(
5646        &self,
5647        mut payload: PairingDelegate2StartRequestRequest,
5648    ) -> Result<(), fidl::Error> {
5649        PairingDelegate2ProxyInterface::r#start_request(self, payload)
5650    }
5651
5652    /// Called when the pairing procedure for a peer has been completed.  This
5653    /// can be due to successful completion or an error (e.g. due to
5654    /// cancellation by the peer, a timeout, or disconnection).
5655    ///
5656    /// + request `id` The Bluetooth peer ID of the peer which was being paired
5657    /// + request `success` true if the pairing succeeded, otherwise false
5658    pub fn r#request_complete(
5659        &self,
5660        mut id: &fidl_fuchsia_bluetooth::PeerId,
5661        mut success: bool,
5662    ) -> Result<(), fidl::Error> {
5663        PairingDelegate2ProxyInterface::r#request_complete(self, id, success)
5664    }
5665}
5666
5667impl PairingDelegate2ProxyInterface for PairingDelegate2Proxy {
5668    fn r#start_request(
5669        &self,
5670        mut payload: PairingDelegate2StartRequestRequest,
5671    ) -> Result<(), fidl::Error> {
5672        self.client.send::<PairingDelegate2StartRequestRequest>(
5673            &mut payload,
5674            0x2a5ab8092a961a01,
5675            fidl::encoding::DynamicFlags::empty(),
5676        )
5677    }
5678
5679    fn r#request_complete(
5680        &self,
5681        mut id: &fidl_fuchsia_bluetooth::PeerId,
5682        mut success: bool,
5683    ) -> Result<(), fidl::Error> {
5684        self.client.send::<PairingDelegate2RequestCompleteRequest>(
5685            (id, success),
5686            0x4b63b44d5dbca192,
5687            fidl::encoding::DynamicFlags::empty(),
5688        )
5689    }
5690}
5691
5692pub struct PairingDelegate2EventStream {
5693    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5694}
5695
5696impl std::marker::Unpin for PairingDelegate2EventStream {}
5697
5698impl futures::stream::FusedStream for PairingDelegate2EventStream {
5699    fn is_terminated(&self) -> bool {
5700        self.event_receiver.is_terminated()
5701    }
5702}
5703
5704impl futures::Stream for PairingDelegate2EventStream {
5705    type Item = Result<PairingDelegate2Event, fidl::Error>;
5706
5707    fn poll_next(
5708        mut self: std::pin::Pin<&mut Self>,
5709        cx: &mut std::task::Context<'_>,
5710    ) -> std::task::Poll<Option<Self::Item>> {
5711        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5712            &mut self.event_receiver,
5713            cx
5714        )?) {
5715            Some(buf) => std::task::Poll::Ready(Some(PairingDelegate2Event::decode(buf))),
5716            None => std::task::Poll::Ready(None),
5717        }
5718    }
5719}
5720
5721#[derive(Debug)]
5722pub enum PairingDelegate2Event {}
5723
5724impl PairingDelegate2Event {
5725    /// Decodes a message buffer as a [`PairingDelegate2Event`].
5726    fn decode(
5727        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5728    ) -> Result<PairingDelegate2Event, fidl::Error> {
5729        let (bytes, _handles) = buf.split_mut();
5730        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5731        debug_assert_eq!(tx_header.tx_id, 0);
5732        match tx_header.ordinal {
5733            _ => Err(fidl::Error::UnknownOrdinal {
5734                ordinal: tx_header.ordinal,
5735                protocol_name:
5736                    <PairingDelegate2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5737            }),
5738        }
5739    }
5740}
5741
5742/// A Stream of incoming requests for fuchsia.bluetooth.sys/PairingDelegate2.
5743pub struct PairingDelegate2RequestStream {
5744    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5745    is_terminated: bool,
5746}
5747
5748impl std::marker::Unpin for PairingDelegate2RequestStream {}
5749
5750impl futures::stream::FusedStream for PairingDelegate2RequestStream {
5751    fn is_terminated(&self) -> bool {
5752        self.is_terminated
5753    }
5754}
5755
5756impl fidl::endpoints::RequestStream for PairingDelegate2RequestStream {
5757    type Protocol = PairingDelegate2Marker;
5758    type ControlHandle = PairingDelegate2ControlHandle;
5759
5760    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5761        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5762    }
5763
5764    fn control_handle(&self) -> Self::ControlHandle {
5765        PairingDelegate2ControlHandle { inner: self.inner.clone() }
5766    }
5767
5768    fn into_inner(
5769        self,
5770    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5771    {
5772        (self.inner, self.is_terminated)
5773    }
5774
5775    fn from_inner(
5776        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5777        is_terminated: bool,
5778    ) -> Self {
5779        Self { inner, is_terminated }
5780    }
5781}
5782
5783impl futures::Stream for PairingDelegate2RequestStream {
5784    type Item = Result<PairingDelegate2Request, fidl::Error>;
5785
5786    fn poll_next(
5787        mut self: std::pin::Pin<&mut Self>,
5788        cx: &mut std::task::Context<'_>,
5789    ) -> std::task::Poll<Option<Self::Item>> {
5790        let this = &mut *self;
5791        if this.inner.check_shutdown(cx) {
5792            this.is_terminated = true;
5793            return std::task::Poll::Ready(None);
5794        }
5795        if this.is_terminated {
5796            panic!("polled PairingDelegate2RequestStream after completion");
5797        }
5798        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5799            |bytes, handles| {
5800                match this.inner.channel().read_etc(cx, bytes, handles) {
5801                    std::task::Poll::Ready(Ok(())) => {}
5802                    std::task::Poll::Pending => return std::task::Poll::Pending,
5803                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5804                        this.is_terminated = true;
5805                        return std::task::Poll::Ready(None);
5806                    }
5807                    std::task::Poll::Ready(Err(e)) => {
5808                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5809                            e.into(),
5810                        ))))
5811                    }
5812                }
5813
5814                // A message has been received from the channel
5815                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5816
5817                std::task::Poll::Ready(Some(match header.ordinal {
5818                    0x2a5ab8092a961a01 => {
5819                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5820                        let mut req = fidl::new_empty!(
5821                            PairingDelegate2StartRequestRequest,
5822                            fidl::encoding::DefaultFuchsiaResourceDialect
5823                        );
5824                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PairingDelegate2StartRequestRequest>(&header, _body_bytes, handles, &mut req)?;
5825                        let control_handle =
5826                            PairingDelegate2ControlHandle { inner: this.inner.clone() };
5827                        Ok(PairingDelegate2Request::StartRequest { payload: req, control_handle })
5828                    }
5829                    0x4b63b44d5dbca192 => {
5830                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5831                        let mut req = fidl::new_empty!(
5832                            PairingDelegate2RequestCompleteRequest,
5833                            fidl::encoding::DefaultFuchsiaResourceDialect
5834                        );
5835                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PairingDelegate2RequestCompleteRequest>(&header, _body_bytes, handles, &mut req)?;
5836                        let control_handle =
5837                            PairingDelegate2ControlHandle { inner: this.inner.clone() };
5838                        Ok(PairingDelegate2Request::RequestComplete {
5839                            id: req.id,
5840                            success: req.success,
5841
5842                            control_handle,
5843                        })
5844                    }
5845                    _ => Err(fidl::Error::UnknownOrdinal {
5846                        ordinal: header.ordinal,
5847                        protocol_name:
5848                            <PairingDelegate2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5849                    }),
5850                }))
5851            },
5852        )
5853    }
5854}
5855
5856/// A Bluetooth Pairing Delegate is responsible for confirming or denying
5857/// pairing requests received from Bluetooth peers that connect or are
5858/// being connected to the local device.
5859///
5860/// Any new pairing will result in a call to `PairingDelegate.StartRequest`,
5861/// including pairings where the InputCapability and OutputCapability are set
5862/// to none. The delegate is expected to have enough context to derive whether
5863/// to accept or reject the pairing.
5864///
5865/// Only one delegate is allowed to be set per system at a time. See
5866/// `fuchsia.bluetooth.sys.Pairing` for how to set the pairing delegate.
5867#[derive(Debug)]
5868pub enum PairingDelegate2Request {
5869    /// Called when a pairing with `peer` is started. The pairing process is
5870    /// continued using the PairingRequest protocol.
5871    ///
5872    /// The properties of the pairing are provided in `info` which indicates
5873    /// what type of interaction is intended locally.
5874    ///
5875    /// Multiple requests can be active at one time for different peers, and
5876    /// requests can outlive this protocol.  Dropping the request protocol will
5877    /// automatically reject the pairing.
5878    ///
5879    /// All fields will always be present.
5880    StartRequest {
5881        payload: PairingDelegate2StartRequestRequest,
5882        control_handle: PairingDelegate2ControlHandle,
5883    },
5884    /// Called when the pairing procedure for a peer has been completed.  This
5885    /// can be due to successful completion or an error (e.g. due to
5886    /// cancellation by the peer, a timeout, or disconnection).
5887    ///
5888    /// + request `id` The Bluetooth peer ID of the peer which was being paired
5889    /// + request `success` true if the pairing succeeded, otherwise false
5890    RequestComplete {
5891        id: fidl_fuchsia_bluetooth::PeerId,
5892        success: bool,
5893        control_handle: PairingDelegate2ControlHandle,
5894    },
5895}
5896
5897impl PairingDelegate2Request {
5898    #[allow(irrefutable_let_patterns)]
5899    pub fn into_start_request(
5900        self,
5901    ) -> Option<(PairingDelegate2StartRequestRequest, PairingDelegate2ControlHandle)> {
5902        if let PairingDelegate2Request::StartRequest { payload, control_handle } = self {
5903            Some((payload, control_handle))
5904        } else {
5905            None
5906        }
5907    }
5908
5909    #[allow(irrefutable_let_patterns)]
5910    pub fn into_request_complete(
5911        self,
5912    ) -> Option<(fidl_fuchsia_bluetooth::PeerId, bool, PairingDelegate2ControlHandle)> {
5913        if let PairingDelegate2Request::RequestComplete { id, success, control_handle } = self {
5914            Some((id, success, control_handle))
5915        } else {
5916            None
5917        }
5918    }
5919
5920    /// Name of the method defined in FIDL
5921    pub fn method_name(&self) -> &'static str {
5922        match *self {
5923            PairingDelegate2Request::StartRequest { .. } => "start_request",
5924            PairingDelegate2Request::RequestComplete { .. } => "request_complete",
5925        }
5926    }
5927}
5928
5929#[derive(Debug, Clone)]
5930pub struct PairingDelegate2ControlHandle {
5931    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5932}
5933
5934impl fidl::endpoints::ControlHandle for PairingDelegate2ControlHandle {
5935    fn shutdown(&self) {
5936        self.inner.shutdown()
5937    }
5938    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5939        self.inner.shutdown_with_epitaph(status)
5940    }
5941
5942    fn is_closed(&self) -> bool {
5943        self.inner.channel().is_closed()
5944    }
5945    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5946        self.inner.channel().on_closed()
5947    }
5948
5949    #[cfg(target_os = "fuchsia")]
5950    fn signal_peer(
5951        &self,
5952        clear_mask: zx::Signals,
5953        set_mask: zx::Signals,
5954    ) -> Result<(), zx_status::Status> {
5955        use fidl::Peered;
5956        self.inner.channel().signal_peer(clear_mask, set_mask)
5957    }
5958}
5959
5960impl PairingDelegate2ControlHandle {}
5961
5962#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5963pub struct PairingRequestMarker;
5964
5965impl fidl::endpoints::ProtocolMarker for PairingRequestMarker {
5966    type Proxy = PairingRequestProxy;
5967    type RequestStream = PairingRequestRequestStream;
5968    #[cfg(target_os = "fuchsia")]
5969    type SynchronousProxy = PairingRequestSynchronousProxy;
5970
5971    const DEBUG_NAME: &'static str = "(anonymous) PairingRequest";
5972}
5973
5974pub trait PairingRequestProxyInterface: Send + Sync {
5975    fn r#accept(&self, payload: &PairingRequestAcceptRequest) -> Result<(), fidl::Error>;
5976    fn r#reject(&self) -> Result<(), fidl::Error>;
5977    type KeypressResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5978    fn r#keypress(&self, keypress: PairingKeypress) -> Self::KeypressResponseFut;
5979}
5980#[derive(Debug)]
5981#[cfg(target_os = "fuchsia")]
5982pub struct PairingRequestSynchronousProxy {
5983    client: fidl::client::sync::Client,
5984}
5985
5986#[cfg(target_os = "fuchsia")]
5987impl fidl::endpoints::SynchronousProxy for PairingRequestSynchronousProxy {
5988    type Proxy = PairingRequestProxy;
5989    type Protocol = PairingRequestMarker;
5990
5991    fn from_channel(inner: fidl::Channel) -> Self {
5992        Self::new(inner)
5993    }
5994
5995    fn into_channel(self) -> fidl::Channel {
5996        self.client.into_channel()
5997    }
5998
5999    fn as_channel(&self) -> &fidl::Channel {
6000        self.client.as_channel()
6001    }
6002}
6003
6004#[cfg(target_os = "fuchsia")]
6005impl PairingRequestSynchronousProxy {
6006    pub fn new(channel: fidl::Channel) -> Self {
6007        let protocol_name = <PairingRequestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6008        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6009    }
6010
6011    pub fn into_channel(self) -> fidl::Channel {
6012        self.client.into_channel()
6013    }
6014
6015    /// Waits until an event arrives and returns it. It is safe for other
6016    /// threads to make concurrent requests while waiting for an event.
6017    pub fn wait_for_event(
6018        &self,
6019        deadline: zx::MonotonicInstant,
6020    ) -> Result<PairingRequestEvent, fidl::Error> {
6021        PairingRequestEvent::decode(self.client.wait_for_event(deadline)?)
6022    }
6023
6024    /// Accept the pairing request.
6025    /// entered_passkey is required if the PairingProperties.passkey_entry
6026    /// method is used, ignored otherwise.
6027    pub fn r#accept(&self, mut payload: &PairingRequestAcceptRequest) -> Result<(), fidl::Error> {
6028        self.client.send::<PairingRequestAcceptRequest>(
6029            payload,
6030            0x67278857ae043a5,
6031            fidl::encoding::DynamicFlags::empty(),
6032        )
6033    }
6034
6035    /// Reject the pairing request.
6036    /// Closing this protocol will also reject the pairing request.
6037    pub fn r#reject(&self) -> Result<(), fidl::Error> {
6038        self.client.send::<fidl::encoding::EmptyPayload>(
6039            (),
6040            0x550414aec8155cf5,
6041            fidl::encoding::DynamicFlags::empty(),
6042        )
6043    }
6044
6045    /// Used to communicate local keypresses to update the remote peer on
6046    /// the progress of the pairing. The responses to this method should
6047    /// be used for flow control.
6048    pub fn r#keypress(
6049        &self,
6050        mut keypress: PairingKeypress,
6051        ___deadline: zx::MonotonicInstant,
6052    ) -> Result<(), fidl::Error> {
6053        let _response =
6054            self.client.send_query::<PairingRequestKeypressRequest, fidl::encoding::EmptyPayload>(
6055                (keypress,),
6056                0x53948ecc921fbe9b,
6057                fidl::encoding::DynamicFlags::empty(),
6058                ___deadline,
6059            )?;
6060        Ok(_response)
6061    }
6062}
6063
6064#[cfg(target_os = "fuchsia")]
6065impl From<PairingRequestSynchronousProxy> for zx::Handle {
6066    fn from(value: PairingRequestSynchronousProxy) -> Self {
6067        value.into_channel().into()
6068    }
6069}
6070
6071#[cfg(target_os = "fuchsia")]
6072impl From<fidl::Channel> for PairingRequestSynchronousProxy {
6073    fn from(value: fidl::Channel) -> Self {
6074        Self::new(value)
6075    }
6076}
6077
6078#[derive(Debug, Clone)]
6079pub struct PairingRequestProxy {
6080    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6081}
6082
6083impl fidl::endpoints::Proxy for PairingRequestProxy {
6084    type Protocol = PairingRequestMarker;
6085
6086    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6087        Self::new(inner)
6088    }
6089
6090    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6091        self.client.into_channel().map_err(|client| Self { client })
6092    }
6093
6094    fn as_channel(&self) -> &::fidl::AsyncChannel {
6095        self.client.as_channel()
6096    }
6097}
6098
6099impl PairingRequestProxy {
6100    /// Create a new Proxy for fuchsia.bluetooth.sys/PairingRequest.
6101    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6102        let protocol_name = <PairingRequestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6103        Self { client: fidl::client::Client::new(channel, protocol_name) }
6104    }
6105
6106    /// Get a Stream of events from the remote end of the protocol.
6107    ///
6108    /// # Panics
6109    ///
6110    /// Panics if the event stream was already taken.
6111    pub fn take_event_stream(&self) -> PairingRequestEventStream {
6112        PairingRequestEventStream { event_receiver: self.client.take_event_receiver() }
6113    }
6114
6115    /// Accept the pairing request.
6116    /// entered_passkey is required if the PairingProperties.passkey_entry
6117    /// method is used, ignored otherwise.
6118    pub fn r#accept(&self, mut payload: &PairingRequestAcceptRequest) -> Result<(), fidl::Error> {
6119        PairingRequestProxyInterface::r#accept(self, payload)
6120    }
6121
6122    /// Reject the pairing request.
6123    /// Closing this protocol will also reject the pairing request.
6124    pub fn r#reject(&self) -> Result<(), fidl::Error> {
6125        PairingRequestProxyInterface::r#reject(self)
6126    }
6127
6128    /// Used to communicate local keypresses to update the remote peer on
6129    /// the progress of the pairing. The responses to this method should
6130    /// be used for flow control.
6131    pub fn r#keypress(
6132        &self,
6133        mut keypress: PairingKeypress,
6134    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
6135        PairingRequestProxyInterface::r#keypress(self, keypress)
6136    }
6137}
6138
6139impl PairingRequestProxyInterface for PairingRequestProxy {
6140    fn r#accept(&self, mut payload: &PairingRequestAcceptRequest) -> Result<(), fidl::Error> {
6141        self.client.send::<PairingRequestAcceptRequest>(
6142            payload,
6143            0x67278857ae043a5,
6144            fidl::encoding::DynamicFlags::empty(),
6145        )
6146    }
6147
6148    fn r#reject(&self) -> Result<(), fidl::Error> {
6149        self.client.send::<fidl::encoding::EmptyPayload>(
6150            (),
6151            0x550414aec8155cf5,
6152            fidl::encoding::DynamicFlags::empty(),
6153        )
6154    }
6155
6156    type KeypressResponseFut =
6157        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
6158    fn r#keypress(&self, mut keypress: PairingKeypress) -> Self::KeypressResponseFut {
6159        fn _decode(
6160            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6161        ) -> Result<(), fidl::Error> {
6162            let _response = fidl::client::decode_transaction_body::<
6163                fidl::encoding::EmptyPayload,
6164                fidl::encoding::DefaultFuchsiaResourceDialect,
6165                0x53948ecc921fbe9b,
6166            >(_buf?)?;
6167            Ok(_response)
6168        }
6169        self.client.send_query_and_decode::<PairingRequestKeypressRequest, ()>(
6170            (keypress,),
6171            0x53948ecc921fbe9b,
6172            fidl::encoding::DynamicFlags::empty(),
6173            _decode,
6174        )
6175    }
6176}
6177
6178pub struct PairingRequestEventStream {
6179    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6180}
6181
6182impl std::marker::Unpin for PairingRequestEventStream {}
6183
6184impl futures::stream::FusedStream for PairingRequestEventStream {
6185    fn is_terminated(&self) -> bool {
6186        self.event_receiver.is_terminated()
6187    }
6188}
6189
6190impl futures::Stream for PairingRequestEventStream {
6191    type Item = Result<PairingRequestEvent, fidl::Error>;
6192
6193    fn poll_next(
6194        mut self: std::pin::Pin<&mut Self>,
6195        cx: &mut std::task::Context<'_>,
6196    ) -> std::task::Poll<Option<Self::Item>> {
6197        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6198            &mut self.event_receiver,
6199            cx
6200        )?) {
6201            Some(buf) => std::task::Poll::Ready(Some(PairingRequestEvent::decode(buf))),
6202            None => std::task::Poll::Ready(None),
6203        }
6204    }
6205}
6206
6207#[derive(Debug)]
6208pub enum PairingRequestEvent {
6209    OnKeypress { keypress: PairingKeypress },
6210    OnComplete { success: bool },
6211}
6212
6213impl PairingRequestEvent {
6214    #[allow(irrefutable_let_patterns)]
6215    pub fn into_on_keypress(self) -> Option<PairingKeypress> {
6216        if let PairingRequestEvent::OnKeypress { keypress } = self {
6217            Some((keypress))
6218        } else {
6219            None
6220        }
6221    }
6222    #[allow(irrefutable_let_patterns)]
6223    pub fn into_on_complete(self) -> Option<bool> {
6224        if let PairingRequestEvent::OnComplete { success } = self {
6225            Some((success))
6226        } else {
6227            None
6228        }
6229    }
6230
6231    /// Decodes a message buffer as a [`PairingRequestEvent`].
6232    fn decode(
6233        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6234    ) -> Result<PairingRequestEvent, fidl::Error> {
6235        let (bytes, _handles) = buf.split_mut();
6236        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6237        debug_assert_eq!(tx_header.tx_id, 0);
6238        match tx_header.ordinal {
6239            0x71a4802e6a5d1aca => {
6240                let mut out = fidl::new_empty!(
6241                    PairingRequestOnKeypressRequest,
6242                    fidl::encoding::DefaultFuchsiaResourceDialect
6243                );
6244                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PairingRequestOnKeypressRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6245                Ok((PairingRequestEvent::OnKeypress { keypress: out.keypress }))
6246            }
6247            0xd38d3220987bc79 => {
6248                let mut out = fidl::new_empty!(
6249                    PairingRequestOnCompleteRequest,
6250                    fidl::encoding::DefaultFuchsiaResourceDialect
6251                );
6252                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PairingRequestOnCompleteRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6253                Ok((PairingRequestEvent::OnComplete { success: out.success }))
6254            }
6255            _ => Err(fidl::Error::UnknownOrdinal {
6256                ordinal: tx_header.ordinal,
6257                protocol_name:
6258                    <PairingRequestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6259            }),
6260        }
6261    }
6262}
6263
6264/// A Stream of incoming requests for fuchsia.bluetooth.sys/PairingRequest.
6265pub struct PairingRequestRequestStream {
6266    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6267    is_terminated: bool,
6268}
6269
6270impl std::marker::Unpin for PairingRequestRequestStream {}
6271
6272impl futures::stream::FusedStream for PairingRequestRequestStream {
6273    fn is_terminated(&self) -> bool {
6274        self.is_terminated
6275    }
6276}
6277
6278impl fidl::endpoints::RequestStream for PairingRequestRequestStream {
6279    type Protocol = PairingRequestMarker;
6280    type ControlHandle = PairingRequestControlHandle;
6281
6282    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6283        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6284    }
6285
6286    fn control_handle(&self) -> Self::ControlHandle {
6287        PairingRequestControlHandle { inner: self.inner.clone() }
6288    }
6289
6290    fn into_inner(
6291        self,
6292    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6293    {
6294        (self.inner, self.is_terminated)
6295    }
6296
6297    fn from_inner(
6298        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6299        is_terminated: bool,
6300    ) -> Self {
6301        Self { inner, is_terminated }
6302    }
6303}
6304
6305impl futures::Stream for PairingRequestRequestStream {
6306    type Item = Result<PairingRequestRequest, fidl::Error>;
6307
6308    fn poll_next(
6309        mut self: std::pin::Pin<&mut Self>,
6310        cx: &mut std::task::Context<'_>,
6311    ) -> std::task::Poll<Option<Self::Item>> {
6312        let this = &mut *self;
6313        if this.inner.check_shutdown(cx) {
6314            this.is_terminated = true;
6315            return std::task::Poll::Ready(None);
6316        }
6317        if this.is_terminated {
6318            panic!("polled PairingRequestRequestStream after completion");
6319        }
6320        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6321            |bytes, handles| {
6322                match this.inner.channel().read_etc(cx, bytes, handles) {
6323                    std::task::Poll::Ready(Ok(())) => {}
6324                    std::task::Poll::Pending => return std::task::Poll::Pending,
6325                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6326                        this.is_terminated = true;
6327                        return std::task::Poll::Ready(None);
6328                    }
6329                    std::task::Poll::Ready(Err(e)) => {
6330                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6331                            e.into(),
6332                        ))))
6333                    }
6334                }
6335
6336                // A message has been received from the channel
6337                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6338
6339                std::task::Poll::Ready(Some(match header.ordinal {
6340                    0x67278857ae043a5 => {
6341                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6342                        let mut req = fidl::new_empty!(
6343                            PairingRequestAcceptRequest,
6344                            fidl::encoding::DefaultFuchsiaResourceDialect
6345                        );
6346                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PairingRequestAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
6347                        let control_handle =
6348                            PairingRequestControlHandle { inner: this.inner.clone() };
6349                        Ok(PairingRequestRequest::Accept { payload: req, control_handle })
6350                    }
6351                    0x550414aec8155cf5 => {
6352                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6353                        let mut req = fidl::new_empty!(
6354                            fidl::encoding::EmptyPayload,
6355                            fidl::encoding::DefaultFuchsiaResourceDialect
6356                        );
6357                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6358                        let control_handle =
6359                            PairingRequestControlHandle { inner: this.inner.clone() };
6360                        Ok(PairingRequestRequest::Reject { control_handle })
6361                    }
6362                    0x53948ecc921fbe9b => {
6363                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6364                        let mut req = fidl::new_empty!(
6365                            PairingRequestKeypressRequest,
6366                            fidl::encoding::DefaultFuchsiaResourceDialect
6367                        );
6368                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PairingRequestKeypressRequest>(&header, _body_bytes, handles, &mut req)?;
6369                        let control_handle =
6370                            PairingRequestControlHandle { inner: this.inner.clone() };
6371                        Ok(PairingRequestRequest::Keypress {
6372                            keypress: req.keypress,
6373
6374                            responder: PairingRequestKeypressResponder {
6375                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6376                                tx_id: header.tx_id,
6377                            },
6378                        })
6379                    }
6380                    _ => Err(fidl::Error::UnknownOrdinal {
6381                        ordinal: header.ordinal,
6382                        protocol_name:
6383                            <PairingRequestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6384                    }),
6385                }))
6386            },
6387        )
6388    }
6389}
6390
6391/// This protocol is active when a pairing is in progress, and provided to the
6392/// PairingDelegate via the `PairingDelegate.StartRequest`
6393/// The server will close this protocol with an epitaph if the pairing process
6394/// completes early without success:
6395///  - ZX_ERR_UNAVAILABLE - Bluetooth peer has disconnected
6396///  - ZX_ERR_NOT_SUPPORTED - a passkey was provided when it was not expected
6397///  - ZX_ERR_BAD_STATE - a keypress was sent when not using
6398///                       PairingProperties.passkey_entry
6399///  - ZX_ERR_TIMED_OUT - no activity was detected, and the pairing was stopped
6400#[derive(Debug)]
6401pub enum PairingRequestRequest {
6402    /// Accept the pairing request.
6403    /// entered_passkey is required if the PairingProperties.passkey_entry
6404    /// method is used, ignored otherwise.
6405    Accept { payload: PairingRequestAcceptRequest, control_handle: PairingRequestControlHandle },
6406    /// Reject the pairing request.
6407    /// Closing this protocol will also reject the pairing request.
6408    Reject { control_handle: PairingRequestControlHandle },
6409    /// Used to communicate local keypresses to update the remote peer on
6410    /// the progress of the pairing. The responses to this method should
6411    /// be used for flow control.
6412    Keypress { keypress: PairingKeypress, responder: PairingRequestKeypressResponder },
6413}
6414
6415impl PairingRequestRequest {
6416    #[allow(irrefutable_let_patterns)]
6417    pub fn into_accept(self) -> Option<(PairingRequestAcceptRequest, PairingRequestControlHandle)> {
6418        if let PairingRequestRequest::Accept { payload, control_handle } = self {
6419            Some((payload, control_handle))
6420        } else {
6421            None
6422        }
6423    }
6424
6425    #[allow(irrefutable_let_patterns)]
6426    pub fn into_reject(self) -> Option<(PairingRequestControlHandle)> {
6427        if let PairingRequestRequest::Reject { control_handle } = self {
6428            Some((control_handle))
6429        } else {
6430            None
6431        }
6432    }
6433
6434    #[allow(irrefutable_let_patterns)]
6435    pub fn into_keypress(self) -> Option<(PairingKeypress, PairingRequestKeypressResponder)> {
6436        if let PairingRequestRequest::Keypress { keypress, responder } = self {
6437            Some((keypress, responder))
6438        } else {
6439            None
6440        }
6441    }
6442
6443    /// Name of the method defined in FIDL
6444    pub fn method_name(&self) -> &'static str {
6445        match *self {
6446            PairingRequestRequest::Accept { .. } => "accept",
6447            PairingRequestRequest::Reject { .. } => "reject",
6448            PairingRequestRequest::Keypress { .. } => "keypress",
6449        }
6450    }
6451}
6452
6453#[derive(Debug, Clone)]
6454pub struct PairingRequestControlHandle {
6455    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6456}
6457
6458impl fidl::endpoints::ControlHandle for PairingRequestControlHandle {
6459    fn shutdown(&self) {
6460        self.inner.shutdown()
6461    }
6462    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6463        self.inner.shutdown_with_epitaph(status)
6464    }
6465
6466    fn is_closed(&self) -> bool {
6467        self.inner.channel().is_closed()
6468    }
6469    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6470        self.inner.channel().on_closed()
6471    }
6472
6473    #[cfg(target_os = "fuchsia")]
6474    fn signal_peer(
6475        &self,
6476        clear_mask: zx::Signals,
6477        set_mask: zx::Signals,
6478    ) -> Result<(), zx_status::Status> {
6479        use fidl::Peered;
6480        self.inner.channel().signal_peer(clear_mask, set_mask)
6481    }
6482}
6483
6484impl PairingRequestControlHandle {
6485    pub fn send_on_keypress(&self, mut keypress: PairingKeypress) -> Result<(), fidl::Error> {
6486        self.inner.send::<PairingRequestOnKeypressRequest>(
6487            (keypress,),
6488            0,
6489            0x71a4802e6a5d1aca,
6490            fidl::encoding::DynamicFlags::empty(),
6491        )
6492    }
6493
6494    pub fn send_on_complete(&self, mut success: bool) -> Result<(), fidl::Error> {
6495        self.inner.send::<PairingRequestOnCompleteRequest>(
6496            (success,),
6497            0,
6498            0xd38d3220987bc79,
6499            fidl::encoding::DynamicFlags::empty(),
6500        )
6501    }
6502}
6503
6504#[must_use = "FIDL methods require a response to be sent"]
6505#[derive(Debug)]
6506pub struct PairingRequestKeypressResponder {
6507    control_handle: std::mem::ManuallyDrop<PairingRequestControlHandle>,
6508    tx_id: u32,
6509}
6510
6511/// Set the the channel to be shutdown (see [`PairingRequestControlHandle::shutdown`])
6512/// if the responder is dropped without sending a response, so that the client
6513/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6514impl std::ops::Drop for PairingRequestKeypressResponder {
6515    fn drop(&mut self) {
6516        self.control_handle.shutdown();
6517        // Safety: drops once, never accessed again
6518        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6519    }
6520}
6521
6522impl fidl::endpoints::Responder for PairingRequestKeypressResponder {
6523    type ControlHandle = PairingRequestControlHandle;
6524
6525    fn control_handle(&self) -> &PairingRequestControlHandle {
6526        &self.control_handle
6527    }
6528
6529    fn drop_without_shutdown(mut self) {
6530        // Safety: drops once, never accessed again due to mem::forget
6531        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6532        // Prevent Drop from running (which would shut down the channel)
6533        std::mem::forget(self);
6534    }
6535}
6536
6537impl PairingRequestKeypressResponder {
6538    /// Sends a response to the FIDL transaction.
6539    ///
6540    /// Sets the channel to shutdown if an error occurs.
6541    pub fn send(self) -> Result<(), fidl::Error> {
6542        let _result = self.send_raw();
6543        if _result.is_err() {
6544            self.control_handle.shutdown();
6545        }
6546        self.drop_without_shutdown();
6547        _result
6548    }
6549
6550    /// Similar to "send" but does not shutdown the channel if an error occurs.
6551    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6552        let _result = self.send_raw();
6553        self.drop_without_shutdown();
6554        _result
6555    }
6556
6557    fn send_raw(&self) -> Result<(), fidl::Error> {
6558        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6559            (),
6560            self.tx_id,
6561            0x53948ecc921fbe9b,
6562            fidl::encoding::DynamicFlags::empty(),
6563        )
6564    }
6565}
6566
6567#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6568pub struct ProcedureTokenMarker;
6569
6570impl fidl::endpoints::ProtocolMarker for ProcedureTokenMarker {
6571    type Proxy = ProcedureTokenProxy;
6572    type RequestStream = ProcedureTokenRequestStream;
6573    #[cfg(target_os = "fuchsia")]
6574    type SynchronousProxy = ProcedureTokenSynchronousProxy;
6575
6576    const DEBUG_NAME: &'static str = "(anonymous) ProcedureToken";
6577}
6578
6579pub trait ProcedureTokenProxyInterface: Send + Sync {}
6580#[derive(Debug)]
6581#[cfg(target_os = "fuchsia")]
6582pub struct ProcedureTokenSynchronousProxy {
6583    client: fidl::client::sync::Client,
6584}
6585
6586#[cfg(target_os = "fuchsia")]
6587impl fidl::endpoints::SynchronousProxy for ProcedureTokenSynchronousProxy {
6588    type Proxy = ProcedureTokenProxy;
6589    type Protocol = ProcedureTokenMarker;
6590
6591    fn from_channel(inner: fidl::Channel) -> Self {
6592        Self::new(inner)
6593    }
6594
6595    fn into_channel(self) -> fidl::Channel {
6596        self.client.into_channel()
6597    }
6598
6599    fn as_channel(&self) -> &fidl::Channel {
6600        self.client.as_channel()
6601    }
6602}
6603
6604#[cfg(target_os = "fuchsia")]
6605impl ProcedureTokenSynchronousProxy {
6606    pub fn new(channel: fidl::Channel) -> Self {
6607        let protocol_name = <ProcedureTokenMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6608        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6609    }
6610
6611    pub fn into_channel(self) -> fidl::Channel {
6612        self.client.into_channel()
6613    }
6614
6615    /// Waits until an event arrives and returns it. It is safe for other
6616    /// threads to make concurrent requests while waiting for an event.
6617    pub fn wait_for_event(
6618        &self,
6619        deadline: zx::MonotonicInstant,
6620    ) -> Result<ProcedureTokenEvent, fidl::Error> {
6621        ProcedureTokenEvent::decode(self.client.wait_for_event(deadline)?)
6622    }
6623}
6624
6625#[cfg(target_os = "fuchsia")]
6626impl From<ProcedureTokenSynchronousProxy> for zx::Handle {
6627    fn from(value: ProcedureTokenSynchronousProxy) -> Self {
6628        value.into_channel().into()
6629    }
6630}
6631
6632#[cfg(target_os = "fuchsia")]
6633impl From<fidl::Channel> for ProcedureTokenSynchronousProxy {
6634    fn from(value: fidl::Channel) -> Self {
6635        Self::new(value)
6636    }
6637}
6638
6639#[derive(Debug, Clone)]
6640pub struct ProcedureTokenProxy {
6641    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6642}
6643
6644impl fidl::endpoints::Proxy for ProcedureTokenProxy {
6645    type Protocol = ProcedureTokenMarker;
6646
6647    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6648        Self::new(inner)
6649    }
6650
6651    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6652        self.client.into_channel().map_err(|client| Self { client })
6653    }
6654
6655    fn as_channel(&self) -> &::fidl::AsyncChannel {
6656        self.client.as_channel()
6657    }
6658}
6659
6660impl ProcedureTokenProxy {
6661    /// Create a new Proxy for fuchsia.bluetooth.sys/ProcedureToken.
6662    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6663        let protocol_name = <ProcedureTokenMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6664        Self { client: fidl::client::Client::new(channel, protocol_name) }
6665    }
6666
6667    /// Get a Stream of events from the remote end of the protocol.
6668    ///
6669    /// # Panics
6670    ///
6671    /// Panics if the event stream was already taken.
6672    pub fn take_event_stream(&self) -> ProcedureTokenEventStream {
6673        ProcedureTokenEventStream { event_receiver: self.client.take_event_receiver() }
6674    }
6675}
6676
6677impl ProcedureTokenProxyInterface for ProcedureTokenProxy {}
6678
6679pub struct ProcedureTokenEventStream {
6680    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6681}
6682
6683impl std::marker::Unpin for ProcedureTokenEventStream {}
6684
6685impl futures::stream::FusedStream for ProcedureTokenEventStream {
6686    fn is_terminated(&self) -> bool {
6687        self.event_receiver.is_terminated()
6688    }
6689}
6690
6691impl futures::Stream for ProcedureTokenEventStream {
6692    type Item = Result<ProcedureTokenEvent, fidl::Error>;
6693
6694    fn poll_next(
6695        mut self: std::pin::Pin<&mut Self>,
6696        cx: &mut std::task::Context<'_>,
6697    ) -> std::task::Poll<Option<Self::Item>> {
6698        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6699            &mut self.event_receiver,
6700            cx
6701        )?) {
6702            Some(buf) => std::task::Poll::Ready(Some(ProcedureTokenEvent::decode(buf))),
6703            None => std::task::Poll::Ready(None),
6704        }
6705    }
6706}
6707
6708#[derive(Debug)]
6709pub enum ProcedureTokenEvent {}
6710
6711impl ProcedureTokenEvent {
6712    /// Decodes a message buffer as a [`ProcedureTokenEvent`].
6713    fn decode(
6714        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6715    ) -> Result<ProcedureTokenEvent, fidl::Error> {
6716        let (bytes, _handles) = buf.split_mut();
6717        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6718        debug_assert_eq!(tx_header.tx_id, 0);
6719        match tx_header.ordinal {
6720            _ => Err(fidl::Error::UnknownOrdinal {
6721                ordinal: tx_header.ordinal,
6722                protocol_name:
6723                    <ProcedureTokenMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6724            }),
6725        }
6726    }
6727}
6728
6729/// A Stream of incoming requests for fuchsia.bluetooth.sys/ProcedureToken.
6730pub struct ProcedureTokenRequestStream {
6731    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6732    is_terminated: bool,
6733}
6734
6735impl std::marker::Unpin for ProcedureTokenRequestStream {}
6736
6737impl futures::stream::FusedStream for ProcedureTokenRequestStream {
6738    fn is_terminated(&self) -> bool {
6739        self.is_terminated
6740    }
6741}
6742
6743impl fidl::endpoints::RequestStream for ProcedureTokenRequestStream {
6744    type Protocol = ProcedureTokenMarker;
6745    type ControlHandle = ProcedureTokenControlHandle;
6746
6747    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6748        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6749    }
6750
6751    fn control_handle(&self) -> Self::ControlHandle {
6752        ProcedureTokenControlHandle { inner: self.inner.clone() }
6753    }
6754
6755    fn into_inner(
6756        self,
6757    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6758    {
6759        (self.inner, self.is_terminated)
6760    }
6761
6762    fn from_inner(
6763        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6764        is_terminated: bool,
6765    ) -> Self {
6766        Self { inner, is_terminated }
6767    }
6768}
6769
6770impl futures::Stream for ProcedureTokenRequestStream {
6771    type Item = Result<ProcedureTokenRequest, fidl::Error>;
6772
6773    fn poll_next(
6774        mut self: std::pin::Pin<&mut Self>,
6775        cx: &mut std::task::Context<'_>,
6776    ) -> std::task::Poll<Option<Self::Item>> {
6777        let this = &mut *self;
6778        if this.inner.check_shutdown(cx) {
6779            this.is_terminated = true;
6780            return std::task::Poll::Ready(None);
6781        }
6782        if this.is_terminated {
6783            panic!("polled ProcedureTokenRequestStream after completion");
6784        }
6785        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6786            |bytes, handles| {
6787                match this.inner.channel().read_etc(cx, bytes, handles) {
6788                    std::task::Poll::Ready(Ok(())) => {}
6789                    std::task::Poll::Pending => return std::task::Poll::Pending,
6790                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6791                        this.is_terminated = true;
6792                        return std::task::Poll::Ready(None);
6793                    }
6794                    std::task::Poll::Ready(Err(e)) => {
6795                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6796                            e.into(),
6797                        ))))
6798                    }
6799                }
6800
6801                // A message has been received from the channel
6802                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6803
6804                std::task::Poll::Ready(Some(match header.ordinal {
6805                    _ => Err(fidl::Error::UnknownOrdinal {
6806                        ordinal: header.ordinal,
6807                        protocol_name:
6808                            <ProcedureTokenMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6809                    }),
6810                }))
6811            },
6812        )
6813    }
6814}
6815
6816/// Represents an active procedure. The validity of a handle that supports this protocol is tied to
6817/// the activity of the procedure that it is attached to. To elaborate:
6818///
6819///   1. Closing a token handle ends the procedure that it is attached to.
6820///   2. The system closes a token handle to communicate that a procedure was internally terminated.
6821#[derive(Debug)]
6822pub enum ProcedureTokenRequest {}
6823
6824impl ProcedureTokenRequest {
6825    /// Name of the method defined in FIDL
6826    pub fn method_name(&self) -> &'static str {
6827        match *self {}
6828    }
6829}
6830
6831#[derive(Debug, Clone)]
6832pub struct ProcedureTokenControlHandle {
6833    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6834}
6835
6836impl fidl::endpoints::ControlHandle for ProcedureTokenControlHandle {
6837    fn shutdown(&self) {
6838        self.inner.shutdown()
6839    }
6840    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6841        self.inner.shutdown_with_epitaph(status)
6842    }
6843
6844    fn is_closed(&self) -> bool {
6845        self.inner.channel().is_closed()
6846    }
6847    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6848        self.inner.channel().on_closed()
6849    }
6850
6851    #[cfg(target_os = "fuchsia")]
6852    fn signal_peer(
6853        &self,
6854        clear_mask: zx::Signals,
6855        set_mask: zx::Signals,
6856    ) -> Result<(), zx_status::Status> {
6857        use fidl::Peered;
6858        self.inner.channel().signal_peer(clear_mask, set_mask)
6859    }
6860}
6861
6862impl ProcedureTokenControlHandle {}
6863
6864mod internal {
6865    use super::*;
6866
6867    impl fidl::encoding::ResourceTypeMarker for AccessMakeDiscoverableRequest {
6868        type Borrowed<'a> = &'a mut Self;
6869        fn take_or_borrow<'a>(
6870            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6871        ) -> Self::Borrowed<'a> {
6872            value
6873        }
6874    }
6875
6876    unsafe impl fidl::encoding::TypeMarker for AccessMakeDiscoverableRequest {
6877        type Owned = Self;
6878
6879        #[inline(always)]
6880        fn inline_align(_context: fidl::encoding::Context) -> usize {
6881            4
6882        }
6883
6884        #[inline(always)]
6885        fn inline_size(_context: fidl::encoding::Context) -> usize {
6886            4
6887        }
6888    }
6889
6890    unsafe impl
6891        fidl::encoding::Encode<
6892            AccessMakeDiscoverableRequest,
6893            fidl::encoding::DefaultFuchsiaResourceDialect,
6894        > for &mut AccessMakeDiscoverableRequest
6895    {
6896        #[inline]
6897        unsafe fn encode(
6898            self,
6899            encoder: &mut fidl::encoding::Encoder<
6900                '_,
6901                fidl::encoding::DefaultFuchsiaResourceDialect,
6902            >,
6903            offset: usize,
6904            _depth: fidl::encoding::Depth,
6905        ) -> fidl::Result<()> {
6906            encoder.debug_check_bounds::<AccessMakeDiscoverableRequest>(offset);
6907            // Delegate to tuple encoding.
6908            fidl::encoding::Encode::<AccessMakeDiscoverableRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6909                (
6910                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ProcedureTokenMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
6911                ),
6912                encoder, offset, _depth
6913            )
6914        }
6915    }
6916    unsafe impl<
6917            T0: fidl::encoding::Encode<
6918                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ProcedureTokenMarker>>,
6919                fidl::encoding::DefaultFuchsiaResourceDialect,
6920            >,
6921        >
6922        fidl::encoding::Encode<
6923            AccessMakeDiscoverableRequest,
6924            fidl::encoding::DefaultFuchsiaResourceDialect,
6925        > for (T0,)
6926    {
6927        #[inline]
6928        unsafe fn encode(
6929            self,
6930            encoder: &mut fidl::encoding::Encoder<
6931                '_,
6932                fidl::encoding::DefaultFuchsiaResourceDialect,
6933            >,
6934            offset: usize,
6935            depth: fidl::encoding::Depth,
6936        ) -> fidl::Result<()> {
6937            encoder.debug_check_bounds::<AccessMakeDiscoverableRequest>(offset);
6938            // Zero out padding regions. There's no need to apply masks
6939            // because the unmasked parts will be overwritten by fields.
6940            // Write the fields.
6941            self.0.encode(encoder, offset + 0, depth)?;
6942            Ok(())
6943        }
6944    }
6945
6946    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6947        for AccessMakeDiscoverableRequest
6948    {
6949        #[inline(always)]
6950        fn new_empty() -> Self {
6951            Self {
6952                token: fidl::new_empty!(
6953                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ProcedureTokenMarker>>,
6954                    fidl::encoding::DefaultFuchsiaResourceDialect
6955                ),
6956            }
6957        }
6958
6959        #[inline]
6960        unsafe fn decode(
6961            &mut self,
6962            decoder: &mut fidl::encoding::Decoder<
6963                '_,
6964                fidl::encoding::DefaultFuchsiaResourceDialect,
6965            >,
6966            offset: usize,
6967            _depth: fidl::encoding::Depth,
6968        ) -> fidl::Result<()> {
6969            decoder.debug_check_bounds::<Self>(offset);
6970            // Verify that padding bytes are zero.
6971            fidl::decode!(
6972                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ProcedureTokenMarker>>,
6973                fidl::encoding::DefaultFuchsiaResourceDialect,
6974                &mut self.token,
6975                decoder,
6976                offset + 0,
6977                _depth
6978            )?;
6979            Ok(())
6980        }
6981    }
6982
6983    impl fidl::encoding::ResourceTypeMarker for AccessSetPairingDelegateRequest {
6984        type Borrowed<'a> = &'a mut Self;
6985        fn take_or_borrow<'a>(
6986            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6987        ) -> Self::Borrowed<'a> {
6988            value
6989        }
6990    }
6991
6992    unsafe impl fidl::encoding::TypeMarker for AccessSetPairingDelegateRequest {
6993        type Owned = Self;
6994
6995        #[inline(always)]
6996        fn inline_align(_context: fidl::encoding::Context) -> usize {
6997            4
6998        }
6999
7000        #[inline(always)]
7001        fn inline_size(_context: fidl::encoding::Context) -> usize {
7002            12
7003        }
7004    }
7005
7006    unsafe impl
7007        fidl::encoding::Encode<
7008            AccessSetPairingDelegateRequest,
7009            fidl::encoding::DefaultFuchsiaResourceDialect,
7010        > for &mut AccessSetPairingDelegateRequest
7011    {
7012        #[inline]
7013        unsafe fn encode(
7014            self,
7015            encoder: &mut fidl::encoding::Encoder<
7016                '_,
7017                fidl::encoding::DefaultFuchsiaResourceDialect,
7018            >,
7019            offset: usize,
7020            _depth: fidl::encoding::Depth,
7021        ) -> fidl::Result<()> {
7022            encoder.debug_check_bounds::<AccessSetPairingDelegateRequest>(offset);
7023            // Delegate to tuple encoding.
7024            fidl::encoding::Encode::<AccessSetPairingDelegateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7025                (
7026                    <InputCapability as fidl::encoding::ValueTypeMarker>::borrow(&self.input),
7027                    <OutputCapability as fidl::encoding::ValueTypeMarker>::borrow(&self.output),
7028                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PairingDelegateMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.delegate),
7029                ),
7030                encoder, offset, _depth
7031            )
7032        }
7033    }
7034    unsafe impl<
7035            T0: fidl::encoding::Encode<InputCapability, fidl::encoding::DefaultFuchsiaResourceDialect>,
7036            T1: fidl::encoding::Encode<OutputCapability, fidl::encoding::DefaultFuchsiaResourceDialect>,
7037            T2: fidl::encoding::Encode<
7038                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PairingDelegateMarker>>,
7039                fidl::encoding::DefaultFuchsiaResourceDialect,
7040            >,
7041        >
7042        fidl::encoding::Encode<
7043            AccessSetPairingDelegateRequest,
7044            fidl::encoding::DefaultFuchsiaResourceDialect,
7045        > for (T0, T1, T2)
7046    {
7047        #[inline]
7048        unsafe fn encode(
7049            self,
7050            encoder: &mut fidl::encoding::Encoder<
7051                '_,
7052                fidl::encoding::DefaultFuchsiaResourceDialect,
7053            >,
7054            offset: usize,
7055            depth: fidl::encoding::Depth,
7056        ) -> fidl::Result<()> {
7057            encoder.debug_check_bounds::<AccessSetPairingDelegateRequest>(offset);
7058            // Zero out padding regions. There's no need to apply masks
7059            // because the unmasked parts will be overwritten by fields.
7060            // Write the fields.
7061            self.0.encode(encoder, offset + 0, depth)?;
7062            self.1.encode(encoder, offset + 4, depth)?;
7063            self.2.encode(encoder, offset + 8, depth)?;
7064            Ok(())
7065        }
7066    }
7067
7068    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7069        for AccessSetPairingDelegateRequest
7070    {
7071        #[inline(always)]
7072        fn new_empty() -> Self {
7073            Self {
7074                input: fidl::new_empty!(
7075                    InputCapability,
7076                    fidl::encoding::DefaultFuchsiaResourceDialect
7077                ),
7078                output: fidl::new_empty!(
7079                    OutputCapability,
7080                    fidl::encoding::DefaultFuchsiaResourceDialect
7081                ),
7082                delegate: fidl::new_empty!(
7083                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PairingDelegateMarker>>,
7084                    fidl::encoding::DefaultFuchsiaResourceDialect
7085                ),
7086            }
7087        }
7088
7089        #[inline]
7090        unsafe fn decode(
7091            &mut self,
7092            decoder: &mut fidl::encoding::Decoder<
7093                '_,
7094                fidl::encoding::DefaultFuchsiaResourceDialect,
7095            >,
7096            offset: usize,
7097            _depth: fidl::encoding::Depth,
7098        ) -> fidl::Result<()> {
7099            decoder.debug_check_bounds::<Self>(offset);
7100            // Verify that padding bytes are zero.
7101            fidl::decode!(
7102                InputCapability,
7103                fidl::encoding::DefaultFuchsiaResourceDialect,
7104                &mut self.input,
7105                decoder,
7106                offset + 0,
7107                _depth
7108            )?;
7109            fidl::decode!(
7110                OutputCapability,
7111                fidl::encoding::DefaultFuchsiaResourceDialect,
7112                &mut self.output,
7113                decoder,
7114                offset + 4,
7115                _depth
7116            )?;
7117            fidl::decode!(
7118                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PairingDelegateMarker>>,
7119                fidl::encoding::DefaultFuchsiaResourceDialect,
7120                &mut self.delegate,
7121                decoder,
7122                offset + 8,
7123                _depth
7124            )?;
7125            Ok(())
7126        }
7127    }
7128
7129    impl fidl::encoding::ResourceTypeMarker for AccessStartDiscoveryRequest {
7130        type Borrowed<'a> = &'a mut Self;
7131        fn take_or_borrow<'a>(
7132            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7133        ) -> Self::Borrowed<'a> {
7134            value
7135        }
7136    }
7137
7138    unsafe impl fidl::encoding::TypeMarker for AccessStartDiscoveryRequest {
7139        type Owned = Self;
7140
7141        #[inline(always)]
7142        fn inline_align(_context: fidl::encoding::Context) -> usize {
7143            4
7144        }
7145
7146        #[inline(always)]
7147        fn inline_size(_context: fidl::encoding::Context) -> usize {
7148            4
7149        }
7150    }
7151
7152    unsafe impl
7153        fidl::encoding::Encode<
7154            AccessStartDiscoveryRequest,
7155            fidl::encoding::DefaultFuchsiaResourceDialect,
7156        > for &mut AccessStartDiscoveryRequest
7157    {
7158        #[inline]
7159        unsafe fn encode(
7160            self,
7161            encoder: &mut fidl::encoding::Encoder<
7162                '_,
7163                fidl::encoding::DefaultFuchsiaResourceDialect,
7164            >,
7165            offset: usize,
7166            _depth: fidl::encoding::Depth,
7167        ) -> fidl::Result<()> {
7168            encoder.debug_check_bounds::<AccessStartDiscoveryRequest>(offset);
7169            // Delegate to tuple encoding.
7170            fidl::encoding::Encode::<AccessStartDiscoveryRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7171                (
7172                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ProcedureTokenMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
7173                ),
7174                encoder, offset, _depth
7175            )
7176        }
7177    }
7178    unsafe impl<
7179            T0: fidl::encoding::Encode<
7180                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ProcedureTokenMarker>>,
7181                fidl::encoding::DefaultFuchsiaResourceDialect,
7182            >,
7183        >
7184        fidl::encoding::Encode<
7185            AccessStartDiscoveryRequest,
7186            fidl::encoding::DefaultFuchsiaResourceDialect,
7187        > for (T0,)
7188    {
7189        #[inline]
7190        unsafe fn encode(
7191            self,
7192            encoder: &mut fidl::encoding::Encoder<
7193                '_,
7194                fidl::encoding::DefaultFuchsiaResourceDialect,
7195            >,
7196            offset: usize,
7197            depth: fidl::encoding::Depth,
7198        ) -> fidl::Result<()> {
7199            encoder.debug_check_bounds::<AccessStartDiscoveryRequest>(offset);
7200            // Zero out padding regions. There's no need to apply masks
7201            // because the unmasked parts will be overwritten by fields.
7202            // Write the fields.
7203            self.0.encode(encoder, offset + 0, depth)?;
7204            Ok(())
7205        }
7206    }
7207
7208    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7209        for AccessStartDiscoveryRequest
7210    {
7211        #[inline(always)]
7212        fn new_empty() -> Self {
7213            Self {
7214                token: fidl::new_empty!(
7215                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ProcedureTokenMarker>>,
7216                    fidl::encoding::DefaultFuchsiaResourceDialect
7217                ),
7218            }
7219        }
7220
7221        #[inline]
7222        unsafe fn decode(
7223            &mut self,
7224            decoder: &mut fidl::encoding::Decoder<
7225                '_,
7226                fidl::encoding::DefaultFuchsiaResourceDialect,
7227            >,
7228            offset: usize,
7229            _depth: fidl::encoding::Depth,
7230        ) -> fidl::Result<()> {
7231            decoder.debug_check_bounds::<Self>(offset);
7232            // Verify that padding bytes are zero.
7233            fidl::decode!(
7234                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ProcedureTokenMarker>>,
7235                fidl::encoding::DefaultFuchsiaResourceDialect,
7236                &mut self.token,
7237                decoder,
7238                offset + 0,
7239                _depth
7240            )?;
7241            Ok(())
7242        }
7243    }
7244
7245    impl fidl::encoding::ResourceTypeMarker for PairingSetDelegateRequest {
7246        type Borrowed<'a> = &'a mut Self;
7247        fn take_or_borrow<'a>(
7248            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7249        ) -> Self::Borrowed<'a> {
7250            value
7251        }
7252    }
7253
7254    unsafe impl fidl::encoding::TypeMarker for PairingSetDelegateRequest {
7255        type Owned = Self;
7256
7257        #[inline(always)]
7258        fn inline_align(_context: fidl::encoding::Context) -> usize {
7259            4
7260        }
7261
7262        #[inline(always)]
7263        fn inline_size(_context: fidl::encoding::Context) -> usize {
7264            12
7265        }
7266    }
7267
7268    unsafe impl
7269        fidl::encoding::Encode<
7270            PairingSetDelegateRequest,
7271            fidl::encoding::DefaultFuchsiaResourceDialect,
7272        > for &mut PairingSetDelegateRequest
7273    {
7274        #[inline]
7275        unsafe fn encode(
7276            self,
7277            encoder: &mut fidl::encoding::Encoder<
7278                '_,
7279                fidl::encoding::DefaultFuchsiaResourceDialect,
7280            >,
7281            offset: usize,
7282            _depth: fidl::encoding::Depth,
7283        ) -> fidl::Result<()> {
7284            encoder.debug_check_bounds::<PairingSetDelegateRequest>(offset);
7285            // Delegate to tuple encoding.
7286            fidl::encoding::Encode::<PairingSetDelegateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7287                (
7288                    <InputCapability as fidl::encoding::ValueTypeMarker>::borrow(&self.input),
7289                    <OutputCapability as fidl::encoding::ValueTypeMarker>::borrow(&self.output),
7290                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PairingDelegate2Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.delegate),
7291                ),
7292                encoder, offset, _depth
7293            )
7294        }
7295    }
7296    unsafe impl<
7297            T0: fidl::encoding::Encode<InputCapability, fidl::encoding::DefaultFuchsiaResourceDialect>,
7298            T1: fidl::encoding::Encode<OutputCapability, fidl::encoding::DefaultFuchsiaResourceDialect>,
7299            T2: fidl::encoding::Encode<
7300                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PairingDelegate2Marker>>,
7301                fidl::encoding::DefaultFuchsiaResourceDialect,
7302            >,
7303        >
7304        fidl::encoding::Encode<
7305            PairingSetDelegateRequest,
7306            fidl::encoding::DefaultFuchsiaResourceDialect,
7307        > for (T0, T1, T2)
7308    {
7309        #[inline]
7310        unsafe fn encode(
7311            self,
7312            encoder: &mut fidl::encoding::Encoder<
7313                '_,
7314                fidl::encoding::DefaultFuchsiaResourceDialect,
7315            >,
7316            offset: usize,
7317            depth: fidl::encoding::Depth,
7318        ) -> fidl::Result<()> {
7319            encoder.debug_check_bounds::<PairingSetDelegateRequest>(offset);
7320            // Zero out padding regions. There's no need to apply masks
7321            // because the unmasked parts will be overwritten by fields.
7322            // Write the fields.
7323            self.0.encode(encoder, offset + 0, depth)?;
7324            self.1.encode(encoder, offset + 4, depth)?;
7325            self.2.encode(encoder, offset + 8, depth)?;
7326            Ok(())
7327        }
7328    }
7329
7330    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7331        for PairingSetDelegateRequest
7332    {
7333        #[inline(always)]
7334        fn new_empty() -> Self {
7335            Self {
7336                input: fidl::new_empty!(
7337                    InputCapability,
7338                    fidl::encoding::DefaultFuchsiaResourceDialect
7339                ),
7340                output: fidl::new_empty!(
7341                    OutputCapability,
7342                    fidl::encoding::DefaultFuchsiaResourceDialect
7343                ),
7344                delegate: fidl::new_empty!(
7345                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PairingDelegate2Marker>>,
7346                    fidl::encoding::DefaultFuchsiaResourceDialect
7347                ),
7348            }
7349        }
7350
7351        #[inline]
7352        unsafe fn decode(
7353            &mut self,
7354            decoder: &mut fidl::encoding::Decoder<
7355                '_,
7356                fidl::encoding::DefaultFuchsiaResourceDialect,
7357            >,
7358            offset: usize,
7359            _depth: fidl::encoding::Depth,
7360        ) -> fidl::Result<()> {
7361            decoder.debug_check_bounds::<Self>(offset);
7362            // Verify that padding bytes are zero.
7363            fidl::decode!(
7364                InputCapability,
7365                fidl::encoding::DefaultFuchsiaResourceDialect,
7366                &mut self.input,
7367                decoder,
7368                offset + 0,
7369                _depth
7370            )?;
7371            fidl::decode!(
7372                OutputCapability,
7373                fidl::encoding::DefaultFuchsiaResourceDialect,
7374                &mut self.output,
7375                decoder,
7376                offset + 4,
7377                _depth
7378            )?;
7379            fidl::decode!(
7380                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PairingDelegate2Marker>>,
7381                fidl::encoding::DefaultFuchsiaResourceDialect,
7382                &mut self.delegate,
7383                decoder,
7384                offset + 8,
7385                _depth
7386            )?;
7387            Ok(())
7388        }
7389    }
7390
7391    impl fidl::encoding::ResourceTypeMarker for PairingSetPairingDelegateRequest {
7392        type Borrowed<'a> = &'a mut Self;
7393        fn take_or_borrow<'a>(
7394            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7395        ) -> Self::Borrowed<'a> {
7396            value
7397        }
7398    }
7399
7400    unsafe impl fidl::encoding::TypeMarker for PairingSetPairingDelegateRequest {
7401        type Owned = Self;
7402
7403        #[inline(always)]
7404        fn inline_align(_context: fidl::encoding::Context) -> usize {
7405            4
7406        }
7407
7408        #[inline(always)]
7409        fn inline_size(_context: fidl::encoding::Context) -> usize {
7410            12
7411        }
7412    }
7413
7414    unsafe impl
7415        fidl::encoding::Encode<
7416            PairingSetPairingDelegateRequest,
7417            fidl::encoding::DefaultFuchsiaResourceDialect,
7418        > for &mut PairingSetPairingDelegateRequest
7419    {
7420        #[inline]
7421        unsafe fn encode(
7422            self,
7423            encoder: &mut fidl::encoding::Encoder<
7424                '_,
7425                fidl::encoding::DefaultFuchsiaResourceDialect,
7426            >,
7427            offset: usize,
7428            _depth: fidl::encoding::Depth,
7429        ) -> fidl::Result<()> {
7430            encoder.debug_check_bounds::<PairingSetPairingDelegateRequest>(offset);
7431            // Delegate to tuple encoding.
7432            fidl::encoding::Encode::<PairingSetPairingDelegateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7433                (
7434                    <InputCapability as fidl::encoding::ValueTypeMarker>::borrow(&self.input),
7435                    <OutputCapability as fidl::encoding::ValueTypeMarker>::borrow(&self.output),
7436                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PairingDelegateMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.delegate),
7437                ),
7438                encoder, offset, _depth
7439            )
7440        }
7441    }
7442    unsafe impl<
7443            T0: fidl::encoding::Encode<InputCapability, fidl::encoding::DefaultFuchsiaResourceDialect>,
7444            T1: fidl::encoding::Encode<OutputCapability, fidl::encoding::DefaultFuchsiaResourceDialect>,
7445            T2: fidl::encoding::Encode<
7446                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PairingDelegateMarker>>,
7447                fidl::encoding::DefaultFuchsiaResourceDialect,
7448            >,
7449        >
7450        fidl::encoding::Encode<
7451            PairingSetPairingDelegateRequest,
7452            fidl::encoding::DefaultFuchsiaResourceDialect,
7453        > for (T0, T1, T2)
7454    {
7455        #[inline]
7456        unsafe fn encode(
7457            self,
7458            encoder: &mut fidl::encoding::Encoder<
7459                '_,
7460                fidl::encoding::DefaultFuchsiaResourceDialect,
7461            >,
7462            offset: usize,
7463            depth: fidl::encoding::Depth,
7464        ) -> fidl::Result<()> {
7465            encoder.debug_check_bounds::<PairingSetPairingDelegateRequest>(offset);
7466            // Zero out padding regions. There's no need to apply masks
7467            // because the unmasked parts will be overwritten by fields.
7468            // Write the fields.
7469            self.0.encode(encoder, offset + 0, depth)?;
7470            self.1.encode(encoder, offset + 4, depth)?;
7471            self.2.encode(encoder, offset + 8, depth)?;
7472            Ok(())
7473        }
7474    }
7475
7476    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7477        for PairingSetPairingDelegateRequest
7478    {
7479        #[inline(always)]
7480        fn new_empty() -> Self {
7481            Self {
7482                input: fidl::new_empty!(
7483                    InputCapability,
7484                    fidl::encoding::DefaultFuchsiaResourceDialect
7485                ),
7486                output: fidl::new_empty!(
7487                    OutputCapability,
7488                    fidl::encoding::DefaultFuchsiaResourceDialect
7489                ),
7490                delegate: fidl::new_empty!(
7491                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PairingDelegateMarker>>,
7492                    fidl::encoding::DefaultFuchsiaResourceDialect
7493                ),
7494            }
7495        }
7496
7497        #[inline]
7498        unsafe fn decode(
7499            &mut self,
7500            decoder: &mut fidl::encoding::Decoder<
7501                '_,
7502                fidl::encoding::DefaultFuchsiaResourceDialect,
7503            >,
7504            offset: usize,
7505            _depth: fidl::encoding::Depth,
7506        ) -> fidl::Result<()> {
7507            decoder.debug_check_bounds::<Self>(offset);
7508            // Verify that padding bytes are zero.
7509            fidl::decode!(
7510                InputCapability,
7511                fidl::encoding::DefaultFuchsiaResourceDialect,
7512                &mut self.input,
7513                decoder,
7514                offset + 0,
7515                _depth
7516            )?;
7517            fidl::decode!(
7518                OutputCapability,
7519                fidl::encoding::DefaultFuchsiaResourceDialect,
7520                &mut self.output,
7521                decoder,
7522                offset + 4,
7523                _depth
7524            )?;
7525            fidl::decode!(
7526                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PairingDelegateMarker>>,
7527                fidl::encoding::DefaultFuchsiaResourceDialect,
7528                &mut self.delegate,
7529                decoder,
7530                offset + 8,
7531                _depth
7532            )?;
7533            Ok(())
7534        }
7535    }
7536
7537    impl AccessSetConnectionPolicyRequest {
7538        #[inline(always)]
7539        fn max_ordinal_present(&self) -> u64 {
7540            if let Some(_) = self.suppress_bredr_connections {
7541                return 1;
7542            }
7543            0
7544        }
7545    }
7546
7547    impl fidl::encoding::ResourceTypeMarker for AccessSetConnectionPolicyRequest {
7548        type Borrowed<'a> = &'a mut Self;
7549        fn take_or_borrow<'a>(
7550            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7551        ) -> Self::Borrowed<'a> {
7552            value
7553        }
7554    }
7555
7556    unsafe impl fidl::encoding::TypeMarker for AccessSetConnectionPolicyRequest {
7557        type Owned = Self;
7558
7559        #[inline(always)]
7560        fn inline_align(_context: fidl::encoding::Context) -> usize {
7561            8
7562        }
7563
7564        #[inline(always)]
7565        fn inline_size(_context: fidl::encoding::Context) -> usize {
7566            16
7567        }
7568    }
7569
7570    unsafe impl
7571        fidl::encoding::Encode<
7572            AccessSetConnectionPolicyRequest,
7573            fidl::encoding::DefaultFuchsiaResourceDialect,
7574        > for &mut AccessSetConnectionPolicyRequest
7575    {
7576        unsafe fn encode(
7577            self,
7578            encoder: &mut fidl::encoding::Encoder<
7579                '_,
7580                fidl::encoding::DefaultFuchsiaResourceDialect,
7581            >,
7582            offset: usize,
7583            mut depth: fidl::encoding::Depth,
7584        ) -> fidl::Result<()> {
7585            encoder.debug_check_bounds::<AccessSetConnectionPolicyRequest>(offset);
7586            // Vector header
7587            let max_ordinal: u64 = self.max_ordinal_present();
7588            encoder.write_num(max_ordinal, offset);
7589            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7590            // Calling encoder.out_of_line_offset(0) is not allowed.
7591            if max_ordinal == 0 {
7592                return Ok(());
7593            }
7594            depth.increment()?;
7595            let envelope_size = 8;
7596            let bytes_len = max_ordinal as usize * envelope_size;
7597            #[allow(unused_variables)]
7598            let offset = encoder.out_of_line_offset(bytes_len);
7599            let mut _prev_end_offset: usize = 0;
7600            if 1 > max_ordinal {
7601                return Ok(());
7602            }
7603
7604            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7605            // are envelope_size bytes.
7606            let cur_offset: usize = (1 - 1) * envelope_size;
7607
7608            // Zero reserved fields.
7609            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7610
7611            // Safety:
7612            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7613            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7614            //   envelope_size bytes, there is always sufficient room.
7615            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ProcedureTokenMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
7616            self.suppress_bredr_connections.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ProcedureTokenMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
7617            encoder, offset + cur_offset, depth
7618        )?;
7619
7620            _prev_end_offset = cur_offset + envelope_size;
7621
7622            Ok(())
7623        }
7624    }
7625
7626    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7627        for AccessSetConnectionPolicyRequest
7628    {
7629        #[inline(always)]
7630        fn new_empty() -> Self {
7631            Self::default()
7632        }
7633
7634        unsafe fn decode(
7635            &mut self,
7636            decoder: &mut fidl::encoding::Decoder<
7637                '_,
7638                fidl::encoding::DefaultFuchsiaResourceDialect,
7639            >,
7640            offset: usize,
7641            mut depth: fidl::encoding::Depth,
7642        ) -> fidl::Result<()> {
7643            decoder.debug_check_bounds::<Self>(offset);
7644            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7645                None => return Err(fidl::Error::NotNullable),
7646                Some(len) => len,
7647            };
7648            // Calling decoder.out_of_line_offset(0) is not allowed.
7649            if len == 0 {
7650                return Ok(());
7651            };
7652            depth.increment()?;
7653            let envelope_size = 8;
7654            let bytes_len = len * envelope_size;
7655            let offset = decoder.out_of_line_offset(bytes_len)?;
7656            // Decode the envelope for each type.
7657            let mut _next_ordinal_to_read = 0;
7658            let mut next_offset = offset;
7659            let end_offset = offset + bytes_len;
7660            _next_ordinal_to_read += 1;
7661            if next_offset >= end_offset {
7662                return Ok(());
7663            }
7664
7665            // Decode unknown envelopes for gaps in ordinals.
7666            while _next_ordinal_to_read < 1 {
7667                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7668                _next_ordinal_to_read += 1;
7669                next_offset += envelope_size;
7670            }
7671
7672            let next_out_of_line = decoder.next_out_of_line();
7673            let handles_before = decoder.remaining_handles();
7674            if let Some((inlined, num_bytes, num_handles)) =
7675                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7676            {
7677                let member_inline_size = <fidl::encoding::Endpoint<
7678                    fidl::endpoints::ServerEnd<ProcedureTokenMarker>,
7679                > as fidl::encoding::TypeMarker>::inline_size(
7680                    decoder.context
7681                );
7682                if inlined != (member_inline_size <= 4) {
7683                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7684                }
7685                let inner_offset;
7686                let mut inner_depth = depth.clone();
7687                if inlined {
7688                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7689                    inner_offset = next_offset;
7690                } else {
7691                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7692                    inner_depth.increment()?;
7693                }
7694                let val_ref = self.suppress_bredr_connections.get_or_insert_with(|| {
7695                    fidl::new_empty!(
7696                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ProcedureTokenMarker>>,
7697                        fidl::encoding::DefaultFuchsiaResourceDialect
7698                    )
7699                });
7700                fidl::decode!(
7701                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ProcedureTokenMarker>>,
7702                    fidl::encoding::DefaultFuchsiaResourceDialect,
7703                    val_ref,
7704                    decoder,
7705                    inner_offset,
7706                    inner_depth
7707                )?;
7708                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7709                {
7710                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7711                }
7712                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7713                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7714                }
7715            }
7716
7717            next_offset += envelope_size;
7718
7719            // Decode the remaining unknown envelopes.
7720            while next_offset < end_offset {
7721                _next_ordinal_to_read += 1;
7722                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7723                next_offset += envelope_size;
7724            }
7725
7726            Ok(())
7727        }
7728    }
7729
7730    impl PairingDelegate2StartRequestRequest {
7731        #[inline(always)]
7732        fn max_ordinal_present(&self) -> u64 {
7733            if let Some(_) = self.request {
7734                return 3;
7735            }
7736            if let Some(_) = self.info {
7737                return 2;
7738            }
7739            if let Some(_) = self.peer {
7740                return 1;
7741            }
7742            0
7743        }
7744    }
7745
7746    impl fidl::encoding::ResourceTypeMarker for PairingDelegate2StartRequestRequest {
7747        type Borrowed<'a> = &'a mut Self;
7748        fn take_or_borrow<'a>(
7749            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7750        ) -> Self::Borrowed<'a> {
7751            value
7752        }
7753    }
7754
7755    unsafe impl fidl::encoding::TypeMarker for PairingDelegate2StartRequestRequest {
7756        type Owned = Self;
7757
7758        #[inline(always)]
7759        fn inline_align(_context: fidl::encoding::Context) -> usize {
7760            8
7761        }
7762
7763        #[inline(always)]
7764        fn inline_size(_context: fidl::encoding::Context) -> usize {
7765            16
7766        }
7767    }
7768
7769    unsafe impl
7770        fidl::encoding::Encode<
7771            PairingDelegate2StartRequestRequest,
7772            fidl::encoding::DefaultFuchsiaResourceDialect,
7773        > for &mut PairingDelegate2StartRequestRequest
7774    {
7775        unsafe fn encode(
7776            self,
7777            encoder: &mut fidl::encoding::Encoder<
7778                '_,
7779                fidl::encoding::DefaultFuchsiaResourceDialect,
7780            >,
7781            offset: usize,
7782            mut depth: fidl::encoding::Depth,
7783        ) -> fidl::Result<()> {
7784            encoder.debug_check_bounds::<PairingDelegate2StartRequestRequest>(offset);
7785            // Vector header
7786            let max_ordinal: u64 = self.max_ordinal_present();
7787            encoder.write_num(max_ordinal, offset);
7788            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7789            // Calling encoder.out_of_line_offset(0) is not allowed.
7790            if max_ordinal == 0 {
7791                return Ok(());
7792            }
7793            depth.increment()?;
7794            let envelope_size = 8;
7795            let bytes_len = max_ordinal as usize * envelope_size;
7796            #[allow(unused_variables)]
7797            let offset = encoder.out_of_line_offset(bytes_len);
7798            let mut _prev_end_offset: usize = 0;
7799            if 1 > max_ordinal {
7800                return Ok(());
7801            }
7802
7803            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7804            // are envelope_size bytes.
7805            let cur_offset: usize = (1 - 1) * envelope_size;
7806
7807            // Zero reserved fields.
7808            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7809
7810            // Safety:
7811            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7812            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7813            //   envelope_size bytes, there is always sufficient room.
7814            fidl::encoding::encode_in_envelope_optional::<
7815                Peer,
7816                fidl::encoding::DefaultFuchsiaResourceDialect,
7817            >(
7818                self.peer.as_ref().map(<Peer as fidl::encoding::ValueTypeMarker>::borrow),
7819                encoder,
7820                offset + cur_offset,
7821                depth,
7822            )?;
7823
7824            _prev_end_offset = cur_offset + envelope_size;
7825            if 2 > max_ordinal {
7826                return Ok(());
7827            }
7828
7829            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7830            // are envelope_size bytes.
7831            let cur_offset: usize = (2 - 1) * envelope_size;
7832
7833            // Zero reserved fields.
7834            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7835
7836            // Safety:
7837            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7838            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7839            //   envelope_size bytes, there is always sufficient room.
7840            fidl::encoding::encode_in_envelope_optional::<
7841                PairingProperties,
7842                fidl::encoding::DefaultFuchsiaResourceDialect,
7843            >(
7844                self.info
7845                    .as_ref()
7846                    .map(<PairingProperties as fidl::encoding::ValueTypeMarker>::borrow),
7847                encoder,
7848                offset + cur_offset,
7849                depth,
7850            )?;
7851
7852            _prev_end_offset = cur_offset + envelope_size;
7853            if 3 > max_ordinal {
7854                return Ok(());
7855            }
7856
7857            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7858            // are envelope_size bytes.
7859            let cur_offset: usize = (3 - 1) * envelope_size;
7860
7861            // Zero reserved fields.
7862            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7863
7864            // Safety:
7865            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7866            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7867            //   envelope_size bytes, there is always sufficient room.
7868            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PairingRequestMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
7869            self.request.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PairingRequestMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
7870            encoder, offset + cur_offset, depth
7871        )?;
7872
7873            _prev_end_offset = cur_offset + envelope_size;
7874
7875            Ok(())
7876        }
7877    }
7878
7879    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7880        for PairingDelegate2StartRequestRequest
7881    {
7882        #[inline(always)]
7883        fn new_empty() -> Self {
7884            Self::default()
7885        }
7886
7887        unsafe fn decode(
7888            &mut self,
7889            decoder: &mut fidl::encoding::Decoder<
7890                '_,
7891                fidl::encoding::DefaultFuchsiaResourceDialect,
7892            >,
7893            offset: usize,
7894            mut depth: fidl::encoding::Depth,
7895        ) -> fidl::Result<()> {
7896            decoder.debug_check_bounds::<Self>(offset);
7897            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7898                None => return Err(fidl::Error::NotNullable),
7899                Some(len) => len,
7900            };
7901            // Calling decoder.out_of_line_offset(0) is not allowed.
7902            if len == 0 {
7903                return Ok(());
7904            };
7905            depth.increment()?;
7906            let envelope_size = 8;
7907            let bytes_len = len * envelope_size;
7908            let offset = decoder.out_of_line_offset(bytes_len)?;
7909            // Decode the envelope for each type.
7910            let mut _next_ordinal_to_read = 0;
7911            let mut next_offset = offset;
7912            let end_offset = offset + bytes_len;
7913            _next_ordinal_to_read += 1;
7914            if next_offset >= end_offset {
7915                return Ok(());
7916            }
7917
7918            // Decode unknown envelopes for gaps in ordinals.
7919            while _next_ordinal_to_read < 1 {
7920                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7921                _next_ordinal_to_read += 1;
7922                next_offset += envelope_size;
7923            }
7924
7925            let next_out_of_line = decoder.next_out_of_line();
7926            let handles_before = decoder.remaining_handles();
7927            if let Some((inlined, num_bytes, num_handles)) =
7928                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7929            {
7930                let member_inline_size =
7931                    <Peer as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7932                if inlined != (member_inline_size <= 4) {
7933                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7934                }
7935                let inner_offset;
7936                let mut inner_depth = depth.clone();
7937                if inlined {
7938                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7939                    inner_offset = next_offset;
7940                } else {
7941                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7942                    inner_depth.increment()?;
7943                }
7944                let val_ref = self.peer.get_or_insert_with(|| {
7945                    fidl::new_empty!(Peer, fidl::encoding::DefaultFuchsiaResourceDialect)
7946                });
7947                fidl::decode!(
7948                    Peer,
7949                    fidl::encoding::DefaultFuchsiaResourceDialect,
7950                    val_ref,
7951                    decoder,
7952                    inner_offset,
7953                    inner_depth
7954                )?;
7955                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7956                {
7957                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7958                }
7959                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7960                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7961                }
7962            }
7963
7964            next_offset += envelope_size;
7965            _next_ordinal_to_read += 1;
7966            if next_offset >= end_offset {
7967                return Ok(());
7968            }
7969
7970            // Decode unknown envelopes for gaps in ordinals.
7971            while _next_ordinal_to_read < 2 {
7972                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7973                _next_ordinal_to_read += 1;
7974                next_offset += envelope_size;
7975            }
7976
7977            let next_out_of_line = decoder.next_out_of_line();
7978            let handles_before = decoder.remaining_handles();
7979            if let Some((inlined, num_bytes, num_handles)) =
7980                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7981            {
7982                let member_inline_size =
7983                    <PairingProperties as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7984                if inlined != (member_inline_size <= 4) {
7985                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7986                }
7987                let inner_offset;
7988                let mut inner_depth = depth.clone();
7989                if inlined {
7990                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7991                    inner_offset = next_offset;
7992                } else {
7993                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7994                    inner_depth.increment()?;
7995                }
7996                let val_ref = self.info.get_or_insert_with(|| {
7997                    fidl::new_empty!(
7998                        PairingProperties,
7999                        fidl::encoding::DefaultFuchsiaResourceDialect
8000                    )
8001                });
8002                fidl::decode!(
8003                    PairingProperties,
8004                    fidl::encoding::DefaultFuchsiaResourceDialect,
8005                    val_ref,
8006                    decoder,
8007                    inner_offset,
8008                    inner_depth
8009                )?;
8010                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8011                {
8012                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8013                }
8014                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8015                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8016                }
8017            }
8018
8019            next_offset += envelope_size;
8020            _next_ordinal_to_read += 1;
8021            if next_offset >= end_offset {
8022                return Ok(());
8023            }
8024
8025            // Decode unknown envelopes for gaps in ordinals.
8026            while _next_ordinal_to_read < 3 {
8027                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8028                _next_ordinal_to_read += 1;
8029                next_offset += envelope_size;
8030            }
8031
8032            let next_out_of_line = decoder.next_out_of_line();
8033            let handles_before = decoder.remaining_handles();
8034            if let Some((inlined, num_bytes, num_handles)) =
8035                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8036            {
8037                let member_inline_size = <fidl::encoding::Endpoint<
8038                    fidl::endpoints::ClientEnd<PairingRequestMarker>,
8039                > as fidl::encoding::TypeMarker>::inline_size(
8040                    decoder.context
8041                );
8042                if inlined != (member_inline_size <= 4) {
8043                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8044                }
8045                let inner_offset;
8046                let mut inner_depth = depth.clone();
8047                if inlined {
8048                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8049                    inner_offset = next_offset;
8050                } else {
8051                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8052                    inner_depth.increment()?;
8053                }
8054                let val_ref = self.request.get_or_insert_with(|| {
8055                    fidl::new_empty!(
8056                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PairingRequestMarker>>,
8057                        fidl::encoding::DefaultFuchsiaResourceDialect
8058                    )
8059                });
8060                fidl::decode!(
8061                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<PairingRequestMarker>>,
8062                    fidl::encoding::DefaultFuchsiaResourceDialect,
8063                    val_ref,
8064                    decoder,
8065                    inner_offset,
8066                    inner_depth
8067                )?;
8068                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8069                {
8070                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8071                }
8072                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8073                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8074                }
8075            }
8076
8077            next_offset += envelope_size;
8078
8079            // Decode the remaining unknown envelopes.
8080            while next_offset < end_offset {
8081                _next_ordinal_to_read += 1;
8082                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8083                next_offset += envelope_size;
8084            }
8085
8086            Ok(())
8087        }
8088    }
8089}