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