Skip to main content

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