Skip to main content

fidl_fuchsia_hardware_bluetooth/
fidl_fuchsia_hardware_bluetooth.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_hardware_bluetooth_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct HciOpenAclDataChannelRequest {
16    pub channel: fidl::Channel,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for HciOpenAclDataChannelRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct HciOpenCommandChannelRequest {
26    pub channel: fidl::Channel,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
30    for HciOpenCommandChannelRequest
31{
32}
33
34#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct HciOpenIsoDataChannelRequest {
36    pub channel: fidl::Channel,
37}
38
39impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
40    for HciOpenIsoDataChannelRequest
41{
42}
43
44#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
45pub struct HciOpenScoDataChannelRequest {
46    pub channel: fidl::Channel,
47}
48
49impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
50    for HciOpenScoDataChannelRequest
51{
52}
53
54#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
55pub struct HciOpenSnoopChannelRequest {
56    pub channel: fidl::Channel,
57}
58
59impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
60    for HciOpenSnoopChannelRequest
61{
62}
63
64#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
65pub struct VendorOpenHciTransportResponse {
66    pub channel: fidl::endpoints::ClientEnd<HciTransportMarker>,
67}
68
69impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
70    for VendorOpenHciTransportResponse
71{
72}
73
74#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
75pub struct VendorOpenHciResponse {
76    pub channel: fidl::endpoints::ClientEnd<HciMarker>,
77}
78
79impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VendorOpenHciResponse {}
80
81#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
82pub struct VendorOpenSnoopResponse {
83    pub channel: fidl::endpoints::ClientEnd<SnoopMarker>,
84}
85
86impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VendorOpenSnoopResponse {}
87
88#[derive(Debug, Default, PartialEq)]
89pub struct HciTransportConfigureScoRequest {
90    /// Required.
91    pub coding_format: Option<ScoCodingFormat>,
92    /// Required.
93    pub encoding: Option<ScoEncoding>,
94    /// Required.
95    pub sample_rate: Option<ScoSampleRate>,
96    /// Required.
97    pub connection: Option<fidl::endpoints::ServerEnd<ScoConnectionMarker>>,
98    #[doc(hidden)]
99    pub __source_breaking: fidl::marker::SourceBreaking,
100}
101
102impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
103    for HciTransportConfigureScoRequest
104{
105}
106
107/// Parameters used to emulate a peer's behavior over the BR/EDR/Low Energy transport.
108#[derive(Debug, Default, PartialEq)]
109pub struct PeerParameters {
110    /// The public BR/EDR BD_ADDR address of a peer. This field is mandatory.
111    pub address: Option<fidl_fuchsia_bluetooth::Address>,
112    /// When present and true, the peer will send connectable advertisements and accept connection
113    /// requests. The peer will ignore connection requests if not connectable.
114    pub connectable: Option<bool>,
115    /// Server end of channel bound to Peer protocol.
116    pub channel: Option<fidl::endpoints::ServerEnd<PeerMarker>>,
117    #[doc(hidden)]
118    pub __source_breaking: fidl::marker::SourceBreaking,
119}
120
121impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PeerParameters {}
122
123#[derive(Debug, Default, PartialEq)]
124pub struct VirtualControllerCreateLoopbackDeviceRequest {
125    pub uart_channel: Option<fidl::Channel>,
126    #[doc(hidden)]
127    pub __source_breaking: fidl::marker::SourceBreaking,
128}
129
130impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
131    for VirtualControllerCreateLoopbackDeviceRequest
132{
133}
134
135#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
136pub struct EmulatorMarker;
137
138impl fidl::endpoints::ProtocolMarker for EmulatorMarker {
139    type Proxy = EmulatorProxy;
140    type RequestStream = EmulatorRequestStream;
141    #[cfg(target_os = "fuchsia")]
142    type SynchronousProxy = EmulatorSynchronousProxy;
143
144    const DEBUG_NAME: &'static str = "fuchsia.hardware.bluetooth.Emulator";
145}
146impl fidl::endpoints::DiscoverableProtocolMarker for EmulatorMarker {}
147pub type EmulatorPublishResult = Result<(), EmulatorError>;
148pub type EmulatorAddLowEnergyPeerResult = Result<(), EmulatorPeerError>;
149pub type EmulatorAddBredrPeerResult = Result<(), EmulatorPeerError>;
150
151pub trait EmulatorProxyInterface: Send + Sync {
152    type PublishResponseFut: std::future::Future<Output = Result<EmulatorPublishResult, fidl::Error>>
153        + Send;
154    fn r#publish(&self, payload: &EmulatorSettings) -> Self::PublishResponseFut;
155    type AddLowEnergyPeerResponseFut: std::future::Future<Output = Result<EmulatorAddLowEnergyPeerResult, fidl::Error>>
156        + Send;
157    fn r#add_low_energy_peer(&self, payload: PeerParameters) -> Self::AddLowEnergyPeerResponseFut;
158    type AddBredrPeerResponseFut: std::future::Future<Output = Result<EmulatorAddBredrPeerResult, fidl::Error>>
159        + Send;
160    fn r#add_bredr_peer(&self, payload: PeerParameters) -> Self::AddBredrPeerResponseFut;
161    type WatchControllerParametersResponseFut: std::future::Future<Output = Result<ControllerParameters, fidl::Error>>
162        + Send;
163    fn r#watch_controller_parameters(&self) -> Self::WatchControllerParametersResponseFut;
164    type WatchLeScanStatesResponseFut: std::future::Future<Output = Result<Vec<LeScanState>, fidl::Error>>
165        + Send;
166    fn r#watch_le_scan_states(&self) -> Self::WatchLeScanStatesResponseFut;
167    type WatchLegacyAdvertisingStatesResponseFut: std::future::Future<Output = Result<Vec<LegacyAdvertisingState>, fidl::Error>>
168        + Send;
169    fn r#watch_legacy_advertising_states(&self) -> Self::WatchLegacyAdvertisingStatesResponseFut;
170}
171#[derive(Debug)]
172#[cfg(target_os = "fuchsia")]
173pub struct EmulatorSynchronousProxy {
174    client: fidl::client::sync::Client,
175}
176
177#[cfg(target_os = "fuchsia")]
178impl fidl::endpoints::SynchronousProxy for EmulatorSynchronousProxy {
179    type Proxy = EmulatorProxy;
180    type Protocol = EmulatorMarker;
181
182    fn from_channel(inner: fidl::Channel) -> Self {
183        Self::new(inner)
184    }
185
186    fn into_channel(self) -> fidl::Channel {
187        self.client.into_channel()
188    }
189
190    fn as_channel(&self) -> &fidl::Channel {
191        self.client.as_channel()
192    }
193}
194
195#[cfg(target_os = "fuchsia")]
196impl EmulatorSynchronousProxy {
197    pub fn new(channel: fidl::Channel) -> Self {
198        Self { client: fidl::client::sync::Client::new(channel) }
199    }
200
201    pub fn into_channel(self) -> fidl::Channel {
202        self.client.into_channel()
203    }
204
205    /// Waits until an event arrives and returns it. It is safe for other
206    /// threads to make concurrent requests while waiting for an event.
207    pub fn wait_for_event(
208        &self,
209        deadline: zx::MonotonicInstant,
210    ) -> Result<EmulatorEvent, fidl::Error> {
211        EmulatorEvent::decode(self.client.wait_for_event::<EmulatorMarker>(deadline)?)
212    }
213
214    /// Publish a bt-hci device using the provided `settings`. Each Emulator instance can only
215    /// manage a single bt-hci device. Returns Emulator.`HCI_ALREADY_PUBLISHED` if the device has
216    /// already been published.
217    pub fn r#publish(
218        &self,
219        mut payload: &EmulatorSettings,
220        ___deadline: zx::MonotonicInstant,
221    ) -> Result<EmulatorPublishResult, fidl::Error> {
222        let _response = self.client.send_query::<
223            EmulatorSettings,
224            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, EmulatorError>,
225            EmulatorMarker,
226        >(
227            payload,
228            0x5b8aeb2ece853c39,
229            fidl::encoding::DynamicFlags::FLEXIBLE,
230            ___deadline,
231        )?
232        .into_result::<EmulatorMarker>("publish")?;
233        Ok(_response.map(|x| x))
234    }
235
236    /// Inserts a new LE peer device to be emulated by this controller. Once registered, the state
237    /// of the fake peer can be driven and observed using the `peer` handle.
238    ///
239    /// A reply will be sent to acknowledge the creation of the fake peer. If a peer cannot be
240    /// initialized (e.g. due to a missing required field in `parameters` or for containing an
241    /// address that is already emulated) the `peer` handle will be closed and an error reply will
242    /// be sent.
243    ///
244    /// The peer will appear in advertising reports and respond to requests according to its
245    /// configuration as long as the `peer` channel is open. The emulator stops emulating this peer
246    /// when the channel gets closed, which makes it no longer discoverable and not respond to any
247    /// requests.
248    pub fn r#add_low_energy_peer(
249        &self,
250        mut payload: PeerParameters,
251        ___deadline: zx::MonotonicInstant,
252    ) -> Result<EmulatorAddLowEnergyPeerResult, fidl::Error> {
253        let _response = self.client.send_query::<
254            PeerParameters,
255            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, EmulatorPeerError>,
256            EmulatorMarker,
257        >(
258            &mut payload,
259            0x4e1fb7adbebc6946,
260            fidl::encoding::DynamicFlags::FLEXIBLE,
261            ___deadline,
262        )?
263        .into_result::<EmulatorMarker>("add_low_energy_peer")?;
264        Ok(_response.map(|x| x))
265    }
266
267    /// Inserts a new BR/EDR peer device to be emulated by this controller. Once registered, the state
268    /// of the fake peer can be driven and observed using the `peer` handle.
269    ///
270    /// A reply will be sent to acknowledge the creation of the fake peer. If a peer cannot be
271    /// initialized (e.g. due to a missing required field in `parameters` or for containing an
272    /// address that is already emulated) the `peer` handle will be closed and an error reply will
273    /// be sent.
274    ///
275    /// The peer will appear in inquiry results and respond to requests according to its
276    /// configuration as long as the `peer` channel is open. The emulator stops emulating this peer
277    /// when the channel gets closed, which makes it no longer discoverable and not respond to any
278    /// requests.
279    pub fn r#add_bredr_peer(
280        &self,
281        mut payload: PeerParameters,
282        ___deadline: zx::MonotonicInstant,
283    ) -> Result<EmulatorAddBredrPeerResult, fidl::Error> {
284        let _response = self.client.send_query::<
285            PeerParameters,
286            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, EmulatorPeerError>,
287            EmulatorMarker,
288        >(
289            &mut payload,
290            0x6d15989a0373e07,
291            fidl::encoding::DynamicFlags::FLEXIBLE,
292            ___deadline,
293        )?
294        .into_result::<EmulatorMarker>("add_bredr_peer")?;
295        Ok(_response.map(|x| x))
296    }
297
298    /// Hanging get pattern for the controller parameter state will not resolve until the state has
299    /// changed from the last response.
300    pub fn r#watch_controller_parameters(
301        &self,
302        ___deadline: zx::MonotonicInstant,
303    ) -> Result<ControllerParameters, fidl::Error> {
304        let _response = self.client.send_query::<
305            fidl::encoding::EmptyPayload,
306            fidl::encoding::FlexibleType<ControllerParameters>,
307            EmulatorMarker,
308        >(
309            (),
310            0x6ed7a918b5800270,
311            fidl::encoding::DynamicFlags::FLEXIBLE,
312            ___deadline,
313        )?
314        .into_result::<EmulatorMarker>("watch_controller_parameters")?;
315        Ok(_response)
316    }
317
318    /// Returns a vector of the least to most recent states for the link layer LE scan procedure.
319    /// This method returns when there has been at least one state change since the last invocation
320    /// of this method by this client.
321    ///
322    /// Multiple calls to this method can be outstanding at a given time. All calls will resolve in
323    /// a response as soon as there is a change to the scan state.
324    pub fn r#watch_le_scan_states(
325        &self,
326        ___deadline: zx::MonotonicInstant,
327    ) -> Result<Vec<LeScanState>, fidl::Error> {
328        let _response = self.client.send_query::<
329            fidl::encoding::EmptyPayload,
330            fidl::encoding::FlexibleType<EmulatorWatchLeScanStatesResponse>,
331            EmulatorMarker,
332        >(
333            (),
334            0x10e6c845831f3b4a,
335            fidl::encoding::DynamicFlags::FLEXIBLE,
336            ___deadline,
337        )?
338        .into_result::<EmulatorMarker>("watch_le_scan_states")?;
339        Ok(_response.states)
340    }
341
342    /// Returns a vector of the least to most recent states for the link layer LE legacy
343    /// advertising procedure. This method returns when there has been at least one state change
344    /// since the last invocation of this method by this client.
345    ///
346    /// Multiple calls to this method can be outstanding at a given time. All calls will resolve in
347    /// a response as soon as there is a change to the scan state.
348    pub fn r#watch_legacy_advertising_states(
349        &self,
350        ___deadline: zx::MonotonicInstant,
351    ) -> Result<Vec<LegacyAdvertisingState>, fidl::Error> {
352        let _response = self.client.send_query::<
353            fidl::encoding::EmptyPayload,
354            fidl::encoding::FlexibleType<EmulatorWatchLegacyAdvertisingStatesResponse>,
355            EmulatorMarker,
356        >(
357            (),
358            0x7067acbe275d0219,
359            fidl::encoding::DynamicFlags::FLEXIBLE,
360            ___deadline,
361        )?
362        .into_result::<EmulatorMarker>("watch_legacy_advertising_states")?;
363        Ok(_response.states)
364    }
365}
366
367#[cfg(target_os = "fuchsia")]
368impl From<EmulatorSynchronousProxy> for zx::NullableHandle {
369    fn from(value: EmulatorSynchronousProxy) -> Self {
370        value.into_channel().into()
371    }
372}
373
374#[cfg(target_os = "fuchsia")]
375impl From<fidl::Channel> for EmulatorSynchronousProxy {
376    fn from(value: fidl::Channel) -> Self {
377        Self::new(value)
378    }
379}
380
381#[cfg(target_os = "fuchsia")]
382impl fidl::endpoints::FromClient for EmulatorSynchronousProxy {
383    type Protocol = EmulatorMarker;
384
385    fn from_client(value: fidl::endpoints::ClientEnd<EmulatorMarker>) -> Self {
386        Self::new(value.into_channel())
387    }
388}
389
390#[derive(Debug, Clone)]
391pub struct EmulatorProxy {
392    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
393}
394
395impl fidl::endpoints::Proxy for EmulatorProxy {
396    type Protocol = EmulatorMarker;
397
398    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
399        Self::new(inner)
400    }
401
402    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
403        self.client.into_channel().map_err(|client| Self { client })
404    }
405
406    fn as_channel(&self) -> &::fidl::AsyncChannel {
407        self.client.as_channel()
408    }
409}
410
411impl EmulatorProxy {
412    /// Create a new Proxy for fuchsia.hardware.bluetooth/Emulator.
413    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
414        let protocol_name = <EmulatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
415        Self { client: fidl::client::Client::new(channel, protocol_name) }
416    }
417
418    /// Get a Stream of events from the remote end of the protocol.
419    ///
420    /// # Panics
421    ///
422    /// Panics if the event stream was already taken.
423    pub fn take_event_stream(&self) -> EmulatorEventStream {
424        EmulatorEventStream { event_receiver: self.client.take_event_receiver() }
425    }
426
427    /// Publish a bt-hci device using the provided `settings`. Each Emulator instance can only
428    /// manage a single bt-hci device. Returns Emulator.`HCI_ALREADY_PUBLISHED` if the device has
429    /// already been published.
430    pub fn r#publish(
431        &self,
432        mut payload: &EmulatorSettings,
433    ) -> fidl::client::QueryResponseFut<
434        EmulatorPublishResult,
435        fidl::encoding::DefaultFuchsiaResourceDialect,
436    > {
437        EmulatorProxyInterface::r#publish(self, payload)
438    }
439
440    /// Inserts a new LE peer device to be emulated by this controller. Once registered, the state
441    /// of the fake peer can be driven and observed using the `peer` handle.
442    ///
443    /// A reply will be sent to acknowledge the creation of the fake peer. If a peer cannot be
444    /// initialized (e.g. due to a missing required field in `parameters` or for containing an
445    /// address that is already emulated) the `peer` handle will be closed and an error reply will
446    /// be sent.
447    ///
448    /// The peer will appear in advertising reports and respond to requests according to its
449    /// configuration as long as the `peer` channel is open. The emulator stops emulating this peer
450    /// when the channel gets closed, which makes it no longer discoverable and not respond to any
451    /// requests.
452    pub fn r#add_low_energy_peer(
453        &self,
454        mut payload: PeerParameters,
455    ) -> fidl::client::QueryResponseFut<
456        EmulatorAddLowEnergyPeerResult,
457        fidl::encoding::DefaultFuchsiaResourceDialect,
458    > {
459        EmulatorProxyInterface::r#add_low_energy_peer(self, payload)
460    }
461
462    /// Inserts a new BR/EDR peer device to be emulated by this controller. Once registered, the state
463    /// of the fake peer can be driven and observed using the `peer` handle.
464    ///
465    /// A reply will be sent to acknowledge the creation of the fake peer. If a peer cannot be
466    /// initialized (e.g. due to a missing required field in `parameters` or for containing an
467    /// address that is already emulated) the `peer` handle will be closed and an error reply will
468    /// be sent.
469    ///
470    /// The peer will appear in inquiry results and respond to requests according to its
471    /// configuration as long as the `peer` channel is open. The emulator stops emulating this peer
472    /// when the channel gets closed, which makes it no longer discoverable and not respond to any
473    /// requests.
474    pub fn r#add_bredr_peer(
475        &self,
476        mut payload: PeerParameters,
477    ) -> fidl::client::QueryResponseFut<
478        EmulatorAddBredrPeerResult,
479        fidl::encoding::DefaultFuchsiaResourceDialect,
480    > {
481        EmulatorProxyInterface::r#add_bredr_peer(self, payload)
482    }
483
484    /// Hanging get pattern for the controller parameter state will not resolve until the state has
485    /// changed from the last response.
486    pub fn r#watch_controller_parameters(
487        &self,
488    ) -> fidl::client::QueryResponseFut<
489        ControllerParameters,
490        fidl::encoding::DefaultFuchsiaResourceDialect,
491    > {
492        EmulatorProxyInterface::r#watch_controller_parameters(self)
493    }
494
495    /// Returns a vector of the least to most recent states for the link layer LE scan procedure.
496    /// This method returns when there has been at least one state change since the last invocation
497    /// of this method by this client.
498    ///
499    /// Multiple calls to this method can be outstanding at a given time. All calls will resolve in
500    /// a response as soon as there is a change to the scan state.
501    pub fn r#watch_le_scan_states(
502        &self,
503    ) -> fidl::client::QueryResponseFut<
504        Vec<LeScanState>,
505        fidl::encoding::DefaultFuchsiaResourceDialect,
506    > {
507        EmulatorProxyInterface::r#watch_le_scan_states(self)
508    }
509
510    /// Returns a vector of the least to most recent states for the link layer LE legacy
511    /// advertising procedure. This method returns when there has been at least one state change
512    /// since the last invocation of this method by this client.
513    ///
514    /// Multiple calls to this method can be outstanding at a given time. All calls will resolve in
515    /// a response as soon as there is a change to the scan state.
516    pub fn r#watch_legacy_advertising_states(
517        &self,
518    ) -> fidl::client::QueryResponseFut<
519        Vec<LegacyAdvertisingState>,
520        fidl::encoding::DefaultFuchsiaResourceDialect,
521    > {
522        EmulatorProxyInterface::r#watch_legacy_advertising_states(self)
523    }
524}
525
526impl EmulatorProxyInterface for EmulatorProxy {
527    type PublishResponseFut = fidl::client::QueryResponseFut<
528        EmulatorPublishResult,
529        fidl::encoding::DefaultFuchsiaResourceDialect,
530    >;
531    fn r#publish(&self, mut payload: &EmulatorSettings) -> Self::PublishResponseFut {
532        fn _decode(
533            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
534        ) -> Result<EmulatorPublishResult, fidl::Error> {
535            let _response = fidl::client::decode_transaction_body::<
536                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, EmulatorError>,
537                fidl::encoding::DefaultFuchsiaResourceDialect,
538                0x5b8aeb2ece853c39,
539            >(_buf?)?
540            .into_result::<EmulatorMarker>("publish")?;
541            Ok(_response.map(|x| x))
542        }
543        self.client.send_query_and_decode::<EmulatorSettings, EmulatorPublishResult>(
544            payload,
545            0x5b8aeb2ece853c39,
546            fidl::encoding::DynamicFlags::FLEXIBLE,
547            _decode,
548        )
549    }
550
551    type AddLowEnergyPeerResponseFut = fidl::client::QueryResponseFut<
552        EmulatorAddLowEnergyPeerResult,
553        fidl::encoding::DefaultFuchsiaResourceDialect,
554    >;
555    fn r#add_low_energy_peer(
556        &self,
557        mut payload: PeerParameters,
558    ) -> Self::AddLowEnergyPeerResponseFut {
559        fn _decode(
560            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
561        ) -> Result<EmulatorAddLowEnergyPeerResult, fidl::Error> {
562            let _response = fidl::client::decode_transaction_body::<
563                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, EmulatorPeerError>,
564                fidl::encoding::DefaultFuchsiaResourceDialect,
565                0x4e1fb7adbebc6946,
566            >(_buf?)?
567            .into_result::<EmulatorMarker>("add_low_energy_peer")?;
568            Ok(_response.map(|x| x))
569        }
570        self.client.send_query_and_decode::<PeerParameters, EmulatorAddLowEnergyPeerResult>(
571            &mut payload,
572            0x4e1fb7adbebc6946,
573            fidl::encoding::DynamicFlags::FLEXIBLE,
574            _decode,
575        )
576    }
577
578    type AddBredrPeerResponseFut = fidl::client::QueryResponseFut<
579        EmulatorAddBredrPeerResult,
580        fidl::encoding::DefaultFuchsiaResourceDialect,
581    >;
582    fn r#add_bredr_peer(&self, mut payload: PeerParameters) -> Self::AddBredrPeerResponseFut {
583        fn _decode(
584            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
585        ) -> Result<EmulatorAddBredrPeerResult, fidl::Error> {
586            let _response = fidl::client::decode_transaction_body::<
587                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, EmulatorPeerError>,
588                fidl::encoding::DefaultFuchsiaResourceDialect,
589                0x6d15989a0373e07,
590            >(_buf?)?
591            .into_result::<EmulatorMarker>("add_bredr_peer")?;
592            Ok(_response.map(|x| x))
593        }
594        self.client.send_query_and_decode::<PeerParameters, EmulatorAddBredrPeerResult>(
595            &mut payload,
596            0x6d15989a0373e07,
597            fidl::encoding::DynamicFlags::FLEXIBLE,
598            _decode,
599        )
600    }
601
602    type WatchControllerParametersResponseFut = fidl::client::QueryResponseFut<
603        ControllerParameters,
604        fidl::encoding::DefaultFuchsiaResourceDialect,
605    >;
606    fn r#watch_controller_parameters(&self) -> Self::WatchControllerParametersResponseFut {
607        fn _decode(
608            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
609        ) -> Result<ControllerParameters, fidl::Error> {
610            let _response = fidl::client::decode_transaction_body::<
611                fidl::encoding::FlexibleType<ControllerParameters>,
612                fidl::encoding::DefaultFuchsiaResourceDialect,
613                0x6ed7a918b5800270,
614            >(_buf?)?
615            .into_result::<EmulatorMarker>("watch_controller_parameters")?;
616            Ok(_response)
617        }
618        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ControllerParameters>(
619            (),
620            0x6ed7a918b5800270,
621            fidl::encoding::DynamicFlags::FLEXIBLE,
622            _decode,
623        )
624    }
625
626    type WatchLeScanStatesResponseFut = fidl::client::QueryResponseFut<
627        Vec<LeScanState>,
628        fidl::encoding::DefaultFuchsiaResourceDialect,
629    >;
630    fn r#watch_le_scan_states(&self) -> Self::WatchLeScanStatesResponseFut {
631        fn _decode(
632            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
633        ) -> Result<Vec<LeScanState>, fidl::Error> {
634            let _response = fidl::client::decode_transaction_body::<
635                fidl::encoding::FlexibleType<EmulatorWatchLeScanStatesResponse>,
636                fidl::encoding::DefaultFuchsiaResourceDialect,
637                0x10e6c845831f3b4a,
638            >(_buf?)?
639            .into_result::<EmulatorMarker>("watch_le_scan_states")?;
640            Ok(_response.states)
641        }
642        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<LeScanState>>(
643            (),
644            0x10e6c845831f3b4a,
645            fidl::encoding::DynamicFlags::FLEXIBLE,
646            _decode,
647        )
648    }
649
650    type WatchLegacyAdvertisingStatesResponseFut = fidl::client::QueryResponseFut<
651        Vec<LegacyAdvertisingState>,
652        fidl::encoding::DefaultFuchsiaResourceDialect,
653    >;
654    fn r#watch_legacy_advertising_states(&self) -> Self::WatchLegacyAdvertisingStatesResponseFut {
655        fn _decode(
656            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
657        ) -> Result<Vec<LegacyAdvertisingState>, fidl::Error> {
658            let _response = fidl::client::decode_transaction_body::<
659                fidl::encoding::FlexibleType<EmulatorWatchLegacyAdvertisingStatesResponse>,
660                fidl::encoding::DefaultFuchsiaResourceDialect,
661                0x7067acbe275d0219,
662            >(_buf?)?
663            .into_result::<EmulatorMarker>("watch_legacy_advertising_states")?;
664            Ok(_response.states)
665        }
666        self.client
667            .send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<LegacyAdvertisingState>>(
668                (),
669                0x7067acbe275d0219,
670                fidl::encoding::DynamicFlags::FLEXIBLE,
671                _decode,
672            )
673    }
674}
675
676pub struct EmulatorEventStream {
677    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
678}
679
680impl std::marker::Unpin for EmulatorEventStream {}
681
682impl futures::stream::FusedStream for EmulatorEventStream {
683    fn is_terminated(&self) -> bool {
684        self.event_receiver.is_terminated()
685    }
686}
687
688impl futures::Stream for EmulatorEventStream {
689    type Item = Result<EmulatorEvent, fidl::Error>;
690
691    fn poll_next(
692        mut self: std::pin::Pin<&mut Self>,
693        cx: &mut std::task::Context<'_>,
694    ) -> std::task::Poll<Option<Self::Item>> {
695        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
696            &mut self.event_receiver,
697            cx
698        )?) {
699            Some(buf) => std::task::Poll::Ready(Some(EmulatorEvent::decode(buf))),
700            None => std::task::Poll::Ready(None),
701        }
702    }
703}
704
705#[derive(Debug)]
706pub enum EmulatorEvent {
707    #[non_exhaustive]
708    _UnknownEvent {
709        /// Ordinal of the event that was sent.
710        ordinal: u64,
711    },
712}
713
714impl EmulatorEvent {
715    /// Decodes a message buffer as a [`EmulatorEvent`].
716    fn decode(
717        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
718    ) -> Result<EmulatorEvent, fidl::Error> {
719        let (bytes, _handles) = buf.split_mut();
720        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
721        debug_assert_eq!(tx_header.tx_id, 0);
722        match tx_header.ordinal {
723            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
724                Ok(EmulatorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
725            }
726            _ => Err(fidl::Error::UnknownOrdinal {
727                ordinal: tx_header.ordinal,
728                protocol_name: <EmulatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
729            }),
730        }
731    }
732}
733
734/// A Stream of incoming requests for fuchsia.hardware.bluetooth/Emulator.
735pub struct EmulatorRequestStream {
736    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
737    is_terminated: bool,
738}
739
740impl std::marker::Unpin for EmulatorRequestStream {}
741
742impl futures::stream::FusedStream for EmulatorRequestStream {
743    fn is_terminated(&self) -> bool {
744        self.is_terminated
745    }
746}
747
748impl fidl::endpoints::RequestStream for EmulatorRequestStream {
749    type Protocol = EmulatorMarker;
750    type ControlHandle = EmulatorControlHandle;
751
752    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
753        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
754    }
755
756    fn control_handle(&self) -> Self::ControlHandle {
757        EmulatorControlHandle { inner: self.inner.clone() }
758    }
759
760    fn into_inner(
761        self,
762    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
763    {
764        (self.inner, self.is_terminated)
765    }
766
767    fn from_inner(
768        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
769        is_terminated: bool,
770    ) -> Self {
771        Self { inner, is_terminated }
772    }
773}
774
775impl futures::Stream for EmulatorRequestStream {
776    type Item = Result<EmulatorRequest, fidl::Error>;
777
778    fn poll_next(
779        mut self: std::pin::Pin<&mut Self>,
780        cx: &mut std::task::Context<'_>,
781    ) -> std::task::Poll<Option<Self::Item>> {
782        let this = &mut *self;
783        if this.inner.check_shutdown(cx) {
784            this.is_terminated = true;
785            return std::task::Poll::Ready(None);
786        }
787        if this.is_terminated {
788            panic!("polled EmulatorRequestStream after completion");
789        }
790        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
791            |bytes, handles| {
792                match this.inner.channel().read_etc(cx, bytes, handles) {
793                    std::task::Poll::Ready(Ok(())) => {}
794                    std::task::Poll::Pending => return std::task::Poll::Pending,
795                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
796                        this.is_terminated = true;
797                        return std::task::Poll::Ready(None);
798                    }
799                    std::task::Poll::Ready(Err(e)) => {
800                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
801                            e.into(),
802                        ))));
803                    }
804                }
805
806                // A message has been received from the channel
807                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
808
809                std::task::Poll::Ready(Some(match header.ordinal {
810                    0x5b8aeb2ece853c39 => {
811                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
812                        let mut req = fidl::new_empty!(
813                            EmulatorSettings,
814                            fidl::encoding::DefaultFuchsiaResourceDialect
815                        );
816                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EmulatorSettings>(&header, _body_bytes, handles, &mut req)?;
817                        let control_handle = EmulatorControlHandle { inner: this.inner.clone() };
818                        Ok(EmulatorRequest::Publish {
819                            payload: req,
820                            responder: EmulatorPublishResponder {
821                                control_handle: std::mem::ManuallyDrop::new(control_handle),
822                                tx_id: header.tx_id,
823                            },
824                        })
825                    }
826                    0x4e1fb7adbebc6946 => {
827                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
828                        let mut req = fidl::new_empty!(
829                            PeerParameters,
830                            fidl::encoding::DefaultFuchsiaResourceDialect
831                        );
832                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerParameters>(&header, _body_bytes, handles, &mut req)?;
833                        let control_handle = EmulatorControlHandle { inner: this.inner.clone() };
834                        Ok(EmulatorRequest::AddLowEnergyPeer {
835                            payload: req,
836                            responder: EmulatorAddLowEnergyPeerResponder {
837                                control_handle: std::mem::ManuallyDrop::new(control_handle),
838                                tx_id: header.tx_id,
839                            },
840                        })
841                    }
842                    0x6d15989a0373e07 => {
843                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
844                        let mut req = fidl::new_empty!(
845                            PeerParameters,
846                            fidl::encoding::DefaultFuchsiaResourceDialect
847                        );
848                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerParameters>(&header, _body_bytes, handles, &mut req)?;
849                        let control_handle = EmulatorControlHandle { inner: this.inner.clone() };
850                        Ok(EmulatorRequest::AddBredrPeer {
851                            payload: req,
852                            responder: EmulatorAddBredrPeerResponder {
853                                control_handle: std::mem::ManuallyDrop::new(control_handle),
854                                tx_id: header.tx_id,
855                            },
856                        })
857                    }
858                    0x6ed7a918b5800270 => {
859                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
860                        let mut req = fidl::new_empty!(
861                            fidl::encoding::EmptyPayload,
862                            fidl::encoding::DefaultFuchsiaResourceDialect
863                        );
864                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
865                        let control_handle = EmulatorControlHandle { inner: this.inner.clone() };
866                        Ok(EmulatorRequest::WatchControllerParameters {
867                            responder: EmulatorWatchControllerParametersResponder {
868                                control_handle: std::mem::ManuallyDrop::new(control_handle),
869                                tx_id: header.tx_id,
870                            },
871                        })
872                    }
873                    0x10e6c845831f3b4a => {
874                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
875                        let mut req = fidl::new_empty!(
876                            fidl::encoding::EmptyPayload,
877                            fidl::encoding::DefaultFuchsiaResourceDialect
878                        );
879                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
880                        let control_handle = EmulatorControlHandle { inner: this.inner.clone() };
881                        Ok(EmulatorRequest::WatchLeScanStates {
882                            responder: EmulatorWatchLeScanStatesResponder {
883                                control_handle: std::mem::ManuallyDrop::new(control_handle),
884                                tx_id: header.tx_id,
885                            },
886                        })
887                    }
888                    0x7067acbe275d0219 => {
889                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
890                        let mut req = fidl::new_empty!(
891                            fidl::encoding::EmptyPayload,
892                            fidl::encoding::DefaultFuchsiaResourceDialect
893                        );
894                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
895                        let control_handle = EmulatorControlHandle { inner: this.inner.clone() };
896                        Ok(EmulatorRequest::WatchLegacyAdvertisingStates {
897                            responder: EmulatorWatchLegacyAdvertisingStatesResponder {
898                                control_handle: std::mem::ManuallyDrop::new(control_handle),
899                                tx_id: header.tx_id,
900                            },
901                        })
902                    }
903                    _ if header.tx_id == 0
904                        && header
905                            .dynamic_flags()
906                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
907                    {
908                        Ok(EmulatorRequest::_UnknownMethod {
909                            ordinal: header.ordinal,
910                            control_handle: EmulatorControlHandle { inner: this.inner.clone() },
911                            method_type: fidl::MethodType::OneWay,
912                        })
913                    }
914                    _ if header
915                        .dynamic_flags()
916                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
917                    {
918                        this.inner.send_framework_err(
919                            fidl::encoding::FrameworkErr::UnknownMethod,
920                            header.tx_id,
921                            header.ordinal,
922                            header.dynamic_flags(),
923                            (bytes, handles),
924                        )?;
925                        Ok(EmulatorRequest::_UnknownMethod {
926                            ordinal: header.ordinal,
927                            control_handle: EmulatorControlHandle { inner: this.inner.clone() },
928                            method_type: fidl::MethodType::TwoWay,
929                        })
930                    }
931                    _ => Err(fidl::Error::UnknownOrdinal {
932                        ordinal: header.ordinal,
933                        protocol_name:
934                            <EmulatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
935                    }),
936                }))
937            },
938        )
939    }
940}
941
942/// Protocol used to emulate a Bluetooth controller that supports the standard Bluetooth HCI.
943/// Represents the bt-emulator device protocol. A bt-emulator device is used for configuring and
944/// publishing fake bt-hci devices.
945#[derive(Debug)]
946pub enum EmulatorRequest {
947    /// Publish a bt-hci device using the provided `settings`. Each Emulator instance can only
948    /// manage a single bt-hci device. Returns Emulator.`HCI_ALREADY_PUBLISHED` if the device has
949    /// already been published.
950    Publish { payload: EmulatorSettings, responder: EmulatorPublishResponder },
951    /// Inserts a new LE peer device to be emulated by this controller. Once registered, the state
952    /// of the fake peer can be driven and observed using the `peer` handle.
953    ///
954    /// A reply will be sent to acknowledge the creation of the fake peer. If a peer cannot be
955    /// initialized (e.g. due to a missing required field in `parameters` or for containing an
956    /// address that is already emulated) the `peer` handle will be closed and an error reply will
957    /// be sent.
958    ///
959    /// The peer will appear in advertising reports and respond to requests according to its
960    /// configuration as long as the `peer` channel is open. The emulator stops emulating this peer
961    /// when the channel gets closed, which makes it no longer discoverable and not respond to any
962    /// requests.
963    AddLowEnergyPeer { payload: PeerParameters, responder: EmulatorAddLowEnergyPeerResponder },
964    /// Inserts a new BR/EDR peer device to be emulated by this controller. Once registered, the state
965    /// of the fake peer can be driven and observed using the `peer` handle.
966    ///
967    /// A reply will be sent to acknowledge the creation of the fake peer. If a peer cannot be
968    /// initialized (e.g. due to a missing required field in `parameters` or for containing an
969    /// address that is already emulated) the `peer` handle will be closed and an error reply will
970    /// be sent.
971    ///
972    /// The peer will appear in inquiry results and respond to requests according to its
973    /// configuration as long as the `peer` channel is open. The emulator stops emulating this peer
974    /// when the channel gets closed, which makes it no longer discoverable and not respond to any
975    /// requests.
976    AddBredrPeer { payload: PeerParameters, responder: EmulatorAddBredrPeerResponder },
977    /// Hanging get pattern for the controller parameter state will not resolve until the state has
978    /// changed from the last response.
979    WatchControllerParameters { responder: EmulatorWatchControllerParametersResponder },
980    /// Returns a vector of the least to most recent states for the link layer LE scan procedure.
981    /// This method returns when there has been at least one state change since the last invocation
982    /// of this method by this client.
983    ///
984    /// Multiple calls to this method can be outstanding at a given time. All calls will resolve in
985    /// a response as soon as there is a change to the scan state.
986    WatchLeScanStates { responder: EmulatorWatchLeScanStatesResponder },
987    /// Returns a vector of the least to most recent states for the link layer LE legacy
988    /// advertising procedure. This method returns when there has been at least one state change
989    /// since the last invocation of this method by this client.
990    ///
991    /// Multiple calls to this method can be outstanding at a given time. All calls will resolve in
992    /// a response as soon as there is a change to the scan state.
993    WatchLegacyAdvertisingStates { responder: EmulatorWatchLegacyAdvertisingStatesResponder },
994    /// An interaction was received which does not match any known method.
995    #[non_exhaustive]
996    _UnknownMethod {
997        /// Ordinal of the method that was called.
998        ordinal: u64,
999        control_handle: EmulatorControlHandle,
1000        method_type: fidl::MethodType,
1001    },
1002}
1003
1004impl EmulatorRequest {
1005    #[allow(irrefutable_let_patterns)]
1006    pub fn into_publish(self) -> Option<(EmulatorSettings, EmulatorPublishResponder)> {
1007        if let EmulatorRequest::Publish { payload, responder } = self {
1008            Some((payload, responder))
1009        } else {
1010            None
1011        }
1012    }
1013
1014    #[allow(irrefutable_let_patterns)]
1015    pub fn into_add_low_energy_peer(
1016        self,
1017    ) -> Option<(PeerParameters, EmulatorAddLowEnergyPeerResponder)> {
1018        if let EmulatorRequest::AddLowEnergyPeer { payload, responder } = self {
1019            Some((payload, responder))
1020        } else {
1021            None
1022        }
1023    }
1024
1025    #[allow(irrefutable_let_patterns)]
1026    pub fn into_add_bredr_peer(self) -> Option<(PeerParameters, EmulatorAddBredrPeerResponder)> {
1027        if let EmulatorRequest::AddBredrPeer { payload, responder } = self {
1028            Some((payload, responder))
1029        } else {
1030            None
1031        }
1032    }
1033
1034    #[allow(irrefutable_let_patterns)]
1035    pub fn into_watch_controller_parameters(
1036        self,
1037    ) -> Option<(EmulatorWatchControllerParametersResponder)> {
1038        if let EmulatorRequest::WatchControllerParameters { responder } = self {
1039            Some((responder))
1040        } else {
1041            None
1042        }
1043    }
1044
1045    #[allow(irrefutable_let_patterns)]
1046    pub fn into_watch_le_scan_states(self) -> Option<(EmulatorWatchLeScanStatesResponder)> {
1047        if let EmulatorRequest::WatchLeScanStates { responder } = self {
1048            Some((responder))
1049        } else {
1050            None
1051        }
1052    }
1053
1054    #[allow(irrefutable_let_patterns)]
1055    pub fn into_watch_legacy_advertising_states(
1056        self,
1057    ) -> Option<(EmulatorWatchLegacyAdvertisingStatesResponder)> {
1058        if let EmulatorRequest::WatchLegacyAdvertisingStates { responder } = self {
1059            Some((responder))
1060        } else {
1061            None
1062        }
1063    }
1064
1065    /// Name of the method defined in FIDL
1066    pub fn method_name(&self) -> &'static str {
1067        match *self {
1068            EmulatorRequest::Publish { .. } => "publish",
1069            EmulatorRequest::AddLowEnergyPeer { .. } => "add_low_energy_peer",
1070            EmulatorRequest::AddBredrPeer { .. } => "add_bredr_peer",
1071            EmulatorRequest::WatchControllerParameters { .. } => "watch_controller_parameters",
1072            EmulatorRequest::WatchLeScanStates { .. } => "watch_le_scan_states",
1073            EmulatorRequest::WatchLegacyAdvertisingStates { .. } => {
1074                "watch_legacy_advertising_states"
1075            }
1076            EmulatorRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1077                "unknown one-way method"
1078            }
1079            EmulatorRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1080                "unknown two-way method"
1081            }
1082        }
1083    }
1084}
1085
1086#[derive(Debug, Clone)]
1087pub struct EmulatorControlHandle {
1088    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1089}
1090
1091impl EmulatorControlHandle {
1092    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1093        self.inner.shutdown_with_epitaph(status.into())
1094    }
1095}
1096
1097impl fidl::endpoints::ControlHandle for EmulatorControlHandle {
1098    fn shutdown(&self) {
1099        self.inner.shutdown()
1100    }
1101
1102    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1103        self.inner.shutdown_with_epitaph(status)
1104    }
1105
1106    fn is_closed(&self) -> bool {
1107        self.inner.channel().is_closed()
1108    }
1109    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1110        self.inner.channel().on_closed()
1111    }
1112
1113    #[cfg(target_os = "fuchsia")]
1114    fn signal_peer(
1115        &self,
1116        clear_mask: zx::Signals,
1117        set_mask: zx::Signals,
1118    ) -> Result<(), zx_status::Status> {
1119        use fidl::Peered;
1120        self.inner.channel().signal_peer(clear_mask, set_mask)
1121    }
1122}
1123
1124impl EmulatorControlHandle {}
1125
1126#[must_use = "FIDL methods require a response to be sent"]
1127#[derive(Debug)]
1128pub struct EmulatorPublishResponder {
1129    control_handle: std::mem::ManuallyDrop<EmulatorControlHandle>,
1130    tx_id: u32,
1131}
1132
1133/// Set the the channel to be shutdown (see [`EmulatorControlHandle::shutdown`])
1134/// if the responder is dropped without sending a response, so that the client
1135/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1136impl std::ops::Drop for EmulatorPublishResponder {
1137    fn drop(&mut self) {
1138        self.control_handle.shutdown();
1139        // Safety: drops once, never accessed again
1140        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1141    }
1142}
1143
1144impl fidl::endpoints::Responder for EmulatorPublishResponder {
1145    type ControlHandle = EmulatorControlHandle;
1146
1147    fn control_handle(&self) -> &EmulatorControlHandle {
1148        &self.control_handle
1149    }
1150
1151    fn drop_without_shutdown(mut self) {
1152        // Safety: drops once, never accessed again due to mem::forget
1153        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1154        // Prevent Drop from running (which would shut down the channel)
1155        std::mem::forget(self);
1156    }
1157}
1158
1159impl EmulatorPublishResponder {
1160    /// Sends a response to the FIDL transaction.
1161    ///
1162    /// Sets the channel to shutdown if an error occurs.
1163    pub fn send(self, mut result: Result<(), EmulatorError>) -> Result<(), fidl::Error> {
1164        let _result = self.send_raw(result);
1165        if _result.is_err() {
1166            self.control_handle.shutdown();
1167        }
1168        self.drop_without_shutdown();
1169        _result
1170    }
1171
1172    /// Similar to "send" but does not shutdown the channel if an error occurs.
1173    pub fn send_no_shutdown_on_err(
1174        self,
1175        mut result: Result<(), EmulatorError>,
1176    ) -> Result<(), fidl::Error> {
1177        let _result = self.send_raw(result);
1178        self.drop_without_shutdown();
1179        _result
1180    }
1181
1182    fn send_raw(&self, mut result: Result<(), EmulatorError>) -> Result<(), fidl::Error> {
1183        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1184            fidl::encoding::EmptyStruct,
1185            EmulatorError,
1186        >>(
1187            fidl::encoding::FlexibleResult::new(result),
1188            self.tx_id,
1189            0x5b8aeb2ece853c39,
1190            fidl::encoding::DynamicFlags::FLEXIBLE,
1191        )
1192    }
1193}
1194
1195#[must_use = "FIDL methods require a response to be sent"]
1196#[derive(Debug)]
1197pub struct EmulatorAddLowEnergyPeerResponder {
1198    control_handle: std::mem::ManuallyDrop<EmulatorControlHandle>,
1199    tx_id: u32,
1200}
1201
1202/// Set the the channel to be shutdown (see [`EmulatorControlHandle::shutdown`])
1203/// if the responder is dropped without sending a response, so that the client
1204/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1205impl std::ops::Drop for EmulatorAddLowEnergyPeerResponder {
1206    fn drop(&mut self) {
1207        self.control_handle.shutdown();
1208        // Safety: drops once, never accessed again
1209        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1210    }
1211}
1212
1213impl fidl::endpoints::Responder for EmulatorAddLowEnergyPeerResponder {
1214    type ControlHandle = EmulatorControlHandle;
1215
1216    fn control_handle(&self) -> &EmulatorControlHandle {
1217        &self.control_handle
1218    }
1219
1220    fn drop_without_shutdown(mut self) {
1221        // Safety: drops once, never accessed again due to mem::forget
1222        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1223        // Prevent Drop from running (which would shut down the channel)
1224        std::mem::forget(self);
1225    }
1226}
1227
1228impl EmulatorAddLowEnergyPeerResponder {
1229    /// Sends a response to the FIDL transaction.
1230    ///
1231    /// Sets the channel to shutdown if an error occurs.
1232    pub fn send(self, mut result: Result<(), EmulatorPeerError>) -> Result<(), fidl::Error> {
1233        let _result = self.send_raw(result);
1234        if _result.is_err() {
1235            self.control_handle.shutdown();
1236        }
1237        self.drop_without_shutdown();
1238        _result
1239    }
1240
1241    /// Similar to "send" but does not shutdown the channel if an error occurs.
1242    pub fn send_no_shutdown_on_err(
1243        self,
1244        mut result: Result<(), EmulatorPeerError>,
1245    ) -> Result<(), fidl::Error> {
1246        let _result = self.send_raw(result);
1247        self.drop_without_shutdown();
1248        _result
1249    }
1250
1251    fn send_raw(&self, mut result: Result<(), EmulatorPeerError>) -> Result<(), fidl::Error> {
1252        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1253            fidl::encoding::EmptyStruct,
1254            EmulatorPeerError,
1255        >>(
1256            fidl::encoding::FlexibleResult::new(result),
1257            self.tx_id,
1258            0x4e1fb7adbebc6946,
1259            fidl::encoding::DynamicFlags::FLEXIBLE,
1260        )
1261    }
1262}
1263
1264#[must_use = "FIDL methods require a response to be sent"]
1265#[derive(Debug)]
1266pub struct EmulatorAddBredrPeerResponder {
1267    control_handle: std::mem::ManuallyDrop<EmulatorControlHandle>,
1268    tx_id: u32,
1269}
1270
1271/// Set the the channel to be shutdown (see [`EmulatorControlHandle::shutdown`])
1272/// if the responder is dropped without sending a response, so that the client
1273/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1274impl std::ops::Drop for EmulatorAddBredrPeerResponder {
1275    fn drop(&mut self) {
1276        self.control_handle.shutdown();
1277        // Safety: drops once, never accessed again
1278        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1279    }
1280}
1281
1282impl fidl::endpoints::Responder for EmulatorAddBredrPeerResponder {
1283    type ControlHandle = EmulatorControlHandle;
1284
1285    fn control_handle(&self) -> &EmulatorControlHandle {
1286        &self.control_handle
1287    }
1288
1289    fn drop_without_shutdown(mut self) {
1290        // Safety: drops once, never accessed again due to mem::forget
1291        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1292        // Prevent Drop from running (which would shut down the channel)
1293        std::mem::forget(self);
1294    }
1295}
1296
1297impl EmulatorAddBredrPeerResponder {
1298    /// Sends a response to the FIDL transaction.
1299    ///
1300    /// Sets the channel to shutdown if an error occurs.
1301    pub fn send(self, mut result: Result<(), EmulatorPeerError>) -> Result<(), fidl::Error> {
1302        let _result = self.send_raw(result);
1303        if _result.is_err() {
1304            self.control_handle.shutdown();
1305        }
1306        self.drop_without_shutdown();
1307        _result
1308    }
1309
1310    /// Similar to "send" but does not shutdown the channel if an error occurs.
1311    pub fn send_no_shutdown_on_err(
1312        self,
1313        mut result: Result<(), EmulatorPeerError>,
1314    ) -> Result<(), fidl::Error> {
1315        let _result = self.send_raw(result);
1316        self.drop_without_shutdown();
1317        _result
1318    }
1319
1320    fn send_raw(&self, mut result: Result<(), EmulatorPeerError>) -> Result<(), fidl::Error> {
1321        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1322            fidl::encoding::EmptyStruct,
1323            EmulatorPeerError,
1324        >>(
1325            fidl::encoding::FlexibleResult::new(result),
1326            self.tx_id,
1327            0x6d15989a0373e07,
1328            fidl::encoding::DynamicFlags::FLEXIBLE,
1329        )
1330    }
1331}
1332
1333#[must_use = "FIDL methods require a response to be sent"]
1334#[derive(Debug)]
1335pub struct EmulatorWatchControllerParametersResponder {
1336    control_handle: std::mem::ManuallyDrop<EmulatorControlHandle>,
1337    tx_id: u32,
1338}
1339
1340/// Set the the channel to be shutdown (see [`EmulatorControlHandle::shutdown`])
1341/// if the responder is dropped without sending a response, so that the client
1342/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1343impl std::ops::Drop for EmulatorWatchControllerParametersResponder {
1344    fn drop(&mut self) {
1345        self.control_handle.shutdown();
1346        // Safety: drops once, never accessed again
1347        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1348    }
1349}
1350
1351impl fidl::endpoints::Responder for EmulatorWatchControllerParametersResponder {
1352    type ControlHandle = EmulatorControlHandle;
1353
1354    fn control_handle(&self) -> &EmulatorControlHandle {
1355        &self.control_handle
1356    }
1357
1358    fn drop_without_shutdown(mut self) {
1359        // Safety: drops once, never accessed again due to mem::forget
1360        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1361        // Prevent Drop from running (which would shut down the channel)
1362        std::mem::forget(self);
1363    }
1364}
1365
1366impl EmulatorWatchControllerParametersResponder {
1367    /// Sends a response to the FIDL transaction.
1368    ///
1369    /// Sets the channel to shutdown if an error occurs.
1370    pub fn send(self, mut payload: &ControllerParameters) -> Result<(), fidl::Error> {
1371        let _result = self.send_raw(payload);
1372        if _result.is_err() {
1373            self.control_handle.shutdown();
1374        }
1375        self.drop_without_shutdown();
1376        _result
1377    }
1378
1379    /// Similar to "send" but does not shutdown the channel if an error occurs.
1380    pub fn send_no_shutdown_on_err(
1381        self,
1382        mut payload: &ControllerParameters,
1383    ) -> Result<(), fidl::Error> {
1384        let _result = self.send_raw(payload);
1385        self.drop_without_shutdown();
1386        _result
1387    }
1388
1389    fn send_raw(&self, mut payload: &ControllerParameters) -> Result<(), fidl::Error> {
1390        self.control_handle.inner.send::<fidl::encoding::FlexibleType<ControllerParameters>>(
1391            fidl::encoding::Flexible::new(payload),
1392            self.tx_id,
1393            0x6ed7a918b5800270,
1394            fidl::encoding::DynamicFlags::FLEXIBLE,
1395        )
1396    }
1397}
1398
1399#[must_use = "FIDL methods require a response to be sent"]
1400#[derive(Debug)]
1401pub struct EmulatorWatchLeScanStatesResponder {
1402    control_handle: std::mem::ManuallyDrop<EmulatorControlHandle>,
1403    tx_id: u32,
1404}
1405
1406/// Set the the channel to be shutdown (see [`EmulatorControlHandle::shutdown`])
1407/// if the responder is dropped without sending a response, so that the client
1408/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1409impl std::ops::Drop for EmulatorWatchLeScanStatesResponder {
1410    fn drop(&mut self) {
1411        self.control_handle.shutdown();
1412        // Safety: drops once, never accessed again
1413        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1414    }
1415}
1416
1417impl fidl::endpoints::Responder for EmulatorWatchLeScanStatesResponder {
1418    type ControlHandle = EmulatorControlHandle;
1419
1420    fn control_handle(&self) -> &EmulatorControlHandle {
1421        &self.control_handle
1422    }
1423
1424    fn drop_without_shutdown(mut self) {
1425        // Safety: drops once, never accessed again due to mem::forget
1426        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1427        // Prevent Drop from running (which would shut down the channel)
1428        std::mem::forget(self);
1429    }
1430}
1431
1432impl EmulatorWatchLeScanStatesResponder {
1433    /// Sends a response to the FIDL transaction.
1434    ///
1435    /// Sets the channel to shutdown if an error occurs.
1436    pub fn send(self, mut states: &[LeScanState]) -> Result<(), fidl::Error> {
1437        let _result = self.send_raw(states);
1438        if _result.is_err() {
1439            self.control_handle.shutdown();
1440        }
1441        self.drop_without_shutdown();
1442        _result
1443    }
1444
1445    /// Similar to "send" but does not shutdown the channel if an error occurs.
1446    pub fn send_no_shutdown_on_err(self, mut states: &[LeScanState]) -> Result<(), fidl::Error> {
1447        let _result = self.send_raw(states);
1448        self.drop_without_shutdown();
1449        _result
1450    }
1451
1452    fn send_raw(&self, mut states: &[LeScanState]) -> Result<(), fidl::Error> {
1453        self.control_handle
1454            .inner
1455            .send::<fidl::encoding::FlexibleType<EmulatorWatchLeScanStatesResponse>>(
1456                fidl::encoding::Flexible::new((states,)),
1457                self.tx_id,
1458                0x10e6c845831f3b4a,
1459                fidl::encoding::DynamicFlags::FLEXIBLE,
1460            )
1461    }
1462}
1463
1464#[must_use = "FIDL methods require a response to be sent"]
1465#[derive(Debug)]
1466pub struct EmulatorWatchLegacyAdvertisingStatesResponder {
1467    control_handle: std::mem::ManuallyDrop<EmulatorControlHandle>,
1468    tx_id: u32,
1469}
1470
1471/// Set the the channel to be shutdown (see [`EmulatorControlHandle::shutdown`])
1472/// if the responder is dropped without sending a response, so that the client
1473/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1474impl std::ops::Drop for EmulatorWatchLegacyAdvertisingStatesResponder {
1475    fn drop(&mut self) {
1476        self.control_handle.shutdown();
1477        // Safety: drops once, never accessed again
1478        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1479    }
1480}
1481
1482impl fidl::endpoints::Responder for EmulatorWatchLegacyAdvertisingStatesResponder {
1483    type ControlHandle = EmulatorControlHandle;
1484
1485    fn control_handle(&self) -> &EmulatorControlHandle {
1486        &self.control_handle
1487    }
1488
1489    fn drop_without_shutdown(mut self) {
1490        // Safety: drops once, never accessed again due to mem::forget
1491        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1492        // Prevent Drop from running (which would shut down the channel)
1493        std::mem::forget(self);
1494    }
1495}
1496
1497impl EmulatorWatchLegacyAdvertisingStatesResponder {
1498    /// Sends a response to the FIDL transaction.
1499    ///
1500    /// Sets the channel to shutdown if an error occurs.
1501    pub fn send(self, mut states: &[LegacyAdvertisingState]) -> Result<(), fidl::Error> {
1502        let _result = self.send_raw(states);
1503        if _result.is_err() {
1504            self.control_handle.shutdown();
1505        }
1506        self.drop_without_shutdown();
1507        _result
1508    }
1509
1510    /// Similar to "send" but does not shutdown the channel if an error occurs.
1511    pub fn send_no_shutdown_on_err(
1512        self,
1513        mut states: &[LegacyAdvertisingState],
1514    ) -> Result<(), fidl::Error> {
1515        let _result = self.send_raw(states);
1516        self.drop_without_shutdown();
1517        _result
1518    }
1519
1520    fn send_raw(&self, mut states: &[LegacyAdvertisingState]) -> Result<(), fidl::Error> {
1521        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1522            EmulatorWatchLegacyAdvertisingStatesResponse,
1523        >>(
1524            fidl::encoding::Flexible::new((states,)),
1525            self.tx_id,
1526            0x7067acbe275d0219,
1527            fidl::encoding::DynamicFlags::FLEXIBLE,
1528        )
1529    }
1530}
1531
1532#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1533pub struct HciMarker;
1534
1535impl fidl::endpoints::ProtocolMarker for HciMarker {
1536    type Proxy = HciProxy;
1537    type RequestStream = HciRequestStream;
1538    #[cfg(target_os = "fuchsia")]
1539    type SynchronousProxy = HciSynchronousProxy;
1540
1541    const DEBUG_NAME: &'static str = "(anonymous) Hci";
1542}
1543pub type HciOpenCommandChannelResult = Result<(), i32>;
1544pub type HciOpenAclDataChannelResult = Result<(), i32>;
1545pub type HciOpenScoDataChannelResult = Result<(), i32>;
1546pub type HciConfigureScoResult = Result<(), i32>;
1547pub type HciResetScoResult = Result<(), i32>;
1548pub type HciOpenIsoDataChannelResult = Result<(), i32>;
1549pub type HciOpenSnoopChannelResult = Result<(), i32>;
1550
1551pub trait HciProxyInterface: Send + Sync {
1552    type OpenCommandChannelResponseFut: std::future::Future<Output = Result<HciOpenCommandChannelResult, fidl::Error>>
1553        + Send;
1554    fn r#open_command_channel(&self, channel: fidl::Channel)
1555    -> Self::OpenCommandChannelResponseFut;
1556    type OpenAclDataChannelResponseFut: std::future::Future<Output = Result<HciOpenAclDataChannelResult, fidl::Error>>
1557        + Send;
1558    fn r#open_acl_data_channel(
1559        &self,
1560        channel: fidl::Channel,
1561    ) -> Self::OpenAclDataChannelResponseFut;
1562    type OpenScoDataChannelResponseFut: std::future::Future<Output = Result<HciOpenScoDataChannelResult, fidl::Error>>
1563        + Send;
1564    fn r#open_sco_data_channel(
1565        &self,
1566        channel: fidl::Channel,
1567    ) -> Self::OpenScoDataChannelResponseFut;
1568    type ConfigureScoResponseFut: std::future::Future<Output = Result<HciConfigureScoResult, fidl::Error>>
1569        + Send;
1570    fn r#configure_sco(
1571        &self,
1572        coding_format: ScoCodingFormat,
1573        encoding: ScoEncoding,
1574        sample_rate: ScoSampleRate,
1575    ) -> Self::ConfigureScoResponseFut;
1576    type ResetScoResponseFut: std::future::Future<Output = Result<HciResetScoResult, fidl::Error>>
1577        + Send;
1578    fn r#reset_sco(&self) -> Self::ResetScoResponseFut;
1579    type OpenIsoDataChannelResponseFut: std::future::Future<Output = Result<HciOpenIsoDataChannelResult, fidl::Error>>
1580        + Send;
1581    fn r#open_iso_data_channel(
1582        &self,
1583        channel: fidl::Channel,
1584    ) -> Self::OpenIsoDataChannelResponseFut;
1585    type OpenSnoopChannelResponseFut: std::future::Future<Output = Result<HciOpenSnoopChannelResult, fidl::Error>>
1586        + Send;
1587    fn r#open_snoop_channel(&self, channel: fidl::Channel) -> Self::OpenSnoopChannelResponseFut;
1588}
1589#[derive(Debug)]
1590#[cfg(target_os = "fuchsia")]
1591pub struct HciSynchronousProxy {
1592    client: fidl::client::sync::Client,
1593}
1594
1595#[cfg(target_os = "fuchsia")]
1596impl fidl::endpoints::SynchronousProxy for HciSynchronousProxy {
1597    type Proxy = HciProxy;
1598    type Protocol = HciMarker;
1599
1600    fn from_channel(inner: fidl::Channel) -> Self {
1601        Self::new(inner)
1602    }
1603
1604    fn into_channel(self) -> fidl::Channel {
1605        self.client.into_channel()
1606    }
1607
1608    fn as_channel(&self) -> &fidl::Channel {
1609        self.client.as_channel()
1610    }
1611}
1612
1613#[cfg(target_os = "fuchsia")]
1614impl HciSynchronousProxy {
1615    pub fn new(channel: fidl::Channel) -> Self {
1616        Self { client: fidl::client::sync::Client::new(channel) }
1617    }
1618
1619    pub fn into_channel(self) -> fidl::Channel {
1620        self.client.into_channel()
1621    }
1622
1623    /// Waits until an event arrives and returns it. It is safe for other
1624    /// threads to make concurrent requests while waiting for an event.
1625    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<HciEvent, fidl::Error> {
1626        HciEvent::decode(self.client.wait_for_event::<HciMarker>(deadline)?)
1627    }
1628
1629    /// Open the two-way HCI command channel for sending HCI commands and
1630    /// receiving event packets.  Returns ZX_ERR_ALREADY_BOUND if the channel
1631    /// is already open.
1632    pub fn r#open_command_channel(
1633        &self,
1634        mut channel: fidl::Channel,
1635        ___deadline: zx::MonotonicInstant,
1636    ) -> Result<HciOpenCommandChannelResult, fidl::Error> {
1637        let _response = self.client.send_query::<
1638            HciOpenCommandChannelRequest,
1639            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1640            HciMarker,
1641        >(
1642            (channel,),
1643            0x2510b52ea3a51ce0,
1644            fidl::encoding::DynamicFlags::FLEXIBLE,
1645            ___deadline,
1646        )?
1647        .into_result::<HciMarker>("open_command_channel")?;
1648        Ok(_response.map(|x| x))
1649    }
1650
1651    /// Open the two-way HCI ACL data channel.
1652    /// Returns ZX_ERR_ALREADY_BOUND if the channel is already open.
1653    pub fn r#open_acl_data_channel(
1654        &self,
1655        mut channel: fidl::Channel,
1656        ___deadline: zx::MonotonicInstant,
1657    ) -> Result<HciOpenAclDataChannelResult, fidl::Error> {
1658        let _response = self.client.send_query::<
1659            HciOpenAclDataChannelRequest,
1660            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1661            HciMarker,
1662        >(
1663            (channel,),
1664            0x210c3dd69156385a,
1665            fidl::encoding::DynamicFlags::FLEXIBLE,
1666            ___deadline,
1667        )?
1668        .into_result::<HciMarker>("open_acl_data_channel")?;
1669        Ok(_response.map(|x| x))
1670    }
1671
1672    /// Opens a SCO channel on the provided handle. The zircon channel is
1673    /// closed in the event of an error opening the hci channel or if the hci
1674    /// channel is already associated with a handle to another zircon channel.
1675    /// Returns ZX_ERR_NOT_SUPPORTED if SCO is not supported by the current vendor or transport
1676    /// driver.
1677    /// Returns ZX_ERR_ALREADY_BOUND if the channel is already open.
1678    pub fn r#open_sco_data_channel(
1679        &self,
1680        mut channel: fidl::Channel,
1681        ___deadline: zx::MonotonicInstant,
1682    ) -> Result<HciOpenScoDataChannelResult, fidl::Error> {
1683        let _response = self.client.send_query::<
1684            HciOpenScoDataChannelRequest,
1685            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1686            HciMarker,
1687        >(
1688            (channel,),
1689            0x5bcb0bf2cbf35bdf,
1690            fidl::encoding::DynamicFlags::FLEXIBLE,
1691            ___deadline,
1692        )?
1693        .into_result::<HciMarker>("open_sco_data_channel")?;
1694        Ok(_response.map(|x| x))
1695    }
1696
1697    /// Configure the HCI for a SCO connection with the indicated parameters.
1698    /// This must be called before sending/receiving data on the SCO channel.
1699    /// Returns ZX_ERR_NOT_SUPPORTED if SCO is not supported by the current vendor or transport
1700    /// driver.
1701    pub fn r#configure_sco(
1702        &self,
1703        mut coding_format: ScoCodingFormat,
1704        mut encoding: ScoEncoding,
1705        mut sample_rate: ScoSampleRate,
1706        ___deadline: zx::MonotonicInstant,
1707    ) -> Result<HciConfigureScoResult, fidl::Error> {
1708        let _response = self.client.send_query::<
1709            HciConfigureScoRequest,
1710            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1711            HciMarker,
1712        >(
1713            (coding_format, encoding, sample_rate,),
1714            0x499ec7edfd65fad7,
1715            fidl::encoding::DynamicFlags::FLEXIBLE,
1716            ___deadline,
1717        )?
1718        .into_result::<HciMarker>("configure_sco")?;
1719        Ok(_response.map(|x| x))
1720    }
1721
1722    /// Releases resources held by an active SCO connection. Must be called
1723    /// when a SCO connection is closed.
1724    /// Returns ZX_ERR_NOT_SUPPORTED if SCO is not supported by the current vendor or transport
1725    /// driver.
1726    pub fn r#reset_sco(
1727        &self,
1728        ___deadline: zx::MonotonicInstant,
1729    ) -> Result<HciResetScoResult, fidl::Error> {
1730        let _response = self.client.send_query::<
1731            fidl::encoding::EmptyPayload,
1732            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1733            HciMarker,
1734        >(
1735            (),
1736            0x6ee56dcb2ce23fcb,
1737            fidl::encoding::DynamicFlags::FLEXIBLE,
1738            ___deadline,
1739        )?
1740        .into_result::<HciMarker>("reset_sco")?;
1741        Ok(_response.map(|x| x))
1742    }
1743
1744    /// Opens a channel on the provided handle for sending and receiving isochronous data packets.
1745    /// The zircon channel is closed in the event of an error opening the hci channel or if the hci
1746    /// channel is already associated with a handle to another zircon channel.
1747    /// Returns ZX_ERR_NOT_SUPPORTED if ISO is not supported by the current vendor or transport
1748    /// driver.
1749    /// Returns ZX_ERR_ALREADY_BOUND if the channel is already open.
1750    pub fn r#open_iso_data_channel(
1751        &self,
1752        mut channel: fidl::Channel,
1753        ___deadline: zx::MonotonicInstant,
1754    ) -> Result<HciOpenIsoDataChannelResult, fidl::Error> {
1755        let _response = self.client.send_query::<
1756            HciOpenIsoDataChannelRequest,
1757            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1758            HciMarker,
1759        >(
1760            (channel,),
1761            0x9adfa1d466cefd4,
1762            fidl::encoding::DynamicFlags::FLEXIBLE,
1763            ___deadline,
1764        )?
1765        .into_result::<HciMarker>("open_iso_data_channel")?;
1766        Ok(_response.map(|x| x))
1767    }
1768
1769    /// Open an output-only channel for monitoring HCI traffic.
1770    /// The format of each message is: [1-octet flags] [n-octet payload]
1771    /// The flags octet is a bitfield with the following values defined:
1772    ///  - 0x00: The payload represents a command packet sent from the host to the
1773    ///          controller.
1774    ///  - 0x01: The payload represents an event packet sent by the controller.
1775    /// Returns ZX_ERR_ALREADY_BOUND if the channel is already open.
1776    pub fn r#open_snoop_channel(
1777        &self,
1778        mut channel: fidl::Channel,
1779        ___deadline: zx::MonotonicInstant,
1780    ) -> Result<HciOpenSnoopChannelResult, fidl::Error> {
1781        let _response = self.client.send_query::<
1782            HciOpenSnoopChannelRequest,
1783            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1784            HciMarker,
1785        >(
1786            (channel,),
1787            0xd31c6d5cbc4e136,
1788            fidl::encoding::DynamicFlags::FLEXIBLE,
1789            ___deadline,
1790        )?
1791        .into_result::<HciMarker>("open_snoop_channel")?;
1792        Ok(_response.map(|x| x))
1793    }
1794}
1795
1796#[cfg(target_os = "fuchsia")]
1797impl From<HciSynchronousProxy> for zx::NullableHandle {
1798    fn from(value: HciSynchronousProxy) -> Self {
1799        value.into_channel().into()
1800    }
1801}
1802
1803#[cfg(target_os = "fuchsia")]
1804impl From<fidl::Channel> for HciSynchronousProxy {
1805    fn from(value: fidl::Channel) -> Self {
1806        Self::new(value)
1807    }
1808}
1809
1810#[cfg(target_os = "fuchsia")]
1811impl fidl::endpoints::FromClient for HciSynchronousProxy {
1812    type Protocol = HciMarker;
1813
1814    fn from_client(value: fidl::endpoints::ClientEnd<HciMarker>) -> Self {
1815        Self::new(value.into_channel())
1816    }
1817}
1818
1819#[derive(Debug, Clone)]
1820pub struct HciProxy {
1821    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1822}
1823
1824impl fidl::endpoints::Proxy for HciProxy {
1825    type Protocol = HciMarker;
1826
1827    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1828        Self::new(inner)
1829    }
1830
1831    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1832        self.client.into_channel().map_err(|client| Self { client })
1833    }
1834
1835    fn as_channel(&self) -> &::fidl::AsyncChannel {
1836        self.client.as_channel()
1837    }
1838}
1839
1840impl HciProxy {
1841    /// Create a new Proxy for fuchsia.hardware.bluetooth/Hci.
1842    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1843        let protocol_name = <HciMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1844        Self { client: fidl::client::Client::new(channel, protocol_name) }
1845    }
1846
1847    /// Get a Stream of events from the remote end of the protocol.
1848    ///
1849    /// # Panics
1850    ///
1851    /// Panics if the event stream was already taken.
1852    pub fn take_event_stream(&self) -> HciEventStream {
1853        HciEventStream { event_receiver: self.client.take_event_receiver() }
1854    }
1855
1856    /// Open the two-way HCI command channel for sending HCI commands and
1857    /// receiving event packets.  Returns ZX_ERR_ALREADY_BOUND if the channel
1858    /// is already open.
1859    pub fn r#open_command_channel(
1860        &self,
1861        mut channel: fidl::Channel,
1862    ) -> fidl::client::QueryResponseFut<
1863        HciOpenCommandChannelResult,
1864        fidl::encoding::DefaultFuchsiaResourceDialect,
1865    > {
1866        HciProxyInterface::r#open_command_channel(self, channel)
1867    }
1868
1869    /// Open the two-way HCI ACL data channel.
1870    /// Returns ZX_ERR_ALREADY_BOUND if the channel is already open.
1871    pub fn r#open_acl_data_channel(
1872        &self,
1873        mut channel: fidl::Channel,
1874    ) -> fidl::client::QueryResponseFut<
1875        HciOpenAclDataChannelResult,
1876        fidl::encoding::DefaultFuchsiaResourceDialect,
1877    > {
1878        HciProxyInterface::r#open_acl_data_channel(self, channel)
1879    }
1880
1881    /// Opens a SCO channel on the provided handle. The zircon channel is
1882    /// closed in the event of an error opening the hci channel or if the hci
1883    /// channel is already associated with a handle to another zircon channel.
1884    /// Returns ZX_ERR_NOT_SUPPORTED if SCO is not supported by the current vendor or transport
1885    /// driver.
1886    /// Returns ZX_ERR_ALREADY_BOUND if the channel is already open.
1887    pub fn r#open_sco_data_channel(
1888        &self,
1889        mut channel: fidl::Channel,
1890    ) -> fidl::client::QueryResponseFut<
1891        HciOpenScoDataChannelResult,
1892        fidl::encoding::DefaultFuchsiaResourceDialect,
1893    > {
1894        HciProxyInterface::r#open_sco_data_channel(self, channel)
1895    }
1896
1897    /// Configure the HCI for a SCO connection with the indicated parameters.
1898    /// This must be called before sending/receiving data on the SCO channel.
1899    /// Returns ZX_ERR_NOT_SUPPORTED if SCO is not supported by the current vendor or transport
1900    /// driver.
1901    pub fn r#configure_sco(
1902        &self,
1903        mut coding_format: ScoCodingFormat,
1904        mut encoding: ScoEncoding,
1905        mut sample_rate: ScoSampleRate,
1906    ) -> fidl::client::QueryResponseFut<
1907        HciConfigureScoResult,
1908        fidl::encoding::DefaultFuchsiaResourceDialect,
1909    > {
1910        HciProxyInterface::r#configure_sco(self, coding_format, encoding, sample_rate)
1911    }
1912
1913    /// Releases resources held by an active SCO connection. Must be called
1914    /// when a SCO connection is closed.
1915    /// Returns ZX_ERR_NOT_SUPPORTED if SCO is not supported by the current vendor or transport
1916    /// driver.
1917    pub fn r#reset_sco(
1918        &self,
1919    ) -> fidl::client::QueryResponseFut<
1920        HciResetScoResult,
1921        fidl::encoding::DefaultFuchsiaResourceDialect,
1922    > {
1923        HciProxyInterface::r#reset_sco(self)
1924    }
1925
1926    /// Opens a channel on the provided handle for sending and receiving isochronous data packets.
1927    /// The zircon channel is closed in the event of an error opening the hci channel or if the hci
1928    /// channel is already associated with a handle to another zircon channel.
1929    /// Returns ZX_ERR_NOT_SUPPORTED if ISO is not supported by the current vendor or transport
1930    /// driver.
1931    /// Returns ZX_ERR_ALREADY_BOUND if the channel is already open.
1932    pub fn r#open_iso_data_channel(
1933        &self,
1934        mut channel: fidl::Channel,
1935    ) -> fidl::client::QueryResponseFut<
1936        HciOpenIsoDataChannelResult,
1937        fidl::encoding::DefaultFuchsiaResourceDialect,
1938    > {
1939        HciProxyInterface::r#open_iso_data_channel(self, channel)
1940    }
1941
1942    /// Open an output-only channel for monitoring HCI traffic.
1943    /// The format of each message is: [1-octet flags] [n-octet payload]
1944    /// The flags octet is a bitfield with the following values defined:
1945    ///  - 0x00: The payload represents a command packet sent from the host to the
1946    ///          controller.
1947    ///  - 0x01: The payload represents an event packet sent by the controller.
1948    /// Returns ZX_ERR_ALREADY_BOUND if the channel is already open.
1949    pub fn r#open_snoop_channel(
1950        &self,
1951        mut channel: fidl::Channel,
1952    ) -> fidl::client::QueryResponseFut<
1953        HciOpenSnoopChannelResult,
1954        fidl::encoding::DefaultFuchsiaResourceDialect,
1955    > {
1956        HciProxyInterface::r#open_snoop_channel(self, channel)
1957    }
1958}
1959
1960impl HciProxyInterface for HciProxy {
1961    type OpenCommandChannelResponseFut = fidl::client::QueryResponseFut<
1962        HciOpenCommandChannelResult,
1963        fidl::encoding::DefaultFuchsiaResourceDialect,
1964    >;
1965    fn r#open_command_channel(
1966        &self,
1967        mut channel: fidl::Channel,
1968    ) -> Self::OpenCommandChannelResponseFut {
1969        fn _decode(
1970            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1971        ) -> Result<HciOpenCommandChannelResult, fidl::Error> {
1972            let _response = fidl::client::decode_transaction_body::<
1973                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1974                fidl::encoding::DefaultFuchsiaResourceDialect,
1975                0x2510b52ea3a51ce0,
1976            >(_buf?)?
1977            .into_result::<HciMarker>("open_command_channel")?;
1978            Ok(_response.map(|x| x))
1979        }
1980        self.client
1981            .send_query_and_decode::<HciOpenCommandChannelRequest, HciOpenCommandChannelResult>(
1982                (channel,),
1983                0x2510b52ea3a51ce0,
1984                fidl::encoding::DynamicFlags::FLEXIBLE,
1985                _decode,
1986            )
1987    }
1988
1989    type OpenAclDataChannelResponseFut = fidl::client::QueryResponseFut<
1990        HciOpenAclDataChannelResult,
1991        fidl::encoding::DefaultFuchsiaResourceDialect,
1992    >;
1993    fn r#open_acl_data_channel(
1994        &self,
1995        mut channel: fidl::Channel,
1996    ) -> Self::OpenAclDataChannelResponseFut {
1997        fn _decode(
1998            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1999        ) -> Result<HciOpenAclDataChannelResult, fidl::Error> {
2000            let _response = fidl::client::decode_transaction_body::<
2001                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2002                fidl::encoding::DefaultFuchsiaResourceDialect,
2003                0x210c3dd69156385a,
2004            >(_buf?)?
2005            .into_result::<HciMarker>("open_acl_data_channel")?;
2006            Ok(_response.map(|x| x))
2007        }
2008        self.client
2009            .send_query_and_decode::<HciOpenAclDataChannelRequest, HciOpenAclDataChannelResult>(
2010                (channel,),
2011                0x210c3dd69156385a,
2012                fidl::encoding::DynamicFlags::FLEXIBLE,
2013                _decode,
2014            )
2015    }
2016
2017    type OpenScoDataChannelResponseFut = fidl::client::QueryResponseFut<
2018        HciOpenScoDataChannelResult,
2019        fidl::encoding::DefaultFuchsiaResourceDialect,
2020    >;
2021    fn r#open_sco_data_channel(
2022        &self,
2023        mut channel: fidl::Channel,
2024    ) -> Self::OpenScoDataChannelResponseFut {
2025        fn _decode(
2026            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2027        ) -> Result<HciOpenScoDataChannelResult, fidl::Error> {
2028            let _response = fidl::client::decode_transaction_body::<
2029                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2030                fidl::encoding::DefaultFuchsiaResourceDialect,
2031                0x5bcb0bf2cbf35bdf,
2032            >(_buf?)?
2033            .into_result::<HciMarker>("open_sco_data_channel")?;
2034            Ok(_response.map(|x| x))
2035        }
2036        self.client
2037            .send_query_and_decode::<HciOpenScoDataChannelRequest, HciOpenScoDataChannelResult>(
2038                (channel,),
2039                0x5bcb0bf2cbf35bdf,
2040                fidl::encoding::DynamicFlags::FLEXIBLE,
2041                _decode,
2042            )
2043    }
2044
2045    type ConfigureScoResponseFut = fidl::client::QueryResponseFut<
2046        HciConfigureScoResult,
2047        fidl::encoding::DefaultFuchsiaResourceDialect,
2048    >;
2049    fn r#configure_sco(
2050        &self,
2051        mut coding_format: ScoCodingFormat,
2052        mut encoding: ScoEncoding,
2053        mut sample_rate: ScoSampleRate,
2054    ) -> Self::ConfigureScoResponseFut {
2055        fn _decode(
2056            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2057        ) -> Result<HciConfigureScoResult, fidl::Error> {
2058            let _response = fidl::client::decode_transaction_body::<
2059                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2060                fidl::encoding::DefaultFuchsiaResourceDialect,
2061                0x499ec7edfd65fad7,
2062            >(_buf?)?
2063            .into_result::<HciMarker>("configure_sco")?;
2064            Ok(_response.map(|x| x))
2065        }
2066        self.client.send_query_and_decode::<HciConfigureScoRequest, HciConfigureScoResult>(
2067            (coding_format, encoding, sample_rate),
2068            0x499ec7edfd65fad7,
2069            fidl::encoding::DynamicFlags::FLEXIBLE,
2070            _decode,
2071        )
2072    }
2073
2074    type ResetScoResponseFut = fidl::client::QueryResponseFut<
2075        HciResetScoResult,
2076        fidl::encoding::DefaultFuchsiaResourceDialect,
2077    >;
2078    fn r#reset_sco(&self) -> Self::ResetScoResponseFut {
2079        fn _decode(
2080            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2081        ) -> Result<HciResetScoResult, fidl::Error> {
2082            let _response = fidl::client::decode_transaction_body::<
2083                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2084                fidl::encoding::DefaultFuchsiaResourceDialect,
2085                0x6ee56dcb2ce23fcb,
2086            >(_buf?)?
2087            .into_result::<HciMarker>("reset_sco")?;
2088            Ok(_response.map(|x| x))
2089        }
2090        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, HciResetScoResult>(
2091            (),
2092            0x6ee56dcb2ce23fcb,
2093            fidl::encoding::DynamicFlags::FLEXIBLE,
2094            _decode,
2095        )
2096    }
2097
2098    type OpenIsoDataChannelResponseFut = fidl::client::QueryResponseFut<
2099        HciOpenIsoDataChannelResult,
2100        fidl::encoding::DefaultFuchsiaResourceDialect,
2101    >;
2102    fn r#open_iso_data_channel(
2103        &self,
2104        mut channel: fidl::Channel,
2105    ) -> Self::OpenIsoDataChannelResponseFut {
2106        fn _decode(
2107            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2108        ) -> Result<HciOpenIsoDataChannelResult, fidl::Error> {
2109            let _response = fidl::client::decode_transaction_body::<
2110                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2111                fidl::encoding::DefaultFuchsiaResourceDialect,
2112                0x9adfa1d466cefd4,
2113            >(_buf?)?
2114            .into_result::<HciMarker>("open_iso_data_channel")?;
2115            Ok(_response.map(|x| x))
2116        }
2117        self.client
2118            .send_query_and_decode::<HciOpenIsoDataChannelRequest, HciOpenIsoDataChannelResult>(
2119                (channel,),
2120                0x9adfa1d466cefd4,
2121                fidl::encoding::DynamicFlags::FLEXIBLE,
2122                _decode,
2123            )
2124    }
2125
2126    type OpenSnoopChannelResponseFut = fidl::client::QueryResponseFut<
2127        HciOpenSnoopChannelResult,
2128        fidl::encoding::DefaultFuchsiaResourceDialect,
2129    >;
2130    fn r#open_snoop_channel(
2131        &self,
2132        mut channel: fidl::Channel,
2133    ) -> Self::OpenSnoopChannelResponseFut {
2134        fn _decode(
2135            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2136        ) -> Result<HciOpenSnoopChannelResult, fidl::Error> {
2137            let _response = fidl::client::decode_transaction_body::<
2138                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2139                fidl::encoding::DefaultFuchsiaResourceDialect,
2140                0xd31c6d5cbc4e136,
2141            >(_buf?)?
2142            .into_result::<HciMarker>("open_snoop_channel")?;
2143            Ok(_response.map(|x| x))
2144        }
2145        self.client.send_query_and_decode::<HciOpenSnoopChannelRequest, HciOpenSnoopChannelResult>(
2146            (channel,),
2147            0xd31c6d5cbc4e136,
2148            fidl::encoding::DynamicFlags::FLEXIBLE,
2149            _decode,
2150        )
2151    }
2152}
2153
2154pub struct HciEventStream {
2155    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2156}
2157
2158impl std::marker::Unpin for HciEventStream {}
2159
2160impl futures::stream::FusedStream for HciEventStream {
2161    fn is_terminated(&self) -> bool {
2162        self.event_receiver.is_terminated()
2163    }
2164}
2165
2166impl futures::Stream for HciEventStream {
2167    type Item = Result<HciEvent, fidl::Error>;
2168
2169    fn poll_next(
2170        mut self: std::pin::Pin<&mut Self>,
2171        cx: &mut std::task::Context<'_>,
2172    ) -> std::task::Poll<Option<Self::Item>> {
2173        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2174            &mut self.event_receiver,
2175            cx
2176        )?) {
2177            Some(buf) => std::task::Poll::Ready(Some(HciEvent::decode(buf))),
2178            None => std::task::Poll::Ready(None),
2179        }
2180    }
2181}
2182
2183#[derive(Debug)]
2184pub enum HciEvent {
2185    #[non_exhaustive]
2186    _UnknownEvent {
2187        /// Ordinal of the event that was sent.
2188        ordinal: u64,
2189    },
2190}
2191
2192impl HciEvent {
2193    /// Decodes a message buffer as a [`HciEvent`].
2194    fn decode(
2195        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2196    ) -> Result<HciEvent, fidl::Error> {
2197        let (bytes, _handles) = buf.split_mut();
2198        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2199        debug_assert_eq!(tx_header.tx_id, 0);
2200        match tx_header.ordinal {
2201            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2202                Ok(HciEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2203            }
2204            _ => Err(fidl::Error::UnknownOrdinal {
2205                ordinal: tx_header.ordinal,
2206                protocol_name: <HciMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2207            }),
2208        }
2209    }
2210}
2211
2212/// A Stream of incoming requests for fuchsia.hardware.bluetooth/Hci.
2213pub struct HciRequestStream {
2214    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2215    is_terminated: bool,
2216}
2217
2218impl std::marker::Unpin for HciRequestStream {}
2219
2220impl futures::stream::FusedStream for HciRequestStream {
2221    fn is_terminated(&self) -> bool {
2222        self.is_terminated
2223    }
2224}
2225
2226impl fidl::endpoints::RequestStream for HciRequestStream {
2227    type Protocol = HciMarker;
2228    type ControlHandle = HciControlHandle;
2229
2230    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2231        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2232    }
2233
2234    fn control_handle(&self) -> Self::ControlHandle {
2235        HciControlHandle { inner: self.inner.clone() }
2236    }
2237
2238    fn into_inner(
2239        self,
2240    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2241    {
2242        (self.inner, self.is_terminated)
2243    }
2244
2245    fn from_inner(
2246        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2247        is_terminated: bool,
2248    ) -> Self {
2249        Self { inner, is_terminated }
2250    }
2251}
2252
2253impl futures::Stream for HciRequestStream {
2254    type Item = Result<HciRequest, fidl::Error>;
2255
2256    fn poll_next(
2257        mut self: std::pin::Pin<&mut Self>,
2258        cx: &mut std::task::Context<'_>,
2259    ) -> std::task::Poll<Option<Self::Item>> {
2260        let this = &mut *self;
2261        if this.inner.check_shutdown(cx) {
2262            this.is_terminated = true;
2263            return std::task::Poll::Ready(None);
2264        }
2265        if this.is_terminated {
2266            panic!("polled HciRequestStream after completion");
2267        }
2268        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2269            |bytes, handles| {
2270                match this.inner.channel().read_etc(cx, bytes, handles) {
2271                    std::task::Poll::Ready(Ok(())) => {}
2272                    std::task::Poll::Pending => return std::task::Poll::Pending,
2273                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2274                        this.is_terminated = true;
2275                        return std::task::Poll::Ready(None);
2276                    }
2277                    std::task::Poll::Ready(Err(e)) => {
2278                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2279                            e.into(),
2280                        ))));
2281                    }
2282                }
2283
2284                // A message has been received from the channel
2285                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2286
2287                std::task::Poll::Ready(Some(match header.ordinal {
2288                    0x2510b52ea3a51ce0 => {
2289                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2290                        let mut req = fidl::new_empty!(
2291                            HciOpenCommandChannelRequest,
2292                            fidl::encoding::DefaultFuchsiaResourceDialect
2293                        );
2294                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HciOpenCommandChannelRequest>(&header, _body_bytes, handles, &mut req)?;
2295                        let control_handle = HciControlHandle { inner: this.inner.clone() };
2296                        Ok(HciRequest::OpenCommandChannel {
2297                            channel: req.channel,
2298
2299                            responder: HciOpenCommandChannelResponder {
2300                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2301                                tx_id: header.tx_id,
2302                            },
2303                        })
2304                    }
2305                    0x210c3dd69156385a => {
2306                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2307                        let mut req = fidl::new_empty!(
2308                            HciOpenAclDataChannelRequest,
2309                            fidl::encoding::DefaultFuchsiaResourceDialect
2310                        );
2311                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HciOpenAclDataChannelRequest>(&header, _body_bytes, handles, &mut req)?;
2312                        let control_handle = HciControlHandle { inner: this.inner.clone() };
2313                        Ok(HciRequest::OpenAclDataChannel {
2314                            channel: req.channel,
2315
2316                            responder: HciOpenAclDataChannelResponder {
2317                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2318                                tx_id: header.tx_id,
2319                            },
2320                        })
2321                    }
2322                    0x5bcb0bf2cbf35bdf => {
2323                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2324                        let mut req = fidl::new_empty!(
2325                            HciOpenScoDataChannelRequest,
2326                            fidl::encoding::DefaultFuchsiaResourceDialect
2327                        );
2328                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HciOpenScoDataChannelRequest>(&header, _body_bytes, handles, &mut req)?;
2329                        let control_handle = HciControlHandle { inner: this.inner.clone() };
2330                        Ok(HciRequest::OpenScoDataChannel {
2331                            channel: req.channel,
2332
2333                            responder: HciOpenScoDataChannelResponder {
2334                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2335                                tx_id: header.tx_id,
2336                            },
2337                        })
2338                    }
2339                    0x499ec7edfd65fad7 => {
2340                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2341                        let mut req = fidl::new_empty!(
2342                            HciConfigureScoRequest,
2343                            fidl::encoding::DefaultFuchsiaResourceDialect
2344                        );
2345                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HciConfigureScoRequest>(&header, _body_bytes, handles, &mut req)?;
2346                        let control_handle = HciControlHandle { inner: this.inner.clone() };
2347                        Ok(HciRequest::ConfigureSco {
2348                            coding_format: req.coding_format,
2349                            encoding: req.encoding,
2350                            sample_rate: req.sample_rate,
2351
2352                            responder: HciConfigureScoResponder {
2353                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2354                                tx_id: header.tx_id,
2355                            },
2356                        })
2357                    }
2358                    0x6ee56dcb2ce23fcb => {
2359                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2360                        let mut req = fidl::new_empty!(
2361                            fidl::encoding::EmptyPayload,
2362                            fidl::encoding::DefaultFuchsiaResourceDialect
2363                        );
2364                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2365                        let control_handle = HciControlHandle { inner: this.inner.clone() };
2366                        Ok(HciRequest::ResetSco {
2367                            responder: HciResetScoResponder {
2368                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2369                                tx_id: header.tx_id,
2370                            },
2371                        })
2372                    }
2373                    0x9adfa1d466cefd4 => {
2374                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2375                        let mut req = fidl::new_empty!(
2376                            HciOpenIsoDataChannelRequest,
2377                            fidl::encoding::DefaultFuchsiaResourceDialect
2378                        );
2379                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HciOpenIsoDataChannelRequest>(&header, _body_bytes, handles, &mut req)?;
2380                        let control_handle = HciControlHandle { inner: this.inner.clone() };
2381                        Ok(HciRequest::OpenIsoDataChannel {
2382                            channel: req.channel,
2383
2384                            responder: HciOpenIsoDataChannelResponder {
2385                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2386                                tx_id: header.tx_id,
2387                            },
2388                        })
2389                    }
2390                    0xd31c6d5cbc4e136 => {
2391                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2392                        let mut req = fidl::new_empty!(
2393                            HciOpenSnoopChannelRequest,
2394                            fidl::encoding::DefaultFuchsiaResourceDialect
2395                        );
2396                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HciOpenSnoopChannelRequest>(&header, _body_bytes, handles, &mut req)?;
2397                        let control_handle = HciControlHandle { inner: this.inner.clone() };
2398                        Ok(HciRequest::OpenSnoopChannel {
2399                            channel: req.channel,
2400
2401                            responder: HciOpenSnoopChannelResponder {
2402                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2403                                tx_id: header.tx_id,
2404                            },
2405                        })
2406                    }
2407                    _ if header.tx_id == 0
2408                        && header
2409                            .dynamic_flags()
2410                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2411                    {
2412                        Ok(HciRequest::_UnknownMethod {
2413                            ordinal: header.ordinal,
2414                            control_handle: HciControlHandle { inner: this.inner.clone() },
2415                            method_type: fidl::MethodType::OneWay,
2416                        })
2417                    }
2418                    _ if header
2419                        .dynamic_flags()
2420                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2421                    {
2422                        this.inner.send_framework_err(
2423                            fidl::encoding::FrameworkErr::UnknownMethod,
2424                            header.tx_id,
2425                            header.ordinal,
2426                            header.dynamic_flags(),
2427                            (bytes, handles),
2428                        )?;
2429                        Ok(HciRequest::_UnknownMethod {
2430                            ordinal: header.ordinal,
2431                            control_handle: HciControlHandle { inner: this.inner.clone() },
2432                            method_type: fidl::MethodType::TwoWay,
2433                        })
2434                    }
2435                    _ => Err(fidl::Error::UnknownOrdinal {
2436                        ordinal: header.ordinal,
2437                        protocol_name: <HciMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2438                    }),
2439                }))
2440            },
2441        )
2442    }
2443}
2444
2445#[derive(Debug)]
2446pub enum HciRequest {
2447    /// Open the two-way HCI command channel for sending HCI commands and
2448    /// receiving event packets.  Returns ZX_ERR_ALREADY_BOUND if the channel
2449    /// is already open.
2450    OpenCommandChannel { channel: fidl::Channel, responder: HciOpenCommandChannelResponder },
2451    /// Open the two-way HCI ACL data channel.
2452    /// Returns ZX_ERR_ALREADY_BOUND if the channel is already open.
2453    OpenAclDataChannel { channel: fidl::Channel, responder: HciOpenAclDataChannelResponder },
2454    /// Opens a SCO channel on the provided handle. The zircon channel is
2455    /// closed in the event of an error opening the hci channel or if the hci
2456    /// channel is already associated with a handle to another zircon channel.
2457    /// Returns ZX_ERR_NOT_SUPPORTED if SCO is not supported by the current vendor or transport
2458    /// driver.
2459    /// Returns ZX_ERR_ALREADY_BOUND if the channel is already open.
2460    OpenScoDataChannel { channel: fidl::Channel, responder: HciOpenScoDataChannelResponder },
2461    /// Configure the HCI for a SCO connection with the indicated parameters.
2462    /// This must be called before sending/receiving data on the SCO channel.
2463    /// Returns ZX_ERR_NOT_SUPPORTED if SCO is not supported by the current vendor or transport
2464    /// driver.
2465    ConfigureSco {
2466        coding_format: ScoCodingFormat,
2467        encoding: ScoEncoding,
2468        sample_rate: ScoSampleRate,
2469        responder: HciConfigureScoResponder,
2470    },
2471    /// Releases resources held by an active SCO connection. Must be called
2472    /// when a SCO connection is closed.
2473    /// Returns ZX_ERR_NOT_SUPPORTED if SCO is not supported by the current vendor or transport
2474    /// driver.
2475    ResetSco { responder: HciResetScoResponder },
2476    /// Opens a channel on the provided handle for sending and receiving isochronous data packets.
2477    /// The zircon channel is closed in the event of an error opening the hci channel or if the hci
2478    /// channel is already associated with a handle to another zircon channel.
2479    /// Returns ZX_ERR_NOT_SUPPORTED if ISO is not supported by the current vendor or transport
2480    /// driver.
2481    /// Returns ZX_ERR_ALREADY_BOUND if the channel is already open.
2482    OpenIsoDataChannel { channel: fidl::Channel, responder: HciOpenIsoDataChannelResponder },
2483    /// Open an output-only channel for monitoring HCI traffic.
2484    /// The format of each message is: [1-octet flags] [n-octet payload]
2485    /// The flags octet is a bitfield with the following values defined:
2486    ///  - 0x00: The payload represents a command packet sent from the host to the
2487    ///          controller.
2488    ///  - 0x01: The payload represents an event packet sent by the controller.
2489    /// Returns ZX_ERR_ALREADY_BOUND if the channel is already open.
2490    OpenSnoopChannel { channel: fidl::Channel, responder: HciOpenSnoopChannelResponder },
2491    /// An interaction was received which does not match any known method.
2492    #[non_exhaustive]
2493    _UnknownMethod {
2494        /// Ordinal of the method that was called.
2495        ordinal: u64,
2496        control_handle: HciControlHandle,
2497        method_type: fidl::MethodType,
2498    },
2499}
2500
2501impl HciRequest {
2502    #[allow(irrefutable_let_patterns)]
2503    pub fn into_open_command_channel(
2504        self,
2505    ) -> Option<(fidl::Channel, HciOpenCommandChannelResponder)> {
2506        if let HciRequest::OpenCommandChannel { channel, responder } = self {
2507            Some((channel, responder))
2508        } else {
2509            None
2510        }
2511    }
2512
2513    #[allow(irrefutable_let_patterns)]
2514    pub fn into_open_acl_data_channel(
2515        self,
2516    ) -> Option<(fidl::Channel, HciOpenAclDataChannelResponder)> {
2517        if let HciRequest::OpenAclDataChannel { channel, responder } = self {
2518            Some((channel, responder))
2519        } else {
2520            None
2521        }
2522    }
2523
2524    #[allow(irrefutable_let_patterns)]
2525    pub fn into_open_sco_data_channel(
2526        self,
2527    ) -> Option<(fidl::Channel, HciOpenScoDataChannelResponder)> {
2528        if let HciRequest::OpenScoDataChannel { channel, responder } = self {
2529            Some((channel, responder))
2530        } else {
2531            None
2532        }
2533    }
2534
2535    #[allow(irrefutable_let_patterns)]
2536    pub fn into_configure_sco(
2537        self,
2538    ) -> Option<(ScoCodingFormat, ScoEncoding, ScoSampleRate, HciConfigureScoResponder)> {
2539        if let HciRequest::ConfigureSco { coding_format, encoding, sample_rate, responder } = self {
2540            Some((coding_format, encoding, sample_rate, responder))
2541        } else {
2542            None
2543        }
2544    }
2545
2546    #[allow(irrefutable_let_patterns)]
2547    pub fn into_reset_sco(self) -> Option<(HciResetScoResponder)> {
2548        if let HciRequest::ResetSco { responder } = self { Some((responder)) } else { None }
2549    }
2550
2551    #[allow(irrefutable_let_patterns)]
2552    pub fn into_open_iso_data_channel(
2553        self,
2554    ) -> Option<(fidl::Channel, HciOpenIsoDataChannelResponder)> {
2555        if let HciRequest::OpenIsoDataChannel { channel, responder } = self {
2556            Some((channel, responder))
2557        } else {
2558            None
2559        }
2560    }
2561
2562    #[allow(irrefutable_let_patterns)]
2563    pub fn into_open_snoop_channel(self) -> Option<(fidl::Channel, HciOpenSnoopChannelResponder)> {
2564        if let HciRequest::OpenSnoopChannel { channel, responder } = self {
2565            Some((channel, responder))
2566        } else {
2567            None
2568        }
2569    }
2570
2571    /// Name of the method defined in FIDL
2572    pub fn method_name(&self) -> &'static str {
2573        match *self {
2574            HciRequest::OpenCommandChannel { .. } => "open_command_channel",
2575            HciRequest::OpenAclDataChannel { .. } => "open_acl_data_channel",
2576            HciRequest::OpenScoDataChannel { .. } => "open_sco_data_channel",
2577            HciRequest::ConfigureSco { .. } => "configure_sco",
2578            HciRequest::ResetSco { .. } => "reset_sco",
2579            HciRequest::OpenIsoDataChannel { .. } => "open_iso_data_channel",
2580            HciRequest::OpenSnoopChannel { .. } => "open_snoop_channel",
2581            HciRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2582                "unknown one-way method"
2583            }
2584            HciRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2585                "unknown two-way method"
2586            }
2587        }
2588    }
2589}
2590
2591#[derive(Debug, Clone)]
2592pub struct HciControlHandle {
2593    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2594}
2595
2596impl HciControlHandle {
2597    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2598        self.inner.shutdown_with_epitaph(status.into())
2599    }
2600}
2601
2602impl fidl::endpoints::ControlHandle for HciControlHandle {
2603    fn shutdown(&self) {
2604        self.inner.shutdown()
2605    }
2606
2607    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2608        self.inner.shutdown_with_epitaph(status)
2609    }
2610
2611    fn is_closed(&self) -> bool {
2612        self.inner.channel().is_closed()
2613    }
2614    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2615        self.inner.channel().on_closed()
2616    }
2617
2618    #[cfg(target_os = "fuchsia")]
2619    fn signal_peer(
2620        &self,
2621        clear_mask: zx::Signals,
2622        set_mask: zx::Signals,
2623    ) -> Result<(), zx_status::Status> {
2624        use fidl::Peered;
2625        self.inner.channel().signal_peer(clear_mask, set_mask)
2626    }
2627}
2628
2629impl HciControlHandle {}
2630
2631#[must_use = "FIDL methods require a response to be sent"]
2632#[derive(Debug)]
2633pub struct HciOpenCommandChannelResponder {
2634    control_handle: std::mem::ManuallyDrop<HciControlHandle>,
2635    tx_id: u32,
2636}
2637
2638/// Set the the channel to be shutdown (see [`HciControlHandle::shutdown`])
2639/// if the responder is dropped without sending a response, so that the client
2640/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2641impl std::ops::Drop for HciOpenCommandChannelResponder {
2642    fn drop(&mut self) {
2643        self.control_handle.shutdown();
2644        // Safety: drops once, never accessed again
2645        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2646    }
2647}
2648
2649impl fidl::endpoints::Responder for HciOpenCommandChannelResponder {
2650    type ControlHandle = HciControlHandle;
2651
2652    fn control_handle(&self) -> &HciControlHandle {
2653        &self.control_handle
2654    }
2655
2656    fn drop_without_shutdown(mut self) {
2657        // Safety: drops once, never accessed again due to mem::forget
2658        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2659        // Prevent Drop from running (which would shut down the channel)
2660        std::mem::forget(self);
2661    }
2662}
2663
2664impl HciOpenCommandChannelResponder {
2665    /// Sends a response to the FIDL transaction.
2666    ///
2667    /// Sets the channel to shutdown if an error occurs.
2668    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2669        let _result = self.send_raw(result);
2670        if _result.is_err() {
2671            self.control_handle.shutdown();
2672        }
2673        self.drop_without_shutdown();
2674        _result
2675    }
2676
2677    /// Similar to "send" but does not shutdown the channel if an error occurs.
2678    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2679        let _result = self.send_raw(result);
2680        self.drop_without_shutdown();
2681        _result
2682    }
2683
2684    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2685        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2686            fidl::encoding::EmptyStruct,
2687            i32,
2688        >>(
2689            fidl::encoding::FlexibleResult::new(result),
2690            self.tx_id,
2691            0x2510b52ea3a51ce0,
2692            fidl::encoding::DynamicFlags::FLEXIBLE,
2693        )
2694    }
2695}
2696
2697#[must_use = "FIDL methods require a response to be sent"]
2698#[derive(Debug)]
2699pub struct HciOpenAclDataChannelResponder {
2700    control_handle: std::mem::ManuallyDrop<HciControlHandle>,
2701    tx_id: u32,
2702}
2703
2704/// Set the the channel to be shutdown (see [`HciControlHandle::shutdown`])
2705/// if the responder is dropped without sending a response, so that the client
2706/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2707impl std::ops::Drop for HciOpenAclDataChannelResponder {
2708    fn drop(&mut self) {
2709        self.control_handle.shutdown();
2710        // Safety: drops once, never accessed again
2711        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2712    }
2713}
2714
2715impl fidl::endpoints::Responder for HciOpenAclDataChannelResponder {
2716    type ControlHandle = HciControlHandle;
2717
2718    fn control_handle(&self) -> &HciControlHandle {
2719        &self.control_handle
2720    }
2721
2722    fn drop_without_shutdown(mut self) {
2723        // Safety: drops once, never accessed again due to mem::forget
2724        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2725        // Prevent Drop from running (which would shut down the channel)
2726        std::mem::forget(self);
2727    }
2728}
2729
2730impl HciOpenAclDataChannelResponder {
2731    /// Sends a response to the FIDL transaction.
2732    ///
2733    /// Sets the channel to shutdown if an error occurs.
2734    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2735        let _result = self.send_raw(result);
2736        if _result.is_err() {
2737            self.control_handle.shutdown();
2738        }
2739        self.drop_without_shutdown();
2740        _result
2741    }
2742
2743    /// Similar to "send" but does not shutdown the channel if an error occurs.
2744    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2745        let _result = self.send_raw(result);
2746        self.drop_without_shutdown();
2747        _result
2748    }
2749
2750    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2751        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2752            fidl::encoding::EmptyStruct,
2753            i32,
2754        >>(
2755            fidl::encoding::FlexibleResult::new(result),
2756            self.tx_id,
2757            0x210c3dd69156385a,
2758            fidl::encoding::DynamicFlags::FLEXIBLE,
2759        )
2760    }
2761}
2762
2763#[must_use = "FIDL methods require a response to be sent"]
2764#[derive(Debug)]
2765pub struct HciOpenScoDataChannelResponder {
2766    control_handle: std::mem::ManuallyDrop<HciControlHandle>,
2767    tx_id: u32,
2768}
2769
2770/// Set the the channel to be shutdown (see [`HciControlHandle::shutdown`])
2771/// if the responder is dropped without sending a response, so that the client
2772/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2773impl std::ops::Drop for HciOpenScoDataChannelResponder {
2774    fn drop(&mut self) {
2775        self.control_handle.shutdown();
2776        // Safety: drops once, never accessed again
2777        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2778    }
2779}
2780
2781impl fidl::endpoints::Responder for HciOpenScoDataChannelResponder {
2782    type ControlHandle = HciControlHandle;
2783
2784    fn control_handle(&self) -> &HciControlHandle {
2785        &self.control_handle
2786    }
2787
2788    fn drop_without_shutdown(mut self) {
2789        // Safety: drops once, never accessed again due to mem::forget
2790        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2791        // Prevent Drop from running (which would shut down the channel)
2792        std::mem::forget(self);
2793    }
2794}
2795
2796impl HciOpenScoDataChannelResponder {
2797    /// Sends a response to the FIDL transaction.
2798    ///
2799    /// Sets the channel to shutdown if an error occurs.
2800    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2801        let _result = self.send_raw(result);
2802        if _result.is_err() {
2803            self.control_handle.shutdown();
2804        }
2805        self.drop_without_shutdown();
2806        _result
2807    }
2808
2809    /// Similar to "send" but does not shutdown the channel if an error occurs.
2810    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2811        let _result = self.send_raw(result);
2812        self.drop_without_shutdown();
2813        _result
2814    }
2815
2816    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2817        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2818            fidl::encoding::EmptyStruct,
2819            i32,
2820        >>(
2821            fidl::encoding::FlexibleResult::new(result),
2822            self.tx_id,
2823            0x5bcb0bf2cbf35bdf,
2824            fidl::encoding::DynamicFlags::FLEXIBLE,
2825        )
2826    }
2827}
2828
2829#[must_use = "FIDL methods require a response to be sent"]
2830#[derive(Debug)]
2831pub struct HciConfigureScoResponder {
2832    control_handle: std::mem::ManuallyDrop<HciControlHandle>,
2833    tx_id: u32,
2834}
2835
2836/// Set the the channel to be shutdown (see [`HciControlHandle::shutdown`])
2837/// if the responder is dropped without sending a response, so that the client
2838/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2839impl std::ops::Drop for HciConfigureScoResponder {
2840    fn drop(&mut self) {
2841        self.control_handle.shutdown();
2842        // Safety: drops once, never accessed again
2843        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2844    }
2845}
2846
2847impl fidl::endpoints::Responder for HciConfigureScoResponder {
2848    type ControlHandle = HciControlHandle;
2849
2850    fn control_handle(&self) -> &HciControlHandle {
2851        &self.control_handle
2852    }
2853
2854    fn drop_without_shutdown(mut self) {
2855        // Safety: drops once, never accessed again due to mem::forget
2856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2857        // Prevent Drop from running (which would shut down the channel)
2858        std::mem::forget(self);
2859    }
2860}
2861
2862impl HciConfigureScoResponder {
2863    /// Sends a response to the FIDL transaction.
2864    ///
2865    /// Sets the channel to shutdown if an error occurs.
2866    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2867        let _result = self.send_raw(result);
2868        if _result.is_err() {
2869            self.control_handle.shutdown();
2870        }
2871        self.drop_without_shutdown();
2872        _result
2873    }
2874
2875    /// Similar to "send" but does not shutdown the channel if an error occurs.
2876    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2877        let _result = self.send_raw(result);
2878        self.drop_without_shutdown();
2879        _result
2880    }
2881
2882    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2883        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2884            fidl::encoding::EmptyStruct,
2885            i32,
2886        >>(
2887            fidl::encoding::FlexibleResult::new(result),
2888            self.tx_id,
2889            0x499ec7edfd65fad7,
2890            fidl::encoding::DynamicFlags::FLEXIBLE,
2891        )
2892    }
2893}
2894
2895#[must_use = "FIDL methods require a response to be sent"]
2896#[derive(Debug)]
2897pub struct HciResetScoResponder {
2898    control_handle: std::mem::ManuallyDrop<HciControlHandle>,
2899    tx_id: u32,
2900}
2901
2902/// Set the the channel to be shutdown (see [`HciControlHandle::shutdown`])
2903/// if the responder is dropped without sending a response, so that the client
2904/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2905impl std::ops::Drop for HciResetScoResponder {
2906    fn drop(&mut self) {
2907        self.control_handle.shutdown();
2908        // Safety: drops once, never accessed again
2909        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2910    }
2911}
2912
2913impl fidl::endpoints::Responder for HciResetScoResponder {
2914    type ControlHandle = HciControlHandle;
2915
2916    fn control_handle(&self) -> &HciControlHandle {
2917        &self.control_handle
2918    }
2919
2920    fn drop_without_shutdown(mut self) {
2921        // Safety: drops once, never accessed again due to mem::forget
2922        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2923        // Prevent Drop from running (which would shut down the channel)
2924        std::mem::forget(self);
2925    }
2926}
2927
2928impl HciResetScoResponder {
2929    /// Sends a response to the FIDL transaction.
2930    ///
2931    /// Sets the channel to shutdown if an error occurs.
2932    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2933        let _result = self.send_raw(result);
2934        if _result.is_err() {
2935            self.control_handle.shutdown();
2936        }
2937        self.drop_without_shutdown();
2938        _result
2939    }
2940
2941    /// Similar to "send" but does not shutdown the channel if an error occurs.
2942    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2943        let _result = self.send_raw(result);
2944        self.drop_without_shutdown();
2945        _result
2946    }
2947
2948    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2949        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2950            fidl::encoding::EmptyStruct,
2951            i32,
2952        >>(
2953            fidl::encoding::FlexibleResult::new(result),
2954            self.tx_id,
2955            0x6ee56dcb2ce23fcb,
2956            fidl::encoding::DynamicFlags::FLEXIBLE,
2957        )
2958    }
2959}
2960
2961#[must_use = "FIDL methods require a response to be sent"]
2962#[derive(Debug)]
2963pub struct HciOpenIsoDataChannelResponder {
2964    control_handle: std::mem::ManuallyDrop<HciControlHandle>,
2965    tx_id: u32,
2966}
2967
2968/// Set the the channel to be shutdown (see [`HciControlHandle::shutdown`])
2969/// if the responder is dropped without sending a response, so that the client
2970/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2971impl std::ops::Drop for HciOpenIsoDataChannelResponder {
2972    fn drop(&mut self) {
2973        self.control_handle.shutdown();
2974        // Safety: drops once, never accessed again
2975        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2976    }
2977}
2978
2979impl fidl::endpoints::Responder for HciOpenIsoDataChannelResponder {
2980    type ControlHandle = HciControlHandle;
2981
2982    fn control_handle(&self) -> &HciControlHandle {
2983        &self.control_handle
2984    }
2985
2986    fn drop_without_shutdown(mut self) {
2987        // Safety: drops once, never accessed again due to mem::forget
2988        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2989        // Prevent Drop from running (which would shut down the channel)
2990        std::mem::forget(self);
2991    }
2992}
2993
2994impl HciOpenIsoDataChannelResponder {
2995    /// Sends a response to the FIDL transaction.
2996    ///
2997    /// Sets the channel to shutdown if an error occurs.
2998    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2999        let _result = self.send_raw(result);
3000        if _result.is_err() {
3001            self.control_handle.shutdown();
3002        }
3003        self.drop_without_shutdown();
3004        _result
3005    }
3006
3007    /// Similar to "send" but does not shutdown the channel if an error occurs.
3008    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3009        let _result = self.send_raw(result);
3010        self.drop_without_shutdown();
3011        _result
3012    }
3013
3014    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3015        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3016            fidl::encoding::EmptyStruct,
3017            i32,
3018        >>(
3019            fidl::encoding::FlexibleResult::new(result),
3020            self.tx_id,
3021            0x9adfa1d466cefd4,
3022            fidl::encoding::DynamicFlags::FLEXIBLE,
3023        )
3024    }
3025}
3026
3027#[must_use = "FIDL methods require a response to be sent"]
3028#[derive(Debug)]
3029pub struct HciOpenSnoopChannelResponder {
3030    control_handle: std::mem::ManuallyDrop<HciControlHandle>,
3031    tx_id: u32,
3032}
3033
3034/// Set the the channel to be shutdown (see [`HciControlHandle::shutdown`])
3035/// if the responder is dropped without sending a response, so that the client
3036/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3037impl std::ops::Drop for HciOpenSnoopChannelResponder {
3038    fn drop(&mut self) {
3039        self.control_handle.shutdown();
3040        // Safety: drops once, never accessed again
3041        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3042    }
3043}
3044
3045impl fidl::endpoints::Responder for HciOpenSnoopChannelResponder {
3046    type ControlHandle = HciControlHandle;
3047
3048    fn control_handle(&self) -> &HciControlHandle {
3049        &self.control_handle
3050    }
3051
3052    fn drop_without_shutdown(mut self) {
3053        // Safety: drops once, never accessed again due to mem::forget
3054        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3055        // Prevent Drop from running (which would shut down the channel)
3056        std::mem::forget(self);
3057    }
3058}
3059
3060impl HciOpenSnoopChannelResponder {
3061    /// Sends a response to the FIDL transaction.
3062    ///
3063    /// Sets the channel to shutdown if an error occurs.
3064    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3065        let _result = self.send_raw(result);
3066        if _result.is_err() {
3067            self.control_handle.shutdown();
3068        }
3069        self.drop_without_shutdown();
3070        _result
3071    }
3072
3073    /// Similar to "send" but does not shutdown the channel if an error occurs.
3074    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3075        let _result = self.send_raw(result);
3076        self.drop_without_shutdown();
3077        _result
3078    }
3079
3080    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3081        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3082            fidl::encoding::EmptyStruct,
3083            i32,
3084        >>(
3085            fidl::encoding::FlexibleResult::new(result),
3086            self.tx_id,
3087            0xd31c6d5cbc4e136,
3088            fidl::encoding::DynamicFlags::FLEXIBLE,
3089        )
3090    }
3091}
3092
3093#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3094pub struct HciTransportMarker;
3095
3096impl fidl::endpoints::ProtocolMarker for HciTransportMarker {
3097    type Proxy = HciTransportProxy;
3098    type RequestStream = HciTransportRequestStream;
3099    #[cfg(target_os = "fuchsia")]
3100    type SynchronousProxy = HciTransportSynchronousProxy;
3101
3102    const DEBUG_NAME: &'static str = "(anonymous) HciTransport";
3103}
3104
3105pub trait HciTransportProxyInterface: Send + Sync {
3106    type Send_ResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3107    fn r#send_(&self, payload: &SentPacket) -> Self::Send_ResponseFut;
3108    fn r#ack_receive(&self) -> Result<(), fidl::Error>;
3109    fn r#configure_sco(&self, payload: HciTransportConfigureScoRequest) -> Result<(), fidl::Error>;
3110}
3111#[derive(Debug)]
3112#[cfg(target_os = "fuchsia")]
3113pub struct HciTransportSynchronousProxy {
3114    client: fidl::client::sync::Client,
3115}
3116
3117#[cfg(target_os = "fuchsia")]
3118impl fidl::endpoints::SynchronousProxy for HciTransportSynchronousProxy {
3119    type Proxy = HciTransportProxy;
3120    type Protocol = HciTransportMarker;
3121
3122    fn from_channel(inner: fidl::Channel) -> Self {
3123        Self::new(inner)
3124    }
3125
3126    fn into_channel(self) -> fidl::Channel {
3127        self.client.into_channel()
3128    }
3129
3130    fn as_channel(&self) -> &fidl::Channel {
3131        self.client.as_channel()
3132    }
3133}
3134
3135#[cfg(target_os = "fuchsia")]
3136impl HciTransportSynchronousProxy {
3137    pub fn new(channel: fidl::Channel) -> Self {
3138        Self { client: fidl::client::sync::Client::new(channel) }
3139    }
3140
3141    pub fn into_channel(self) -> fidl::Channel {
3142        self.client.into_channel()
3143    }
3144
3145    /// Waits until an event arrives and returns it. It is safe for other
3146    /// threads to make concurrent requests while waiting for an event.
3147    pub fn wait_for_event(
3148        &self,
3149        deadline: zx::MonotonicInstant,
3150    ) -> Result<HciTransportEvent, fidl::Error> {
3151        HciTransportEvent::decode(self.client.wait_for_event::<HciTransportMarker>(deadline)?)
3152    }
3153
3154    /// More than one Send can be pending simultaneously.
3155    /// Prefer to limit the number of pending calls to avoid overflow.
3156    /// A maximum of 10 pending calls is suggested.
3157    /// If an event or SCO packet is received by the server, the server should close the protocol.
3158    pub fn r#send_(
3159        &self,
3160        mut payload: &SentPacket,
3161        ___deadline: zx::MonotonicInstant,
3162    ) -> Result<(), fidl::Error> {
3163        let _response = self.client.send_query::<
3164            SentPacket,
3165            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3166            HciTransportMarker,
3167        >(
3168            payload,
3169            0x4793b5e66fd79e0b,
3170            fidl::encoding::DynamicFlags::FLEXIBLE,
3171            ___deadline,
3172        )?
3173        .into_result::<HciTransportMarker>("send_")?;
3174        Ok(_response)
3175    }
3176
3177    pub fn r#ack_receive(&self) -> Result<(), fidl::Error> {
3178        self.client.send::<fidl::encoding::EmptyPayload>(
3179            (),
3180            0x25de8c1f760f0c89,
3181            fidl::encoding::DynamicFlags::FLEXIBLE,
3182        )
3183    }
3184
3185    /// Establish a SCO connection. Only 1 SCO connection can be configured at a time.
3186    pub fn r#configure_sco(
3187        &self,
3188        mut payload: HciTransportConfigureScoRequest,
3189    ) -> Result<(), fidl::Error> {
3190        self.client.send::<HciTransportConfigureScoRequest>(
3191            &mut payload,
3192            0x4298072d0498b612,
3193            fidl::encoding::DynamicFlags::FLEXIBLE,
3194        )
3195    }
3196}
3197
3198#[cfg(target_os = "fuchsia")]
3199impl From<HciTransportSynchronousProxy> for zx::NullableHandle {
3200    fn from(value: HciTransportSynchronousProxy) -> Self {
3201        value.into_channel().into()
3202    }
3203}
3204
3205#[cfg(target_os = "fuchsia")]
3206impl From<fidl::Channel> for HciTransportSynchronousProxy {
3207    fn from(value: fidl::Channel) -> Self {
3208        Self::new(value)
3209    }
3210}
3211
3212#[cfg(target_os = "fuchsia")]
3213impl fidl::endpoints::FromClient for HciTransportSynchronousProxy {
3214    type Protocol = HciTransportMarker;
3215
3216    fn from_client(value: fidl::endpoints::ClientEnd<HciTransportMarker>) -> Self {
3217        Self::new(value.into_channel())
3218    }
3219}
3220
3221#[derive(Debug, Clone)]
3222pub struct HciTransportProxy {
3223    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3224}
3225
3226impl fidl::endpoints::Proxy for HciTransportProxy {
3227    type Protocol = HciTransportMarker;
3228
3229    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3230        Self::new(inner)
3231    }
3232
3233    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3234        self.client.into_channel().map_err(|client| Self { client })
3235    }
3236
3237    fn as_channel(&self) -> &::fidl::AsyncChannel {
3238        self.client.as_channel()
3239    }
3240}
3241
3242impl HciTransportProxy {
3243    /// Create a new Proxy for fuchsia.hardware.bluetooth/HciTransport.
3244    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3245        let protocol_name = <HciTransportMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3246        Self { client: fidl::client::Client::new(channel, protocol_name) }
3247    }
3248
3249    /// Get a Stream of events from the remote end of the protocol.
3250    ///
3251    /// # Panics
3252    ///
3253    /// Panics if the event stream was already taken.
3254    pub fn take_event_stream(&self) -> HciTransportEventStream {
3255        HciTransportEventStream { event_receiver: self.client.take_event_receiver() }
3256    }
3257
3258    /// More than one Send can be pending simultaneously.
3259    /// Prefer to limit the number of pending calls to avoid overflow.
3260    /// A maximum of 10 pending calls is suggested.
3261    /// If an event or SCO packet is received by the server, the server should close the protocol.
3262    pub fn r#send_(
3263        &self,
3264        mut payload: &SentPacket,
3265    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3266        HciTransportProxyInterface::r#send_(self, payload)
3267    }
3268
3269    pub fn r#ack_receive(&self) -> Result<(), fidl::Error> {
3270        HciTransportProxyInterface::r#ack_receive(self)
3271    }
3272
3273    /// Establish a SCO connection. Only 1 SCO connection can be configured at a time.
3274    pub fn r#configure_sco(
3275        &self,
3276        mut payload: HciTransportConfigureScoRequest,
3277    ) -> Result<(), fidl::Error> {
3278        HciTransportProxyInterface::r#configure_sco(self, payload)
3279    }
3280}
3281
3282impl HciTransportProxyInterface for HciTransportProxy {
3283    type Send_ResponseFut =
3284        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3285    fn r#send_(&self, mut payload: &SentPacket) -> Self::Send_ResponseFut {
3286        fn _decode(
3287            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3288        ) -> Result<(), fidl::Error> {
3289            let _response = fidl::client::decode_transaction_body::<
3290                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3291                fidl::encoding::DefaultFuchsiaResourceDialect,
3292                0x4793b5e66fd79e0b,
3293            >(_buf?)?
3294            .into_result::<HciTransportMarker>("send_")?;
3295            Ok(_response)
3296        }
3297        self.client.send_query_and_decode::<SentPacket, ()>(
3298            payload,
3299            0x4793b5e66fd79e0b,
3300            fidl::encoding::DynamicFlags::FLEXIBLE,
3301            _decode,
3302        )
3303    }
3304
3305    fn r#ack_receive(&self) -> Result<(), fidl::Error> {
3306        self.client.send::<fidl::encoding::EmptyPayload>(
3307            (),
3308            0x25de8c1f760f0c89,
3309            fidl::encoding::DynamicFlags::FLEXIBLE,
3310        )
3311    }
3312
3313    fn r#configure_sco(
3314        &self,
3315        mut payload: HciTransportConfigureScoRequest,
3316    ) -> Result<(), fidl::Error> {
3317        self.client.send::<HciTransportConfigureScoRequest>(
3318            &mut payload,
3319            0x4298072d0498b612,
3320            fidl::encoding::DynamicFlags::FLEXIBLE,
3321        )
3322    }
3323}
3324
3325pub struct HciTransportEventStream {
3326    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3327}
3328
3329impl std::marker::Unpin for HciTransportEventStream {}
3330
3331impl futures::stream::FusedStream for HciTransportEventStream {
3332    fn is_terminated(&self) -> bool {
3333        self.event_receiver.is_terminated()
3334    }
3335}
3336
3337impl futures::Stream for HciTransportEventStream {
3338    type Item = Result<HciTransportEvent, fidl::Error>;
3339
3340    fn poll_next(
3341        mut self: std::pin::Pin<&mut Self>,
3342        cx: &mut std::task::Context<'_>,
3343    ) -> std::task::Poll<Option<Self::Item>> {
3344        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3345            &mut self.event_receiver,
3346            cx
3347        )?) {
3348            Some(buf) => std::task::Poll::Ready(Some(HciTransportEvent::decode(buf))),
3349            None => std::task::Poll::Ready(None),
3350        }
3351    }
3352}
3353
3354#[derive(Debug)]
3355pub enum HciTransportEvent {
3356    OnReceive {
3357        payload: ReceivedPacket,
3358    },
3359    #[non_exhaustive]
3360    _UnknownEvent {
3361        /// Ordinal of the event that was sent.
3362        ordinal: u64,
3363    },
3364}
3365
3366impl HciTransportEvent {
3367    #[allow(irrefutable_let_patterns)]
3368    pub fn into_on_receive(self) -> Option<ReceivedPacket> {
3369        if let HciTransportEvent::OnReceive { payload } = self { Some((payload)) } else { None }
3370    }
3371
3372    /// Decodes a message buffer as a [`HciTransportEvent`].
3373    fn decode(
3374        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3375    ) -> Result<HciTransportEvent, fidl::Error> {
3376        let (bytes, _handles) = buf.split_mut();
3377        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3378        debug_assert_eq!(tx_header.tx_id, 0);
3379        match tx_header.ordinal {
3380            0xcb102e573e5049c => {
3381                let mut out =
3382                    fidl::new_empty!(ReceivedPacket, fidl::encoding::DefaultFuchsiaResourceDialect);
3383                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ReceivedPacket>(&tx_header, _body_bytes, _handles, &mut out)?;
3384                Ok((HciTransportEvent::OnReceive { payload: out }))
3385            }
3386            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3387                Ok(HciTransportEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3388            }
3389            _ => Err(fidl::Error::UnknownOrdinal {
3390                ordinal: tx_header.ordinal,
3391                protocol_name: <HciTransportMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3392            }),
3393        }
3394    }
3395}
3396
3397/// A Stream of incoming requests for fuchsia.hardware.bluetooth/HciTransport.
3398pub struct HciTransportRequestStream {
3399    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3400    is_terminated: bool,
3401}
3402
3403impl std::marker::Unpin for HciTransportRequestStream {}
3404
3405impl futures::stream::FusedStream for HciTransportRequestStream {
3406    fn is_terminated(&self) -> bool {
3407        self.is_terminated
3408    }
3409}
3410
3411impl fidl::endpoints::RequestStream for HciTransportRequestStream {
3412    type Protocol = HciTransportMarker;
3413    type ControlHandle = HciTransportControlHandle;
3414
3415    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3416        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3417    }
3418
3419    fn control_handle(&self) -> Self::ControlHandle {
3420        HciTransportControlHandle { inner: self.inner.clone() }
3421    }
3422
3423    fn into_inner(
3424        self,
3425    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3426    {
3427        (self.inner, self.is_terminated)
3428    }
3429
3430    fn from_inner(
3431        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3432        is_terminated: bool,
3433    ) -> Self {
3434        Self { inner, is_terminated }
3435    }
3436}
3437
3438impl futures::Stream for HciTransportRequestStream {
3439    type Item = Result<HciTransportRequest, fidl::Error>;
3440
3441    fn poll_next(
3442        mut self: std::pin::Pin<&mut Self>,
3443        cx: &mut std::task::Context<'_>,
3444    ) -> std::task::Poll<Option<Self::Item>> {
3445        let this = &mut *self;
3446        if this.inner.check_shutdown(cx) {
3447            this.is_terminated = true;
3448            return std::task::Poll::Ready(None);
3449        }
3450        if this.is_terminated {
3451            panic!("polled HciTransportRequestStream after completion");
3452        }
3453        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3454            |bytes, handles| {
3455                match this.inner.channel().read_etc(cx, bytes, handles) {
3456                    std::task::Poll::Ready(Ok(())) => {}
3457                    std::task::Poll::Pending => return std::task::Poll::Pending,
3458                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3459                        this.is_terminated = true;
3460                        return std::task::Poll::Ready(None);
3461                    }
3462                    std::task::Poll::Ready(Err(e)) => {
3463                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3464                            e.into(),
3465                        ))));
3466                    }
3467                }
3468
3469                // A message has been received from the channel
3470                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3471
3472                std::task::Poll::Ready(Some(match header.ordinal {
3473                    0x4793b5e66fd79e0b => {
3474                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3475                        let mut req = fidl::new_empty!(
3476                            SentPacket,
3477                            fidl::encoding::DefaultFuchsiaResourceDialect
3478                        );
3479                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SentPacket>(&header, _body_bytes, handles, &mut req)?;
3480                        let control_handle =
3481                            HciTransportControlHandle { inner: this.inner.clone() };
3482                        Ok(HciTransportRequest::Send_ {
3483                            payload: req,
3484                            responder: HciTransportSend_Responder {
3485                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3486                                tx_id: header.tx_id,
3487                            },
3488                        })
3489                    }
3490                    0x25de8c1f760f0c89 => {
3491                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3492                        let mut req = fidl::new_empty!(
3493                            fidl::encoding::EmptyPayload,
3494                            fidl::encoding::DefaultFuchsiaResourceDialect
3495                        );
3496                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3497                        let control_handle =
3498                            HciTransportControlHandle { inner: this.inner.clone() };
3499                        Ok(HciTransportRequest::AckReceive { control_handle })
3500                    }
3501                    0x4298072d0498b612 => {
3502                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3503                        let mut req = fidl::new_empty!(
3504                            HciTransportConfigureScoRequest,
3505                            fidl::encoding::DefaultFuchsiaResourceDialect
3506                        );
3507                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HciTransportConfigureScoRequest>(&header, _body_bytes, handles, &mut req)?;
3508                        let control_handle =
3509                            HciTransportControlHandle { inner: this.inner.clone() };
3510                        Ok(HciTransportRequest::ConfigureSco { payload: req, control_handle })
3511                    }
3512                    _ if header.tx_id == 0
3513                        && header
3514                            .dynamic_flags()
3515                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3516                    {
3517                        Ok(HciTransportRequest::_UnknownMethod {
3518                            ordinal: header.ordinal,
3519                            control_handle: HciTransportControlHandle { inner: this.inner.clone() },
3520                            method_type: fidl::MethodType::OneWay,
3521                        })
3522                    }
3523                    _ if header
3524                        .dynamic_flags()
3525                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3526                    {
3527                        this.inner.send_framework_err(
3528                            fidl::encoding::FrameworkErr::UnknownMethod,
3529                            header.tx_id,
3530                            header.ordinal,
3531                            header.dynamic_flags(),
3532                            (bytes, handles),
3533                        )?;
3534                        Ok(HciTransportRequest::_UnknownMethod {
3535                            ordinal: header.ordinal,
3536                            control_handle: HciTransportControlHandle { inner: this.inner.clone() },
3537                            method_type: fidl::MethodType::TwoWay,
3538                        })
3539                    }
3540                    _ => Err(fidl::Error::UnknownOrdinal {
3541                        ordinal: header.ordinal,
3542                        protocol_name:
3543                            <HciTransportMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3544                    }),
3545                }))
3546            },
3547        )
3548    }
3549}
3550
3551#[derive(Debug)]
3552pub enum HciTransportRequest {
3553    /// More than one Send can be pending simultaneously.
3554    /// Prefer to limit the number of pending calls to avoid overflow.
3555    /// A maximum of 10 pending calls is suggested.
3556    /// If an event or SCO packet is received by the server, the server should close the protocol.
3557    Send_ {
3558        payload: SentPacket,
3559        responder: HciTransportSend_Responder,
3560    },
3561    AckReceive {
3562        control_handle: HciTransportControlHandle,
3563    },
3564    /// Establish a SCO connection. Only 1 SCO connection can be configured at a time.
3565    ConfigureSco {
3566        payload: HciTransportConfigureScoRequest,
3567        control_handle: HciTransportControlHandle,
3568    },
3569    /// An interaction was received which does not match any known method.
3570    #[non_exhaustive]
3571    _UnknownMethod {
3572        /// Ordinal of the method that was called.
3573        ordinal: u64,
3574        control_handle: HciTransportControlHandle,
3575        method_type: fidl::MethodType,
3576    },
3577}
3578
3579impl HciTransportRequest {
3580    #[allow(irrefutable_let_patterns)]
3581    pub fn into_send_(self) -> Option<(SentPacket, HciTransportSend_Responder)> {
3582        if let HciTransportRequest::Send_ { payload, responder } = self {
3583            Some((payload, responder))
3584        } else {
3585            None
3586        }
3587    }
3588
3589    #[allow(irrefutable_let_patterns)]
3590    pub fn into_ack_receive(self) -> Option<(HciTransportControlHandle)> {
3591        if let HciTransportRequest::AckReceive { control_handle } = self {
3592            Some((control_handle))
3593        } else {
3594            None
3595        }
3596    }
3597
3598    #[allow(irrefutable_let_patterns)]
3599    pub fn into_configure_sco(
3600        self,
3601    ) -> Option<(HciTransportConfigureScoRequest, HciTransportControlHandle)> {
3602        if let HciTransportRequest::ConfigureSco { payload, control_handle } = self {
3603            Some((payload, control_handle))
3604        } else {
3605            None
3606        }
3607    }
3608
3609    /// Name of the method defined in FIDL
3610    pub fn method_name(&self) -> &'static str {
3611        match *self {
3612            HciTransportRequest::Send_ { .. } => "send_",
3613            HciTransportRequest::AckReceive { .. } => "ack_receive",
3614            HciTransportRequest::ConfigureSco { .. } => "configure_sco",
3615            HciTransportRequest::_UnknownMethod {
3616                method_type: fidl::MethodType::OneWay, ..
3617            } => "unknown one-way method",
3618            HciTransportRequest::_UnknownMethod {
3619                method_type: fidl::MethodType::TwoWay, ..
3620            } => "unknown two-way method",
3621        }
3622    }
3623}
3624
3625#[derive(Debug, Clone)]
3626pub struct HciTransportControlHandle {
3627    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3628}
3629
3630impl HciTransportControlHandle {
3631    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3632        self.inner.shutdown_with_epitaph(status.into())
3633    }
3634}
3635
3636impl fidl::endpoints::ControlHandle for HciTransportControlHandle {
3637    fn shutdown(&self) {
3638        self.inner.shutdown()
3639    }
3640
3641    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3642        self.inner.shutdown_with_epitaph(status)
3643    }
3644
3645    fn is_closed(&self) -> bool {
3646        self.inner.channel().is_closed()
3647    }
3648    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3649        self.inner.channel().on_closed()
3650    }
3651
3652    #[cfg(target_os = "fuchsia")]
3653    fn signal_peer(
3654        &self,
3655        clear_mask: zx::Signals,
3656        set_mask: zx::Signals,
3657    ) -> Result<(), zx_status::Status> {
3658        use fidl::Peered;
3659        self.inner.channel().signal_peer(clear_mask, set_mask)
3660    }
3661}
3662
3663impl HciTransportControlHandle {
3664    pub fn send_on_receive(&self, mut payload: &ReceivedPacket) -> Result<(), fidl::Error> {
3665        self.inner.send::<ReceivedPacket>(
3666            payload,
3667            0,
3668            0xcb102e573e5049c,
3669            fidl::encoding::DynamicFlags::FLEXIBLE,
3670        )
3671    }
3672}
3673
3674#[must_use = "FIDL methods require a response to be sent"]
3675#[derive(Debug)]
3676pub struct HciTransportSend_Responder {
3677    control_handle: std::mem::ManuallyDrop<HciTransportControlHandle>,
3678    tx_id: u32,
3679}
3680
3681/// Set the the channel to be shutdown (see [`HciTransportControlHandle::shutdown`])
3682/// if the responder is dropped without sending a response, so that the client
3683/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3684impl std::ops::Drop for HciTransportSend_Responder {
3685    fn drop(&mut self) {
3686        self.control_handle.shutdown();
3687        // Safety: drops once, never accessed again
3688        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3689    }
3690}
3691
3692impl fidl::endpoints::Responder for HciTransportSend_Responder {
3693    type ControlHandle = HciTransportControlHandle;
3694
3695    fn control_handle(&self) -> &HciTransportControlHandle {
3696        &self.control_handle
3697    }
3698
3699    fn drop_without_shutdown(mut self) {
3700        // Safety: drops once, never accessed again due to mem::forget
3701        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3702        // Prevent Drop from running (which would shut down the channel)
3703        std::mem::forget(self);
3704    }
3705}
3706
3707impl HciTransportSend_Responder {
3708    /// Sends a response to the FIDL transaction.
3709    ///
3710    /// Sets the channel to shutdown if an error occurs.
3711    pub fn send(self) -> Result<(), fidl::Error> {
3712        let _result = self.send_raw();
3713        if _result.is_err() {
3714            self.control_handle.shutdown();
3715        }
3716        self.drop_without_shutdown();
3717        _result
3718    }
3719
3720    /// Similar to "send" but does not shutdown the channel if an error occurs.
3721    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3722        let _result = self.send_raw();
3723        self.drop_without_shutdown();
3724        _result
3725    }
3726
3727    fn send_raw(&self) -> Result<(), fidl::Error> {
3728        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
3729            fidl::encoding::Flexible::new(()),
3730            self.tx_id,
3731            0x4793b5e66fd79e0b,
3732            fidl::encoding::DynamicFlags::FLEXIBLE,
3733        )
3734    }
3735}
3736
3737#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3738pub struct PeerMarker;
3739
3740impl fidl::endpoints::ProtocolMarker for PeerMarker {
3741    type Proxy = PeerProxy;
3742    type RequestStream = PeerRequestStream;
3743    #[cfg(target_os = "fuchsia")]
3744    type SynchronousProxy = PeerSynchronousProxy;
3745
3746    const DEBUG_NAME: &'static str = "(anonymous) Peer";
3747}
3748pub type PeerSetLeAdvertisementResult = Result<(), EmulatorPeerError>;
3749
3750pub trait PeerProxyInterface: Send + Sync {
3751    type AssignConnectionStatusResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
3752        + Send;
3753    fn r#assign_connection_status(
3754        &self,
3755        status: HciError,
3756    ) -> Self::AssignConnectionStatusResponseFut;
3757    fn r#emulate_le_connection_complete(
3758        &self,
3759        role: fidl_fuchsia_bluetooth::ConnectionRole,
3760    ) -> Result<(), fidl::Error>;
3761    fn r#emulate_disconnection_complete(&self) -> Result<(), fidl::Error>;
3762    type WatchConnectionStatesResponseFut: std::future::Future<Output = Result<Vec<ConnectionState>, fidl::Error>>
3763        + Send;
3764    fn r#watch_connection_states(&self) -> Self::WatchConnectionStatesResponseFut;
3765    type SetDeviceClassResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3766    fn r#set_device_class(&self, value: u32) -> Self::SetDeviceClassResponseFut;
3767    type SetServiceDefinitionsResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
3768        + Send;
3769    fn r#set_service_definitions(
3770        &self,
3771        service_definitions: &[fidl_fuchsia_bluetooth_bredr::ServiceDefinition],
3772    ) -> Self::SetServiceDefinitionsResponseFut;
3773    type SetLeAdvertisementResponseFut: std::future::Future<Output = Result<PeerSetLeAdvertisementResult, fidl::Error>>
3774        + Send;
3775    fn r#set_le_advertisement(
3776        &self,
3777        payload: &PeerSetLeAdvertisementRequest,
3778    ) -> Self::SetLeAdvertisementResponseFut;
3779}
3780#[derive(Debug)]
3781#[cfg(target_os = "fuchsia")]
3782pub struct PeerSynchronousProxy {
3783    client: fidl::client::sync::Client,
3784}
3785
3786#[cfg(target_os = "fuchsia")]
3787impl fidl::endpoints::SynchronousProxy for PeerSynchronousProxy {
3788    type Proxy = PeerProxy;
3789    type Protocol = PeerMarker;
3790
3791    fn from_channel(inner: fidl::Channel) -> Self {
3792        Self::new(inner)
3793    }
3794
3795    fn into_channel(self) -> fidl::Channel {
3796        self.client.into_channel()
3797    }
3798
3799    fn as_channel(&self) -> &fidl::Channel {
3800        self.client.as_channel()
3801    }
3802}
3803
3804#[cfg(target_os = "fuchsia")]
3805impl PeerSynchronousProxy {
3806    pub fn new(channel: fidl::Channel) -> Self {
3807        Self { client: fidl::client::sync::Client::new(channel) }
3808    }
3809
3810    pub fn into_channel(self) -> fidl::Channel {
3811        self.client.into_channel()
3812    }
3813
3814    /// Waits until an event arrives and returns it. It is safe for other
3815    /// threads to make concurrent requests while waiting for an event.
3816    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<PeerEvent, fidl::Error> {
3817        PeerEvent::decode(self.client.wait_for_event::<PeerMarker>(deadline)?)
3818    }
3819
3820    /// Assign a HCI `status` for the controller to generate in response to connection requests.
3821    /// Applies to all successive HCI_Create_Connection and HCI_LE_Create_Connection commands. The
3822    /// procedure is acknowledged with an empty response.
3823    pub fn r#assign_connection_status(
3824        &self,
3825        mut status: HciError,
3826        ___deadline: zx::MonotonicInstant,
3827    ) -> Result<(), fidl::Error> {
3828        let _response = self.client.send_query::<
3829            PeerAssignConnectionStatusRequest,
3830            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3831            PeerMarker,
3832        >(
3833            (status,),
3834            0x52810c5ba7a2555c,
3835            fidl::encoding::DynamicFlags::FLEXIBLE,
3836            ___deadline,
3837        )?
3838        .into_result::<PeerMarker>("assign_connection_status")?;
3839        Ok(_response)
3840    }
3841
3842    /// Emulates a LE connection event. Does nothing if the peer is already connected. The
3843    /// `role` parameter determines the link layer connection role.
3844    pub fn r#emulate_le_connection_complete(
3845        &self,
3846        mut role: fidl_fuchsia_bluetooth::ConnectionRole,
3847    ) -> Result<(), fidl::Error> {
3848        self.client.send::<PeerEmulateLeConnectionCompleteRequest>(
3849            (role,),
3850            0x3dfba319b8d2fc2a,
3851            fidl::encoding::DynamicFlags::FLEXIBLE,
3852        )
3853    }
3854
3855    /// Emulate disconnection. Does nothing if the peer is not connected.
3856    pub fn r#emulate_disconnection_complete(&self) -> Result<(), fidl::Error> {
3857        self.client.send::<fidl::encoding::EmptyPayload>(
3858            (),
3859            0x4d3955084d85a15c,
3860            fidl::encoding::DynamicFlags::FLEXIBLE,
3861        )
3862    }
3863
3864    /// Returns a vector of the least to most recent controller connection states.
3865    /// This method returns when there has been a state change since the last invocation of this
3866    /// method by this client.
3867    ///
3868    /// Multiple calls to this method can be outstanding at a given time. All calls will resolve in
3869    /// a response as soon as there is a change to the scan state.
3870    pub fn r#watch_connection_states(
3871        &self,
3872        ___deadline: zx::MonotonicInstant,
3873    ) -> Result<Vec<ConnectionState>, fidl::Error> {
3874        let _response = self.client.send_query::<
3875            fidl::encoding::EmptyPayload,
3876            fidl::encoding::FlexibleType<PeerWatchConnectionStatesResponse>,
3877            PeerMarker,
3878        >(
3879            (),
3880            0x5a5190211980c70f,
3881            fidl::encoding::DynamicFlags::FLEXIBLE,
3882            ___deadline,
3883        )?
3884        .into_result::<PeerMarker>("watch_connection_states")?;
3885        Ok(_response.states)
3886    }
3887
3888    /// Sets the device class reported in the inquiry response for this peer during device
3889    /// discovery. If the peer is not BR/EDR, the server will close with the `ZX_ERR_NOT_SUPPORTED`
3890    /// epitaph.
3891    pub fn r#set_device_class(
3892        &self,
3893        mut value: u32,
3894        ___deadline: zx::MonotonicInstant,
3895    ) -> Result<(), fidl::Error> {
3896        let _response = self.client.send_query::<
3897            fidl_fuchsia_bluetooth::DeviceClass,
3898            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3899            PeerMarker,
3900        >(
3901            (value,),
3902            0x3e52fa234758e1ea,
3903            fidl::encoding::DynamicFlags::FLEXIBLE,
3904            ___deadline,
3905        )?
3906        .into_result::<PeerMarker>("set_device_class")?;
3907        Ok(_response)
3908    }
3909
3910    /// Sets the peer's services that will be discoverable via Service Discovery Protocol. If the
3911    /// peer is not BR/EDR, the server will close with the `ZX_ERR_NOT_SUPPORTED` epitaph.
3912    pub fn r#set_service_definitions(
3913        &self,
3914        mut service_definitions: &[fidl_fuchsia_bluetooth_bredr::ServiceDefinition],
3915        ___deadline: zx::MonotonicInstant,
3916    ) -> Result<(), fidl::Error> {
3917        let _response = self.client.send_query::<
3918            PeerSetServiceDefinitionsRequest,
3919            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3920            PeerMarker,
3921        >(
3922            (service_definitions,),
3923            0x58ce9f22fce272df,
3924            fidl::encoding::DynamicFlags::FLEXIBLE,
3925            ___deadline,
3926        )?
3927        .into_result::<PeerMarker>("set_service_definitions")?;
3928        Ok(_response)
3929    }
3930
3931    pub fn r#set_le_advertisement(
3932        &self,
3933        mut payload: &PeerSetLeAdvertisementRequest,
3934        ___deadline: zx::MonotonicInstant,
3935    ) -> Result<PeerSetLeAdvertisementResult, fidl::Error> {
3936        let _response = self.client.send_query::<
3937            PeerSetLeAdvertisementRequest,
3938            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, EmulatorPeerError>,
3939            PeerMarker,
3940        >(
3941            payload,
3942            0x481b9aea1b39cfb4,
3943            fidl::encoding::DynamicFlags::FLEXIBLE,
3944            ___deadline,
3945        )?
3946        .into_result::<PeerMarker>("set_le_advertisement")?;
3947        Ok(_response.map(|x| x))
3948    }
3949}
3950
3951#[cfg(target_os = "fuchsia")]
3952impl From<PeerSynchronousProxy> for zx::NullableHandle {
3953    fn from(value: PeerSynchronousProxy) -> Self {
3954        value.into_channel().into()
3955    }
3956}
3957
3958#[cfg(target_os = "fuchsia")]
3959impl From<fidl::Channel> for PeerSynchronousProxy {
3960    fn from(value: fidl::Channel) -> Self {
3961        Self::new(value)
3962    }
3963}
3964
3965#[cfg(target_os = "fuchsia")]
3966impl fidl::endpoints::FromClient for PeerSynchronousProxy {
3967    type Protocol = PeerMarker;
3968
3969    fn from_client(value: fidl::endpoints::ClientEnd<PeerMarker>) -> Self {
3970        Self::new(value.into_channel())
3971    }
3972}
3973
3974#[derive(Debug, Clone)]
3975pub struct PeerProxy {
3976    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3977}
3978
3979impl fidl::endpoints::Proxy for PeerProxy {
3980    type Protocol = PeerMarker;
3981
3982    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3983        Self::new(inner)
3984    }
3985
3986    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3987        self.client.into_channel().map_err(|client| Self { client })
3988    }
3989
3990    fn as_channel(&self) -> &::fidl::AsyncChannel {
3991        self.client.as_channel()
3992    }
3993}
3994
3995impl PeerProxy {
3996    /// Create a new Proxy for fuchsia.hardware.bluetooth/Peer.
3997    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3998        let protocol_name = <PeerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3999        Self { client: fidl::client::Client::new(channel, protocol_name) }
4000    }
4001
4002    /// Get a Stream of events from the remote end of the protocol.
4003    ///
4004    /// # Panics
4005    ///
4006    /// Panics if the event stream was already taken.
4007    pub fn take_event_stream(&self) -> PeerEventStream {
4008        PeerEventStream { event_receiver: self.client.take_event_receiver() }
4009    }
4010
4011    /// Assign a HCI `status` for the controller to generate in response to connection requests.
4012    /// Applies to all successive HCI_Create_Connection and HCI_LE_Create_Connection commands. The
4013    /// procedure is acknowledged with an empty response.
4014    pub fn r#assign_connection_status(
4015        &self,
4016        mut status: HciError,
4017    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4018        PeerProxyInterface::r#assign_connection_status(self, status)
4019    }
4020
4021    /// Emulates a LE connection event. Does nothing if the peer is already connected. The
4022    /// `role` parameter determines the link layer connection role.
4023    pub fn r#emulate_le_connection_complete(
4024        &self,
4025        mut role: fidl_fuchsia_bluetooth::ConnectionRole,
4026    ) -> Result<(), fidl::Error> {
4027        PeerProxyInterface::r#emulate_le_connection_complete(self, role)
4028    }
4029
4030    /// Emulate disconnection. Does nothing if the peer is not connected.
4031    pub fn r#emulate_disconnection_complete(&self) -> Result<(), fidl::Error> {
4032        PeerProxyInterface::r#emulate_disconnection_complete(self)
4033    }
4034
4035    /// Returns a vector of the least to most recent controller connection states.
4036    /// This method returns when there has been a state change since the last invocation of this
4037    /// method by this client.
4038    ///
4039    /// Multiple calls to this method can be outstanding at a given time. All calls will resolve in
4040    /// a response as soon as there is a change to the scan state.
4041    pub fn r#watch_connection_states(
4042        &self,
4043    ) -> fidl::client::QueryResponseFut<
4044        Vec<ConnectionState>,
4045        fidl::encoding::DefaultFuchsiaResourceDialect,
4046    > {
4047        PeerProxyInterface::r#watch_connection_states(self)
4048    }
4049
4050    /// Sets the device class reported in the inquiry response for this peer during device
4051    /// discovery. If the peer is not BR/EDR, the server will close with the `ZX_ERR_NOT_SUPPORTED`
4052    /// epitaph.
4053    pub fn r#set_device_class(
4054        &self,
4055        mut value: u32,
4056    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4057        PeerProxyInterface::r#set_device_class(self, value)
4058    }
4059
4060    /// Sets the peer's services that will be discoverable via Service Discovery Protocol. If the
4061    /// peer is not BR/EDR, the server will close with the `ZX_ERR_NOT_SUPPORTED` epitaph.
4062    pub fn r#set_service_definitions(
4063        &self,
4064        mut service_definitions: &[fidl_fuchsia_bluetooth_bredr::ServiceDefinition],
4065    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4066        PeerProxyInterface::r#set_service_definitions(self, service_definitions)
4067    }
4068
4069    pub fn r#set_le_advertisement(
4070        &self,
4071        mut payload: &PeerSetLeAdvertisementRequest,
4072    ) -> fidl::client::QueryResponseFut<
4073        PeerSetLeAdvertisementResult,
4074        fidl::encoding::DefaultFuchsiaResourceDialect,
4075    > {
4076        PeerProxyInterface::r#set_le_advertisement(self, payload)
4077    }
4078}
4079
4080impl PeerProxyInterface for PeerProxy {
4081    type AssignConnectionStatusResponseFut =
4082        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4083    fn r#assign_connection_status(
4084        &self,
4085        mut status: HciError,
4086    ) -> Self::AssignConnectionStatusResponseFut {
4087        fn _decode(
4088            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4089        ) -> Result<(), fidl::Error> {
4090            let _response = fidl::client::decode_transaction_body::<
4091                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
4092                fidl::encoding::DefaultFuchsiaResourceDialect,
4093                0x52810c5ba7a2555c,
4094            >(_buf?)?
4095            .into_result::<PeerMarker>("assign_connection_status")?;
4096            Ok(_response)
4097        }
4098        self.client.send_query_and_decode::<PeerAssignConnectionStatusRequest, ()>(
4099            (status,),
4100            0x52810c5ba7a2555c,
4101            fidl::encoding::DynamicFlags::FLEXIBLE,
4102            _decode,
4103        )
4104    }
4105
4106    fn r#emulate_le_connection_complete(
4107        &self,
4108        mut role: fidl_fuchsia_bluetooth::ConnectionRole,
4109    ) -> Result<(), fidl::Error> {
4110        self.client.send::<PeerEmulateLeConnectionCompleteRequest>(
4111            (role,),
4112            0x3dfba319b8d2fc2a,
4113            fidl::encoding::DynamicFlags::FLEXIBLE,
4114        )
4115    }
4116
4117    fn r#emulate_disconnection_complete(&self) -> Result<(), fidl::Error> {
4118        self.client.send::<fidl::encoding::EmptyPayload>(
4119            (),
4120            0x4d3955084d85a15c,
4121            fidl::encoding::DynamicFlags::FLEXIBLE,
4122        )
4123    }
4124
4125    type WatchConnectionStatesResponseFut = fidl::client::QueryResponseFut<
4126        Vec<ConnectionState>,
4127        fidl::encoding::DefaultFuchsiaResourceDialect,
4128    >;
4129    fn r#watch_connection_states(&self) -> Self::WatchConnectionStatesResponseFut {
4130        fn _decode(
4131            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4132        ) -> Result<Vec<ConnectionState>, fidl::Error> {
4133            let _response = fidl::client::decode_transaction_body::<
4134                fidl::encoding::FlexibleType<PeerWatchConnectionStatesResponse>,
4135                fidl::encoding::DefaultFuchsiaResourceDialect,
4136                0x5a5190211980c70f,
4137            >(_buf?)?
4138            .into_result::<PeerMarker>("watch_connection_states")?;
4139            Ok(_response.states)
4140        }
4141        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<ConnectionState>>(
4142            (),
4143            0x5a5190211980c70f,
4144            fidl::encoding::DynamicFlags::FLEXIBLE,
4145            _decode,
4146        )
4147    }
4148
4149    type SetDeviceClassResponseFut =
4150        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4151    fn r#set_device_class(&self, mut value: u32) -> Self::SetDeviceClassResponseFut {
4152        fn _decode(
4153            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4154        ) -> Result<(), fidl::Error> {
4155            let _response = fidl::client::decode_transaction_body::<
4156                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
4157                fidl::encoding::DefaultFuchsiaResourceDialect,
4158                0x3e52fa234758e1ea,
4159            >(_buf?)?
4160            .into_result::<PeerMarker>("set_device_class")?;
4161            Ok(_response)
4162        }
4163        self.client.send_query_and_decode::<fidl_fuchsia_bluetooth::DeviceClass, ()>(
4164            (value,),
4165            0x3e52fa234758e1ea,
4166            fidl::encoding::DynamicFlags::FLEXIBLE,
4167            _decode,
4168        )
4169    }
4170
4171    type SetServiceDefinitionsResponseFut =
4172        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4173    fn r#set_service_definitions(
4174        &self,
4175        mut service_definitions: &[fidl_fuchsia_bluetooth_bredr::ServiceDefinition],
4176    ) -> Self::SetServiceDefinitionsResponseFut {
4177        fn _decode(
4178            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4179        ) -> Result<(), fidl::Error> {
4180            let _response = fidl::client::decode_transaction_body::<
4181                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
4182                fidl::encoding::DefaultFuchsiaResourceDialect,
4183                0x58ce9f22fce272df,
4184            >(_buf?)?
4185            .into_result::<PeerMarker>("set_service_definitions")?;
4186            Ok(_response)
4187        }
4188        self.client.send_query_and_decode::<PeerSetServiceDefinitionsRequest, ()>(
4189            (service_definitions,),
4190            0x58ce9f22fce272df,
4191            fidl::encoding::DynamicFlags::FLEXIBLE,
4192            _decode,
4193        )
4194    }
4195
4196    type SetLeAdvertisementResponseFut = fidl::client::QueryResponseFut<
4197        PeerSetLeAdvertisementResult,
4198        fidl::encoding::DefaultFuchsiaResourceDialect,
4199    >;
4200    fn r#set_le_advertisement(
4201        &self,
4202        mut payload: &PeerSetLeAdvertisementRequest,
4203    ) -> Self::SetLeAdvertisementResponseFut {
4204        fn _decode(
4205            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4206        ) -> Result<PeerSetLeAdvertisementResult, fidl::Error> {
4207            let _response = fidl::client::decode_transaction_body::<
4208                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, EmulatorPeerError>,
4209                fidl::encoding::DefaultFuchsiaResourceDialect,
4210                0x481b9aea1b39cfb4,
4211            >(_buf?)?
4212            .into_result::<PeerMarker>("set_le_advertisement")?;
4213            Ok(_response.map(|x| x))
4214        }
4215        self.client
4216            .send_query_and_decode::<PeerSetLeAdvertisementRequest, PeerSetLeAdvertisementResult>(
4217                payload,
4218                0x481b9aea1b39cfb4,
4219                fidl::encoding::DynamicFlags::FLEXIBLE,
4220                _decode,
4221            )
4222    }
4223}
4224
4225pub struct PeerEventStream {
4226    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4227}
4228
4229impl std::marker::Unpin for PeerEventStream {}
4230
4231impl futures::stream::FusedStream for PeerEventStream {
4232    fn is_terminated(&self) -> bool {
4233        self.event_receiver.is_terminated()
4234    }
4235}
4236
4237impl futures::Stream for PeerEventStream {
4238    type Item = Result<PeerEvent, fidl::Error>;
4239
4240    fn poll_next(
4241        mut self: std::pin::Pin<&mut Self>,
4242        cx: &mut std::task::Context<'_>,
4243    ) -> std::task::Poll<Option<Self::Item>> {
4244        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4245            &mut self.event_receiver,
4246            cx
4247        )?) {
4248            Some(buf) => std::task::Poll::Ready(Some(PeerEvent::decode(buf))),
4249            None => std::task::Poll::Ready(None),
4250        }
4251    }
4252}
4253
4254#[derive(Debug)]
4255pub enum PeerEvent {
4256    #[non_exhaustive]
4257    _UnknownEvent {
4258        /// Ordinal of the event that was sent.
4259        ordinal: u64,
4260    },
4261}
4262
4263impl PeerEvent {
4264    /// Decodes a message buffer as a [`PeerEvent`].
4265    fn decode(
4266        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4267    ) -> Result<PeerEvent, fidl::Error> {
4268        let (bytes, _handles) = buf.split_mut();
4269        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4270        debug_assert_eq!(tx_header.tx_id, 0);
4271        match tx_header.ordinal {
4272            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4273                Ok(PeerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4274            }
4275            _ => Err(fidl::Error::UnknownOrdinal {
4276                ordinal: tx_header.ordinal,
4277                protocol_name: <PeerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4278            }),
4279        }
4280    }
4281}
4282
4283/// A Stream of incoming requests for fuchsia.hardware.bluetooth/Peer.
4284pub struct PeerRequestStream {
4285    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4286    is_terminated: bool,
4287}
4288
4289impl std::marker::Unpin for PeerRequestStream {}
4290
4291impl futures::stream::FusedStream for PeerRequestStream {
4292    fn is_terminated(&self) -> bool {
4293        self.is_terminated
4294    }
4295}
4296
4297impl fidl::endpoints::RequestStream for PeerRequestStream {
4298    type Protocol = PeerMarker;
4299    type ControlHandle = PeerControlHandle;
4300
4301    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4302        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4303    }
4304
4305    fn control_handle(&self) -> Self::ControlHandle {
4306        PeerControlHandle { inner: self.inner.clone() }
4307    }
4308
4309    fn into_inner(
4310        self,
4311    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4312    {
4313        (self.inner, self.is_terminated)
4314    }
4315
4316    fn from_inner(
4317        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4318        is_terminated: bool,
4319    ) -> Self {
4320        Self { inner, is_terminated }
4321    }
4322}
4323
4324impl futures::Stream for PeerRequestStream {
4325    type Item = Result<PeerRequest, fidl::Error>;
4326
4327    fn poll_next(
4328        mut self: std::pin::Pin<&mut Self>,
4329        cx: &mut std::task::Context<'_>,
4330    ) -> std::task::Poll<Option<Self::Item>> {
4331        let this = &mut *self;
4332        if this.inner.check_shutdown(cx) {
4333            this.is_terminated = true;
4334            return std::task::Poll::Ready(None);
4335        }
4336        if this.is_terminated {
4337            panic!("polled PeerRequestStream after completion");
4338        }
4339        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4340            |bytes, handles| {
4341                match this.inner.channel().read_etc(cx, bytes, handles) {
4342                    std::task::Poll::Ready(Ok(())) => {}
4343                    std::task::Poll::Pending => return std::task::Poll::Pending,
4344                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4345                        this.is_terminated = true;
4346                        return std::task::Poll::Ready(None);
4347                    }
4348                    std::task::Poll::Ready(Err(e)) => {
4349                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4350                            e.into(),
4351                        ))));
4352                    }
4353                }
4354
4355                // A message has been received from the channel
4356                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4357
4358                std::task::Poll::Ready(Some(match header.ordinal {
4359                    0x52810c5ba7a2555c => {
4360                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4361                        let mut req = fidl::new_empty!(
4362                            PeerAssignConnectionStatusRequest,
4363                            fidl::encoding::DefaultFuchsiaResourceDialect
4364                        );
4365                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerAssignConnectionStatusRequest>(&header, _body_bytes, handles, &mut req)?;
4366                        let control_handle = PeerControlHandle { inner: this.inner.clone() };
4367                        Ok(PeerRequest::AssignConnectionStatus {
4368                            status: req.status,
4369
4370                            responder: PeerAssignConnectionStatusResponder {
4371                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4372                                tx_id: header.tx_id,
4373                            },
4374                        })
4375                    }
4376                    0x3dfba319b8d2fc2a => {
4377                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4378                        let mut req = fidl::new_empty!(
4379                            PeerEmulateLeConnectionCompleteRequest,
4380                            fidl::encoding::DefaultFuchsiaResourceDialect
4381                        );
4382                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerEmulateLeConnectionCompleteRequest>(&header, _body_bytes, handles, &mut req)?;
4383                        let control_handle = PeerControlHandle { inner: this.inner.clone() };
4384                        Ok(PeerRequest::EmulateLeConnectionComplete {
4385                            role: req.role,
4386
4387                            control_handle,
4388                        })
4389                    }
4390                    0x4d3955084d85a15c => {
4391                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4392                        let mut req = fidl::new_empty!(
4393                            fidl::encoding::EmptyPayload,
4394                            fidl::encoding::DefaultFuchsiaResourceDialect
4395                        );
4396                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4397                        let control_handle = PeerControlHandle { inner: this.inner.clone() };
4398                        Ok(PeerRequest::EmulateDisconnectionComplete { control_handle })
4399                    }
4400                    0x5a5190211980c70f => {
4401                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4402                        let mut req = fidl::new_empty!(
4403                            fidl::encoding::EmptyPayload,
4404                            fidl::encoding::DefaultFuchsiaResourceDialect
4405                        );
4406                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4407                        let control_handle = PeerControlHandle { inner: this.inner.clone() };
4408                        Ok(PeerRequest::WatchConnectionStates {
4409                            responder: PeerWatchConnectionStatesResponder {
4410                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4411                                tx_id: header.tx_id,
4412                            },
4413                        })
4414                    }
4415                    0x3e52fa234758e1ea => {
4416                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4417                        let mut req = fidl::new_empty!(
4418                            fidl_fuchsia_bluetooth::DeviceClass,
4419                            fidl::encoding::DefaultFuchsiaResourceDialect
4420                        );
4421                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_bluetooth::DeviceClass>(&header, _body_bytes, handles, &mut req)?;
4422                        let control_handle = PeerControlHandle { inner: this.inner.clone() };
4423                        Ok(PeerRequest::SetDeviceClass {
4424                            value: req.value,
4425
4426                            responder: PeerSetDeviceClassResponder {
4427                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4428                                tx_id: header.tx_id,
4429                            },
4430                        })
4431                    }
4432                    0x58ce9f22fce272df => {
4433                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4434                        let mut req = fidl::new_empty!(
4435                            PeerSetServiceDefinitionsRequest,
4436                            fidl::encoding::DefaultFuchsiaResourceDialect
4437                        );
4438                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerSetServiceDefinitionsRequest>(&header, _body_bytes, handles, &mut req)?;
4439                        let control_handle = PeerControlHandle { inner: this.inner.clone() };
4440                        Ok(PeerRequest::SetServiceDefinitions {
4441                            service_definitions: req.service_definitions,
4442
4443                            responder: PeerSetServiceDefinitionsResponder {
4444                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4445                                tx_id: header.tx_id,
4446                            },
4447                        })
4448                    }
4449                    0x481b9aea1b39cfb4 => {
4450                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4451                        let mut req = fidl::new_empty!(
4452                            PeerSetLeAdvertisementRequest,
4453                            fidl::encoding::DefaultFuchsiaResourceDialect
4454                        );
4455                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerSetLeAdvertisementRequest>(&header, _body_bytes, handles, &mut req)?;
4456                        let control_handle = PeerControlHandle { inner: this.inner.clone() };
4457                        Ok(PeerRequest::SetLeAdvertisement {
4458                            payload: req,
4459                            responder: PeerSetLeAdvertisementResponder {
4460                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4461                                tx_id: header.tx_id,
4462                            },
4463                        })
4464                    }
4465                    _ if header.tx_id == 0
4466                        && header
4467                            .dynamic_flags()
4468                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4469                    {
4470                        Ok(PeerRequest::_UnknownMethod {
4471                            ordinal: header.ordinal,
4472                            control_handle: PeerControlHandle { inner: this.inner.clone() },
4473                            method_type: fidl::MethodType::OneWay,
4474                        })
4475                    }
4476                    _ if header
4477                        .dynamic_flags()
4478                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4479                    {
4480                        this.inner.send_framework_err(
4481                            fidl::encoding::FrameworkErr::UnknownMethod,
4482                            header.tx_id,
4483                            header.ordinal,
4484                            header.dynamic_flags(),
4485                            (bytes, handles),
4486                        )?;
4487                        Ok(PeerRequest::_UnknownMethod {
4488                            ordinal: header.ordinal,
4489                            control_handle: PeerControlHandle { inner: this.inner.clone() },
4490                            method_type: fidl::MethodType::TwoWay,
4491                        })
4492                    }
4493                    _ => Err(fidl::Error::UnknownOrdinal {
4494                        ordinal: header.ordinal,
4495                        protocol_name: <PeerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4496                    }),
4497                }))
4498            },
4499        )
4500    }
4501}
4502
4503/// Protocol used to drive the state of a fake peer device.
4504#[derive(Debug)]
4505pub enum PeerRequest {
4506    /// Assign a HCI `status` for the controller to generate in response to connection requests.
4507    /// Applies to all successive HCI_Create_Connection and HCI_LE_Create_Connection commands. The
4508    /// procedure is acknowledged with an empty response.
4509    AssignConnectionStatus { status: HciError, responder: PeerAssignConnectionStatusResponder },
4510    /// Emulates a LE connection event. Does nothing if the peer is already connected. The
4511    /// `role` parameter determines the link layer connection role.
4512    EmulateLeConnectionComplete {
4513        role: fidl_fuchsia_bluetooth::ConnectionRole,
4514        control_handle: PeerControlHandle,
4515    },
4516    /// Emulate disconnection. Does nothing if the peer is not connected.
4517    EmulateDisconnectionComplete { control_handle: PeerControlHandle },
4518    /// Returns a vector of the least to most recent controller connection states.
4519    /// This method returns when there has been a state change since the last invocation of this
4520    /// method by this client.
4521    ///
4522    /// Multiple calls to this method can be outstanding at a given time. All calls will resolve in
4523    /// a response as soon as there is a change to the scan state.
4524    WatchConnectionStates { responder: PeerWatchConnectionStatesResponder },
4525    /// Sets the device class reported in the inquiry response for this peer during device
4526    /// discovery. If the peer is not BR/EDR, the server will close with the `ZX_ERR_NOT_SUPPORTED`
4527    /// epitaph.
4528    SetDeviceClass { value: u32, responder: PeerSetDeviceClassResponder },
4529    /// Sets the peer's services that will be discoverable via Service Discovery Protocol. If the
4530    /// peer is not BR/EDR, the server will close with the `ZX_ERR_NOT_SUPPORTED` epitaph.
4531    SetServiceDefinitions {
4532        service_definitions: Vec<fidl_fuchsia_bluetooth_bredr::ServiceDefinition>,
4533        responder: PeerSetServiceDefinitionsResponder,
4534    },
4535    SetLeAdvertisement {
4536        payload: PeerSetLeAdvertisementRequest,
4537        responder: PeerSetLeAdvertisementResponder,
4538    },
4539    /// An interaction was received which does not match any known method.
4540    #[non_exhaustive]
4541    _UnknownMethod {
4542        /// Ordinal of the method that was called.
4543        ordinal: u64,
4544        control_handle: PeerControlHandle,
4545        method_type: fidl::MethodType,
4546    },
4547}
4548
4549impl PeerRequest {
4550    #[allow(irrefutable_let_patterns)]
4551    pub fn into_assign_connection_status(
4552        self,
4553    ) -> Option<(HciError, PeerAssignConnectionStatusResponder)> {
4554        if let PeerRequest::AssignConnectionStatus { status, responder } = self {
4555            Some((status, responder))
4556        } else {
4557            None
4558        }
4559    }
4560
4561    #[allow(irrefutable_let_patterns)]
4562    pub fn into_emulate_le_connection_complete(
4563        self,
4564    ) -> Option<(fidl_fuchsia_bluetooth::ConnectionRole, PeerControlHandle)> {
4565        if let PeerRequest::EmulateLeConnectionComplete { role, control_handle } = self {
4566            Some((role, control_handle))
4567        } else {
4568            None
4569        }
4570    }
4571
4572    #[allow(irrefutable_let_patterns)]
4573    pub fn into_emulate_disconnection_complete(self) -> Option<(PeerControlHandle)> {
4574        if let PeerRequest::EmulateDisconnectionComplete { control_handle } = self {
4575            Some((control_handle))
4576        } else {
4577            None
4578        }
4579    }
4580
4581    #[allow(irrefutable_let_patterns)]
4582    pub fn into_watch_connection_states(self) -> Option<(PeerWatchConnectionStatesResponder)> {
4583        if let PeerRequest::WatchConnectionStates { responder } = self {
4584            Some((responder))
4585        } else {
4586            None
4587        }
4588    }
4589
4590    #[allow(irrefutable_let_patterns)]
4591    pub fn into_set_device_class(self) -> Option<(u32, PeerSetDeviceClassResponder)> {
4592        if let PeerRequest::SetDeviceClass { value, responder } = self {
4593            Some((value, responder))
4594        } else {
4595            None
4596        }
4597    }
4598
4599    #[allow(irrefutable_let_patterns)]
4600    pub fn into_set_service_definitions(
4601        self,
4602    ) -> Option<(
4603        Vec<fidl_fuchsia_bluetooth_bredr::ServiceDefinition>,
4604        PeerSetServiceDefinitionsResponder,
4605    )> {
4606        if let PeerRequest::SetServiceDefinitions { service_definitions, responder } = self {
4607            Some((service_definitions, responder))
4608        } else {
4609            None
4610        }
4611    }
4612
4613    #[allow(irrefutable_let_patterns)]
4614    pub fn into_set_le_advertisement(
4615        self,
4616    ) -> Option<(PeerSetLeAdvertisementRequest, PeerSetLeAdvertisementResponder)> {
4617        if let PeerRequest::SetLeAdvertisement { payload, responder } = self {
4618            Some((payload, responder))
4619        } else {
4620            None
4621        }
4622    }
4623
4624    /// Name of the method defined in FIDL
4625    pub fn method_name(&self) -> &'static str {
4626        match *self {
4627            PeerRequest::AssignConnectionStatus { .. } => "assign_connection_status",
4628            PeerRequest::EmulateLeConnectionComplete { .. } => "emulate_le_connection_complete",
4629            PeerRequest::EmulateDisconnectionComplete { .. } => "emulate_disconnection_complete",
4630            PeerRequest::WatchConnectionStates { .. } => "watch_connection_states",
4631            PeerRequest::SetDeviceClass { .. } => "set_device_class",
4632            PeerRequest::SetServiceDefinitions { .. } => "set_service_definitions",
4633            PeerRequest::SetLeAdvertisement { .. } => "set_le_advertisement",
4634            PeerRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
4635                "unknown one-way method"
4636            }
4637            PeerRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
4638                "unknown two-way method"
4639            }
4640        }
4641    }
4642}
4643
4644#[derive(Debug, Clone)]
4645pub struct PeerControlHandle {
4646    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4647}
4648
4649impl PeerControlHandle {
4650    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4651        self.inner.shutdown_with_epitaph(status.into())
4652    }
4653}
4654
4655impl fidl::endpoints::ControlHandle for PeerControlHandle {
4656    fn shutdown(&self) {
4657        self.inner.shutdown()
4658    }
4659
4660    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4661        self.inner.shutdown_with_epitaph(status)
4662    }
4663
4664    fn is_closed(&self) -> bool {
4665        self.inner.channel().is_closed()
4666    }
4667    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4668        self.inner.channel().on_closed()
4669    }
4670
4671    #[cfg(target_os = "fuchsia")]
4672    fn signal_peer(
4673        &self,
4674        clear_mask: zx::Signals,
4675        set_mask: zx::Signals,
4676    ) -> Result<(), zx_status::Status> {
4677        use fidl::Peered;
4678        self.inner.channel().signal_peer(clear_mask, set_mask)
4679    }
4680}
4681
4682impl PeerControlHandle {}
4683
4684#[must_use = "FIDL methods require a response to be sent"]
4685#[derive(Debug)]
4686pub struct PeerAssignConnectionStatusResponder {
4687    control_handle: std::mem::ManuallyDrop<PeerControlHandle>,
4688    tx_id: u32,
4689}
4690
4691/// Set the the channel to be shutdown (see [`PeerControlHandle::shutdown`])
4692/// if the responder is dropped without sending a response, so that the client
4693/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4694impl std::ops::Drop for PeerAssignConnectionStatusResponder {
4695    fn drop(&mut self) {
4696        self.control_handle.shutdown();
4697        // Safety: drops once, never accessed again
4698        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4699    }
4700}
4701
4702impl fidl::endpoints::Responder for PeerAssignConnectionStatusResponder {
4703    type ControlHandle = PeerControlHandle;
4704
4705    fn control_handle(&self) -> &PeerControlHandle {
4706        &self.control_handle
4707    }
4708
4709    fn drop_without_shutdown(mut self) {
4710        // Safety: drops once, never accessed again due to mem::forget
4711        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4712        // Prevent Drop from running (which would shut down the channel)
4713        std::mem::forget(self);
4714    }
4715}
4716
4717impl PeerAssignConnectionStatusResponder {
4718    /// Sends a response to the FIDL transaction.
4719    ///
4720    /// Sets the channel to shutdown if an error occurs.
4721    pub fn send(self) -> Result<(), fidl::Error> {
4722        let _result = self.send_raw();
4723        if _result.is_err() {
4724            self.control_handle.shutdown();
4725        }
4726        self.drop_without_shutdown();
4727        _result
4728    }
4729
4730    /// Similar to "send" but does not shutdown the channel if an error occurs.
4731    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4732        let _result = self.send_raw();
4733        self.drop_without_shutdown();
4734        _result
4735    }
4736
4737    fn send_raw(&self) -> Result<(), fidl::Error> {
4738        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
4739            fidl::encoding::Flexible::new(()),
4740            self.tx_id,
4741            0x52810c5ba7a2555c,
4742            fidl::encoding::DynamicFlags::FLEXIBLE,
4743        )
4744    }
4745}
4746
4747#[must_use = "FIDL methods require a response to be sent"]
4748#[derive(Debug)]
4749pub struct PeerWatchConnectionStatesResponder {
4750    control_handle: std::mem::ManuallyDrop<PeerControlHandle>,
4751    tx_id: u32,
4752}
4753
4754/// Set the the channel to be shutdown (see [`PeerControlHandle::shutdown`])
4755/// if the responder is dropped without sending a response, so that the client
4756/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4757impl std::ops::Drop for PeerWatchConnectionStatesResponder {
4758    fn drop(&mut self) {
4759        self.control_handle.shutdown();
4760        // Safety: drops once, never accessed again
4761        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4762    }
4763}
4764
4765impl fidl::endpoints::Responder for PeerWatchConnectionStatesResponder {
4766    type ControlHandle = PeerControlHandle;
4767
4768    fn control_handle(&self) -> &PeerControlHandle {
4769        &self.control_handle
4770    }
4771
4772    fn drop_without_shutdown(mut self) {
4773        // Safety: drops once, never accessed again due to mem::forget
4774        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4775        // Prevent Drop from running (which would shut down the channel)
4776        std::mem::forget(self);
4777    }
4778}
4779
4780impl PeerWatchConnectionStatesResponder {
4781    /// Sends a response to the FIDL transaction.
4782    ///
4783    /// Sets the channel to shutdown if an error occurs.
4784    pub fn send(self, mut states: &[ConnectionState]) -> Result<(), fidl::Error> {
4785        let _result = self.send_raw(states);
4786        if _result.is_err() {
4787            self.control_handle.shutdown();
4788        }
4789        self.drop_without_shutdown();
4790        _result
4791    }
4792
4793    /// Similar to "send" but does not shutdown the channel if an error occurs.
4794    pub fn send_no_shutdown_on_err(
4795        self,
4796        mut states: &[ConnectionState],
4797    ) -> Result<(), fidl::Error> {
4798        let _result = self.send_raw(states);
4799        self.drop_without_shutdown();
4800        _result
4801    }
4802
4803    fn send_raw(&self, mut states: &[ConnectionState]) -> Result<(), fidl::Error> {
4804        self.control_handle
4805            .inner
4806            .send::<fidl::encoding::FlexibleType<PeerWatchConnectionStatesResponse>>(
4807                fidl::encoding::Flexible::new((states,)),
4808                self.tx_id,
4809                0x5a5190211980c70f,
4810                fidl::encoding::DynamicFlags::FLEXIBLE,
4811            )
4812    }
4813}
4814
4815#[must_use = "FIDL methods require a response to be sent"]
4816#[derive(Debug)]
4817pub struct PeerSetDeviceClassResponder {
4818    control_handle: std::mem::ManuallyDrop<PeerControlHandle>,
4819    tx_id: u32,
4820}
4821
4822/// Set the the channel to be shutdown (see [`PeerControlHandle::shutdown`])
4823/// if the responder is dropped without sending a response, so that the client
4824/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4825impl std::ops::Drop for PeerSetDeviceClassResponder {
4826    fn drop(&mut self) {
4827        self.control_handle.shutdown();
4828        // Safety: drops once, never accessed again
4829        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4830    }
4831}
4832
4833impl fidl::endpoints::Responder for PeerSetDeviceClassResponder {
4834    type ControlHandle = PeerControlHandle;
4835
4836    fn control_handle(&self) -> &PeerControlHandle {
4837        &self.control_handle
4838    }
4839
4840    fn drop_without_shutdown(mut self) {
4841        // Safety: drops once, never accessed again due to mem::forget
4842        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4843        // Prevent Drop from running (which would shut down the channel)
4844        std::mem::forget(self);
4845    }
4846}
4847
4848impl PeerSetDeviceClassResponder {
4849    /// Sends a response to the FIDL transaction.
4850    ///
4851    /// Sets the channel to shutdown if an error occurs.
4852    pub fn send(self) -> Result<(), fidl::Error> {
4853        let _result = self.send_raw();
4854        if _result.is_err() {
4855            self.control_handle.shutdown();
4856        }
4857        self.drop_without_shutdown();
4858        _result
4859    }
4860
4861    /// Similar to "send" but does not shutdown the channel if an error occurs.
4862    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4863        let _result = self.send_raw();
4864        self.drop_without_shutdown();
4865        _result
4866    }
4867
4868    fn send_raw(&self) -> Result<(), fidl::Error> {
4869        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
4870            fidl::encoding::Flexible::new(()),
4871            self.tx_id,
4872            0x3e52fa234758e1ea,
4873            fidl::encoding::DynamicFlags::FLEXIBLE,
4874        )
4875    }
4876}
4877
4878#[must_use = "FIDL methods require a response to be sent"]
4879#[derive(Debug)]
4880pub struct PeerSetServiceDefinitionsResponder {
4881    control_handle: std::mem::ManuallyDrop<PeerControlHandle>,
4882    tx_id: u32,
4883}
4884
4885/// Set the the channel to be shutdown (see [`PeerControlHandle::shutdown`])
4886/// if the responder is dropped without sending a response, so that the client
4887/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4888impl std::ops::Drop for PeerSetServiceDefinitionsResponder {
4889    fn drop(&mut self) {
4890        self.control_handle.shutdown();
4891        // Safety: drops once, never accessed again
4892        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4893    }
4894}
4895
4896impl fidl::endpoints::Responder for PeerSetServiceDefinitionsResponder {
4897    type ControlHandle = PeerControlHandle;
4898
4899    fn control_handle(&self) -> &PeerControlHandle {
4900        &self.control_handle
4901    }
4902
4903    fn drop_without_shutdown(mut self) {
4904        // Safety: drops once, never accessed again due to mem::forget
4905        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4906        // Prevent Drop from running (which would shut down the channel)
4907        std::mem::forget(self);
4908    }
4909}
4910
4911impl PeerSetServiceDefinitionsResponder {
4912    /// Sends a response to the FIDL transaction.
4913    ///
4914    /// Sets the channel to shutdown if an error occurs.
4915    pub fn send(self) -> Result<(), fidl::Error> {
4916        let _result = self.send_raw();
4917        if _result.is_err() {
4918            self.control_handle.shutdown();
4919        }
4920        self.drop_without_shutdown();
4921        _result
4922    }
4923
4924    /// Similar to "send" but does not shutdown the channel if an error occurs.
4925    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4926        let _result = self.send_raw();
4927        self.drop_without_shutdown();
4928        _result
4929    }
4930
4931    fn send_raw(&self) -> Result<(), fidl::Error> {
4932        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
4933            fidl::encoding::Flexible::new(()),
4934            self.tx_id,
4935            0x58ce9f22fce272df,
4936            fidl::encoding::DynamicFlags::FLEXIBLE,
4937        )
4938    }
4939}
4940
4941#[must_use = "FIDL methods require a response to be sent"]
4942#[derive(Debug)]
4943pub struct PeerSetLeAdvertisementResponder {
4944    control_handle: std::mem::ManuallyDrop<PeerControlHandle>,
4945    tx_id: u32,
4946}
4947
4948/// Set the the channel to be shutdown (see [`PeerControlHandle::shutdown`])
4949/// if the responder is dropped without sending a response, so that the client
4950/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4951impl std::ops::Drop for PeerSetLeAdvertisementResponder {
4952    fn drop(&mut self) {
4953        self.control_handle.shutdown();
4954        // Safety: drops once, never accessed again
4955        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4956    }
4957}
4958
4959impl fidl::endpoints::Responder for PeerSetLeAdvertisementResponder {
4960    type ControlHandle = PeerControlHandle;
4961
4962    fn control_handle(&self) -> &PeerControlHandle {
4963        &self.control_handle
4964    }
4965
4966    fn drop_without_shutdown(mut self) {
4967        // Safety: drops once, never accessed again due to mem::forget
4968        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4969        // Prevent Drop from running (which would shut down the channel)
4970        std::mem::forget(self);
4971    }
4972}
4973
4974impl PeerSetLeAdvertisementResponder {
4975    /// Sends a response to the FIDL transaction.
4976    ///
4977    /// Sets the channel to shutdown if an error occurs.
4978    pub fn send(self, mut result: Result<(), EmulatorPeerError>) -> Result<(), fidl::Error> {
4979        let _result = self.send_raw(result);
4980        if _result.is_err() {
4981            self.control_handle.shutdown();
4982        }
4983        self.drop_without_shutdown();
4984        _result
4985    }
4986
4987    /// Similar to "send" but does not shutdown the channel if an error occurs.
4988    pub fn send_no_shutdown_on_err(
4989        self,
4990        mut result: Result<(), EmulatorPeerError>,
4991    ) -> Result<(), fidl::Error> {
4992        let _result = self.send_raw(result);
4993        self.drop_without_shutdown();
4994        _result
4995    }
4996
4997    fn send_raw(&self, mut result: Result<(), EmulatorPeerError>) -> Result<(), fidl::Error> {
4998        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4999            fidl::encoding::EmptyStruct,
5000            EmulatorPeerError,
5001        >>(
5002            fidl::encoding::FlexibleResult::new(result),
5003            self.tx_id,
5004            0x481b9aea1b39cfb4,
5005            fidl::encoding::DynamicFlags::FLEXIBLE,
5006        )
5007    }
5008}
5009
5010#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5011pub struct ScoConnectionMarker;
5012
5013impl fidl::endpoints::ProtocolMarker for ScoConnectionMarker {
5014    type Proxy = ScoConnectionProxy;
5015    type RequestStream = ScoConnectionRequestStream;
5016    #[cfg(target_os = "fuchsia")]
5017    type SynchronousProxy = ScoConnectionSynchronousProxy;
5018
5019    const DEBUG_NAME: &'static str = "(anonymous) ScoConnection";
5020}
5021
5022pub trait ScoConnectionProxyInterface: Send + Sync {
5023    type Send_ResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5024    fn r#send_(&self, packet: &[u8]) -> Self::Send_ResponseFut;
5025    fn r#ack_receive(&self) -> Result<(), fidl::Error>;
5026    fn r#stop(&self) -> Result<(), fidl::Error>;
5027}
5028#[derive(Debug)]
5029#[cfg(target_os = "fuchsia")]
5030pub struct ScoConnectionSynchronousProxy {
5031    client: fidl::client::sync::Client,
5032}
5033
5034#[cfg(target_os = "fuchsia")]
5035impl fidl::endpoints::SynchronousProxy for ScoConnectionSynchronousProxy {
5036    type Proxy = ScoConnectionProxy;
5037    type Protocol = ScoConnectionMarker;
5038
5039    fn from_channel(inner: fidl::Channel) -> Self {
5040        Self::new(inner)
5041    }
5042
5043    fn into_channel(self) -> fidl::Channel {
5044        self.client.into_channel()
5045    }
5046
5047    fn as_channel(&self) -> &fidl::Channel {
5048        self.client.as_channel()
5049    }
5050}
5051
5052#[cfg(target_os = "fuchsia")]
5053impl ScoConnectionSynchronousProxy {
5054    pub fn new(channel: fidl::Channel) -> Self {
5055        Self { client: fidl::client::sync::Client::new(channel) }
5056    }
5057
5058    pub fn into_channel(self) -> fidl::Channel {
5059        self.client.into_channel()
5060    }
5061
5062    /// Waits until an event arrives and returns it. It is safe for other
5063    /// threads to make concurrent requests while waiting for an event.
5064    pub fn wait_for_event(
5065        &self,
5066        deadline: zx::MonotonicInstant,
5067    ) -> Result<ScoConnectionEvent, fidl::Error> {
5068        ScoConnectionEvent::decode(self.client.wait_for_event::<ScoConnectionMarker>(deadline)?)
5069    }
5070
5071    /// More than one Send can be pending simultaneously.
5072    /// Prefer to limit the number of pending calls to avoid overflow.
5073    /// A maximum of 10 pending calls is suggested.
5074    pub fn r#send_(
5075        &self,
5076        mut packet: &[u8],
5077        ___deadline: zx::MonotonicInstant,
5078    ) -> Result<(), fidl::Error> {
5079        let _response = self.client.send_query::<
5080            ScoPacket,
5081            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
5082            ScoConnectionMarker,
5083        >(
5084            (packet,),
5085            0x6e0c000ccd50adec,
5086            fidl::encoding::DynamicFlags::FLEXIBLE,
5087            ___deadline,
5088        )?
5089        .into_result::<ScoConnectionMarker>("send_")?;
5090        Ok(_response)
5091    }
5092
5093    pub fn r#ack_receive(&self) -> Result<(), fidl::Error> {
5094        self.client.send::<fidl::encoding::EmptyPayload>(
5095            (),
5096            0x7e6af45151224a6a,
5097            fidl::encoding::DynamicFlags::FLEXIBLE,
5098        )
5099    }
5100
5101    /// The server will close the protocol when `Stop` is received. This is useful for
5102    /// synchronization (e.g. before configuring another `ScoConnection`).
5103    pub fn r#stop(&self) -> Result<(), fidl::Error> {
5104        self.client.send::<fidl::encoding::EmptyPayload>(
5105            (),
5106            0x5df8b0ab265b449d,
5107            fidl::encoding::DynamicFlags::FLEXIBLE,
5108        )
5109    }
5110}
5111
5112#[cfg(target_os = "fuchsia")]
5113impl From<ScoConnectionSynchronousProxy> for zx::NullableHandle {
5114    fn from(value: ScoConnectionSynchronousProxy) -> Self {
5115        value.into_channel().into()
5116    }
5117}
5118
5119#[cfg(target_os = "fuchsia")]
5120impl From<fidl::Channel> for ScoConnectionSynchronousProxy {
5121    fn from(value: fidl::Channel) -> Self {
5122        Self::new(value)
5123    }
5124}
5125
5126#[cfg(target_os = "fuchsia")]
5127impl fidl::endpoints::FromClient for ScoConnectionSynchronousProxy {
5128    type Protocol = ScoConnectionMarker;
5129
5130    fn from_client(value: fidl::endpoints::ClientEnd<ScoConnectionMarker>) -> Self {
5131        Self::new(value.into_channel())
5132    }
5133}
5134
5135#[derive(Debug, Clone)]
5136pub struct ScoConnectionProxy {
5137    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5138}
5139
5140impl fidl::endpoints::Proxy for ScoConnectionProxy {
5141    type Protocol = ScoConnectionMarker;
5142
5143    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5144        Self::new(inner)
5145    }
5146
5147    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5148        self.client.into_channel().map_err(|client| Self { client })
5149    }
5150
5151    fn as_channel(&self) -> &::fidl::AsyncChannel {
5152        self.client.as_channel()
5153    }
5154}
5155
5156impl ScoConnectionProxy {
5157    /// Create a new Proxy for fuchsia.hardware.bluetooth/ScoConnection.
5158    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5159        let protocol_name = <ScoConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5160        Self { client: fidl::client::Client::new(channel, protocol_name) }
5161    }
5162
5163    /// Get a Stream of events from the remote end of the protocol.
5164    ///
5165    /// # Panics
5166    ///
5167    /// Panics if the event stream was already taken.
5168    pub fn take_event_stream(&self) -> ScoConnectionEventStream {
5169        ScoConnectionEventStream { event_receiver: self.client.take_event_receiver() }
5170    }
5171
5172    /// More than one Send can be pending simultaneously.
5173    /// Prefer to limit the number of pending calls to avoid overflow.
5174    /// A maximum of 10 pending calls is suggested.
5175    pub fn r#send_(
5176        &self,
5177        mut packet: &[u8],
5178    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5179        ScoConnectionProxyInterface::r#send_(self, packet)
5180    }
5181
5182    pub fn r#ack_receive(&self) -> Result<(), fidl::Error> {
5183        ScoConnectionProxyInterface::r#ack_receive(self)
5184    }
5185
5186    /// The server will close the protocol when `Stop` is received. This is useful for
5187    /// synchronization (e.g. before configuring another `ScoConnection`).
5188    pub fn r#stop(&self) -> Result<(), fidl::Error> {
5189        ScoConnectionProxyInterface::r#stop(self)
5190    }
5191}
5192
5193impl ScoConnectionProxyInterface for ScoConnectionProxy {
5194    type Send_ResponseFut =
5195        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5196    fn r#send_(&self, mut packet: &[u8]) -> Self::Send_ResponseFut {
5197        fn _decode(
5198            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5199        ) -> Result<(), fidl::Error> {
5200            let _response = fidl::client::decode_transaction_body::<
5201                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
5202                fidl::encoding::DefaultFuchsiaResourceDialect,
5203                0x6e0c000ccd50adec,
5204            >(_buf?)?
5205            .into_result::<ScoConnectionMarker>("send_")?;
5206            Ok(_response)
5207        }
5208        self.client.send_query_and_decode::<ScoPacket, ()>(
5209            (packet,),
5210            0x6e0c000ccd50adec,
5211            fidl::encoding::DynamicFlags::FLEXIBLE,
5212            _decode,
5213        )
5214    }
5215
5216    fn r#ack_receive(&self) -> Result<(), fidl::Error> {
5217        self.client.send::<fidl::encoding::EmptyPayload>(
5218            (),
5219            0x7e6af45151224a6a,
5220            fidl::encoding::DynamicFlags::FLEXIBLE,
5221        )
5222    }
5223
5224    fn r#stop(&self) -> Result<(), fidl::Error> {
5225        self.client.send::<fidl::encoding::EmptyPayload>(
5226            (),
5227            0x5df8b0ab265b449d,
5228            fidl::encoding::DynamicFlags::FLEXIBLE,
5229        )
5230    }
5231}
5232
5233pub struct ScoConnectionEventStream {
5234    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5235}
5236
5237impl std::marker::Unpin for ScoConnectionEventStream {}
5238
5239impl futures::stream::FusedStream for ScoConnectionEventStream {
5240    fn is_terminated(&self) -> bool {
5241        self.event_receiver.is_terminated()
5242    }
5243}
5244
5245impl futures::Stream for ScoConnectionEventStream {
5246    type Item = Result<ScoConnectionEvent, fidl::Error>;
5247
5248    fn poll_next(
5249        mut self: std::pin::Pin<&mut Self>,
5250        cx: &mut std::task::Context<'_>,
5251    ) -> std::task::Poll<Option<Self::Item>> {
5252        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5253            &mut self.event_receiver,
5254            cx
5255        )?) {
5256            Some(buf) => std::task::Poll::Ready(Some(ScoConnectionEvent::decode(buf))),
5257            None => std::task::Poll::Ready(None),
5258        }
5259    }
5260}
5261
5262#[derive(Debug)]
5263pub enum ScoConnectionEvent {
5264    OnReceive {
5265        packet: Vec<u8>,
5266    },
5267    #[non_exhaustive]
5268    _UnknownEvent {
5269        /// Ordinal of the event that was sent.
5270        ordinal: u64,
5271    },
5272}
5273
5274impl ScoConnectionEvent {
5275    #[allow(irrefutable_let_patterns)]
5276    pub fn into_on_receive(self) -> Option<Vec<u8>> {
5277        if let ScoConnectionEvent::OnReceive { packet } = self { Some((packet)) } else { None }
5278    }
5279
5280    /// Decodes a message buffer as a [`ScoConnectionEvent`].
5281    fn decode(
5282        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5283    ) -> Result<ScoConnectionEvent, fidl::Error> {
5284        let (bytes, _handles) = buf.split_mut();
5285        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5286        debug_assert_eq!(tx_header.tx_id, 0);
5287        match tx_header.ordinal {
5288            0x4d4e96f6f7d1aa12 => {
5289                let mut out =
5290                    fidl::new_empty!(ScoPacket, fidl::encoding::DefaultFuchsiaResourceDialect);
5291                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScoPacket>(&tx_header, _body_bytes, _handles, &mut out)?;
5292                Ok((ScoConnectionEvent::OnReceive { packet: out.packet }))
5293            }
5294            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5295                Ok(ScoConnectionEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5296            }
5297            _ => Err(fidl::Error::UnknownOrdinal {
5298                ordinal: tx_header.ordinal,
5299                protocol_name: <ScoConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5300            }),
5301        }
5302    }
5303}
5304
5305/// A Stream of incoming requests for fuchsia.hardware.bluetooth/ScoConnection.
5306pub struct ScoConnectionRequestStream {
5307    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5308    is_terminated: bool,
5309}
5310
5311impl std::marker::Unpin for ScoConnectionRequestStream {}
5312
5313impl futures::stream::FusedStream for ScoConnectionRequestStream {
5314    fn is_terminated(&self) -> bool {
5315        self.is_terminated
5316    }
5317}
5318
5319impl fidl::endpoints::RequestStream for ScoConnectionRequestStream {
5320    type Protocol = ScoConnectionMarker;
5321    type ControlHandle = ScoConnectionControlHandle;
5322
5323    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5324        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5325    }
5326
5327    fn control_handle(&self) -> Self::ControlHandle {
5328        ScoConnectionControlHandle { inner: self.inner.clone() }
5329    }
5330
5331    fn into_inner(
5332        self,
5333    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5334    {
5335        (self.inner, self.is_terminated)
5336    }
5337
5338    fn from_inner(
5339        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5340        is_terminated: bool,
5341    ) -> Self {
5342        Self { inner, is_terminated }
5343    }
5344}
5345
5346impl futures::Stream for ScoConnectionRequestStream {
5347    type Item = Result<ScoConnectionRequest, fidl::Error>;
5348
5349    fn poll_next(
5350        mut self: std::pin::Pin<&mut Self>,
5351        cx: &mut std::task::Context<'_>,
5352    ) -> std::task::Poll<Option<Self::Item>> {
5353        let this = &mut *self;
5354        if this.inner.check_shutdown(cx) {
5355            this.is_terminated = true;
5356            return std::task::Poll::Ready(None);
5357        }
5358        if this.is_terminated {
5359            panic!("polled ScoConnectionRequestStream after completion");
5360        }
5361        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5362            |bytes, handles| {
5363                match this.inner.channel().read_etc(cx, bytes, handles) {
5364                    std::task::Poll::Ready(Ok(())) => {}
5365                    std::task::Poll::Pending => return std::task::Poll::Pending,
5366                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5367                        this.is_terminated = true;
5368                        return std::task::Poll::Ready(None);
5369                    }
5370                    std::task::Poll::Ready(Err(e)) => {
5371                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5372                            e.into(),
5373                        ))));
5374                    }
5375                }
5376
5377                // A message has been received from the channel
5378                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5379
5380                std::task::Poll::Ready(Some(match header.ordinal {
5381                    0x6e0c000ccd50adec => {
5382                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5383                        let mut req = fidl::new_empty!(
5384                            ScoPacket,
5385                            fidl::encoding::DefaultFuchsiaResourceDialect
5386                        );
5387                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScoPacket>(&header, _body_bytes, handles, &mut req)?;
5388                        let control_handle =
5389                            ScoConnectionControlHandle { inner: this.inner.clone() };
5390                        Ok(ScoConnectionRequest::Send_ {
5391                            packet: req.packet,
5392
5393                            responder: ScoConnectionSend_Responder {
5394                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5395                                tx_id: header.tx_id,
5396                            },
5397                        })
5398                    }
5399                    0x7e6af45151224a6a => {
5400                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5401                        let mut req = fidl::new_empty!(
5402                            fidl::encoding::EmptyPayload,
5403                            fidl::encoding::DefaultFuchsiaResourceDialect
5404                        );
5405                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5406                        let control_handle =
5407                            ScoConnectionControlHandle { inner: this.inner.clone() };
5408                        Ok(ScoConnectionRequest::AckReceive { control_handle })
5409                    }
5410                    0x5df8b0ab265b449d => {
5411                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5412                        let mut req = fidl::new_empty!(
5413                            fidl::encoding::EmptyPayload,
5414                            fidl::encoding::DefaultFuchsiaResourceDialect
5415                        );
5416                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5417                        let control_handle =
5418                            ScoConnectionControlHandle { inner: this.inner.clone() };
5419                        Ok(ScoConnectionRequest::Stop { control_handle })
5420                    }
5421                    _ if header.tx_id == 0
5422                        && header
5423                            .dynamic_flags()
5424                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5425                    {
5426                        Ok(ScoConnectionRequest::_UnknownMethod {
5427                            ordinal: header.ordinal,
5428                            control_handle: ScoConnectionControlHandle {
5429                                inner: this.inner.clone(),
5430                            },
5431                            method_type: fidl::MethodType::OneWay,
5432                        })
5433                    }
5434                    _ if header
5435                        .dynamic_flags()
5436                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5437                    {
5438                        this.inner.send_framework_err(
5439                            fidl::encoding::FrameworkErr::UnknownMethod,
5440                            header.tx_id,
5441                            header.ordinal,
5442                            header.dynamic_flags(),
5443                            (bytes, handles),
5444                        )?;
5445                        Ok(ScoConnectionRequest::_UnknownMethod {
5446                            ordinal: header.ordinal,
5447                            control_handle: ScoConnectionControlHandle {
5448                                inner: this.inner.clone(),
5449                            },
5450                            method_type: fidl::MethodType::TwoWay,
5451                        })
5452                    }
5453                    _ => Err(fidl::Error::UnknownOrdinal {
5454                        ordinal: header.ordinal,
5455                        protocol_name:
5456                            <ScoConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5457                    }),
5458                }))
5459            },
5460        )
5461    }
5462}
5463
5464#[derive(Debug)]
5465pub enum ScoConnectionRequest {
5466    /// More than one Send can be pending simultaneously.
5467    /// Prefer to limit the number of pending calls to avoid overflow.
5468    /// A maximum of 10 pending calls is suggested.
5469    Send_ {
5470        packet: Vec<u8>,
5471        responder: ScoConnectionSend_Responder,
5472    },
5473    AckReceive {
5474        control_handle: ScoConnectionControlHandle,
5475    },
5476    /// The server will close the protocol when `Stop` is received. This is useful for
5477    /// synchronization (e.g. before configuring another `ScoConnection`).
5478    Stop {
5479        control_handle: ScoConnectionControlHandle,
5480    },
5481    /// An interaction was received which does not match any known method.
5482    #[non_exhaustive]
5483    _UnknownMethod {
5484        /// Ordinal of the method that was called.
5485        ordinal: u64,
5486        control_handle: ScoConnectionControlHandle,
5487        method_type: fidl::MethodType,
5488    },
5489}
5490
5491impl ScoConnectionRequest {
5492    #[allow(irrefutable_let_patterns)]
5493    pub fn into_send_(self) -> Option<(Vec<u8>, ScoConnectionSend_Responder)> {
5494        if let ScoConnectionRequest::Send_ { packet, responder } = self {
5495            Some((packet, responder))
5496        } else {
5497            None
5498        }
5499    }
5500
5501    #[allow(irrefutable_let_patterns)]
5502    pub fn into_ack_receive(self) -> Option<(ScoConnectionControlHandle)> {
5503        if let ScoConnectionRequest::AckReceive { control_handle } = self {
5504            Some((control_handle))
5505        } else {
5506            None
5507        }
5508    }
5509
5510    #[allow(irrefutable_let_patterns)]
5511    pub fn into_stop(self) -> Option<(ScoConnectionControlHandle)> {
5512        if let ScoConnectionRequest::Stop { control_handle } = self {
5513            Some((control_handle))
5514        } else {
5515            None
5516        }
5517    }
5518
5519    /// Name of the method defined in FIDL
5520    pub fn method_name(&self) -> &'static str {
5521        match *self {
5522            ScoConnectionRequest::Send_ { .. } => "send_",
5523            ScoConnectionRequest::AckReceive { .. } => "ack_receive",
5524            ScoConnectionRequest::Stop { .. } => "stop",
5525            ScoConnectionRequest::_UnknownMethod {
5526                method_type: fidl::MethodType::OneWay, ..
5527            } => "unknown one-way method",
5528            ScoConnectionRequest::_UnknownMethod {
5529                method_type: fidl::MethodType::TwoWay, ..
5530            } => "unknown two-way method",
5531        }
5532    }
5533}
5534
5535#[derive(Debug, Clone)]
5536pub struct ScoConnectionControlHandle {
5537    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5538}
5539
5540impl ScoConnectionControlHandle {
5541    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
5542        self.inner.shutdown_with_epitaph(status.into())
5543    }
5544}
5545
5546impl fidl::endpoints::ControlHandle for ScoConnectionControlHandle {
5547    fn shutdown(&self) {
5548        self.inner.shutdown()
5549    }
5550
5551    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
5552        self.inner.shutdown_with_epitaph(status)
5553    }
5554
5555    fn is_closed(&self) -> bool {
5556        self.inner.channel().is_closed()
5557    }
5558    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5559        self.inner.channel().on_closed()
5560    }
5561
5562    #[cfg(target_os = "fuchsia")]
5563    fn signal_peer(
5564        &self,
5565        clear_mask: zx::Signals,
5566        set_mask: zx::Signals,
5567    ) -> Result<(), zx_status::Status> {
5568        use fidl::Peered;
5569        self.inner.channel().signal_peer(clear_mask, set_mask)
5570    }
5571}
5572
5573impl ScoConnectionControlHandle {
5574    pub fn send_on_receive(&self, mut packet: &[u8]) -> Result<(), fidl::Error> {
5575        self.inner.send::<ScoPacket>(
5576            (packet,),
5577            0,
5578            0x4d4e96f6f7d1aa12,
5579            fidl::encoding::DynamicFlags::FLEXIBLE,
5580        )
5581    }
5582}
5583
5584#[must_use = "FIDL methods require a response to be sent"]
5585#[derive(Debug)]
5586pub struct ScoConnectionSend_Responder {
5587    control_handle: std::mem::ManuallyDrop<ScoConnectionControlHandle>,
5588    tx_id: u32,
5589}
5590
5591/// Set the the channel to be shutdown (see [`ScoConnectionControlHandle::shutdown`])
5592/// if the responder is dropped without sending a response, so that the client
5593/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5594impl std::ops::Drop for ScoConnectionSend_Responder {
5595    fn drop(&mut self) {
5596        self.control_handle.shutdown();
5597        // Safety: drops once, never accessed again
5598        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5599    }
5600}
5601
5602impl fidl::endpoints::Responder for ScoConnectionSend_Responder {
5603    type ControlHandle = ScoConnectionControlHandle;
5604
5605    fn control_handle(&self) -> &ScoConnectionControlHandle {
5606        &self.control_handle
5607    }
5608
5609    fn drop_without_shutdown(mut self) {
5610        // Safety: drops once, never accessed again due to mem::forget
5611        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5612        // Prevent Drop from running (which would shut down the channel)
5613        std::mem::forget(self);
5614    }
5615}
5616
5617impl ScoConnectionSend_Responder {
5618    /// Sends a response to the FIDL transaction.
5619    ///
5620    /// Sets the channel to shutdown if an error occurs.
5621    pub fn send(self) -> Result<(), fidl::Error> {
5622        let _result = self.send_raw();
5623        if _result.is_err() {
5624            self.control_handle.shutdown();
5625        }
5626        self.drop_without_shutdown();
5627        _result
5628    }
5629
5630    /// Similar to "send" but does not shutdown the channel if an error occurs.
5631    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5632        let _result = self.send_raw();
5633        self.drop_without_shutdown();
5634        _result
5635    }
5636
5637    fn send_raw(&self) -> Result<(), fidl::Error> {
5638        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
5639            fidl::encoding::Flexible::new(()),
5640            self.tx_id,
5641            0x6e0c000ccd50adec,
5642            fidl::encoding::DynamicFlags::FLEXIBLE,
5643        )
5644    }
5645}
5646
5647#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5648pub struct SnoopMarker;
5649
5650impl fidl::endpoints::ProtocolMarker for SnoopMarker {
5651    type Proxy = SnoopProxy;
5652    type RequestStream = SnoopRequestStream;
5653    #[cfg(target_os = "fuchsia")]
5654    type SynchronousProxy = SnoopSynchronousProxy;
5655
5656    const DEBUG_NAME: &'static str = "(anonymous) Snoop";
5657}
5658
5659pub trait SnoopProxyInterface: Send + Sync {
5660    fn r#acknowledge_packets(&self, sequence: u64) -> Result<(), fidl::Error>;
5661}
5662#[derive(Debug)]
5663#[cfg(target_os = "fuchsia")]
5664pub struct SnoopSynchronousProxy {
5665    client: fidl::client::sync::Client,
5666}
5667
5668#[cfg(target_os = "fuchsia")]
5669impl fidl::endpoints::SynchronousProxy for SnoopSynchronousProxy {
5670    type Proxy = SnoopProxy;
5671    type Protocol = SnoopMarker;
5672
5673    fn from_channel(inner: fidl::Channel) -> Self {
5674        Self::new(inner)
5675    }
5676
5677    fn into_channel(self) -> fidl::Channel {
5678        self.client.into_channel()
5679    }
5680
5681    fn as_channel(&self) -> &fidl::Channel {
5682        self.client.as_channel()
5683    }
5684}
5685
5686#[cfg(target_os = "fuchsia")]
5687impl SnoopSynchronousProxy {
5688    pub fn new(channel: fidl::Channel) -> Self {
5689        Self { client: fidl::client::sync::Client::new(channel) }
5690    }
5691
5692    pub fn into_channel(self) -> fidl::Channel {
5693        self.client.into_channel()
5694    }
5695
5696    /// Waits until an event arrives and returns it. It is safe for other
5697    /// threads to make concurrent requests while waiting for an event.
5698    pub fn wait_for_event(
5699        &self,
5700        deadline: zx::MonotonicInstant,
5701    ) -> Result<SnoopEvent, fidl::Error> {
5702        SnoopEvent::decode(self.client.wait_for_event::<SnoopMarker>(deadline)?)
5703    }
5704
5705    /// Acknowledge packets have been received up to `sequence`.
5706    pub fn r#acknowledge_packets(&self, mut sequence: u64) -> Result<(), fidl::Error> {
5707        self.client.send::<SnoopAcknowledgePacketsRequest>(
5708            (sequence,),
5709            0x3336b5082c111286,
5710            fidl::encoding::DynamicFlags::FLEXIBLE,
5711        )
5712    }
5713}
5714
5715#[cfg(target_os = "fuchsia")]
5716impl From<SnoopSynchronousProxy> for zx::NullableHandle {
5717    fn from(value: SnoopSynchronousProxy) -> Self {
5718        value.into_channel().into()
5719    }
5720}
5721
5722#[cfg(target_os = "fuchsia")]
5723impl From<fidl::Channel> for SnoopSynchronousProxy {
5724    fn from(value: fidl::Channel) -> Self {
5725        Self::new(value)
5726    }
5727}
5728
5729#[cfg(target_os = "fuchsia")]
5730impl fidl::endpoints::FromClient for SnoopSynchronousProxy {
5731    type Protocol = SnoopMarker;
5732
5733    fn from_client(value: fidl::endpoints::ClientEnd<SnoopMarker>) -> Self {
5734        Self::new(value.into_channel())
5735    }
5736}
5737
5738#[derive(Debug, Clone)]
5739pub struct SnoopProxy {
5740    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5741}
5742
5743impl fidl::endpoints::Proxy for SnoopProxy {
5744    type Protocol = SnoopMarker;
5745
5746    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5747        Self::new(inner)
5748    }
5749
5750    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5751        self.client.into_channel().map_err(|client| Self { client })
5752    }
5753
5754    fn as_channel(&self) -> &::fidl::AsyncChannel {
5755        self.client.as_channel()
5756    }
5757}
5758
5759impl SnoopProxy {
5760    /// Create a new Proxy for fuchsia.hardware.bluetooth/Snoop.
5761    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5762        let protocol_name = <SnoopMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5763        Self { client: fidl::client::Client::new(channel, protocol_name) }
5764    }
5765
5766    /// Get a Stream of events from the remote end of the protocol.
5767    ///
5768    /// # Panics
5769    ///
5770    /// Panics if the event stream was already taken.
5771    pub fn take_event_stream(&self) -> SnoopEventStream {
5772        SnoopEventStream { event_receiver: self.client.take_event_receiver() }
5773    }
5774
5775    /// Acknowledge packets have been received up to `sequence`.
5776    pub fn r#acknowledge_packets(&self, mut sequence: u64) -> Result<(), fidl::Error> {
5777        SnoopProxyInterface::r#acknowledge_packets(self, sequence)
5778    }
5779}
5780
5781impl SnoopProxyInterface for SnoopProxy {
5782    fn r#acknowledge_packets(&self, mut sequence: u64) -> Result<(), fidl::Error> {
5783        self.client.send::<SnoopAcknowledgePacketsRequest>(
5784            (sequence,),
5785            0x3336b5082c111286,
5786            fidl::encoding::DynamicFlags::FLEXIBLE,
5787        )
5788    }
5789}
5790
5791pub struct SnoopEventStream {
5792    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5793}
5794
5795impl std::marker::Unpin for SnoopEventStream {}
5796
5797impl futures::stream::FusedStream for SnoopEventStream {
5798    fn is_terminated(&self) -> bool {
5799        self.event_receiver.is_terminated()
5800    }
5801}
5802
5803impl futures::Stream for SnoopEventStream {
5804    type Item = Result<SnoopEvent, fidl::Error>;
5805
5806    fn poll_next(
5807        mut self: std::pin::Pin<&mut Self>,
5808        cx: &mut std::task::Context<'_>,
5809    ) -> std::task::Poll<Option<Self::Item>> {
5810        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5811            &mut self.event_receiver,
5812            cx
5813        )?) {
5814            Some(buf) => std::task::Poll::Ready(Some(SnoopEvent::decode(buf))),
5815            None => std::task::Poll::Ready(None),
5816        }
5817    }
5818}
5819
5820#[derive(Debug)]
5821pub enum SnoopEvent {
5822    OnObservePacket {
5823        payload: SnoopOnObservePacketRequest,
5824    },
5825    OnDroppedPackets {
5826        payload: SnoopOnDroppedPacketsRequest,
5827    },
5828    #[non_exhaustive]
5829    _UnknownEvent {
5830        /// Ordinal of the event that was sent.
5831        ordinal: u64,
5832    },
5833}
5834
5835impl SnoopEvent {
5836    #[allow(irrefutable_let_patterns)]
5837    pub fn into_on_observe_packet(self) -> Option<SnoopOnObservePacketRequest> {
5838        if let SnoopEvent::OnObservePacket { payload } = self { Some((payload)) } else { None }
5839    }
5840    #[allow(irrefutable_let_patterns)]
5841    pub fn into_on_dropped_packets(self) -> Option<SnoopOnDroppedPacketsRequest> {
5842        if let SnoopEvent::OnDroppedPackets { payload } = self { Some((payload)) } else { None }
5843    }
5844
5845    /// Decodes a message buffer as a [`SnoopEvent`].
5846    fn decode(
5847        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5848    ) -> Result<SnoopEvent, fidl::Error> {
5849        let (bytes, _handles) = buf.split_mut();
5850        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5851        debug_assert_eq!(tx_header.tx_id, 0);
5852        match tx_header.ordinal {
5853            0x34d9f4c9c6bc10ca => {
5854                let mut out = fidl::new_empty!(
5855                    SnoopOnObservePacketRequest,
5856                    fidl::encoding::DefaultFuchsiaResourceDialect
5857                );
5858                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SnoopOnObservePacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
5859                Ok((SnoopEvent::OnObservePacket { payload: out }))
5860            }
5861            0x102a8d21278578b9 => {
5862                let mut out = fidl::new_empty!(
5863                    SnoopOnDroppedPacketsRequest,
5864                    fidl::encoding::DefaultFuchsiaResourceDialect
5865                );
5866                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SnoopOnDroppedPacketsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
5867                Ok((SnoopEvent::OnDroppedPackets { payload: out }))
5868            }
5869            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5870                Ok(SnoopEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5871            }
5872            _ => Err(fidl::Error::UnknownOrdinal {
5873                ordinal: tx_header.ordinal,
5874                protocol_name: <SnoopMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5875            }),
5876        }
5877    }
5878}
5879
5880/// A Stream of incoming requests for fuchsia.hardware.bluetooth/Snoop.
5881pub struct SnoopRequestStream {
5882    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5883    is_terminated: bool,
5884}
5885
5886impl std::marker::Unpin for SnoopRequestStream {}
5887
5888impl futures::stream::FusedStream for SnoopRequestStream {
5889    fn is_terminated(&self) -> bool {
5890        self.is_terminated
5891    }
5892}
5893
5894impl fidl::endpoints::RequestStream for SnoopRequestStream {
5895    type Protocol = SnoopMarker;
5896    type ControlHandle = SnoopControlHandle;
5897
5898    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5899        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5900    }
5901
5902    fn control_handle(&self) -> Self::ControlHandle {
5903        SnoopControlHandle { inner: self.inner.clone() }
5904    }
5905
5906    fn into_inner(
5907        self,
5908    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5909    {
5910        (self.inner, self.is_terminated)
5911    }
5912
5913    fn from_inner(
5914        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5915        is_terminated: bool,
5916    ) -> Self {
5917        Self { inner, is_terminated }
5918    }
5919}
5920
5921impl futures::Stream for SnoopRequestStream {
5922    type Item = Result<SnoopRequest, fidl::Error>;
5923
5924    fn poll_next(
5925        mut self: std::pin::Pin<&mut Self>,
5926        cx: &mut std::task::Context<'_>,
5927    ) -> std::task::Poll<Option<Self::Item>> {
5928        let this = &mut *self;
5929        if this.inner.check_shutdown(cx) {
5930            this.is_terminated = true;
5931            return std::task::Poll::Ready(None);
5932        }
5933        if this.is_terminated {
5934            panic!("polled SnoopRequestStream after completion");
5935        }
5936        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5937            |bytes, handles| {
5938                match this.inner.channel().read_etc(cx, bytes, handles) {
5939                    std::task::Poll::Ready(Ok(())) => {}
5940                    std::task::Poll::Pending => return std::task::Poll::Pending,
5941                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5942                        this.is_terminated = true;
5943                        return std::task::Poll::Ready(None);
5944                    }
5945                    std::task::Poll::Ready(Err(e)) => {
5946                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5947                            e.into(),
5948                        ))));
5949                    }
5950                }
5951
5952                // A message has been received from the channel
5953                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5954
5955                std::task::Poll::Ready(Some(match header.ordinal {
5956                    0x3336b5082c111286 => {
5957                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5958                        let mut req = fidl::new_empty!(
5959                            SnoopAcknowledgePacketsRequest,
5960                            fidl::encoding::DefaultFuchsiaResourceDialect
5961                        );
5962                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SnoopAcknowledgePacketsRequest>(&header, _body_bytes, handles, &mut req)?;
5963                        let control_handle = SnoopControlHandle { inner: this.inner.clone() };
5964                        Ok(SnoopRequest::AcknowledgePackets {
5965                            sequence: req.sequence,
5966
5967                            control_handle,
5968                        })
5969                    }
5970                    _ if header.tx_id == 0
5971                        && header
5972                            .dynamic_flags()
5973                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5974                    {
5975                        Ok(SnoopRequest::_UnknownMethod {
5976                            ordinal: header.ordinal,
5977                            control_handle: SnoopControlHandle { inner: this.inner.clone() },
5978                            method_type: fidl::MethodType::OneWay,
5979                        })
5980                    }
5981                    _ if header
5982                        .dynamic_flags()
5983                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5984                    {
5985                        this.inner.send_framework_err(
5986                            fidl::encoding::FrameworkErr::UnknownMethod,
5987                            header.tx_id,
5988                            header.ordinal,
5989                            header.dynamic_flags(),
5990                            (bytes, handles),
5991                        )?;
5992                        Ok(SnoopRequest::_UnknownMethod {
5993                            ordinal: header.ordinal,
5994                            control_handle: SnoopControlHandle { inner: this.inner.clone() },
5995                            method_type: fidl::MethodType::TwoWay,
5996                        })
5997                    }
5998                    _ => Err(fidl::Error::UnknownOrdinal {
5999                        ordinal: header.ordinal,
6000                        protocol_name: <SnoopMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6001                    }),
6002                }))
6003            },
6004        )
6005    }
6006}
6007
6008#[derive(Debug)]
6009pub enum SnoopRequest {
6010    /// Acknowledge packets have been received up to `sequence`.
6011    AcknowledgePackets { sequence: u64, control_handle: SnoopControlHandle },
6012    /// An interaction was received which does not match any known method.
6013    #[non_exhaustive]
6014    _UnknownMethod {
6015        /// Ordinal of the method that was called.
6016        ordinal: u64,
6017        control_handle: SnoopControlHandle,
6018        method_type: fidl::MethodType,
6019    },
6020}
6021
6022impl SnoopRequest {
6023    #[allow(irrefutable_let_patterns)]
6024    pub fn into_acknowledge_packets(self) -> Option<(u64, SnoopControlHandle)> {
6025        if let SnoopRequest::AcknowledgePackets { sequence, control_handle } = self {
6026            Some((sequence, control_handle))
6027        } else {
6028            None
6029        }
6030    }
6031
6032    /// Name of the method defined in FIDL
6033    pub fn method_name(&self) -> &'static str {
6034        match *self {
6035            SnoopRequest::AcknowledgePackets { .. } => "acknowledge_packets",
6036            SnoopRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
6037                "unknown one-way method"
6038            }
6039            SnoopRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
6040                "unknown two-way method"
6041            }
6042        }
6043    }
6044}
6045
6046#[derive(Debug, Clone)]
6047pub struct SnoopControlHandle {
6048    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6049}
6050
6051impl SnoopControlHandle {
6052    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
6053        self.inner.shutdown_with_epitaph(status.into())
6054    }
6055}
6056
6057impl fidl::endpoints::ControlHandle for SnoopControlHandle {
6058    fn shutdown(&self) {
6059        self.inner.shutdown()
6060    }
6061
6062    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
6063        self.inner.shutdown_with_epitaph(status)
6064    }
6065
6066    fn is_closed(&self) -> bool {
6067        self.inner.channel().is_closed()
6068    }
6069    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6070        self.inner.channel().on_closed()
6071    }
6072
6073    #[cfg(target_os = "fuchsia")]
6074    fn signal_peer(
6075        &self,
6076        clear_mask: zx::Signals,
6077        set_mask: zx::Signals,
6078    ) -> Result<(), zx_status::Status> {
6079        use fidl::Peered;
6080        self.inner.channel().signal_peer(clear_mask, set_mask)
6081    }
6082}
6083
6084impl SnoopControlHandle {
6085    pub fn send_on_observe_packet(
6086        &self,
6087        mut payload: &SnoopOnObservePacketRequest,
6088    ) -> Result<(), fidl::Error> {
6089        self.inner.send::<SnoopOnObservePacketRequest>(
6090            payload,
6091            0,
6092            0x34d9f4c9c6bc10ca,
6093            fidl::encoding::DynamicFlags::FLEXIBLE,
6094        )
6095    }
6096
6097    pub fn send_on_dropped_packets(
6098        &self,
6099        mut payload: &SnoopOnDroppedPacketsRequest,
6100    ) -> Result<(), fidl::Error> {
6101        self.inner.send::<SnoopOnDroppedPacketsRequest>(
6102            payload,
6103            0,
6104            0x102a8d21278578b9,
6105            fidl::encoding::DynamicFlags::FLEXIBLE,
6106        )
6107    }
6108}
6109
6110#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6111pub struct VendorMarker;
6112
6113impl fidl::endpoints::ProtocolMarker for VendorMarker {
6114    type Proxy = VendorProxy;
6115    type RequestStream = VendorRequestStream;
6116    #[cfg(target_os = "fuchsia")]
6117    type SynchronousProxy = VendorSynchronousProxy;
6118
6119    const DEBUG_NAME: &'static str = "(anonymous) Vendor";
6120}
6121pub type VendorEncodeCommandResult = Result<Vec<u8>, i32>;
6122pub type VendorOpenHciResult = Result<fidl::endpoints::ClientEnd<HciMarker>, i32>;
6123pub type VendorOpenHciTransportResult = Result<fidl::endpoints::ClientEnd<HciTransportMarker>, i32>;
6124pub type VendorOpenSnoopResult = Result<fidl::endpoints::ClientEnd<SnoopMarker>, i32>;
6125pub type VendorGetCrashParametersResult = Result<VendorCrashParameters, i32>;
6126
6127pub trait VendorProxyInterface: Send + Sync {
6128    type GetFeaturesResponseFut: std::future::Future<Output = Result<VendorFeatures, fidl::Error>>
6129        + Send;
6130    fn r#get_features(&self) -> Self::GetFeaturesResponseFut;
6131    type EncodeCommandResponseFut: std::future::Future<Output = Result<VendorEncodeCommandResult, fidl::Error>>
6132        + Send;
6133    fn r#encode_command(&self, payload: &VendorCommand) -> Self::EncodeCommandResponseFut;
6134    type OpenHciResponseFut: std::future::Future<Output = Result<VendorOpenHciResult, fidl::Error>>
6135        + Send;
6136    fn r#open_hci(&self) -> Self::OpenHciResponseFut;
6137    type OpenHciTransportResponseFut: std::future::Future<Output = Result<VendorOpenHciTransportResult, fidl::Error>>
6138        + Send;
6139    fn r#open_hci_transport(&self) -> Self::OpenHciTransportResponseFut;
6140    type OpenSnoopResponseFut: std::future::Future<Output = Result<VendorOpenSnoopResult, fidl::Error>>
6141        + Send;
6142    fn r#open_snoop(&self) -> Self::OpenSnoopResponseFut;
6143    type GetCrashParametersResponseFut: std::future::Future<Output = Result<VendorGetCrashParametersResult, fidl::Error>>
6144        + Send;
6145    fn r#get_crash_parameters(&self) -> Self::GetCrashParametersResponseFut;
6146}
6147#[derive(Debug)]
6148#[cfg(target_os = "fuchsia")]
6149pub struct VendorSynchronousProxy {
6150    client: fidl::client::sync::Client,
6151}
6152
6153#[cfg(target_os = "fuchsia")]
6154impl fidl::endpoints::SynchronousProxy for VendorSynchronousProxy {
6155    type Proxy = VendorProxy;
6156    type Protocol = VendorMarker;
6157
6158    fn from_channel(inner: fidl::Channel) -> Self {
6159        Self::new(inner)
6160    }
6161
6162    fn into_channel(self) -> fidl::Channel {
6163        self.client.into_channel()
6164    }
6165
6166    fn as_channel(&self) -> &fidl::Channel {
6167        self.client.as_channel()
6168    }
6169}
6170
6171#[cfg(target_os = "fuchsia")]
6172impl VendorSynchronousProxy {
6173    pub fn new(channel: fidl::Channel) -> Self {
6174        Self { client: fidl::client::sync::Client::new(channel) }
6175    }
6176
6177    pub fn into_channel(self) -> fidl::Channel {
6178        self.client.into_channel()
6179    }
6180
6181    /// Waits until an event arrives and returns it. It is safe for other
6182    /// threads to make concurrent requests while waiting for an event.
6183    pub fn wait_for_event(
6184        &self,
6185        deadline: zx::MonotonicInstant,
6186    ) -> Result<VendorEvent, fidl::Error> {
6187        VendorEvent::decode(self.client.wait_for_event::<VendorMarker>(deadline)?)
6188    }
6189
6190    /// Returns the Vendor Features supported by this controller.
6191    pub fn r#get_features(
6192        &self,
6193        ___deadline: zx::MonotonicInstant,
6194    ) -> Result<VendorFeatures, fidl::Error> {
6195        let _response = self.client.send_query::<
6196            fidl::encoding::EmptyPayload,
6197            fidl::encoding::FlexibleType<VendorFeatures>,
6198            VendorMarker,
6199        >(
6200            (),
6201            0x102e70164c1dc911,
6202            fidl::encoding::DynamicFlags::FLEXIBLE,
6203            ___deadline,
6204        )?
6205        .into_result::<VendorMarker>("get_features")?;
6206        Ok(_response)
6207    }
6208
6209    /// Encode the vendor HCI command and return the encoded command.
6210    /// See `VendorCommand` for possible commands and parameters.
6211    /// * error `ZX_ERR_NOT_SUPPORTED` The command is not supported.
6212    /// * error `ZX_ERR_INVALID_ARGS` The parameters of the command are invalid.
6213    pub fn r#encode_command(
6214        &self,
6215        mut payload: &VendorCommand,
6216        ___deadline: zx::MonotonicInstant,
6217    ) -> Result<VendorEncodeCommandResult, fidl::Error> {
6218        let _response = self.client.send_query::<
6219            VendorCommand,
6220            fidl::encoding::FlexibleResultType<VendorEncodeCommandResponse, i32>,
6221            VendorMarker,
6222        >(
6223            payload,
6224            0x75430542c197cbe8,
6225            fidl::encoding::DynamicFlags::FLEXIBLE,
6226            ___deadline,
6227        )?
6228        .into_result::<VendorMarker>("encode_command")?;
6229        Ok(_response.map(|x| x.encoded))
6230    }
6231
6232    /// Deprecated.
6233    /// Open the HCI protocol to the controller.  This call may block until the
6234    /// controller has been initialized.
6235    /// Returns ALREADY_BOUND if another client has already connected.
6236    pub fn r#open_hci(
6237        &self,
6238        ___deadline: zx::MonotonicInstant,
6239    ) -> Result<VendorOpenHciResult, fidl::Error> {
6240        let _response = self.client.send_query::<
6241            fidl::encoding::EmptyPayload,
6242            fidl::encoding::FlexibleResultType<VendorOpenHciResponse, i32>,
6243            VendorMarker,
6244        >(
6245            (),
6246            0x7f05862f7ef92ec8,
6247            fidl::encoding::DynamicFlags::FLEXIBLE,
6248            ___deadline,
6249        )?
6250        .into_result::<VendorMarker>("open_hci")?;
6251        Ok(_response.map(|x| x.channel))
6252    }
6253
6254    /// Open the HciTransport protocol to the controller. This call may block until the
6255    /// controller has been initialized.
6256    /// Returns ALREADY_BOUND if another client has already connected.
6257    pub fn r#open_hci_transport(
6258        &self,
6259        ___deadline: zx::MonotonicInstant,
6260    ) -> Result<VendorOpenHciTransportResult, fidl::Error> {
6261        let _response = self.client.send_query::<
6262            fidl::encoding::EmptyPayload,
6263            fidl::encoding::FlexibleResultType<VendorOpenHciTransportResponse, i32>,
6264            VendorMarker,
6265        >(
6266            (),
6267            0x1f785b656fb00834,
6268            fidl::encoding::DynamicFlags::FLEXIBLE,
6269            ___deadline,
6270        )?
6271        .into_result::<VendorMarker>("open_hci_transport")?;
6272        Ok(_response.map(|x| x.channel))
6273    }
6274
6275    /// Open the Snoop protocol to the transport driver.
6276    /// Returns ALREADY_BOUND if another client has already connected.
6277    pub fn r#open_snoop(
6278        &self,
6279        ___deadline: zx::MonotonicInstant,
6280    ) -> Result<VendorOpenSnoopResult, fidl::Error> {
6281        let _response = self.client.send_query::<
6282            fidl::encoding::EmptyPayload,
6283            fidl::encoding::FlexibleResultType<VendorOpenSnoopResponse, i32>,
6284            VendorMarker,
6285        >(
6286            (),
6287            0xafeca0e3c789043,
6288            fidl::encoding::DynamicFlags::FLEXIBLE,
6289            ___deadline,
6290        )?
6291        .into_result::<VendorMarker>("open_snoop")?;
6292        Ok(_response.map(|x| x.channel))
6293    }
6294
6295    /// Returns parameters used by bt-snoop to record and file Bluetooth controller crash reports.
6296    /// Core dump events will be redacted from snoop logs.
6297    /// Returns NOT_SUPPORTED if crash dumps are not supported by this vendor.
6298    pub fn r#get_crash_parameters(
6299        &self,
6300        ___deadline: zx::MonotonicInstant,
6301    ) -> Result<VendorGetCrashParametersResult, fidl::Error> {
6302        let _response = self.client.send_query::<
6303            fidl::encoding::EmptyPayload,
6304            fidl::encoding::FlexibleResultType<VendorCrashParameters, i32>,
6305            VendorMarker,
6306        >(
6307            (),
6308            0xb16601642b3a567,
6309            fidl::encoding::DynamicFlags::FLEXIBLE,
6310            ___deadline,
6311        )?
6312        .into_result::<VendorMarker>("get_crash_parameters")?;
6313        Ok(_response.map(|x| x))
6314    }
6315}
6316
6317#[cfg(target_os = "fuchsia")]
6318impl From<VendorSynchronousProxy> for zx::NullableHandle {
6319    fn from(value: VendorSynchronousProxy) -> Self {
6320        value.into_channel().into()
6321    }
6322}
6323
6324#[cfg(target_os = "fuchsia")]
6325impl From<fidl::Channel> for VendorSynchronousProxy {
6326    fn from(value: fidl::Channel) -> Self {
6327        Self::new(value)
6328    }
6329}
6330
6331#[cfg(target_os = "fuchsia")]
6332impl fidl::endpoints::FromClient for VendorSynchronousProxy {
6333    type Protocol = VendorMarker;
6334
6335    fn from_client(value: fidl::endpoints::ClientEnd<VendorMarker>) -> Self {
6336        Self::new(value.into_channel())
6337    }
6338}
6339
6340#[derive(Debug, Clone)]
6341pub struct VendorProxy {
6342    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6343}
6344
6345impl fidl::endpoints::Proxy for VendorProxy {
6346    type Protocol = VendorMarker;
6347
6348    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6349        Self::new(inner)
6350    }
6351
6352    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6353        self.client.into_channel().map_err(|client| Self { client })
6354    }
6355
6356    fn as_channel(&self) -> &::fidl::AsyncChannel {
6357        self.client.as_channel()
6358    }
6359}
6360
6361impl VendorProxy {
6362    /// Create a new Proxy for fuchsia.hardware.bluetooth/Vendor.
6363    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6364        let protocol_name = <VendorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6365        Self { client: fidl::client::Client::new(channel, protocol_name) }
6366    }
6367
6368    /// Get a Stream of events from the remote end of the protocol.
6369    ///
6370    /// # Panics
6371    ///
6372    /// Panics if the event stream was already taken.
6373    pub fn take_event_stream(&self) -> VendorEventStream {
6374        VendorEventStream { event_receiver: self.client.take_event_receiver() }
6375    }
6376
6377    /// Returns the Vendor Features supported by this controller.
6378    pub fn r#get_features(
6379        &self,
6380    ) -> fidl::client::QueryResponseFut<VendorFeatures, fidl::encoding::DefaultFuchsiaResourceDialect>
6381    {
6382        VendorProxyInterface::r#get_features(self)
6383    }
6384
6385    /// Encode the vendor HCI command and return the encoded command.
6386    /// See `VendorCommand` for possible commands and parameters.
6387    /// * error `ZX_ERR_NOT_SUPPORTED` The command is not supported.
6388    /// * error `ZX_ERR_INVALID_ARGS` The parameters of the command are invalid.
6389    pub fn r#encode_command(
6390        &self,
6391        mut payload: &VendorCommand,
6392    ) -> fidl::client::QueryResponseFut<
6393        VendorEncodeCommandResult,
6394        fidl::encoding::DefaultFuchsiaResourceDialect,
6395    > {
6396        VendorProxyInterface::r#encode_command(self, payload)
6397    }
6398
6399    /// Deprecated.
6400    /// Open the HCI protocol to the controller.  This call may block until the
6401    /// controller has been initialized.
6402    /// Returns ALREADY_BOUND if another client has already connected.
6403    pub fn r#open_hci(
6404        &self,
6405    ) -> fidl::client::QueryResponseFut<
6406        VendorOpenHciResult,
6407        fidl::encoding::DefaultFuchsiaResourceDialect,
6408    > {
6409        VendorProxyInterface::r#open_hci(self)
6410    }
6411
6412    /// Open the HciTransport protocol to the controller. This call may block until the
6413    /// controller has been initialized.
6414    /// Returns ALREADY_BOUND if another client has already connected.
6415    pub fn r#open_hci_transport(
6416        &self,
6417    ) -> fidl::client::QueryResponseFut<
6418        VendorOpenHciTransportResult,
6419        fidl::encoding::DefaultFuchsiaResourceDialect,
6420    > {
6421        VendorProxyInterface::r#open_hci_transport(self)
6422    }
6423
6424    /// Open the Snoop protocol to the transport driver.
6425    /// Returns ALREADY_BOUND if another client has already connected.
6426    pub fn r#open_snoop(
6427        &self,
6428    ) -> fidl::client::QueryResponseFut<
6429        VendorOpenSnoopResult,
6430        fidl::encoding::DefaultFuchsiaResourceDialect,
6431    > {
6432        VendorProxyInterface::r#open_snoop(self)
6433    }
6434
6435    /// Returns parameters used by bt-snoop to record and file Bluetooth controller crash reports.
6436    /// Core dump events will be redacted from snoop logs.
6437    /// Returns NOT_SUPPORTED if crash dumps are not supported by this vendor.
6438    pub fn r#get_crash_parameters(
6439        &self,
6440    ) -> fidl::client::QueryResponseFut<
6441        VendorGetCrashParametersResult,
6442        fidl::encoding::DefaultFuchsiaResourceDialect,
6443    > {
6444        VendorProxyInterface::r#get_crash_parameters(self)
6445    }
6446}
6447
6448impl VendorProxyInterface for VendorProxy {
6449    type GetFeaturesResponseFut = fidl::client::QueryResponseFut<
6450        VendorFeatures,
6451        fidl::encoding::DefaultFuchsiaResourceDialect,
6452    >;
6453    fn r#get_features(&self) -> Self::GetFeaturesResponseFut {
6454        fn _decode(
6455            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6456        ) -> Result<VendorFeatures, fidl::Error> {
6457            let _response = fidl::client::decode_transaction_body::<
6458                fidl::encoding::FlexibleType<VendorFeatures>,
6459                fidl::encoding::DefaultFuchsiaResourceDialect,
6460                0x102e70164c1dc911,
6461            >(_buf?)?
6462            .into_result::<VendorMarker>("get_features")?;
6463            Ok(_response)
6464        }
6465        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, VendorFeatures>(
6466            (),
6467            0x102e70164c1dc911,
6468            fidl::encoding::DynamicFlags::FLEXIBLE,
6469            _decode,
6470        )
6471    }
6472
6473    type EncodeCommandResponseFut = fidl::client::QueryResponseFut<
6474        VendorEncodeCommandResult,
6475        fidl::encoding::DefaultFuchsiaResourceDialect,
6476    >;
6477    fn r#encode_command(&self, mut payload: &VendorCommand) -> Self::EncodeCommandResponseFut {
6478        fn _decode(
6479            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6480        ) -> Result<VendorEncodeCommandResult, fidl::Error> {
6481            let _response = fidl::client::decode_transaction_body::<
6482                fidl::encoding::FlexibleResultType<VendorEncodeCommandResponse, i32>,
6483                fidl::encoding::DefaultFuchsiaResourceDialect,
6484                0x75430542c197cbe8,
6485            >(_buf?)?
6486            .into_result::<VendorMarker>("encode_command")?;
6487            Ok(_response.map(|x| x.encoded))
6488        }
6489        self.client.send_query_and_decode::<VendorCommand, VendorEncodeCommandResult>(
6490            payload,
6491            0x75430542c197cbe8,
6492            fidl::encoding::DynamicFlags::FLEXIBLE,
6493            _decode,
6494        )
6495    }
6496
6497    type OpenHciResponseFut = fidl::client::QueryResponseFut<
6498        VendorOpenHciResult,
6499        fidl::encoding::DefaultFuchsiaResourceDialect,
6500    >;
6501    fn r#open_hci(&self) -> Self::OpenHciResponseFut {
6502        fn _decode(
6503            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6504        ) -> Result<VendorOpenHciResult, fidl::Error> {
6505            let _response = fidl::client::decode_transaction_body::<
6506                fidl::encoding::FlexibleResultType<VendorOpenHciResponse, i32>,
6507                fidl::encoding::DefaultFuchsiaResourceDialect,
6508                0x7f05862f7ef92ec8,
6509            >(_buf?)?
6510            .into_result::<VendorMarker>("open_hci")?;
6511            Ok(_response.map(|x| x.channel))
6512        }
6513        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, VendorOpenHciResult>(
6514            (),
6515            0x7f05862f7ef92ec8,
6516            fidl::encoding::DynamicFlags::FLEXIBLE,
6517            _decode,
6518        )
6519    }
6520
6521    type OpenHciTransportResponseFut = fidl::client::QueryResponseFut<
6522        VendorOpenHciTransportResult,
6523        fidl::encoding::DefaultFuchsiaResourceDialect,
6524    >;
6525    fn r#open_hci_transport(&self) -> Self::OpenHciTransportResponseFut {
6526        fn _decode(
6527            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6528        ) -> Result<VendorOpenHciTransportResult, fidl::Error> {
6529            let _response = fidl::client::decode_transaction_body::<
6530                fidl::encoding::FlexibleResultType<VendorOpenHciTransportResponse, i32>,
6531                fidl::encoding::DefaultFuchsiaResourceDialect,
6532                0x1f785b656fb00834,
6533            >(_buf?)?
6534            .into_result::<VendorMarker>("open_hci_transport")?;
6535            Ok(_response.map(|x| x.channel))
6536        }
6537        self.client
6538            .send_query_and_decode::<fidl::encoding::EmptyPayload, VendorOpenHciTransportResult>(
6539                (),
6540                0x1f785b656fb00834,
6541                fidl::encoding::DynamicFlags::FLEXIBLE,
6542                _decode,
6543            )
6544    }
6545
6546    type OpenSnoopResponseFut = fidl::client::QueryResponseFut<
6547        VendorOpenSnoopResult,
6548        fidl::encoding::DefaultFuchsiaResourceDialect,
6549    >;
6550    fn r#open_snoop(&self) -> Self::OpenSnoopResponseFut {
6551        fn _decode(
6552            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6553        ) -> Result<VendorOpenSnoopResult, fidl::Error> {
6554            let _response = fidl::client::decode_transaction_body::<
6555                fidl::encoding::FlexibleResultType<VendorOpenSnoopResponse, i32>,
6556                fidl::encoding::DefaultFuchsiaResourceDialect,
6557                0xafeca0e3c789043,
6558            >(_buf?)?
6559            .into_result::<VendorMarker>("open_snoop")?;
6560            Ok(_response.map(|x| x.channel))
6561        }
6562        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, VendorOpenSnoopResult>(
6563            (),
6564            0xafeca0e3c789043,
6565            fidl::encoding::DynamicFlags::FLEXIBLE,
6566            _decode,
6567        )
6568    }
6569
6570    type GetCrashParametersResponseFut = fidl::client::QueryResponseFut<
6571        VendorGetCrashParametersResult,
6572        fidl::encoding::DefaultFuchsiaResourceDialect,
6573    >;
6574    fn r#get_crash_parameters(&self) -> Self::GetCrashParametersResponseFut {
6575        fn _decode(
6576            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6577        ) -> Result<VendorGetCrashParametersResult, fidl::Error> {
6578            let _response = fidl::client::decode_transaction_body::<
6579                fidl::encoding::FlexibleResultType<VendorCrashParameters, i32>,
6580                fidl::encoding::DefaultFuchsiaResourceDialect,
6581                0xb16601642b3a567,
6582            >(_buf?)?
6583            .into_result::<VendorMarker>("get_crash_parameters")?;
6584            Ok(_response.map(|x| x))
6585        }
6586        self.client
6587            .send_query_and_decode::<fidl::encoding::EmptyPayload, VendorGetCrashParametersResult>(
6588                (),
6589                0xb16601642b3a567,
6590                fidl::encoding::DynamicFlags::FLEXIBLE,
6591                _decode,
6592            )
6593    }
6594}
6595
6596pub struct VendorEventStream {
6597    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6598}
6599
6600impl std::marker::Unpin for VendorEventStream {}
6601
6602impl futures::stream::FusedStream for VendorEventStream {
6603    fn is_terminated(&self) -> bool {
6604        self.event_receiver.is_terminated()
6605    }
6606}
6607
6608impl futures::Stream for VendorEventStream {
6609    type Item = Result<VendorEvent, fidl::Error>;
6610
6611    fn poll_next(
6612        mut self: std::pin::Pin<&mut Self>,
6613        cx: &mut std::task::Context<'_>,
6614    ) -> std::task::Poll<Option<Self::Item>> {
6615        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6616            &mut self.event_receiver,
6617            cx
6618        )?) {
6619            Some(buf) => std::task::Poll::Ready(Some(VendorEvent::decode(buf))),
6620            None => std::task::Poll::Ready(None),
6621        }
6622    }
6623}
6624
6625#[derive(Debug)]
6626pub enum VendorEvent {
6627    #[non_exhaustive]
6628    _UnknownEvent {
6629        /// Ordinal of the event that was sent.
6630        ordinal: u64,
6631    },
6632}
6633
6634impl VendorEvent {
6635    /// Decodes a message buffer as a [`VendorEvent`].
6636    fn decode(
6637        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6638    ) -> Result<VendorEvent, fidl::Error> {
6639        let (bytes, _handles) = buf.split_mut();
6640        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6641        debug_assert_eq!(tx_header.tx_id, 0);
6642        match tx_header.ordinal {
6643            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
6644                Ok(VendorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
6645            }
6646            _ => Err(fidl::Error::UnknownOrdinal {
6647                ordinal: tx_header.ordinal,
6648                protocol_name: <VendorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6649            }),
6650        }
6651    }
6652}
6653
6654/// A Stream of incoming requests for fuchsia.hardware.bluetooth/Vendor.
6655pub struct VendorRequestStream {
6656    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6657    is_terminated: bool,
6658}
6659
6660impl std::marker::Unpin for VendorRequestStream {}
6661
6662impl futures::stream::FusedStream for VendorRequestStream {
6663    fn is_terminated(&self) -> bool {
6664        self.is_terminated
6665    }
6666}
6667
6668impl fidl::endpoints::RequestStream for VendorRequestStream {
6669    type Protocol = VendorMarker;
6670    type ControlHandle = VendorControlHandle;
6671
6672    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6673        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6674    }
6675
6676    fn control_handle(&self) -> Self::ControlHandle {
6677        VendorControlHandle { inner: self.inner.clone() }
6678    }
6679
6680    fn into_inner(
6681        self,
6682    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6683    {
6684        (self.inner, self.is_terminated)
6685    }
6686
6687    fn from_inner(
6688        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6689        is_terminated: bool,
6690    ) -> Self {
6691        Self { inner, is_terminated }
6692    }
6693}
6694
6695impl futures::Stream for VendorRequestStream {
6696    type Item = Result<VendorRequest, fidl::Error>;
6697
6698    fn poll_next(
6699        mut self: std::pin::Pin<&mut Self>,
6700        cx: &mut std::task::Context<'_>,
6701    ) -> std::task::Poll<Option<Self::Item>> {
6702        let this = &mut *self;
6703        if this.inner.check_shutdown(cx) {
6704            this.is_terminated = true;
6705            return std::task::Poll::Ready(None);
6706        }
6707        if this.is_terminated {
6708            panic!("polled VendorRequestStream after completion");
6709        }
6710        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6711            |bytes, handles| {
6712                match this.inner.channel().read_etc(cx, bytes, handles) {
6713                    std::task::Poll::Ready(Ok(())) => {}
6714                    std::task::Poll::Pending => return std::task::Poll::Pending,
6715                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6716                        this.is_terminated = true;
6717                        return std::task::Poll::Ready(None);
6718                    }
6719                    std::task::Poll::Ready(Err(e)) => {
6720                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6721                            e.into(),
6722                        ))));
6723                    }
6724                }
6725
6726                // A message has been received from the channel
6727                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6728
6729                std::task::Poll::Ready(Some(match header.ordinal {
6730                    0x102e70164c1dc911 => {
6731                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6732                        let mut req = fidl::new_empty!(
6733                            fidl::encoding::EmptyPayload,
6734                            fidl::encoding::DefaultFuchsiaResourceDialect
6735                        );
6736                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6737                        let control_handle = VendorControlHandle { inner: this.inner.clone() };
6738                        Ok(VendorRequest::GetFeatures {
6739                            responder: VendorGetFeaturesResponder {
6740                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6741                                tx_id: header.tx_id,
6742                            },
6743                        })
6744                    }
6745                    0x75430542c197cbe8 => {
6746                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6747                        let mut req = fidl::new_empty!(
6748                            VendorCommand,
6749                            fidl::encoding::DefaultFuchsiaResourceDialect
6750                        );
6751                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VendorCommand>(&header, _body_bytes, handles, &mut req)?;
6752                        let control_handle = VendorControlHandle { inner: this.inner.clone() };
6753                        Ok(VendorRequest::EncodeCommand {
6754                            payload: req,
6755                            responder: VendorEncodeCommandResponder {
6756                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6757                                tx_id: header.tx_id,
6758                            },
6759                        })
6760                    }
6761                    0x7f05862f7ef92ec8 => {
6762                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6763                        let mut req = fidl::new_empty!(
6764                            fidl::encoding::EmptyPayload,
6765                            fidl::encoding::DefaultFuchsiaResourceDialect
6766                        );
6767                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6768                        let control_handle = VendorControlHandle { inner: this.inner.clone() };
6769                        Ok(VendorRequest::OpenHci {
6770                            responder: VendorOpenHciResponder {
6771                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6772                                tx_id: header.tx_id,
6773                            },
6774                        })
6775                    }
6776                    0x1f785b656fb00834 => {
6777                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6778                        let mut req = fidl::new_empty!(
6779                            fidl::encoding::EmptyPayload,
6780                            fidl::encoding::DefaultFuchsiaResourceDialect
6781                        );
6782                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6783                        let control_handle = VendorControlHandle { inner: this.inner.clone() };
6784                        Ok(VendorRequest::OpenHciTransport {
6785                            responder: VendorOpenHciTransportResponder {
6786                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6787                                tx_id: header.tx_id,
6788                            },
6789                        })
6790                    }
6791                    0xafeca0e3c789043 => {
6792                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6793                        let mut req = fidl::new_empty!(
6794                            fidl::encoding::EmptyPayload,
6795                            fidl::encoding::DefaultFuchsiaResourceDialect
6796                        );
6797                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6798                        let control_handle = VendorControlHandle { inner: this.inner.clone() };
6799                        Ok(VendorRequest::OpenSnoop {
6800                            responder: VendorOpenSnoopResponder {
6801                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6802                                tx_id: header.tx_id,
6803                            },
6804                        })
6805                    }
6806                    0xb16601642b3a567 => {
6807                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6808                        let mut req = fidl::new_empty!(
6809                            fidl::encoding::EmptyPayload,
6810                            fidl::encoding::DefaultFuchsiaResourceDialect
6811                        );
6812                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6813                        let control_handle = VendorControlHandle { inner: this.inner.clone() };
6814                        Ok(VendorRequest::GetCrashParameters {
6815                            responder: VendorGetCrashParametersResponder {
6816                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6817                                tx_id: header.tx_id,
6818                            },
6819                        })
6820                    }
6821                    _ if header.tx_id == 0
6822                        && header
6823                            .dynamic_flags()
6824                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6825                    {
6826                        Ok(VendorRequest::_UnknownMethod {
6827                            ordinal: header.ordinal,
6828                            control_handle: VendorControlHandle { inner: this.inner.clone() },
6829                            method_type: fidl::MethodType::OneWay,
6830                        })
6831                    }
6832                    _ if header
6833                        .dynamic_flags()
6834                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6835                    {
6836                        this.inner.send_framework_err(
6837                            fidl::encoding::FrameworkErr::UnknownMethod,
6838                            header.tx_id,
6839                            header.ordinal,
6840                            header.dynamic_flags(),
6841                            (bytes, handles),
6842                        )?;
6843                        Ok(VendorRequest::_UnknownMethod {
6844                            ordinal: header.ordinal,
6845                            control_handle: VendorControlHandle { inner: this.inner.clone() },
6846                            method_type: fidl::MethodType::TwoWay,
6847                        })
6848                    }
6849                    _ => Err(fidl::Error::UnknownOrdinal {
6850                        ordinal: header.ordinal,
6851                        protocol_name:
6852                            <VendorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6853                    }),
6854                }))
6855            },
6856        )
6857    }
6858}
6859
6860/// The BtVendor protocol may be implemented by vendor drivers to support feature interrogation
6861/// and vendor command encoding.
6862#[derive(Debug)]
6863pub enum VendorRequest {
6864    /// Returns the Vendor Features supported by this controller.
6865    GetFeatures { responder: VendorGetFeaturesResponder },
6866    /// Encode the vendor HCI command and return the encoded command.
6867    /// See `VendorCommand` for possible commands and parameters.
6868    /// * error `ZX_ERR_NOT_SUPPORTED` The command is not supported.
6869    /// * error `ZX_ERR_INVALID_ARGS` The parameters of the command are invalid.
6870    EncodeCommand { payload: VendorCommand, responder: VendorEncodeCommandResponder },
6871    /// Deprecated.
6872    /// Open the HCI protocol to the controller.  This call may block until the
6873    /// controller has been initialized.
6874    /// Returns ALREADY_BOUND if another client has already connected.
6875    OpenHci { responder: VendorOpenHciResponder },
6876    /// Open the HciTransport protocol to the controller. This call may block until the
6877    /// controller has been initialized.
6878    /// Returns ALREADY_BOUND if another client has already connected.
6879    OpenHciTransport { responder: VendorOpenHciTransportResponder },
6880    /// Open the Snoop protocol to the transport driver.
6881    /// Returns ALREADY_BOUND if another client has already connected.
6882    OpenSnoop { responder: VendorOpenSnoopResponder },
6883    /// Returns parameters used by bt-snoop to record and file Bluetooth controller crash reports.
6884    /// Core dump events will be redacted from snoop logs.
6885    /// Returns NOT_SUPPORTED if crash dumps are not supported by this vendor.
6886    GetCrashParameters { responder: VendorGetCrashParametersResponder },
6887    /// An interaction was received which does not match any known method.
6888    #[non_exhaustive]
6889    _UnknownMethod {
6890        /// Ordinal of the method that was called.
6891        ordinal: u64,
6892        control_handle: VendorControlHandle,
6893        method_type: fidl::MethodType,
6894    },
6895}
6896
6897impl VendorRequest {
6898    #[allow(irrefutable_let_patterns)]
6899    pub fn into_get_features(self) -> Option<(VendorGetFeaturesResponder)> {
6900        if let VendorRequest::GetFeatures { responder } = self { Some((responder)) } else { None }
6901    }
6902
6903    #[allow(irrefutable_let_patterns)]
6904    pub fn into_encode_command(self) -> Option<(VendorCommand, VendorEncodeCommandResponder)> {
6905        if let VendorRequest::EncodeCommand { payload, responder } = self {
6906            Some((payload, responder))
6907        } else {
6908            None
6909        }
6910    }
6911
6912    #[allow(irrefutable_let_patterns)]
6913    pub fn into_open_hci(self) -> Option<(VendorOpenHciResponder)> {
6914        if let VendorRequest::OpenHci { responder } = self { Some((responder)) } else { None }
6915    }
6916
6917    #[allow(irrefutable_let_patterns)]
6918    pub fn into_open_hci_transport(self) -> Option<(VendorOpenHciTransportResponder)> {
6919        if let VendorRequest::OpenHciTransport { responder } = self {
6920            Some((responder))
6921        } else {
6922            None
6923        }
6924    }
6925
6926    #[allow(irrefutable_let_patterns)]
6927    pub fn into_open_snoop(self) -> Option<(VendorOpenSnoopResponder)> {
6928        if let VendorRequest::OpenSnoop { responder } = self { Some((responder)) } else { None }
6929    }
6930
6931    #[allow(irrefutable_let_patterns)]
6932    pub fn into_get_crash_parameters(self) -> Option<(VendorGetCrashParametersResponder)> {
6933        if let VendorRequest::GetCrashParameters { responder } = self {
6934            Some((responder))
6935        } else {
6936            None
6937        }
6938    }
6939
6940    /// Name of the method defined in FIDL
6941    pub fn method_name(&self) -> &'static str {
6942        match *self {
6943            VendorRequest::GetFeatures { .. } => "get_features",
6944            VendorRequest::EncodeCommand { .. } => "encode_command",
6945            VendorRequest::OpenHci { .. } => "open_hci",
6946            VendorRequest::OpenHciTransport { .. } => "open_hci_transport",
6947            VendorRequest::OpenSnoop { .. } => "open_snoop",
6948            VendorRequest::GetCrashParameters { .. } => "get_crash_parameters",
6949            VendorRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
6950                "unknown one-way method"
6951            }
6952            VendorRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
6953                "unknown two-way method"
6954            }
6955        }
6956    }
6957}
6958
6959#[derive(Debug, Clone)]
6960pub struct VendorControlHandle {
6961    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6962}
6963
6964impl VendorControlHandle {
6965    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
6966        self.inner.shutdown_with_epitaph(status.into())
6967    }
6968}
6969
6970impl fidl::endpoints::ControlHandle for VendorControlHandle {
6971    fn shutdown(&self) {
6972        self.inner.shutdown()
6973    }
6974
6975    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
6976        self.inner.shutdown_with_epitaph(status)
6977    }
6978
6979    fn is_closed(&self) -> bool {
6980        self.inner.channel().is_closed()
6981    }
6982    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6983        self.inner.channel().on_closed()
6984    }
6985
6986    #[cfg(target_os = "fuchsia")]
6987    fn signal_peer(
6988        &self,
6989        clear_mask: zx::Signals,
6990        set_mask: zx::Signals,
6991    ) -> Result<(), zx_status::Status> {
6992        use fidl::Peered;
6993        self.inner.channel().signal_peer(clear_mask, set_mask)
6994    }
6995}
6996
6997impl VendorControlHandle {}
6998
6999#[must_use = "FIDL methods require a response to be sent"]
7000#[derive(Debug)]
7001pub struct VendorGetFeaturesResponder {
7002    control_handle: std::mem::ManuallyDrop<VendorControlHandle>,
7003    tx_id: u32,
7004}
7005
7006/// Set the the channel to be shutdown (see [`VendorControlHandle::shutdown`])
7007/// if the responder is dropped without sending a response, so that the client
7008/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7009impl std::ops::Drop for VendorGetFeaturesResponder {
7010    fn drop(&mut self) {
7011        self.control_handle.shutdown();
7012        // Safety: drops once, never accessed again
7013        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7014    }
7015}
7016
7017impl fidl::endpoints::Responder for VendorGetFeaturesResponder {
7018    type ControlHandle = VendorControlHandle;
7019
7020    fn control_handle(&self) -> &VendorControlHandle {
7021        &self.control_handle
7022    }
7023
7024    fn drop_without_shutdown(mut self) {
7025        // Safety: drops once, never accessed again due to mem::forget
7026        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7027        // Prevent Drop from running (which would shut down the channel)
7028        std::mem::forget(self);
7029    }
7030}
7031
7032impl VendorGetFeaturesResponder {
7033    /// Sends a response to the FIDL transaction.
7034    ///
7035    /// Sets the channel to shutdown if an error occurs.
7036    pub fn send(self, mut payload: &VendorFeatures) -> Result<(), fidl::Error> {
7037        let _result = self.send_raw(payload);
7038        if _result.is_err() {
7039            self.control_handle.shutdown();
7040        }
7041        self.drop_without_shutdown();
7042        _result
7043    }
7044
7045    /// Similar to "send" but does not shutdown the channel if an error occurs.
7046    pub fn send_no_shutdown_on_err(self, mut payload: &VendorFeatures) -> Result<(), fidl::Error> {
7047        let _result = self.send_raw(payload);
7048        self.drop_without_shutdown();
7049        _result
7050    }
7051
7052    fn send_raw(&self, mut payload: &VendorFeatures) -> Result<(), fidl::Error> {
7053        self.control_handle.inner.send::<fidl::encoding::FlexibleType<VendorFeatures>>(
7054            fidl::encoding::Flexible::new(payload),
7055            self.tx_id,
7056            0x102e70164c1dc911,
7057            fidl::encoding::DynamicFlags::FLEXIBLE,
7058        )
7059    }
7060}
7061
7062#[must_use = "FIDL methods require a response to be sent"]
7063#[derive(Debug)]
7064pub struct VendorEncodeCommandResponder {
7065    control_handle: std::mem::ManuallyDrop<VendorControlHandle>,
7066    tx_id: u32,
7067}
7068
7069/// Set the the channel to be shutdown (see [`VendorControlHandle::shutdown`])
7070/// if the responder is dropped without sending a response, so that the client
7071/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7072impl std::ops::Drop for VendorEncodeCommandResponder {
7073    fn drop(&mut self) {
7074        self.control_handle.shutdown();
7075        // Safety: drops once, never accessed again
7076        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7077    }
7078}
7079
7080impl fidl::endpoints::Responder for VendorEncodeCommandResponder {
7081    type ControlHandle = VendorControlHandle;
7082
7083    fn control_handle(&self) -> &VendorControlHandle {
7084        &self.control_handle
7085    }
7086
7087    fn drop_without_shutdown(mut self) {
7088        // Safety: drops once, never accessed again due to mem::forget
7089        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7090        // Prevent Drop from running (which would shut down the channel)
7091        std::mem::forget(self);
7092    }
7093}
7094
7095impl VendorEncodeCommandResponder {
7096    /// Sends a response to the FIDL transaction.
7097    ///
7098    /// Sets the channel to shutdown if an error occurs.
7099    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
7100        let _result = self.send_raw(result);
7101        if _result.is_err() {
7102            self.control_handle.shutdown();
7103        }
7104        self.drop_without_shutdown();
7105        _result
7106    }
7107
7108    /// Similar to "send" but does not shutdown the channel if an error occurs.
7109    pub fn send_no_shutdown_on_err(
7110        self,
7111        mut result: Result<&[u8], i32>,
7112    ) -> Result<(), fidl::Error> {
7113        let _result = self.send_raw(result);
7114        self.drop_without_shutdown();
7115        _result
7116    }
7117
7118    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
7119        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7120            VendorEncodeCommandResponse,
7121            i32,
7122        >>(
7123            fidl::encoding::FlexibleResult::new(result.map(|encoded| (encoded,))),
7124            self.tx_id,
7125            0x75430542c197cbe8,
7126            fidl::encoding::DynamicFlags::FLEXIBLE,
7127        )
7128    }
7129}
7130
7131#[must_use = "FIDL methods require a response to be sent"]
7132#[derive(Debug)]
7133pub struct VendorOpenHciResponder {
7134    control_handle: std::mem::ManuallyDrop<VendorControlHandle>,
7135    tx_id: u32,
7136}
7137
7138/// Set the the channel to be shutdown (see [`VendorControlHandle::shutdown`])
7139/// if the responder is dropped without sending a response, so that the client
7140/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7141impl std::ops::Drop for VendorOpenHciResponder {
7142    fn drop(&mut self) {
7143        self.control_handle.shutdown();
7144        // Safety: drops once, never accessed again
7145        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7146    }
7147}
7148
7149impl fidl::endpoints::Responder for VendorOpenHciResponder {
7150    type ControlHandle = VendorControlHandle;
7151
7152    fn control_handle(&self) -> &VendorControlHandle {
7153        &self.control_handle
7154    }
7155
7156    fn drop_without_shutdown(mut self) {
7157        // Safety: drops once, never accessed again due to mem::forget
7158        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7159        // Prevent Drop from running (which would shut down the channel)
7160        std::mem::forget(self);
7161    }
7162}
7163
7164impl VendorOpenHciResponder {
7165    /// Sends a response to the FIDL transaction.
7166    ///
7167    /// Sets the channel to shutdown if an error occurs.
7168    pub fn send(
7169        self,
7170        mut result: Result<fidl::endpoints::ClientEnd<HciMarker>, i32>,
7171    ) -> Result<(), fidl::Error> {
7172        let _result = self.send_raw(result);
7173        if _result.is_err() {
7174            self.control_handle.shutdown();
7175        }
7176        self.drop_without_shutdown();
7177        _result
7178    }
7179
7180    /// Similar to "send" but does not shutdown the channel if an error occurs.
7181    pub fn send_no_shutdown_on_err(
7182        self,
7183        mut result: Result<fidl::endpoints::ClientEnd<HciMarker>, i32>,
7184    ) -> Result<(), fidl::Error> {
7185        let _result = self.send_raw(result);
7186        self.drop_without_shutdown();
7187        _result
7188    }
7189
7190    fn send_raw(
7191        &self,
7192        mut result: Result<fidl::endpoints::ClientEnd<HciMarker>, i32>,
7193    ) -> Result<(), fidl::Error> {
7194        self.control_handle
7195            .inner
7196            .send::<fidl::encoding::FlexibleResultType<VendorOpenHciResponse, i32>>(
7197                fidl::encoding::FlexibleResult::new(result.map(|channel| (channel,))),
7198                self.tx_id,
7199                0x7f05862f7ef92ec8,
7200                fidl::encoding::DynamicFlags::FLEXIBLE,
7201            )
7202    }
7203}
7204
7205#[must_use = "FIDL methods require a response to be sent"]
7206#[derive(Debug)]
7207pub struct VendorOpenHciTransportResponder {
7208    control_handle: std::mem::ManuallyDrop<VendorControlHandle>,
7209    tx_id: u32,
7210}
7211
7212/// Set the the channel to be shutdown (see [`VendorControlHandle::shutdown`])
7213/// if the responder is dropped without sending a response, so that the client
7214/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7215impl std::ops::Drop for VendorOpenHciTransportResponder {
7216    fn drop(&mut self) {
7217        self.control_handle.shutdown();
7218        // Safety: drops once, never accessed again
7219        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7220    }
7221}
7222
7223impl fidl::endpoints::Responder for VendorOpenHciTransportResponder {
7224    type ControlHandle = VendorControlHandle;
7225
7226    fn control_handle(&self) -> &VendorControlHandle {
7227        &self.control_handle
7228    }
7229
7230    fn drop_without_shutdown(mut self) {
7231        // Safety: drops once, never accessed again due to mem::forget
7232        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7233        // Prevent Drop from running (which would shut down the channel)
7234        std::mem::forget(self);
7235    }
7236}
7237
7238impl VendorOpenHciTransportResponder {
7239    /// Sends a response to the FIDL transaction.
7240    ///
7241    /// Sets the channel to shutdown if an error occurs.
7242    pub fn send(
7243        self,
7244        mut result: Result<fidl::endpoints::ClientEnd<HciTransportMarker>, i32>,
7245    ) -> Result<(), fidl::Error> {
7246        let _result = self.send_raw(result);
7247        if _result.is_err() {
7248            self.control_handle.shutdown();
7249        }
7250        self.drop_without_shutdown();
7251        _result
7252    }
7253
7254    /// Similar to "send" but does not shutdown the channel if an error occurs.
7255    pub fn send_no_shutdown_on_err(
7256        self,
7257        mut result: Result<fidl::endpoints::ClientEnd<HciTransportMarker>, i32>,
7258    ) -> Result<(), fidl::Error> {
7259        let _result = self.send_raw(result);
7260        self.drop_without_shutdown();
7261        _result
7262    }
7263
7264    fn send_raw(
7265        &self,
7266        mut result: Result<fidl::endpoints::ClientEnd<HciTransportMarker>, i32>,
7267    ) -> Result<(), fidl::Error> {
7268        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7269            VendorOpenHciTransportResponse,
7270            i32,
7271        >>(
7272            fidl::encoding::FlexibleResult::new(result.map(|channel| (channel,))),
7273            self.tx_id,
7274            0x1f785b656fb00834,
7275            fidl::encoding::DynamicFlags::FLEXIBLE,
7276        )
7277    }
7278}
7279
7280#[must_use = "FIDL methods require a response to be sent"]
7281#[derive(Debug)]
7282pub struct VendorOpenSnoopResponder {
7283    control_handle: std::mem::ManuallyDrop<VendorControlHandle>,
7284    tx_id: u32,
7285}
7286
7287/// Set the the channel to be shutdown (see [`VendorControlHandle::shutdown`])
7288/// if the responder is dropped without sending a response, so that the client
7289/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7290impl std::ops::Drop for VendorOpenSnoopResponder {
7291    fn drop(&mut self) {
7292        self.control_handle.shutdown();
7293        // Safety: drops once, never accessed again
7294        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7295    }
7296}
7297
7298impl fidl::endpoints::Responder for VendorOpenSnoopResponder {
7299    type ControlHandle = VendorControlHandle;
7300
7301    fn control_handle(&self) -> &VendorControlHandle {
7302        &self.control_handle
7303    }
7304
7305    fn drop_without_shutdown(mut self) {
7306        // Safety: drops once, never accessed again due to mem::forget
7307        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7308        // Prevent Drop from running (which would shut down the channel)
7309        std::mem::forget(self);
7310    }
7311}
7312
7313impl VendorOpenSnoopResponder {
7314    /// Sends a response to the FIDL transaction.
7315    ///
7316    /// Sets the channel to shutdown if an error occurs.
7317    pub fn send(
7318        self,
7319        mut result: Result<fidl::endpoints::ClientEnd<SnoopMarker>, i32>,
7320    ) -> Result<(), fidl::Error> {
7321        let _result = self.send_raw(result);
7322        if _result.is_err() {
7323            self.control_handle.shutdown();
7324        }
7325        self.drop_without_shutdown();
7326        _result
7327    }
7328
7329    /// Similar to "send" but does not shutdown the channel if an error occurs.
7330    pub fn send_no_shutdown_on_err(
7331        self,
7332        mut result: Result<fidl::endpoints::ClientEnd<SnoopMarker>, i32>,
7333    ) -> Result<(), fidl::Error> {
7334        let _result = self.send_raw(result);
7335        self.drop_without_shutdown();
7336        _result
7337    }
7338
7339    fn send_raw(
7340        &self,
7341        mut result: Result<fidl::endpoints::ClientEnd<SnoopMarker>, i32>,
7342    ) -> Result<(), fidl::Error> {
7343        self.control_handle
7344            .inner
7345            .send::<fidl::encoding::FlexibleResultType<VendorOpenSnoopResponse, i32>>(
7346                fidl::encoding::FlexibleResult::new(result.map(|channel| (channel,))),
7347                self.tx_id,
7348                0xafeca0e3c789043,
7349                fidl::encoding::DynamicFlags::FLEXIBLE,
7350            )
7351    }
7352}
7353
7354#[must_use = "FIDL methods require a response to be sent"]
7355#[derive(Debug)]
7356pub struct VendorGetCrashParametersResponder {
7357    control_handle: std::mem::ManuallyDrop<VendorControlHandle>,
7358    tx_id: u32,
7359}
7360
7361/// Set the the channel to be shutdown (see [`VendorControlHandle::shutdown`])
7362/// if the responder is dropped without sending a response, so that the client
7363/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7364impl std::ops::Drop for VendorGetCrashParametersResponder {
7365    fn drop(&mut self) {
7366        self.control_handle.shutdown();
7367        // Safety: drops once, never accessed again
7368        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7369    }
7370}
7371
7372impl fidl::endpoints::Responder for VendorGetCrashParametersResponder {
7373    type ControlHandle = VendorControlHandle;
7374
7375    fn control_handle(&self) -> &VendorControlHandle {
7376        &self.control_handle
7377    }
7378
7379    fn drop_without_shutdown(mut self) {
7380        // Safety: drops once, never accessed again due to mem::forget
7381        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7382        // Prevent Drop from running (which would shut down the channel)
7383        std::mem::forget(self);
7384    }
7385}
7386
7387impl VendorGetCrashParametersResponder {
7388    /// Sends a response to the FIDL transaction.
7389    ///
7390    /// Sets the channel to shutdown if an error occurs.
7391    pub fn send(self, mut result: Result<&VendorCrashParameters, i32>) -> Result<(), fidl::Error> {
7392        let _result = self.send_raw(result);
7393        if _result.is_err() {
7394            self.control_handle.shutdown();
7395        }
7396        self.drop_without_shutdown();
7397        _result
7398    }
7399
7400    /// Similar to "send" but does not shutdown the channel if an error occurs.
7401    pub fn send_no_shutdown_on_err(
7402        self,
7403        mut result: Result<&VendorCrashParameters, i32>,
7404    ) -> Result<(), fidl::Error> {
7405        let _result = self.send_raw(result);
7406        self.drop_without_shutdown();
7407        _result
7408    }
7409
7410    fn send_raw(&self, mut result: Result<&VendorCrashParameters, i32>) -> Result<(), fidl::Error> {
7411        self.control_handle
7412            .inner
7413            .send::<fidl::encoding::FlexibleResultType<VendorCrashParameters, i32>>(
7414                fidl::encoding::FlexibleResult::new(result),
7415                self.tx_id,
7416                0xb16601642b3a567,
7417                fidl::encoding::DynamicFlags::FLEXIBLE,
7418            )
7419    }
7420}
7421
7422#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7423pub struct VirtualControllerMarker;
7424
7425impl fidl::endpoints::ProtocolMarker for VirtualControllerMarker {
7426    type Proxy = VirtualControllerProxy;
7427    type RequestStream = VirtualControllerRequestStream;
7428    #[cfg(target_os = "fuchsia")]
7429    type SynchronousProxy = VirtualControllerSynchronousProxy;
7430
7431    const DEBUG_NAME: &'static str = "(anonymous) VirtualController";
7432}
7433pub type VirtualControllerCreateEmulatorResult = Result<Option<String>, i32>;
7434
7435pub trait VirtualControllerProxyInterface: Send + Sync {
7436    type CreateEmulatorResponseFut: std::future::Future<Output = Result<VirtualControllerCreateEmulatorResult, fidl::Error>>
7437        + Send;
7438    fn r#create_emulator(&self) -> Self::CreateEmulatorResponseFut;
7439    fn r#create_loopback_device(
7440        &self,
7441        payload: VirtualControllerCreateLoopbackDeviceRequest,
7442    ) -> Result<(), fidl::Error>;
7443}
7444#[derive(Debug)]
7445#[cfg(target_os = "fuchsia")]
7446pub struct VirtualControllerSynchronousProxy {
7447    client: fidl::client::sync::Client,
7448}
7449
7450#[cfg(target_os = "fuchsia")]
7451impl fidl::endpoints::SynchronousProxy for VirtualControllerSynchronousProxy {
7452    type Proxy = VirtualControllerProxy;
7453    type Protocol = VirtualControllerMarker;
7454
7455    fn from_channel(inner: fidl::Channel) -> Self {
7456        Self::new(inner)
7457    }
7458
7459    fn into_channel(self) -> fidl::Channel {
7460        self.client.into_channel()
7461    }
7462
7463    fn as_channel(&self) -> &fidl::Channel {
7464        self.client.as_channel()
7465    }
7466}
7467
7468#[cfg(target_os = "fuchsia")]
7469impl VirtualControllerSynchronousProxy {
7470    pub fn new(channel: fidl::Channel) -> Self {
7471        Self { client: fidl::client::sync::Client::new(channel) }
7472    }
7473
7474    pub fn into_channel(self) -> fidl::Channel {
7475        self.client.into_channel()
7476    }
7477
7478    /// Waits until an event arrives and returns it. It is safe for other
7479    /// threads to make concurrent requests while waiting for an event.
7480    pub fn wait_for_event(
7481        &self,
7482        deadline: zx::MonotonicInstant,
7483    ) -> Result<VirtualControllerEvent, fidl::Error> {
7484        VirtualControllerEvent::decode(
7485            self.client.wait_for_event::<VirtualControllerMarker>(deadline)?,
7486        )
7487    }
7488
7489    /// Creates a child device, and returns the name of the child created.
7490    pub fn r#create_emulator(
7491        &self,
7492        ___deadline: zx::MonotonicInstant,
7493    ) -> Result<VirtualControllerCreateEmulatorResult, fidl::Error> {
7494        let _response = self.client.send_query::<
7495            fidl::encoding::EmptyPayload,
7496            fidl::encoding::FlexibleResultType<VirtualControllerCreateEmulatorResponse, i32>,
7497            VirtualControllerMarker,
7498        >(
7499            (),
7500            0x130273fc0a35cedb,
7501            fidl::encoding::DynamicFlags::FLEXIBLE,
7502            ___deadline,
7503        )?
7504        .into_result::<VirtualControllerMarker>("create_emulator")?;
7505        Ok(_response.map(|x| x.name))
7506    }
7507
7508    /// Creates a virtual Bluetooth serial device, speaking the BT HCI UART
7509    /// protocol on the provided handle.
7510    /// The zircon channel is closed in the event of an error.
7511    pub fn r#create_loopback_device(
7512        &self,
7513        mut payload: VirtualControllerCreateLoopbackDeviceRequest,
7514    ) -> Result<(), fidl::Error> {
7515        self.client.send::<VirtualControllerCreateLoopbackDeviceRequest>(
7516            &mut payload,
7517            0x7525af8edecb6c0c,
7518            fidl::encoding::DynamicFlags::FLEXIBLE,
7519        )
7520    }
7521}
7522
7523#[cfg(target_os = "fuchsia")]
7524impl From<VirtualControllerSynchronousProxy> for zx::NullableHandle {
7525    fn from(value: VirtualControllerSynchronousProxy) -> Self {
7526        value.into_channel().into()
7527    }
7528}
7529
7530#[cfg(target_os = "fuchsia")]
7531impl From<fidl::Channel> for VirtualControllerSynchronousProxy {
7532    fn from(value: fidl::Channel) -> Self {
7533        Self::new(value)
7534    }
7535}
7536
7537#[cfg(target_os = "fuchsia")]
7538impl fidl::endpoints::FromClient for VirtualControllerSynchronousProxy {
7539    type Protocol = VirtualControllerMarker;
7540
7541    fn from_client(value: fidl::endpoints::ClientEnd<VirtualControllerMarker>) -> Self {
7542        Self::new(value.into_channel())
7543    }
7544}
7545
7546#[derive(Debug, Clone)]
7547pub struct VirtualControllerProxy {
7548    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7549}
7550
7551impl fidl::endpoints::Proxy for VirtualControllerProxy {
7552    type Protocol = VirtualControllerMarker;
7553
7554    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7555        Self::new(inner)
7556    }
7557
7558    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7559        self.client.into_channel().map_err(|client| Self { client })
7560    }
7561
7562    fn as_channel(&self) -> &::fidl::AsyncChannel {
7563        self.client.as_channel()
7564    }
7565}
7566
7567impl VirtualControllerProxy {
7568    /// Create a new Proxy for fuchsia.hardware.bluetooth/VirtualController.
7569    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7570        let protocol_name =
7571            <VirtualControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7572        Self { client: fidl::client::Client::new(channel, protocol_name) }
7573    }
7574
7575    /// Get a Stream of events from the remote end of the protocol.
7576    ///
7577    /// # Panics
7578    ///
7579    /// Panics if the event stream was already taken.
7580    pub fn take_event_stream(&self) -> VirtualControllerEventStream {
7581        VirtualControllerEventStream { event_receiver: self.client.take_event_receiver() }
7582    }
7583
7584    /// Creates a child device, and returns the name of the child created.
7585    pub fn r#create_emulator(
7586        &self,
7587    ) -> fidl::client::QueryResponseFut<
7588        VirtualControllerCreateEmulatorResult,
7589        fidl::encoding::DefaultFuchsiaResourceDialect,
7590    > {
7591        VirtualControllerProxyInterface::r#create_emulator(self)
7592    }
7593
7594    /// Creates a virtual Bluetooth serial device, speaking the BT HCI UART
7595    /// protocol on the provided handle.
7596    /// The zircon channel is closed in the event of an error.
7597    pub fn r#create_loopback_device(
7598        &self,
7599        mut payload: VirtualControllerCreateLoopbackDeviceRequest,
7600    ) -> Result<(), fidl::Error> {
7601        VirtualControllerProxyInterface::r#create_loopback_device(self, payload)
7602    }
7603}
7604
7605impl VirtualControllerProxyInterface for VirtualControllerProxy {
7606    type CreateEmulatorResponseFut = fidl::client::QueryResponseFut<
7607        VirtualControllerCreateEmulatorResult,
7608        fidl::encoding::DefaultFuchsiaResourceDialect,
7609    >;
7610    fn r#create_emulator(&self) -> Self::CreateEmulatorResponseFut {
7611        fn _decode(
7612            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7613        ) -> Result<VirtualControllerCreateEmulatorResult, fidl::Error> {
7614            let _response = fidl::client::decode_transaction_body::<
7615                fidl::encoding::FlexibleResultType<VirtualControllerCreateEmulatorResponse, i32>,
7616                fidl::encoding::DefaultFuchsiaResourceDialect,
7617                0x130273fc0a35cedb,
7618            >(_buf?)?
7619            .into_result::<VirtualControllerMarker>("create_emulator")?;
7620            Ok(_response.map(|x| x.name))
7621        }
7622        self.client.send_query_and_decode::<
7623            fidl::encoding::EmptyPayload,
7624            VirtualControllerCreateEmulatorResult,
7625        >(
7626            (),
7627            0x130273fc0a35cedb,
7628            fidl::encoding::DynamicFlags::FLEXIBLE,
7629            _decode,
7630        )
7631    }
7632
7633    fn r#create_loopback_device(
7634        &self,
7635        mut payload: VirtualControllerCreateLoopbackDeviceRequest,
7636    ) -> Result<(), fidl::Error> {
7637        self.client.send::<VirtualControllerCreateLoopbackDeviceRequest>(
7638            &mut payload,
7639            0x7525af8edecb6c0c,
7640            fidl::encoding::DynamicFlags::FLEXIBLE,
7641        )
7642    }
7643}
7644
7645pub struct VirtualControllerEventStream {
7646    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7647}
7648
7649impl std::marker::Unpin for VirtualControllerEventStream {}
7650
7651impl futures::stream::FusedStream for VirtualControllerEventStream {
7652    fn is_terminated(&self) -> bool {
7653        self.event_receiver.is_terminated()
7654    }
7655}
7656
7657impl futures::Stream for VirtualControllerEventStream {
7658    type Item = Result<VirtualControllerEvent, fidl::Error>;
7659
7660    fn poll_next(
7661        mut self: std::pin::Pin<&mut Self>,
7662        cx: &mut std::task::Context<'_>,
7663    ) -> std::task::Poll<Option<Self::Item>> {
7664        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7665            &mut self.event_receiver,
7666            cx
7667        )?) {
7668            Some(buf) => std::task::Poll::Ready(Some(VirtualControllerEvent::decode(buf))),
7669            None => std::task::Poll::Ready(None),
7670        }
7671    }
7672}
7673
7674#[derive(Debug)]
7675pub enum VirtualControllerEvent {
7676    #[non_exhaustive]
7677    _UnknownEvent {
7678        /// Ordinal of the event that was sent.
7679        ordinal: u64,
7680    },
7681}
7682
7683impl VirtualControllerEvent {
7684    /// Decodes a message buffer as a [`VirtualControllerEvent`].
7685    fn decode(
7686        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7687    ) -> Result<VirtualControllerEvent, fidl::Error> {
7688        let (bytes, _handles) = buf.split_mut();
7689        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7690        debug_assert_eq!(tx_header.tx_id, 0);
7691        match tx_header.ordinal {
7692            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7693                Ok(VirtualControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
7694            }
7695            _ => Err(fidl::Error::UnknownOrdinal {
7696                ordinal: tx_header.ordinal,
7697                protocol_name:
7698                    <VirtualControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7699            }),
7700        }
7701    }
7702}
7703
7704/// A Stream of incoming requests for fuchsia.hardware.bluetooth/VirtualController.
7705pub struct VirtualControllerRequestStream {
7706    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7707    is_terminated: bool,
7708}
7709
7710impl std::marker::Unpin for VirtualControllerRequestStream {}
7711
7712impl futures::stream::FusedStream for VirtualControllerRequestStream {
7713    fn is_terminated(&self) -> bool {
7714        self.is_terminated
7715    }
7716}
7717
7718impl fidl::endpoints::RequestStream for VirtualControllerRequestStream {
7719    type Protocol = VirtualControllerMarker;
7720    type ControlHandle = VirtualControllerControlHandle;
7721
7722    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7723        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7724    }
7725
7726    fn control_handle(&self) -> Self::ControlHandle {
7727        VirtualControllerControlHandle { inner: self.inner.clone() }
7728    }
7729
7730    fn into_inner(
7731        self,
7732    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7733    {
7734        (self.inner, self.is_terminated)
7735    }
7736
7737    fn from_inner(
7738        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7739        is_terminated: bool,
7740    ) -> Self {
7741        Self { inner, is_terminated }
7742    }
7743}
7744
7745impl futures::Stream for VirtualControllerRequestStream {
7746    type Item = Result<VirtualControllerRequest, fidl::Error>;
7747
7748    fn poll_next(
7749        mut self: std::pin::Pin<&mut Self>,
7750        cx: &mut std::task::Context<'_>,
7751    ) -> std::task::Poll<Option<Self::Item>> {
7752        let this = &mut *self;
7753        if this.inner.check_shutdown(cx) {
7754            this.is_terminated = true;
7755            return std::task::Poll::Ready(None);
7756        }
7757        if this.is_terminated {
7758            panic!("polled VirtualControllerRequestStream after completion");
7759        }
7760        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7761            |bytes, handles| {
7762                match this.inner.channel().read_etc(cx, bytes, handles) {
7763                    std::task::Poll::Ready(Ok(())) => {}
7764                    std::task::Poll::Pending => return std::task::Poll::Pending,
7765                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7766                        this.is_terminated = true;
7767                        return std::task::Poll::Ready(None);
7768                    }
7769                    std::task::Poll::Ready(Err(e)) => {
7770                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7771                            e.into(),
7772                        ))));
7773                    }
7774                }
7775
7776                // A message has been received from the channel
7777                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7778
7779                std::task::Poll::Ready(Some(match header.ordinal {
7780                    0x130273fc0a35cedb => {
7781                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7782                        let mut req = fidl::new_empty!(
7783                            fidl::encoding::EmptyPayload,
7784                            fidl::encoding::DefaultFuchsiaResourceDialect
7785                        );
7786                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7787                        let control_handle =
7788                            VirtualControllerControlHandle { inner: this.inner.clone() };
7789                        Ok(VirtualControllerRequest::CreateEmulator {
7790                            responder: VirtualControllerCreateEmulatorResponder {
7791                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7792                                tx_id: header.tx_id,
7793                            },
7794                        })
7795                    }
7796                    0x7525af8edecb6c0c => {
7797                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7798                        let mut req = fidl::new_empty!(
7799                            VirtualControllerCreateLoopbackDeviceRequest,
7800                            fidl::encoding::DefaultFuchsiaResourceDialect
7801                        );
7802                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtualControllerCreateLoopbackDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
7803                        let control_handle =
7804                            VirtualControllerControlHandle { inner: this.inner.clone() };
7805                        Ok(VirtualControllerRequest::CreateLoopbackDevice {
7806                            payload: req,
7807                            control_handle,
7808                        })
7809                    }
7810                    _ if header.tx_id == 0
7811                        && header
7812                            .dynamic_flags()
7813                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
7814                    {
7815                        Ok(VirtualControllerRequest::_UnknownMethod {
7816                            ordinal: header.ordinal,
7817                            control_handle: VirtualControllerControlHandle {
7818                                inner: this.inner.clone(),
7819                            },
7820                            method_type: fidl::MethodType::OneWay,
7821                        })
7822                    }
7823                    _ if header
7824                        .dynamic_flags()
7825                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
7826                    {
7827                        this.inner.send_framework_err(
7828                            fidl::encoding::FrameworkErr::UnknownMethod,
7829                            header.tx_id,
7830                            header.ordinal,
7831                            header.dynamic_flags(),
7832                            (bytes, handles),
7833                        )?;
7834                        Ok(VirtualControllerRequest::_UnknownMethod {
7835                            ordinal: header.ordinal,
7836                            control_handle: VirtualControllerControlHandle {
7837                                inner: this.inner.clone(),
7838                            },
7839                            method_type: fidl::MethodType::TwoWay,
7840                        })
7841                    }
7842                    _ => Err(fidl::Error::UnknownOrdinal {
7843                        ordinal: header.ordinal,
7844                        protocol_name:
7845                            <VirtualControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7846                    }),
7847                }))
7848            },
7849        )
7850    }
7851}
7852
7853/// Used for spawning virtual Bluetooth devices.
7854#[derive(Debug)]
7855pub enum VirtualControllerRequest {
7856    /// Creates a child device, and returns the name of the child created.
7857    CreateEmulator { responder: VirtualControllerCreateEmulatorResponder },
7858    /// Creates a virtual Bluetooth serial device, speaking the BT HCI UART
7859    /// protocol on the provided handle.
7860    /// The zircon channel is closed in the event of an error.
7861    CreateLoopbackDevice {
7862        payload: VirtualControllerCreateLoopbackDeviceRequest,
7863        control_handle: VirtualControllerControlHandle,
7864    },
7865    /// An interaction was received which does not match any known method.
7866    #[non_exhaustive]
7867    _UnknownMethod {
7868        /// Ordinal of the method that was called.
7869        ordinal: u64,
7870        control_handle: VirtualControllerControlHandle,
7871        method_type: fidl::MethodType,
7872    },
7873}
7874
7875impl VirtualControllerRequest {
7876    #[allow(irrefutable_let_patterns)]
7877    pub fn into_create_emulator(self) -> Option<(VirtualControllerCreateEmulatorResponder)> {
7878        if let VirtualControllerRequest::CreateEmulator { responder } = self {
7879            Some((responder))
7880        } else {
7881            None
7882        }
7883    }
7884
7885    #[allow(irrefutable_let_patterns)]
7886    pub fn into_create_loopback_device(
7887        self,
7888    ) -> Option<(VirtualControllerCreateLoopbackDeviceRequest, VirtualControllerControlHandle)>
7889    {
7890        if let VirtualControllerRequest::CreateLoopbackDevice { payload, control_handle } = self {
7891            Some((payload, control_handle))
7892        } else {
7893            None
7894        }
7895    }
7896
7897    /// Name of the method defined in FIDL
7898    pub fn method_name(&self) -> &'static str {
7899        match *self {
7900            VirtualControllerRequest::CreateEmulator { .. } => "create_emulator",
7901            VirtualControllerRequest::CreateLoopbackDevice { .. } => "create_loopback_device",
7902            VirtualControllerRequest::_UnknownMethod {
7903                method_type: fidl::MethodType::OneWay,
7904                ..
7905            } => "unknown one-way method",
7906            VirtualControllerRequest::_UnknownMethod {
7907                method_type: fidl::MethodType::TwoWay,
7908                ..
7909            } => "unknown two-way method",
7910        }
7911    }
7912}
7913
7914#[derive(Debug, Clone)]
7915pub struct VirtualControllerControlHandle {
7916    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7917}
7918
7919impl VirtualControllerControlHandle {
7920    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
7921        self.inner.shutdown_with_epitaph(status.into())
7922    }
7923}
7924
7925impl fidl::endpoints::ControlHandle for VirtualControllerControlHandle {
7926    fn shutdown(&self) {
7927        self.inner.shutdown()
7928    }
7929
7930    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
7931        self.inner.shutdown_with_epitaph(status)
7932    }
7933
7934    fn is_closed(&self) -> bool {
7935        self.inner.channel().is_closed()
7936    }
7937    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7938        self.inner.channel().on_closed()
7939    }
7940
7941    #[cfg(target_os = "fuchsia")]
7942    fn signal_peer(
7943        &self,
7944        clear_mask: zx::Signals,
7945        set_mask: zx::Signals,
7946    ) -> Result<(), zx_status::Status> {
7947        use fidl::Peered;
7948        self.inner.channel().signal_peer(clear_mask, set_mask)
7949    }
7950}
7951
7952impl VirtualControllerControlHandle {}
7953
7954#[must_use = "FIDL methods require a response to be sent"]
7955#[derive(Debug)]
7956pub struct VirtualControllerCreateEmulatorResponder {
7957    control_handle: std::mem::ManuallyDrop<VirtualControllerControlHandle>,
7958    tx_id: u32,
7959}
7960
7961/// Set the the channel to be shutdown (see [`VirtualControllerControlHandle::shutdown`])
7962/// if the responder is dropped without sending a response, so that the client
7963/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7964impl std::ops::Drop for VirtualControllerCreateEmulatorResponder {
7965    fn drop(&mut self) {
7966        self.control_handle.shutdown();
7967        // Safety: drops once, never accessed again
7968        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7969    }
7970}
7971
7972impl fidl::endpoints::Responder for VirtualControllerCreateEmulatorResponder {
7973    type ControlHandle = VirtualControllerControlHandle;
7974
7975    fn control_handle(&self) -> &VirtualControllerControlHandle {
7976        &self.control_handle
7977    }
7978
7979    fn drop_without_shutdown(mut self) {
7980        // Safety: drops once, never accessed again due to mem::forget
7981        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7982        // Prevent Drop from running (which would shut down the channel)
7983        std::mem::forget(self);
7984    }
7985}
7986
7987impl VirtualControllerCreateEmulatorResponder {
7988    /// Sends a response to the FIDL transaction.
7989    ///
7990    /// Sets the channel to shutdown if an error occurs.
7991    pub fn send(self, mut result: Result<Option<&str>, i32>) -> Result<(), fidl::Error> {
7992        let _result = self.send_raw(result);
7993        if _result.is_err() {
7994            self.control_handle.shutdown();
7995        }
7996        self.drop_without_shutdown();
7997        _result
7998    }
7999
8000    /// Similar to "send" but does not shutdown the channel if an error occurs.
8001    pub fn send_no_shutdown_on_err(
8002        self,
8003        mut result: Result<Option<&str>, i32>,
8004    ) -> Result<(), fidl::Error> {
8005        let _result = self.send_raw(result);
8006        self.drop_without_shutdown();
8007        _result
8008    }
8009
8010    fn send_raw(&self, mut result: Result<Option<&str>, i32>) -> Result<(), fidl::Error> {
8011        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
8012            VirtualControllerCreateEmulatorResponse,
8013            i32,
8014        >>(
8015            fidl::encoding::FlexibleResult::new(result.map(|name| (name,))),
8016            self.tx_id,
8017            0x130273fc0a35cedb,
8018            fidl::encoding::DynamicFlags::FLEXIBLE,
8019        )
8020    }
8021}
8022
8023#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8024pub struct EmulatorServiceMarker;
8025
8026#[cfg(target_os = "fuchsia")]
8027impl fidl::endpoints::ServiceMarker for EmulatorServiceMarker {
8028    type Proxy = EmulatorServiceProxy;
8029    type Request = EmulatorServiceRequest;
8030    const SERVICE_NAME: &'static str = "fuchsia.hardware.bluetooth.EmulatorService";
8031}
8032
8033/// A request for one of the member protocols of EmulatorService.
8034///
8035#[cfg(target_os = "fuchsia")]
8036pub enum EmulatorServiceRequest {
8037    Device(EmulatorRequestStream),
8038}
8039
8040#[cfg(target_os = "fuchsia")]
8041impl fidl::endpoints::ServiceRequest for EmulatorServiceRequest {
8042    type Service = EmulatorServiceMarker;
8043
8044    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
8045        match name {
8046            "device" => Self::Device(
8047                <EmulatorRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
8048            ),
8049            _ => panic!("no such member protocol name for service EmulatorService"),
8050        }
8051    }
8052
8053    fn member_names() -> &'static [&'static str] {
8054        &["device"]
8055    }
8056}
8057#[cfg(target_os = "fuchsia")]
8058pub struct EmulatorServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
8059
8060#[cfg(target_os = "fuchsia")]
8061impl fidl::endpoints::ServiceProxy for EmulatorServiceProxy {
8062    type Service = EmulatorServiceMarker;
8063
8064    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
8065        Self(opener)
8066    }
8067}
8068
8069#[cfg(target_os = "fuchsia")]
8070impl EmulatorServiceProxy {
8071    pub fn connect_to_device(&self) -> Result<EmulatorProxy, fidl::Error> {
8072        let (proxy, server_end) = fidl::endpoints::create_proxy::<EmulatorMarker>();
8073        self.connect_channel_to_device(server_end)?;
8074        Ok(proxy)
8075    }
8076
8077    /// Like `connect_to_device`, but returns a sync proxy.
8078    /// See [`Self::connect_to_device`] for more details.
8079    pub fn connect_to_device_sync(&self) -> Result<EmulatorSynchronousProxy, fidl::Error> {
8080        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<EmulatorMarker>();
8081        self.connect_channel_to_device(server_end)?;
8082        Ok(proxy)
8083    }
8084
8085    /// Like `connect_to_device`, but accepts a server end.
8086    /// See [`Self::connect_to_device`] for more details.
8087    pub fn connect_channel_to_device(
8088        &self,
8089        server_end: fidl::endpoints::ServerEnd<EmulatorMarker>,
8090    ) -> Result<(), fidl::Error> {
8091        self.0.open_member("device", server_end.into_channel())
8092    }
8093
8094    pub fn instance_name(&self) -> &str {
8095        self.0.instance_name()
8096    }
8097}
8098
8099#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8100pub struct HciServiceMarker;
8101
8102#[cfg(target_os = "fuchsia")]
8103impl fidl::endpoints::ServiceMarker for HciServiceMarker {
8104    type Proxy = HciServiceProxy;
8105    type Request = HciServiceRequest;
8106    const SERVICE_NAME: &'static str = "fuchsia.hardware.bluetooth.HciService";
8107}
8108
8109/// A request for one of the member protocols of HciService.
8110///
8111/// Wrap the protocol in a service that will be exposed to the child driver.
8112#[cfg(target_os = "fuchsia")]
8113pub enum HciServiceRequest {
8114    Hci(HciRequestStream),
8115    HciTransport(HciTransportRequestStream),
8116    Snoop(SnoopRequestStream),
8117}
8118
8119#[cfg(target_os = "fuchsia")]
8120impl fidl::endpoints::ServiceRequest for HciServiceRequest {
8121    type Service = HciServiceMarker;
8122
8123    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
8124        match name {
8125            "hci" => Self::Hci(<HciRequestStream as fidl::endpoints::RequestStream>::from_channel(
8126                _channel,
8127            )),
8128            "hci_transport" => Self::HciTransport(
8129                <HciTransportRequestStream as fidl::endpoints::RequestStream>::from_channel(
8130                    _channel,
8131                ),
8132            ),
8133            "snoop" => Self::Snoop(
8134                <SnoopRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
8135            ),
8136            _ => panic!("no such member protocol name for service HciService"),
8137        }
8138    }
8139
8140    fn member_names() -> &'static [&'static str] {
8141        &["hci", "hci_transport", "snoop"]
8142    }
8143}
8144/// Wrap the protocol in a service that will be exposed to the child driver.
8145#[cfg(target_os = "fuchsia")]
8146pub struct HciServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
8147
8148#[cfg(target_os = "fuchsia")]
8149impl fidl::endpoints::ServiceProxy for HciServiceProxy {
8150    type Service = HciServiceMarker;
8151
8152    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
8153        Self(opener)
8154    }
8155}
8156
8157#[cfg(target_os = "fuchsia")]
8158impl HciServiceProxy {
8159    pub fn connect_to_hci(&self) -> Result<HciProxy, fidl::Error> {
8160        let (proxy, server_end) = fidl::endpoints::create_proxy::<HciMarker>();
8161        self.connect_channel_to_hci(server_end)?;
8162        Ok(proxy)
8163    }
8164
8165    /// Like `connect_to_hci`, but returns a sync proxy.
8166    /// See [`Self::connect_to_hci`] for more details.
8167    pub fn connect_to_hci_sync(&self) -> Result<HciSynchronousProxy, fidl::Error> {
8168        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<HciMarker>();
8169        self.connect_channel_to_hci(server_end)?;
8170        Ok(proxy)
8171    }
8172
8173    /// Like `connect_to_hci`, but accepts a server end.
8174    /// See [`Self::connect_to_hci`] for more details.
8175    pub fn connect_channel_to_hci(
8176        &self,
8177        server_end: fidl::endpoints::ServerEnd<HciMarker>,
8178    ) -> Result<(), fidl::Error> {
8179        self.0.open_member("hci", server_end.into_channel())
8180    }
8181    pub fn connect_to_hci_transport(&self) -> Result<HciTransportProxy, fidl::Error> {
8182        let (proxy, server_end) = fidl::endpoints::create_proxy::<HciTransportMarker>();
8183        self.connect_channel_to_hci_transport(server_end)?;
8184        Ok(proxy)
8185    }
8186
8187    /// Like `connect_to_hci_transport`, but returns a sync proxy.
8188    /// See [`Self::connect_to_hci_transport`] for more details.
8189    pub fn connect_to_hci_transport_sync(
8190        &self,
8191    ) -> Result<HciTransportSynchronousProxy, fidl::Error> {
8192        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<HciTransportMarker>();
8193        self.connect_channel_to_hci_transport(server_end)?;
8194        Ok(proxy)
8195    }
8196
8197    /// Like `connect_to_hci_transport`, but accepts a server end.
8198    /// See [`Self::connect_to_hci_transport`] for more details.
8199    pub fn connect_channel_to_hci_transport(
8200        &self,
8201        server_end: fidl::endpoints::ServerEnd<HciTransportMarker>,
8202    ) -> Result<(), fidl::Error> {
8203        self.0.open_member("hci_transport", server_end.into_channel())
8204    }
8205    pub fn connect_to_snoop(&self) -> Result<SnoopProxy, fidl::Error> {
8206        let (proxy, server_end) = fidl::endpoints::create_proxy::<SnoopMarker>();
8207        self.connect_channel_to_snoop(server_end)?;
8208        Ok(proxy)
8209    }
8210
8211    /// Like `connect_to_snoop`, but returns a sync proxy.
8212    /// See [`Self::connect_to_snoop`] for more details.
8213    pub fn connect_to_snoop_sync(&self) -> Result<SnoopSynchronousProxy, fidl::Error> {
8214        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<SnoopMarker>();
8215        self.connect_channel_to_snoop(server_end)?;
8216        Ok(proxy)
8217    }
8218
8219    /// Like `connect_to_snoop`, but accepts a server end.
8220    /// See [`Self::connect_to_snoop`] for more details.
8221    pub fn connect_channel_to_snoop(
8222        &self,
8223        server_end: fidl::endpoints::ServerEnd<SnoopMarker>,
8224    ) -> Result<(), fidl::Error> {
8225        self.0.open_member("snoop", server_end.into_channel())
8226    }
8227
8228    pub fn instance_name(&self) -> &str {
8229        self.0.instance_name()
8230    }
8231}
8232
8233#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8234pub struct ServiceMarker;
8235
8236#[cfg(target_os = "fuchsia")]
8237impl fidl::endpoints::ServiceMarker for ServiceMarker {
8238    type Proxy = ServiceProxy;
8239    type Request = ServiceRequest;
8240    const SERVICE_NAME: &'static str = "fuchsia.hardware.bluetooth.Service";
8241}
8242
8243/// A request for one of the member protocols of Service.
8244///
8245#[cfg(target_os = "fuchsia")]
8246pub enum ServiceRequest {
8247    Vendor(VendorRequestStream),
8248}
8249
8250#[cfg(target_os = "fuchsia")]
8251impl fidl::endpoints::ServiceRequest for ServiceRequest {
8252    type Service = ServiceMarker;
8253
8254    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
8255        match name {
8256            "vendor" => Self::Vendor(
8257                <VendorRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
8258            ),
8259            _ => panic!("no such member protocol name for service Service"),
8260        }
8261    }
8262
8263    fn member_names() -> &'static [&'static str] {
8264        &["vendor"]
8265    }
8266}
8267#[cfg(target_os = "fuchsia")]
8268pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
8269
8270#[cfg(target_os = "fuchsia")]
8271impl fidl::endpoints::ServiceProxy for ServiceProxy {
8272    type Service = ServiceMarker;
8273
8274    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
8275        Self(opener)
8276    }
8277}
8278
8279#[cfg(target_os = "fuchsia")]
8280impl ServiceProxy {
8281    pub fn connect_to_vendor(&self) -> Result<VendorProxy, fidl::Error> {
8282        let (proxy, server_end) = fidl::endpoints::create_proxy::<VendorMarker>();
8283        self.connect_channel_to_vendor(server_end)?;
8284        Ok(proxy)
8285    }
8286
8287    /// Like `connect_to_vendor`, but returns a sync proxy.
8288    /// See [`Self::connect_to_vendor`] for more details.
8289    pub fn connect_to_vendor_sync(&self) -> Result<VendorSynchronousProxy, fidl::Error> {
8290        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<VendorMarker>();
8291        self.connect_channel_to_vendor(server_end)?;
8292        Ok(proxy)
8293    }
8294
8295    /// Like `connect_to_vendor`, but accepts a server end.
8296    /// See [`Self::connect_to_vendor`] for more details.
8297    pub fn connect_channel_to_vendor(
8298        &self,
8299        server_end: fidl::endpoints::ServerEnd<VendorMarker>,
8300    ) -> Result<(), fidl::Error> {
8301        self.0.open_member("vendor", server_end.into_channel())
8302    }
8303
8304    pub fn instance_name(&self) -> &str {
8305        self.0.instance_name()
8306    }
8307}
8308
8309mod internal {
8310    use super::*;
8311
8312    impl fidl::encoding::ResourceTypeMarker for HciOpenAclDataChannelRequest {
8313        type Borrowed<'a> = &'a mut Self;
8314        fn take_or_borrow<'a>(
8315            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8316        ) -> Self::Borrowed<'a> {
8317            value
8318        }
8319    }
8320
8321    unsafe impl fidl::encoding::TypeMarker for HciOpenAclDataChannelRequest {
8322        type Owned = Self;
8323
8324        #[inline(always)]
8325        fn inline_align(_context: fidl::encoding::Context) -> usize {
8326            4
8327        }
8328
8329        #[inline(always)]
8330        fn inline_size(_context: fidl::encoding::Context) -> usize {
8331            4
8332        }
8333    }
8334
8335    unsafe impl
8336        fidl::encoding::Encode<
8337            HciOpenAclDataChannelRequest,
8338            fidl::encoding::DefaultFuchsiaResourceDialect,
8339        > for &mut HciOpenAclDataChannelRequest
8340    {
8341        #[inline]
8342        unsafe fn encode(
8343            self,
8344            encoder: &mut fidl::encoding::Encoder<
8345                '_,
8346                fidl::encoding::DefaultFuchsiaResourceDialect,
8347            >,
8348            offset: usize,
8349            _depth: fidl::encoding::Depth,
8350        ) -> fidl::Result<()> {
8351            encoder.debug_check_bounds::<HciOpenAclDataChannelRequest>(offset);
8352            // Delegate to tuple encoding.
8353            fidl::encoding::Encode::<
8354                HciOpenAclDataChannelRequest,
8355                fidl::encoding::DefaultFuchsiaResourceDialect,
8356            >::encode(
8357                (<fidl::encoding::HandleType<
8358                    fidl::Channel,
8359                    { fidl::ObjectType::CHANNEL.into_raw() },
8360                    2147483648,
8361                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8362                    &mut self.channel
8363                ),),
8364                encoder,
8365                offset,
8366                _depth,
8367            )
8368        }
8369    }
8370    unsafe impl<
8371        T0: fidl::encoding::Encode<
8372                fidl::encoding::HandleType<
8373                    fidl::Channel,
8374                    { fidl::ObjectType::CHANNEL.into_raw() },
8375                    2147483648,
8376                >,
8377                fidl::encoding::DefaultFuchsiaResourceDialect,
8378            >,
8379    >
8380        fidl::encoding::Encode<
8381            HciOpenAclDataChannelRequest,
8382            fidl::encoding::DefaultFuchsiaResourceDialect,
8383        > for (T0,)
8384    {
8385        #[inline]
8386        unsafe fn encode(
8387            self,
8388            encoder: &mut fidl::encoding::Encoder<
8389                '_,
8390                fidl::encoding::DefaultFuchsiaResourceDialect,
8391            >,
8392            offset: usize,
8393            depth: fidl::encoding::Depth,
8394        ) -> fidl::Result<()> {
8395            encoder.debug_check_bounds::<HciOpenAclDataChannelRequest>(offset);
8396            // Zero out padding regions. There's no need to apply masks
8397            // because the unmasked parts will be overwritten by fields.
8398            // Write the fields.
8399            self.0.encode(encoder, offset + 0, depth)?;
8400            Ok(())
8401        }
8402    }
8403
8404    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8405        for HciOpenAclDataChannelRequest
8406    {
8407        #[inline(always)]
8408        fn new_empty() -> Self {
8409            Self {
8410                channel: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8411            }
8412        }
8413
8414        #[inline]
8415        unsafe fn decode(
8416            &mut self,
8417            decoder: &mut fidl::encoding::Decoder<
8418                '_,
8419                fidl::encoding::DefaultFuchsiaResourceDialect,
8420            >,
8421            offset: usize,
8422            _depth: fidl::encoding::Depth,
8423        ) -> fidl::Result<()> {
8424            decoder.debug_check_bounds::<Self>(offset);
8425            // Verify that padding bytes are zero.
8426            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.channel, decoder, offset + 0, _depth)?;
8427            Ok(())
8428        }
8429    }
8430
8431    impl fidl::encoding::ResourceTypeMarker for HciOpenCommandChannelRequest {
8432        type Borrowed<'a> = &'a mut Self;
8433        fn take_or_borrow<'a>(
8434            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8435        ) -> Self::Borrowed<'a> {
8436            value
8437        }
8438    }
8439
8440    unsafe impl fidl::encoding::TypeMarker for HciOpenCommandChannelRequest {
8441        type Owned = Self;
8442
8443        #[inline(always)]
8444        fn inline_align(_context: fidl::encoding::Context) -> usize {
8445            4
8446        }
8447
8448        #[inline(always)]
8449        fn inline_size(_context: fidl::encoding::Context) -> usize {
8450            4
8451        }
8452    }
8453
8454    unsafe impl
8455        fidl::encoding::Encode<
8456            HciOpenCommandChannelRequest,
8457            fidl::encoding::DefaultFuchsiaResourceDialect,
8458        > for &mut HciOpenCommandChannelRequest
8459    {
8460        #[inline]
8461        unsafe fn encode(
8462            self,
8463            encoder: &mut fidl::encoding::Encoder<
8464                '_,
8465                fidl::encoding::DefaultFuchsiaResourceDialect,
8466            >,
8467            offset: usize,
8468            _depth: fidl::encoding::Depth,
8469        ) -> fidl::Result<()> {
8470            encoder.debug_check_bounds::<HciOpenCommandChannelRequest>(offset);
8471            // Delegate to tuple encoding.
8472            fidl::encoding::Encode::<
8473                HciOpenCommandChannelRequest,
8474                fidl::encoding::DefaultFuchsiaResourceDialect,
8475            >::encode(
8476                (<fidl::encoding::HandleType<
8477                    fidl::Channel,
8478                    { fidl::ObjectType::CHANNEL.into_raw() },
8479                    2147483648,
8480                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8481                    &mut self.channel
8482                ),),
8483                encoder,
8484                offset,
8485                _depth,
8486            )
8487        }
8488    }
8489    unsafe impl<
8490        T0: fidl::encoding::Encode<
8491                fidl::encoding::HandleType<
8492                    fidl::Channel,
8493                    { fidl::ObjectType::CHANNEL.into_raw() },
8494                    2147483648,
8495                >,
8496                fidl::encoding::DefaultFuchsiaResourceDialect,
8497            >,
8498    >
8499        fidl::encoding::Encode<
8500            HciOpenCommandChannelRequest,
8501            fidl::encoding::DefaultFuchsiaResourceDialect,
8502        > for (T0,)
8503    {
8504        #[inline]
8505        unsafe fn encode(
8506            self,
8507            encoder: &mut fidl::encoding::Encoder<
8508                '_,
8509                fidl::encoding::DefaultFuchsiaResourceDialect,
8510            >,
8511            offset: usize,
8512            depth: fidl::encoding::Depth,
8513        ) -> fidl::Result<()> {
8514            encoder.debug_check_bounds::<HciOpenCommandChannelRequest>(offset);
8515            // Zero out padding regions. There's no need to apply masks
8516            // because the unmasked parts will be overwritten by fields.
8517            // Write the fields.
8518            self.0.encode(encoder, offset + 0, depth)?;
8519            Ok(())
8520        }
8521    }
8522
8523    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8524        for HciOpenCommandChannelRequest
8525    {
8526        #[inline(always)]
8527        fn new_empty() -> Self {
8528            Self {
8529                channel: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8530            }
8531        }
8532
8533        #[inline]
8534        unsafe fn decode(
8535            &mut self,
8536            decoder: &mut fidl::encoding::Decoder<
8537                '_,
8538                fidl::encoding::DefaultFuchsiaResourceDialect,
8539            >,
8540            offset: usize,
8541            _depth: fidl::encoding::Depth,
8542        ) -> fidl::Result<()> {
8543            decoder.debug_check_bounds::<Self>(offset);
8544            // Verify that padding bytes are zero.
8545            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.channel, decoder, offset + 0, _depth)?;
8546            Ok(())
8547        }
8548    }
8549
8550    impl fidl::encoding::ResourceTypeMarker for HciOpenIsoDataChannelRequest {
8551        type Borrowed<'a> = &'a mut Self;
8552        fn take_or_borrow<'a>(
8553            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8554        ) -> Self::Borrowed<'a> {
8555            value
8556        }
8557    }
8558
8559    unsafe impl fidl::encoding::TypeMarker for HciOpenIsoDataChannelRequest {
8560        type Owned = Self;
8561
8562        #[inline(always)]
8563        fn inline_align(_context: fidl::encoding::Context) -> usize {
8564            4
8565        }
8566
8567        #[inline(always)]
8568        fn inline_size(_context: fidl::encoding::Context) -> usize {
8569            4
8570        }
8571    }
8572
8573    unsafe impl
8574        fidl::encoding::Encode<
8575            HciOpenIsoDataChannelRequest,
8576            fidl::encoding::DefaultFuchsiaResourceDialect,
8577        > for &mut HciOpenIsoDataChannelRequest
8578    {
8579        #[inline]
8580        unsafe fn encode(
8581            self,
8582            encoder: &mut fidl::encoding::Encoder<
8583                '_,
8584                fidl::encoding::DefaultFuchsiaResourceDialect,
8585            >,
8586            offset: usize,
8587            _depth: fidl::encoding::Depth,
8588        ) -> fidl::Result<()> {
8589            encoder.debug_check_bounds::<HciOpenIsoDataChannelRequest>(offset);
8590            // Delegate to tuple encoding.
8591            fidl::encoding::Encode::<
8592                HciOpenIsoDataChannelRequest,
8593                fidl::encoding::DefaultFuchsiaResourceDialect,
8594            >::encode(
8595                (<fidl::encoding::HandleType<
8596                    fidl::Channel,
8597                    { fidl::ObjectType::CHANNEL.into_raw() },
8598                    2147483648,
8599                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8600                    &mut self.channel
8601                ),),
8602                encoder,
8603                offset,
8604                _depth,
8605            )
8606        }
8607    }
8608    unsafe impl<
8609        T0: fidl::encoding::Encode<
8610                fidl::encoding::HandleType<
8611                    fidl::Channel,
8612                    { fidl::ObjectType::CHANNEL.into_raw() },
8613                    2147483648,
8614                >,
8615                fidl::encoding::DefaultFuchsiaResourceDialect,
8616            >,
8617    >
8618        fidl::encoding::Encode<
8619            HciOpenIsoDataChannelRequest,
8620            fidl::encoding::DefaultFuchsiaResourceDialect,
8621        > for (T0,)
8622    {
8623        #[inline]
8624        unsafe fn encode(
8625            self,
8626            encoder: &mut fidl::encoding::Encoder<
8627                '_,
8628                fidl::encoding::DefaultFuchsiaResourceDialect,
8629            >,
8630            offset: usize,
8631            depth: fidl::encoding::Depth,
8632        ) -> fidl::Result<()> {
8633            encoder.debug_check_bounds::<HciOpenIsoDataChannelRequest>(offset);
8634            // Zero out padding regions. There's no need to apply masks
8635            // because the unmasked parts will be overwritten by fields.
8636            // Write the fields.
8637            self.0.encode(encoder, offset + 0, depth)?;
8638            Ok(())
8639        }
8640    }
8641
8642    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8643        for HciOpenIsoDataChannelRequest
8644    {
8645        #[inline(always)]
8646        fn new_empty() -> Self {
8647            Self {
8648                channel: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8649            }
8650        }
8651
8652        #[inline]
8653        unsafe fn decode(
8654            &mut self,
8655            decoder: &mut fidl::encoding::Decoder<
8656                '_,
8657                fidl::encoding::DefaultFuchsiaResourceDialect,
8658            >,
8659            offset: usize,
8660            _depth: fidl::encoding::Depth,
8661        ) -> fidl::Result<()> {
8662            decoder.debug_check_bounds::<Self>(offset);
8663            // Verify that padding bytes are zero.
8664            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.channel, decoder, offset + 0, _depth)?;
8665            Ok(())
8666        }
8667    }
8668
8669    impl fidl::encoding::ResourceTypeMarker for HciOpenScoDataChannelRequest {
8670        type Borrowed<'a> = &'a mut Self;
8671        fn take_or_borrow<'a>(
8672            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8673        ) -> Self::Borrowed<'a> {
8674            value
8675        }
8676    }
8677
8678    unsafe impl fidl::encoding::TypeMarker for HciOpenScoDataChannelRequest {
8679        type Owned = Self;
8680
8681        #[inline(always)]
8682        fn inline_align(_context: fidl::encoding::Context) -> usize {
8683            4
8684        }
8685
8686        #[inline(always)]
8687        fn inline_size(_context: fidl::encoding::Context) -> usize {
8688            4
8689        }
8690    }
8691
8692    unsafe impl
8693        fidl::encoding::Encode<
8694            HciOpenScoDataChannelRequest,
8695            fidl::encoding::DefaultFuchsiaResourceDialect,
8696        > for &mut HciOpenScoDataChannelRequest
8697    {
8698        #[inline]
8699        unsafe fn encode(
8700            self,
8701            encoder: &mut fidl::encoding::Encoder<
8702                '_,
8703                fidl::encoding::DefaultFuchsiaResourceDialect,
8704            >,
8705            offset: usize,
8706            _depth: fidl::encoding::Depth,
8707        ) -> fidl::Result<()> {
8708            encoder.debug_check_bounds::<HciOpenScoDataChannelRequest>(offset);
8709            // Delegate to tuple encoding.
8710            fidl::encoding::Encode::<
8711                HciOpenScoDataChannelRequest,
8712                fidl::encoding::DefaultFuchsiaResourceDialect,
8713            >::encode(
8714                (<fidl::encoding::HandleType<
8715                    fidl::Channel,
8716                    { fidl::ObjectType::CHANNEL.into_raw() },
8717                    2147483648,
8718                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8719                    &mut self.channel
8720                ),),
8721                encoder,
8722                offset,
8723                _depth,
8724            )
8725        }
8726    }
8727    unsafe impl<
8728        T0: fidl::encoding::Encode<
8729                fidl::encoding::HandleType<
8730                    fidl::Channel,
8731                    { fidl::ObjectType::CHANNEL.into_raw() },
8732                    2147483648,
8733                >,
8734                fidl::encoding::DefaultFuchsiaResourceDialect,
8735            >,
8736    >
8737        fidl::encoding::Encode<
8738            HciOpenScoDataChannelRequest,
8739            fidl::encoding::DefaultFuchsiaResourceDialect,
8740        > for (T0,)
8741    {
8742        #[inline]
8743        unsafe fn encode(
8744            self,
8745            encoder: &mut fidl::encoding::Encoder<
8746                '_,
8747                fidl::encoding::DefaultFuchsiaResourceDialect,
8748            >,
8749            offset: usize,
8750            depth: fidl::encoding::Depth,
8751        ) -> fidl::Result<()> {
8752            encoder.debug_check_bounds::<HciOpenScoDataChannelRequest>(offset);
8753            // Zero out padding regions. There's no need to apply masks
8754            // because the unmasked parts will be overwritten by fields.
8755            // Write the fields.
8756            self.0.encode(encoder, offset + 0, depth)?;
8757            Ok(())
8758        }
8759    }
8760
8761    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8762        for HciOpenScoDataChannelRequest
8763    {
8764        #[inline(always)]
8765        fn new_empty() -> Self {
8766            Self {
8767                channel: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8768            }
8769        }
8770
8771        #[inline]
8772        unsafe fn decode(
8773            &mut self,
8774            decoder: &mut fidl::encoding::Decoder<
8775                '_,
8776                fidl::encoding::DefaultFuchsiaResourceDialect,
8777            >,
8778            offset: usize,
8779            _depth: fidl::encoding::Depth,
8780        ) -> fidl::Result<()> {
8781            decoder.debug_check_bounds::<Self>(offset);
8782            // Verify that padding bytes are zero.
8783            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.channel, decoder, offset + 0, _depth)?;
8784            Ok(())
8785        }
8786    }
8787
8788    impl fidl::encoding::ResourceTypeMarker for HciOpenSnoopChannelRequest {
8789        type Borrowed<'a> = &'a mut Self;
8790        fn take_or_borrow<'a>(
8791            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8792        ) -> Self::Borrowed<'a> {
8793            value
8794        }
8795    }
8796
8797    unsafe impl fidl::encoding::TypeMarker for HciOpenSnoopChannelRequest {
8798        type Owned = Self;
8799
8800        #[inline(always)]
8801        fn inline_align(_context: fidl::encoding::Context) -> usize {
8802            4
8803        }
8804
8805        #[inline(always)]
8806        fn inline_size(_context: fidl::encoding::Context) -> usize {
8807            4
8808        }
8809    }
8810
8811    unsafe impl
8812        fidl::encoding::Encode<
8813            HciOpenSnoopChannelRequest,
8814            fidl::encoding::DefaultFuchsiaResourceDialect,
8815        > for &mut HciOpenSnoopChannelRequest
8816    {
8817        #[inline]
8818        unsafe fn encode(
8819            self,
8820            encoder: &mut fidl::encoding::Encoder<
8821                '_,
8822                fidl::encoding::DefaultFuchsiaResourceDialect,
8823            >,
8824            offset: usize,
8825            _depth: fidl::encoding::Depth,
8826        ) -> fidl::Result<()> {
8827            encoder.debug_check_bounds::<HciOpenSnoopChannelRequest>(offset);
8828            // Delegate to tuple encoding.
8829            fidl::encoding::Encode::<
8830                HciOpenSnoopChannelRequest,
8831                fidl::encoding::DefaultFuchsiaResourceDialect,
8832            >::encode(
8833                (<fidl::encoding::HandleType<
8834                    fidl::Channel,
8835                    { fidl::ObjectType::CHANNEL.into_raw() },
8836                    2147483648,
8837                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8838                    &mut self.channel
8839                ),),
8840                encoder,
8841                offset,
8842                _depth,
8843            )
8844        }
8845    }
8846    unsafe impl<
8847        T0: fidl::encoding::Encode<
8848                fidl::encoding::HandleType<
8849                    fidl::Channel,
8850                    { fidl::ObjectType::CHANNEL.into_raw() },
8851                    2147483648,
8852                >,
8853                fidl::encoding::DefaultFuchsiaResourceDialect,
8854            >,
8855    >
8856        fidl::encoding::Encode<
8857            HciOpenSnoopChannelRequest,
8858            fidl::encoding::DefaultFuchsiaResourceDialect,
8859        > for (T0,)
8860    {
8861        #[inline]
8862        unsafe fn encode(
8863            self,
8864            encoder: &mut fidl::encoding::Encoder<
8865                '_,
8866                fidl::encoding::DefaultFuchsiaResourceDialect,
8867            >,
8868            offset: usize,
8869            depth: fidl::encoding::Depth,
8870        ) -> fidl::Result<()> {
8871            encoder.debug_check_bounds::<HciOpenSnoopChannelRequest>(offset);
8872            // Zero out padding regions. There's no need to apply masks
8873            // because the unmasked parts will be overwritten by fields.
8874            // Write the fields.
8875            self.0.encode(encoder, offset + 0, depth)?;
8876            Ok(())
8877        }
8878    }
8879
8880    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8881        for HciOpenSnoopChannelRequest
8882    {
8883        #[inline(always)]
8884        fn new_empty() -> Self {
8885            Self {
8886                channel: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8887            }
8888        }
8889
8890        #[inline]
8891        unsafe fn decode(
8892            &mut self,
8893            decoder: &mut fidl::encoding::Decoder<
8894                '_,
8895                fidl::encoding::DefaultFuchsiaResourceDialect,
8896            >,
8897            offset: usize,
8898            _depth: fidl::encoding::Depth,
8899        ) -> fidl::Result<()> {
8900            decoder.debug_check_bounds::<Self>(offset);
8901            // Verify that padding bytes are zero.
8902            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.channel, decoder, offset + 0, _depth)?;
8903            Ok(())
8904        }
8905    }
8906
8907    impl fidl::encoding::ResourceTypeMarker for VendorOpenHciTransportResponse {
8908        type Borrowed<'a> = &'a mut Self;
8909        fn take_or_borrow<'a>(
8910            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8911        ) -> Self::Borrowed<'a> {
8912            value
8913        }
8914    }
8915
8916    unsafe impl fidl::encoding::TypeMarker for VendorOpenHciTransportResponse {
8917        type Owned = Self;
8918
8919        #[inline(always)]
8920        fn inline_align(_context: fidl::encoding::Context) -> usize {
8921            4
8922        }
8923
8924        #[inline(always)]
8925        fn inline_size(_context: fidl::encoding::Context) -> usize {
8926            4
8927        }
8928    }
8929
8930    unsafe impl
8931        fidl::encoding::Encode<
8932            VendorOpenHciTransportResponse,
8933            fidl::encoding::DefaultFuchsiaResourceDialect,
8934        > for &mut VendorOpenHciTransportResponse
8935    {
8936        #[inline]
8937        unsafe fn encode(
8938            self,
8939            encoder: &mut fidl::encoding::Encoder<
8940                '_,
8941                fidl::encoding::DefaultFuchsiaResourceDialect,
8942            >,
8943            offset: usize,
8944            _depth: fidl::encoding::Depth,
8945        ) -> fidl::Result<()> {
8946            encoder.debug_check_bounds::<VendorOpenHciTransportResponse>(offset);
8947            // Delegate to tuple encoding.
8948            fidl::encoding::Encode::<VendorOpenHciTransportResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
8949                (
8950                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HciTransportMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.channel),
8951                ),
8952                encoder, offset, _depth
8953            )
8954        }
8955    }
8956    unsafe impl<
8957        T0: fidl::encoding::Encode<
8958                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HciTransportMarker>>,
8959                fidl::encoding::DefaultFuchsiaResourceDialect,
8960            >,
8961    >
8962        fidl::encoding::Encode<
8963            VendorOpenHciTransportResponse,
8964            fidl::encoding::DefaultFuchsiaResourceDialect,
8965        > for (T0,)
8966    {
8967        #[inline]
8968        unsafe fn encode(
8969            self,
8970            encoder: &mut fidl::encoding::Encoder<
8971                '_,
8972                fidl::encoding::DefaultFuchsiaResourceDialect,
8973            >,
8974            offset: usize,
8975            depth: fidl::encoding::Depth,
8976        ) -> fidl::Result<()> {
8977            encoder.debug_check_bounds::<VendorOpenHciTransportResponse>(offset);
8978            // Zero out padding regions. There's no need to apply masks
8979            // because the unmasked parts will be overwritten by fields.
8980            // Write the fields.
8981            self.0.encode(encoder, offset + 0, depth)?;
8982            Ok(())
8983        }
8984    }
8985
8986    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8987        for VendorOpenHciTransportResponse
8988    {
8989        #[inline(always)]
8990        fn new_empty() -> Self {
8991            Self {
8992                channel: fidl::new_empty!(
8993                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HciTransportMarker>>,
8994                    fidl::encoding::DefaultFuchsiaResourceDialect
8995                ),
8996            }
8997        }
8998
8999        #[inline]
9000        unsafe fn decode(
9001            &mut self,
9002            decoder: &mut fidl::encoding::Decoder<
9003                '_,
9004                fidl::encoding::DefaultFuchsiaResourceDialect,
9005            >,
9006            offset: usize,
9007            _depth: fidl::encoding::Depth,
9008        ) -> fidl::Result<()> {
9009            decoder.debug_check_bounds::<Self>(offset);
9010            // Verify that padding bytes are zero.
9011            fidl::decode!(
9012                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HciTransportMarker>>,
9013                fidl::encoding::DefaultFuchsiaResourceDialect,
9014                &mut self.channel,
9015                decoder,
9016                offset + 0,
9017                _depth
9018            )?;
9019            Ok(())
9020        }
9021    }
9022
9023    impl fidl::encoding::ResourceTypeMarker for VendorOpenHciResponse {
9024        type Borrowed<'a> = &'a mut Self;
9025        fn take_or_borrow<'a>(
9026            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9027        ) -> Self::Borrowed<'a> {
9028            value
9029        }
9030    }
9031
9032    unsafe impl fidl::encoding::TypeMarker for VendorOpenHciResponse {
9033        type Owned = Self;
9034
9035        #[inline(always)]
9036        fn inline_align(_context: fidl::encoding::Context) -> usize {
9037            4
9038        }
9039
9040        #[inline(always)]
9041        fn inline_size(_context: fidl::encoding::Context) -> usize {
9042            4
9043        }
9044    }
9045
9046    unsafe impl
9047        fidl::encoding::Encode<VendorOpenHciResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
9048        for &mut VendorOpenHciResponse
9049    {
9050        #[inline]
9051        unsafe fn encode(
9052            self,
9053            encoder: &mut fidl::encoding::Encoder<
9054                '_,
9055                fidl::encoding::DefaultFuchsiaResourceDialect,
9056            >,
9057            offset: usize,
9058            _depth: fidl::encoding::Depth,
9059        ) -> fidl::Result<()> {
9060            encoder.debug_check_bounds::<VendorOpenHciResponse>(offset);
9061            // Delegate to tuple encoding.
9062            fidl::encoding::Encode::<VendorOpenHciResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9063                (
9064                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HciMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.channel),
9065                ),
9066                encoder, offset, _depth
9067            )
9068        }
9069    }
9070    unsafe impl<
9071        T0: fidl::encoding::Encode<
9072                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HciMarker>>,
9073                fidl::encoding::DefaultFuchsiaResourceDialect,
9074            >,
9075    >
9076        fidl::encoding::Encode<VendorOpenHciResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
9077        for (T0,)
9078    {
9079        #[inline]
9080        unsafe fn encode(
9081            self,
9082            encoder: &mut fidl::encoding::Encoder<
9083                '_,
9084                fidl::encoding::DefaultFuchsiaResourceDialect,
9085            >,
9086            offset: usize,
9087            depth: fidl::encoding::Depth,
9088        ) -> fidl::Result<()> {
9089            encoder.debug_check_bounds::<VendorOpenHciResponse>(offset);
9090            // Zero out padding regions. There's no need to apply masks
9091            // because the unmasked parts will be overwritten by fields.
9092            // Write the fields.
9093            self.0.encode(encoder, offset + 0, depth)?;
9094            Ok(())
9095        }
9096    }
9097
9098    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9099        for VendorOpenHciResponse
9100    {
9101        #[inline(always)]
9102        fn new_empty() -> Self {
9103            Self {
9104                channel: fidl::new_empty!(
9105                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HciMarker>>,
9106                    fidl::encoding::DefaultFuchsiaResourceDialect
9107                ),
9108            }
9109        }
9110
9111        #[inline]
9112        unsafe fn decode(
9113            &mut self,
9114            decoder: &mut fidl::encoding::Decoder<
9115                '_,
9116                fidl::encoding::DefaultFuchsiaResourceDialect,
9117            >,
9118            offset: usize,
9119            _depth: fidl::encoding::Depth,
9120        ) -> fidl::Result<()> {
9121            decoder.debug_check_bounds::<Self>(offset);
9122            // Verify that padding bytes are zero.
9123            fidl::decode!(
9124                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HciMarker>>,
9125                fidl::encoding::DefaultFuchsiaResourceDialect,
9126                &mut self.channel,
9127                decoder,
9128                offset + 0,
9129                _depth
9130            )?;
9131            Ok(())
9132        }
9133    }
9134
9135    impl fidl::encoding::ResourceTypeMarker for VendorOpenSnoopResponse {
9136        type Borrowed<'a> = &'a mut Self;
9137        fn take_or_borrow<'a>(
9138            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9139        ) -> Self::Borrowed<'a> {
9140            value
9141        }
9142    }
9143
9144    unsafe impl fidl::encoding::TypeMarker for VendorOpenSnoopResponse {
9145        type Owned = Self;
9146
9147        #[inline(always)]
9148        fn inline_align(_context: fidl::encoding::Context) -> usize {
9149            4
9150        }
9151
9152        #[inline(always)]
9153        fn inline_size(_context: fidl::encoding::Context) -> usize {
9154            4
9155        }
9156    }
9157
9158    unsafe impl
9159        fidl::encoding::Encode<
9160            VendorOpenSnoopResponse,
9161            fidl::encoding::DefaultFuchsiaResourceDialect,
9162        > for &mut VendorOpenSnoopResponse
9163    {
9164        #[inline]
9165        unsafe fn encode(
9166            self,
9167            encoder: &mut fidl::encoding::Encoder<
9168                '_,
9169                fidl::encoding::DefaultFuchsiaResourceDialect,
9170            >,
9171            offset: usize,
9172            _depth: fidl::encoding::Depth,
9173        ) -> fidl::Result<()> {
9174            encoder.debug_check_bounds::<VendorOpenSnoopResponse>(offset);
9175            // Delegate to tuple encoding.
9176            fidl::encoding::Encode::<VendorOpenSnoopResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9177                (
9178                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnoopMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.channel),
9179                ),
9180                encoder, offset, _depth
9181            )
9182        }
9183    }
9184    unsafe impl<
9185        T0: fidl::encoding::Encode<
9186                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnoopMarker>>,
9187                fidl::encoding::DefaultFuchsiaResourceDialect,
9188            >,
9189    >
9190        fidl::encoding::Encode<
9191            VendorOpenSnoopResponse,
9192            fidl::encoding::DefaultFuchsiaResourceDialect,
9193        > for (T0,)
9194    {
9195        #[inline]
9196        unsafe fn encode(
9197            self,
9198            encoder: &mut fidl::encoding::Encoder<
9199                '_,
9200                fidl::encoding::DefaultFuchsiaResourceDialect,
9201            >,
9202            offset: usize,
9203            depth: fidl::encoding::Depth,
9204        ) -> fidl::Result<()> {
9205            encoder.debug_check_bounds::<VendorOpenSnoopResponse>(offset);
9206            // Zero out padding regions. There's no need to apply masks
9207            // because the unmasked parts will be overwritten by fields.
9208            // Write the fields.
9209            self.0.encode(encoder, offset + 0, depth)?;
9210            Ok(())
9211        }
9212    }
9213
9214    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9215        for VendorOpenSnoopResponse
9216    {
9217        #[inline(always)]
9218        fn new_empty() -> Self {
9219            Self {
9220                channel: fidl::new_empty!(
9221                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnoopMarker>>,
9222                    fidl::encoding::DefaultFuchsiaResourceDialect
9223                ),
9224            }
9225        }
9226
9227        #[inline]
9228        unsafe fn decode(
9229            &mut self,
9230            decoder: &mut fidl::encoding::Decoder<
9231                '_,
9232                fidl::encoding::DefaultFuchsiaResourceDialect,
9233            >,
9234            offset: usize,
9235            _depth: fidl::encoding::Depth,
9236        ) -> fidl::Result<()> {
9237            decoder.debug_check_bounds::<Self>(offset);
9238            // Verify that padding bytes are zero.
9239            fidl::decode!(
9240                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnoopMarker>>,
9241                fidl::encoding::DefaultFuchsiaResourceDialect,
9242                &mut self.channel,
9243                decoder,
9244                offset + 0,
9245                _depth
9246            )?;
9247            Ok(())
9248        }
9249    }
9250
9251    impl HciTransportConfigureScoRequest {
9252        #[inline(always)]
9253        fn max_ordinal_present(&self) -> u64 {
9254            if let Some(_) = self.connection {
9255                return 4;
9256            }
9257            if let Some(_) = self.sample_rate {
9258                return 3;
9259            }
9260            if let Some(_) = self.encoding {
9261                return 2;
9262            }
9263            if let Some(_) = self.coding_format {
9264                return 1;
9265            }
9266            0
9267        }
9268    }
9269
9270    impl fidl::encoding::ResourceTypeMarker for HciTransportConfigureScoRequest {
9271        type Borrowed<'a> = &'a mut Self;
9272        fn take_or_borrow<'a>(
9273            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9274        ) -> Self::Borrowed<'a> {
9275            value
9276        }
9277    }
9278
9279    unsafe impl fidl::encoding::TypeMarker for HciTransportConfigureScoRequest {
9280        type Owned = Self;
9281
9282        #[inline(always)]
9283        fn inline_align(_context: fidl::encoding::Context) -> usize {
9284            8
9285        }
9286
9287        #[inline(always)]
9288        fn inline_size(_context: fidl::encoding::Context) -> usize {
9289            16
9290        }
9291    }
9292
9293    unsafe impl
9294        fidl::encoding::Encode<
9295            HciTransportConfigureScoRequest,
9296            fidl::encoding::DefaultFuchsiaResourceDialect,
9297        > for &mut HciTransportConfigureScoRequest
9298    {
9299        unsafe fn encode(
9300            self,
9301            encoder: &mut fidl::encoding::Encoder<
9302                '_,
9303                fidl::encoding::DefaultFuchsiaResourceDialect,
9304            >,
9305            offset: usize,
9306            mut depth: fidl::encoding::Depth,
9307        ) -> fidl::Result<()> {
9308            encoder.debug_check_bounds::<HciTransportConfigureScoRequest>(offset);
9309            // Vector header
9310            let max_ordinal: u64 = self.max_ordinal_present();
9311            encoder.write_num(max_ordinal, offset);
9312            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9313            // Calling encoder.out_of_line_offset(0) is not allowed.
9314            if max_ordinal == 0 {
9315                return Ok(());
9316            }
9317            depth.increment()?;
9318            let envelope_size = 8;
9319            let bytes_len = max_ordinal as usize * envelope_size;
9320            #[allow(unused_variables)]
9321            let offset = encoder.out_of_line_offset(bytes_len);
9322            let mut _prev_end_offset: usize = 0;
9323            if 1 > max_ordinal {
9324                return Ok(());
9325            }
9326
9327            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9328            // are envelope_size bytes.
9329            let cur_offset: usize = (1 - 1) * envelope_size;
9330
9331            // Zero reserved fields.
9332            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9333
9334            // Safety:
9335            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9336            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9337            //   envelope_size bytes, there is always sufficient room.
9338            fidl::encoding::encode_in_envelope_optional::<
9339                ScoCodingFormat,
9340                fidl::encoding::DefaultFuchsiaResourceDialect,
9341            >(
9342                self.coding_format
9343                    .as_ref()
9344                    .map(<ScoCodingFormat as fidl::encoding::ValueTypeMarker>::borrow),
9345                encoder,
9346                offset + cur_offset,
9347                depth,
9348            )?;
9349
9350            _prev_end_offset = cur_offset + envelope_size;
9351            if 2 > max_ordinal {
9352                return Ok(());
9353            }
9354
9355            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9356            // are envelope_size bytes.
9357            let cur_offset: usize = (2 - 1) * envelope_size;
9358
9359            // Zero reserved fields.
9360            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9361
9362            // Safety:
9363            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9364            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9365            //   envelope_size bytes, there is always sufficient room.
9366            fidl::encoding::encode_in_envelope_optional::<
9367                ScoEncoding,
9368                fidl::encoding::DefaultFuchsiaResourceDialect,
9369            >(
9370                self.encoding
9371                    .as_ref()
9372                    .map(<ScoEncoding as fidl::encoding::ValueTypeMarker>::borrow),
9373                encoder,
9374                offset + cur_offset,
9375                depth,
9376            )?;
9377
9378            _prev_end_offset = cur_offset + envelope_size;
9379            if 3 > max_ordinal {
9380                return Ok(());
9381            }
9382
9383            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9384            // are envelope_size bytes.
9385            let cur_offset: usize = (3 - 1) * envelope_size;
9386
9387            // Zero reserved fields.
9388            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9389
9390            // Safety:
9391            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9392            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9393            //   envelope_size bytes, there is always sufficient room.
9394            fidl::encoding::encode_in_envelope_optional::<
9395                ScoSampleRate,
9396                fidl::encoding::DefaultFuchsiaResourceDialect,
9397            >(
9398                self.sample_rate
9399                    .as_ref()
9400                    .map(<ScoSampleRate as fidl::encoding::ValueTypeMarker>::borrow),
9401                encoder,
9402                offset + cur_offset,
9403                depth,
9404            )?;
9405
9406            _prev_end_offset = cur_offset + envelope_size;
9407            if 4 > max_ordinal {
9408                return Ok(());
9409            }
9410
9411            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9412            // are envelope_size bytes.
9413            let cur_offset: usize = (4 - 1) * envelope_size;
9414
9415            // Zero reserved fields.
9416            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9417
9418            // Safety:
9419            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9420            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9421            //   envelope_size bytes, there is always sufficient room.
9422            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScoConnectionMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
9423            self.connection.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScoConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
9424            encoder, offset + cur_offset, depth
9425        )?;
9426
9427            _prev_end_offset = cur_offset + envelope_size;
9428
9429            Ok(())
9430        }
9431    }
9432
9433    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9434        for HciTransportConfigureScoRequest
9435    {
9436        #[inline(always)]
9437        fn new_empty() -> Self {
9438            Self::default()
9439        }
9440
9441        unsafe fn decode(
9442            &mut self,
9443            decoder: &mut fidl::encoding::Decoder<
9444                '_,
9445                fidl::encoding::DefaultFuchsiaResourceDialect,
9446            >,
9447            offset: usize,
9448            mut depth: fidl::encoding::Depth,
9449        ) -> fidl::Result<()> {
9450            decoder.debug_check_bounds::<Self>(offset);
9451            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9452                None => return Err(fidl::Error::NotNullable),
9453                Some(len) => len,
9454            };
9455            // Calling decoder.out_of_line_offset(0) is not allowed.
9456            if len == 0 {
9457                return Ok(());
9458            };
9459            depth.increment()?;
9460            let envelope_size = 8;
9461            let bytes_len = len * envelope_size;
9462            let offset = decoder.out_of_line_offset(bytes_len)?;
9463            // Decode the envelope for each type.
9464            let mut _next_ordinal_to_read = 0;
9465            let mut next_offset = offset;
9466            let end_offset = offset + bytes_len;
9467            _next_ordinal_to_read += 1;
9468            if next_offset >= end_offset {
9469                return Ok(());
9470            }
9471
9472            // Decode unknown envelopes for gaps in ordinals.
9473            while _next_ordinal_to_read < 1 {
9474                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9475                _next_ordinal_to_read += 1;
9476                next_offset += envelope_size;
9477            }
9478
9479            let next_out_of_line = decoder.next_out_of_line();
9480            let handles_before = decoder.remaining_handles();
9481            if let Some((inlined, num_bytes, num_handles)) =
9482                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9483            {
9484                let member_inline_size =
9485                    <ScoCodingFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9486                if inlined != (member_inline_size <= 4) {
9487                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9488                }
9489                let inner_offset;
9490                let mut inner_depth = depth.clone();
9491                if inlined {
9492                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9493                    inner_offset = next_offset;
9494                } else {
9495                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9496                    inner_depth.increment()?;
9497                }
9498                let val_ref = self.coding_format.get_or_insert_with(|| {
9499                    fidl::new_empty!(ScoCodingFormat, fidl::encoding::DefaultFuchsiaResourceDialect)
9500                });
9501                fidl::decode!(
9502                    ScoCodingFormat,
9503                    fidl::encoding::DefaultFuchsiaResourceDialect,
9504                    val_ref,
9505                    decoder,
9506                    inner_offset,
9507                    inner_depth
9508                )?;
9509                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9510                {
9511                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9512                }
9513                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9514                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9515                }
9516            }
9517
9518            next_offset += envelope_size;
9519            _next_ordinal_to_read += 1;
9520            if next_offset >= end_offset {
9521                return Ok(());
9522            }
9523
9524            // Decode unknown envelopes for gaps in ordinals.
9525            while _next_ordinal_to_read < 2 {
9526                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9527                _next_ordinal_to_read += 1;
9528                next_offset += envelope_size;
9529            }
9530
9531            let next_out_of_line = decoder.next_out_of_line();
9532            let handles_before = decoder.remaining_handles();
9533            if let Some((inlined, num_bytes, num_handles)) =
9534                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9535            {
9536                let member_inline_size =
9537                    <ScoEncoding as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9538                if inlined != (member_inline_size <= 4) {
9539                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9540                }
9541                let inner_offset;
9542                let mut inner_depth = depth.clone();
9543                if inlined {
9544                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9545                    inner_offset = next_offset;
9546                } else {
9547                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9548                    inner_depth.increment()?;
9549                }
9550                let val_ref = self.encoding.get_or_insert_with(|| {
9551                    fidl::new_empty!(ScoEncoding, fidl::encoding::DefaultFuchsiaResourceDialect)
9552                });
9553                fidl::decode!(
9554                    ScoEncoding,
9555                    fidl::encoding::DefaultFuchsiaResourceDialect,
9556                    val_ref,
9557                    decoder,
9558                    inner_offset,
9559                    inner_depth
9560                )?;
9561                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9562                {
9563                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9564                }
9565                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9566                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9567                }
9568            }
9569
9570            next_offset += envelope_size;
9571            _next_ordinal_to_read += 1;
9572            if next_offset >= end_offset {
9573                return Ok(());
9574            }
9575
9576            // Decode unknown envelopes for gaps in ordinals.
9577            while _next_ordinal_to_read < 3 {
9578                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9579                _next_ordinal_to_read += 1;
9580                next_offset += envelope_size;
9581            }
9582
9583            let next_out_of_line = decoder.next_out_of_line();
9584            let handles_before = decoder.remaining_handles();
9585            if let Some((inlined, num_bytes, num_handles)) =
9586                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9587            {
9588                let member_inline_size =
9589                    <ScoSampleRate as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9590                if inlined != (member_inline_size <= 4) {
9591                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9592                }
9593                let inner_offset;
9594                let mut inner_depth = depth.clone();
9595                if inlined {
9596                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9597                    inner_offset = next_offset;
9598                } else {
9599                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9600                    inner_depth.increment()?;
9601                }
9602                let val_ref = self.sample_rate.get_or_insert_with(|| {
9603                    fidl::new_empty!(ScoSampleRate, fidl::encoding::DefaultFuchsiaResourceDialect)
9604                });
9605                fidl::decode!(
9606                    ScoSampleRate,
9607                    fidl::encoding::DefaultFuchsiaResourceDialect,
9608                    val_ref,
9609                    decoder,
9610                    inner_offset,
9611                    inner_depth
9612                )?;
9613                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9614                {
9615                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9616                }
9617                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9618                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9619                }
9620            }
9621
9622            next_offset += envelope_size;
9623            _next_ordinal_to_read += 1;
9624            if next_offset >= end_offset {
9625                return Ok(());
9626            }
9627
9628            // Decode unknown envelopes for gaps in ordinals.
9629            while _next_ordinal_to_read < 4 {
9630                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9631                _next_ordinal_to_read += 1;
9632                next_offset += envelope_size;
9633            }
9634
9635            let next_out_of_line = decoder.next_out_of_line();
9636            let handles_before = decoder.remaining_handles();
9637            if let Some((inlined, num_bytes, num_handles)) =
9638                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9639            {
9640                let member_inline_size = <fidl::encoding::Endpoint<
9641                    fidl::endpoints::ServerEnd<ScoConnectionMarker>,
9642                > as fidl::encoding::TypeMarker>::inline_size(
9643                    decoder.context
9644                );
9645                if inlined != (member_inline_size <= 4) {
9646                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9647                }
9648                let inner_offset;
9649                let mut inner_depth = depth.clone();
9650                if inlined {
9651                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9652                    inner_offset = next_offset;
9653                } else {
9654                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9655                    inner_depth.increment()?;
9656                }
9657                let val_ref = self.connection.get_or_insert_with(|| {
9658                    fidl::new_empty!(
9659                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScoConnectionMarker>>,
9660                        fidl::encoding::DefaultFuchsiaResourceDialect
9661                    )
9662                });
9663                fidl::decode!(
9664                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScoConnectionMarker>>,
9665                    fidl::encoding::DefaultFuchsiaResourceDialect,
9666                    val_ref,
9667                    decoder,
9668                    inner_offset,
9669                    inner_depth
9670                )?;
9671                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9672                {
9673                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9674                }
9675                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9676                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9677                }
9678            }
9679
9680            next_offset += envelope_size;
9681
9682            // Decode the remaining unknown envelopes.
9683            while next_offset < end_offset {
9684                _next_ordinal_to_read += 1;
9685                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9686                next_offset += envelope_size;
9687            }
9688
9689            Ok(())
9690        }
9691    }
9692
9693    impl PeerParameters {
9694        #[inline(always)]
9695        fn max_ordinal_present(&self) -> u64 {
9696            if let Some(_) = self.channel {
9697                return 3;
9698            }
9699            if let Some(_) = self.connectable {
9700                return 2;
9701            }
9702            if let Some(_) = self.address {
9703                return 1;
9704            }
9705            0
9706        }
9707    }
9708
9709    impl fidl::encoding::ResourceTypeMarker for PeerParameters {
9710        type Borrowed<'a> = &'a mut Self;
9711        fn take_or_borrow<'a>(
9712            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9713        ) -> Self::Borrowed<'a> {
9714            value
9715        }
9716    }
9717
9718    unsafe impl fidl::encoding::TypeMarker for PeerParameters {
9719        type Owned = Self;
9720
9721        #[inline(always)]
9722        fn inline_align(_context: fidl::encoding::Context) -> usize {
9723            8
9724        }
9725
9726        #[inline(always)]
9727        fn inline_size(_context: fidl::encoding::Context) -> usize {
9728            16
9729        }
9730    }
9731
9732    unsafe impl
9733        fidl::encoding::Encode<PeerParameters, fidl::encoding::DefaultFuchsiaResourceDialect>
9734        for &mut PeerParameters
9735    {
9736        unsafe fn encode(
9737            self,
9738            encoder: &mut fidl::encoding::Encoder<
9739                '_,
9740                fidl::encoding::DefaultFuchsiaResourceDialect,
9741            >,
9742            offset: usize,
9743            mut depth: fidl::encoding::Depth,
9744        ) -> fidl::Result<()> {
9745            encoder.debug_check_bounds::<PeerParameters>(offset);
9746            // Vector header
9747            let max_ordinal: u64 = self.max_ordinal_present();
9748            encoder.write_num(max_ordinal, offset);
9749            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9750            // Calling encoder.out_of_line_offset(0) is not allowed.
9751            if max_ordinal == 0 {
9752                return Ok(());
9753            }
9754            depth.increment()?;
9755            let envelope_size = 8;
9756            let bytes_len = max_ordinal as usize * envelope_size;
9757            #[allow(unused_variables)]
9758            let offset = encoder.out_of_line_offset(bytes_len);
9759            let mut _prev_end_offset: usize = 0;
9760            if 1 > max_ordinal {
9761                return Ok(());
9762            }
9763
9764            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9765            // are envelope_size bytes.
9766            let cur_offset: usize = (1 - 1) * envelope_size;
9767
9768            // Zero reserved fields.
9769            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9770
9771            // Safety:
9772            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9773            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9774            //   envelope_size bytes, there is always sufficient room.
9775            fidl::encoding::encode_in_envelope_optional::<
9776                fidl_fuchsia_bluetooth::Address,
9777                fidl::encoding::DefaultFuchsiaResourceDialect,
9778            >(
9779                self.address.as_ref().map(
9780                    <fidl_fuchsia_bluetooth::Address as fidl::encoding::ValueTypeMarker>::borrow,
9781                ),
9782                encoder,
9783                offset + cur_offset,
9784                depth,
9785            )?;
9786
9787            _prev_end_offset = cur_offset + envelope_size;
9788            if 2 > max_ordinal {
9789                return Ok(());
9790            }
9791
9792            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9793            // are envelope_size bytes.
9794            let cur_offset: usize = (2 - 1) * envelope_size;
9795
9796            // Zero reserved fields.
9797            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9798
9799            // Safety:
9800            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9801            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9802            //   envelope_size bytes, there is always sufficient room.
9803            fidl::encoding::encode_in_envelope_optional::<
9804                bool,
9805                fidl::encoding::DefaultFuchsiaResourceDialect,
9806            >(
9807                self.connectable.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
9808                encoder,
9809                offset + cur_offset,
9810                depth,
9811            )?;
9812
9813            _prev_end_offset = cur_offset + envelope_size;
9814            if 3 > max_ordinal {
9815                return Ok(());
9816            }
9817
9818            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9819            // are envelope_size bytes.
9820            let cur_offset: usize = (3 - 1) * envelope_size;
9821
9822            // Zero reserved fields.
9823            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9824
9825            // Safety:
9826            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9827            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9828            //   envelope_size bytes, there is always sufficient room.
9829            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
9830            self.channel.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
9831            encoder, offset + cur_offset, depth
9832        )?;
9833
9834            _prev_end_offset = cur_offset + envelope_size;
9835
9836            Ok(())
9837        }
9838    }
9839
9840    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9841        for PeerParameters
9842    {
9843        #[inline(always)]
9844        fn new_empty() -> Self {
9845            Self::default()
9846        }
9847
9848        unsafe fn decode(
9849            &mut self,
9850            decoder: &mut fidl::encoding::Decoder<
9851                '_,
9852                fidl::encoding::DefaultFuchsiaResourceDialect,
9853            >,
9854            offset: usize,
9855            mut depth: fidl::encoding::Depth,
9856        ) -> fidl::Result<()> {
9857            decoder.debug_check_bounds::<Self>(offset);
9858            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9859                None => return Err(fidl::Error::NotNullable),
9860                Some(len) => len,
9861            };
9862            // Calling decoder.out_of_line_offset(0) is not allowed.
9863            if len == 0 {
9864                return Ok(());
9865            };
9866            depth.increment()?;
9867            let envelope_size = 8;
9868            let bytes_len = len * envelope_size;
9869            let offset = decoder.out_of_line_offset(bytes_len)?;
9870            // Decode the envelope for each type.
9871            let mut _next_ordinal_to_read = 0;
9872            let mut next_offset = offset;
9873            let end_offset = offset + bytes_len;
9874            _next_ordinal_to_read += 1;
9875            if next_offset >= end_offset {
9876                return Ok(());
9877            }
9878
9879            // Decode unknown envelopes for gaps in ordinals.
9880            while _next_ordinal_to_read < 1 {
9881                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9882                _next_ordinal_to_read += 1;
9883                next_offset += envelope_size;
9884            }
9885
9886            let next_out_of_line = decoder.next_out_of_line();
9887            let handles_before = decoder.remaining_handles();
9888            if let Some((inlined, num_bytes, num_handles)) =
9889                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9890            {
9891                let member_inline_size =
9892                    <fidl_fuchsia_bluetooth::Address as fidl::encoding::TypeMarker>::inline_size(
9893                        decoder.context,
9894                    );
9895                if inlined != (member_inline_size <= 4) {
9896                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9897                }
9898                let inner_offset;
9899                let mut inner_depth = depth.clone();
9900                if inlined {
9901                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9902                    inner_offset = next_offset;
9903                } else {
9904                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9905                    inner_depth.increment()?;
9906                }
9907                let val_ref = self.address.get_or_insert_with(|| {
9908                    fidl::new_empty!(
9909                        fidl_fuchsia_bluetooth::Address,
9910                        fidl::encoding::DefaultFuchsiaResourceDialect
9911                    )
9912                });
9913                fidl::decode!(
9914                    fidl_fuchsia_bluetooth::Address,
9915                    fidl::encoding::DefaultFuchsiaResourceDialect,
9916                    val_ref,
9917                    decoder,
9918                    inner_offset,
9919                    inner_depth
9920                )?;
9921                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9922                {
9923                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9924                }
9925                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9926                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9927                }
9928            }
9929
9930            next_offset += envelope_size;
9931            _next_ordinal_to_read += 1;
9932            if next_offset >= end_offset {
9933                return Ok(());
9934            }
9935
9936            // Decode unknown envelopes for gaps in ordinals.
9937            while _next_ordinal_to_read < 2 {
9938                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9939                _next_ordinal_to_read += 1;
9940                next_offset += envelope_size;
9941            }
9942
9943            let next_out_of_line = decoder.next_out_of_line();
9944            let handles_before = decoder.remaining_handles();
9945            if let Some((inlined, num_bytes, num_handles)) =
9946                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9947            {
9948                let member_inline_size =
9949                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9950                if inlined != (member_inline_size <= 4) {
9951                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9952                }
9953                let inner_offset;
9954                let mut inner_depth = depth.clone();
9955                if inlined {
9956                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9957                    inner_offset = next_offset;
9958                } else {
9959                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9960                    inner_depth.increment()?;
9961                }
9962                let val_ref = self.connectable.get_or_insert_with(|| {
9963                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
9964                });
9965                fidl::decode!(
9966                    bool,
9967                    fidl::encoding::DefaultFuchsiaResourceDialect,
9968                    val_ref,
9969                    decoder,
9970                    inner_offset,
9971                    inner_depth
9972                )?;
9973                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9974                {
9975                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9976                }
9977                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9978                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9979                }
9980            }
9981
9982            next_offset += envelope_size;
9983            _next_ordinal_to_read += 1;
9984            if next_offset >= end_offset {
9985                return Ok(());
9986            }
9987
9988            // Decode unknown envelopes for gaps in ordinals.
9989            while _next_ordinal_to_read < 3 {
9990                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9991                _next_ordinal_to_read += 1;
9992                next_offset += envelope_size;
9993            }
9994
9995            let next_out_of_line = decoder.next_out_of_line();
9996            let handles_before = decoder.remaining_handles();
9997            if let Some((inlined, num_bytes, num_handles)) =
9998                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9999            {
10000                let member_inline_size = <fidl::encoding::Endpoint<
10001                    fidl::endpoints::ServerEnd<PeerMarker>,
10002                > as fidl::encoding::TypeMarker>::inline_size(
10003                    decoder.context
10004                );
10005                if inlined != (member_inline_size <= 4) {
10006                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10007                }
10008                let inner_offset;
10009                let mut inner_depth = depth.clone();
10010                if inlined {
10011                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10012                    inner_offset = next_offset;
10013                } else {
10014                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10015                    inner_depth.increment()?;
10016                }
10017                let val_ref = self.channel.get_or_insert_with(|| {
10018                    fidl::new_empty!(
10019                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerMarker>>,
10020                        fidl::encoding::DefaultFuchsiaResourceDialect
10021                    )
10022                });
10023                fidl::decode!(
10024                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerMarker>>,
10025                    fidl::encoding::DefaultFuchsiaResourceDialect,
10026                    val_ref,
10027                    decoder,
10028                    inner_offset,
10029                    inner_depth
10030                )?;
10031                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10032                {
10033                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10034                }
10035                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10036                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10037                }
10038            }
10039
10040            next_offset += envelope_size;
10041
10042            // Decode the remaining unknown envelopes.
10043            while next_offset < end_offset {
10044                _next_ordinal_to_read += 1;
10045                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10046                next_offset += envelope_size;
10047            }
10048
10049            Ok(())
10050        }
10051    }
10052
10053    impl VirtualControllerCreateLoopbackDeviceRequest {
10054        #[inline(always)]
10055        fn max_ordinal_present(&self) -> u64 {
10056            if let Some(_) = self.uart_channel {
10057                return 1;
10058            }
10059            0
10060        }
10061    }
10062
10063    impl fidl::encoding::ResourceTypeMarker for VirtualControllerCreateLoopbackDeviceRequest {
10064        type Borrowed<'a> = &'a mut Self;
10065        fn take_or_borrow<'a>(
10066            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10067        ) -> Self::Borrowed<'a> {
10068            value
10069        }
10070    }
10071
10072    unsafe impl fidl::encoding::TypeMarker for VirtualControllerCreateLoopbackDeviceRequest {
10073        type Owned = Self;
10074
10075        #[inline(always)]
10076        fn inline_align(_context: fidl::encoding::Context) -> usize {
10077            8
10078        }
10079
10080        #[inline(always)]
10081        fn inline_size(_context: fidl::encoding::Context) -> usize {
10082            16
10083        }
10084    }
10085
10086    unsafe impl
10087        fidl::encoding::Encode<
10088            VirtualControllerCreateLoopbackDeviceRequest,
10089            fidl::encoding::DefaultFuchsiaResourceDialect,
10090        > for &mut VirtualControllerCreateLoopbackDeviceRequest
10091    {
10092        unsafe fn encode(
10093            self,
10094            encoder: &mut fidl::encoding::Encoder<
10095                '_,
10096                fidl::encoding::DefaultFuchsiaResourceDialect,
10097            >,
10098            offset: usize,
10099            mut depth: fidl::encoding::Depth,
10100        ) -> fidl::Result<()> {
10101            encoder.debug_check_bounds::<VirtualControllerCreateLoopbackDeviceRequest>(offset);
10102            // Vector header
10103            let max_ordinal: u64 = self.max_ordinal_present();
10104            encoder.write_num(max_ordinal, offset);
10105            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10106            // Calling encoder.out_of_line_offset(0) is not allowed.
10107            if max_ordinal == 0 {
10108                return Ok(());
10109            }
10110            depth.increment()?;
10111            let envelope_size = 8;
10112            let bytes_len = max_ordinal as usize * envelope_size;
10113            #[allow(unused_variables)]
10114            let offset = encoder.out_of_line_offset(bytes_len);
10115            let mut _prev_end_offset: usize = 0;
10116            if 1 > max_ordinal {
10117                return Ok(());
10118            }
10119
10120            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10121            // are envelope_size bytes.
10122            let cur_offset: usize = (1 - 1) * envelope_size;
10123
10124            // Zero reserved fields.
10125            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10126
10127            // Safety:
10128            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10129            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10130            //   envelope_size bytes, there is always sufficient room.
10131            fidl::encoding::encode_in_envelope_optional::<
10132                fidl::encoding::HandleType<
10133                    fidl::Channel,
10134                    { fidl::ObjectType::CHANNEL.into_raw() },
10135                    2147483648,
10136                >,
10137                fidl::encoding::DefaultFuchsiaResourceDialect,
10138            >(
10139                self.uart_channel.as_mut().map(
10140                    <fidl::encoding::HandleType<
10141                        fidl::Channel,
10142                        { fidl::ObjectType::CHANNEL.into_raw() },
10143                        2147483648,
10144                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
10145                ),
10146                encoder,
10147                offset + cur_offset,
10148                depth,
10149            )?;
10150
10151            _prev_end_offset = cur_offset + envelope_size;
10152
10153            Ok(())
10154        }
10155    }
10156
10157    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10158        for VirtualControllerCreateLoopbackDeviceRequest
10159    {
10160        #[inline(always)]
10161        fn new_empty() -> Self {
10162            Self::default()
10163        }
10164
10165        unsafe fn decode(
10166            &mut self,
10167            decoder: &mut fidl::encoding::Decoder<
10168                '_,
10169                fidl::encoding::DefaultFuchsiaResourceDialect,
10170            >,
10171            offset: usize,
10172            mut depth: fidl::encoding::Depth,
10173        ) -> fidl::Result<()> {
10174            decoder.debug_check_bounds::<Self>(offset);
10175            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10176                None => return Err(fidl::Error::NotNullable),
10177                Some(len) => len,
10178            };
10179            // Calling decoder.out_of_line_offset(0) is not allowed.
10180            if len == 0 {
10181                return Ok(());
10182            };
10183            depth.increment()?;
10184            let envelope_size = 8;
10185            let bytes_len = len * envelope_size;
10186            let offset = decoder.out_of_line_offset(bytes_len)?;
10187            // Decode the envelope for each type.
10188            let mut _next_ordinal_to_read = 0;
10189            let mut next_offset = offset;
10190            let end_offset = offset + bytes_len;
10191            _next_ordinal_to_read += 1;
10192            if next_offset >= end_offset {
10193                return Ok(());
10194            }
10195
10196            // Decode unknown envelopes for gaps in ordinals.
10197            while _next_ordinal_to_read < 1 {
10198                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10199                _next_ordinal_to_read += 1;
10200                next_offset += envelope_size;
10201            }
10202
10203            let next_out_of_line = decoder.next_out_of_line();
10204            let handles_before = decoder.remaining_handles();
10205            if let Some((inlined, num_bytes, num_handles)) =
10206                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10207            {
10208                let member_inline_size = <fidl::encoding::HandleType<
10209                    fidl::Channel,
10210                    { fidl::ObjectType::CHANNEL.into_raw() },
10211                    2147483648,
10212                > as fidl::encoding::TypeMarker>::inline_size(
10213                    decoder.context
10214                );
10215                if inlined != (member_inline_size <= 4) {
10216                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10217                }
10218                let inner_offset;
10219                let mut inner_depth = depth.clone();
10220                if inlined {
10221                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10222                    inner_offset = next_offset;
10223                } else {
10224                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10225                    inner_depth.increment()?;
10226                }
10227                let val_ref =
10228                self.uart_channel.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
10229                fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
10230                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10231                {
10232                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10233                }
10234                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10235                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10236                }
10237            }
10238
10239            next_offset += envelope_size;
10240
10241            // Decode the remaining unknown envelopes.
10242            while next_offset < end_offset {
10243                _next_ordinal_to_read += 1;
10244                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10245                next_offset += envelope_size;
10246            }
10247
10248            Ok(())
10249        }
10250    }
10251}