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