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 { Some((responder)) } else { None }
2531    }
2532
2533    #[allow(irrefutable_let_patterns)]
2534    pub fn into_open_iso_data_channel(
2535        self,
2536    ) -> Option<(fidl::Channel, HciOpenIsoDataChannelResponder)> {
2537        if let HciRequest::OpenIsoDataChannel { channel, responder } = self {
2538            Some((channel, responder))
2539        } else {
2540            None
2541        }
2542    }
2543
2544    #[allow(irrefutable_let_patterns)]
2545    pub fn into_open_snoop_channel(self) -> Option<(fidl::Channel, HciOpenSnoopChannelResponder)> {
2546        if let HciRequest::OpenSnoopChannel { channel, responder } = self {
2547            Some((channel, responder))
2548        } else {
2549            None
2550        }
2551    }
2552
2553    /// Name of the method defined in FIDL
2554    pub fn method_name(&self) -> &'static str {
2555        match *self {
2556            HciRequest::OpenCommandChannel { .. } => "open_command_channel",
2557            HciRequest::OpenAclDataChannel { .. } => "open_acl_data_channel",
2558            HciRequest::OpenScoDataChannel { .. } => "open_sco_data_channel",
2559            HciRequest::ConfigureSco { .. } => "configure_sco",
2560            HciRequest::ResetSco { .. } => "reset_sco",
2561            HciRequest::OpenIsoDataChannel { .. } => "open_iso_data_channel",
2562            HciRequest::OpenSnoopChannel { .. } => "open_snoop_channel",
2563            HciRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2564                "unknown one-way method"
2565            }
2566            HciRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2567                "unknown two-way method"
2568            }
2569        }
2570    }
2571}
2572
2573#[derive(Debug, Clone)]
2574pub struct HciControlHandle {
2575    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2576}
2577
2578impl fidl::endpoints::ControlHandle for HciControlHandle {
2579    fn shutdown(&self) {
2580        self.inner.shutdown()
2581    }
2582    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2583        self.inner.shutdown_with_epitaph(status)
2584    }
2585
2586    fn is_closed(&self) -> bool {
2587        self.inner.channel().is_closed()
2588    }
2589    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2590        self.inner.channel().on_closed()
2591    }
2592
2593    #[cfg(target_os = "fuchsia")]
2594    fn signal_peer(
2595        &self,
2596        clear_mask: zx::Signals,
2597        set_mask: zx::Signals,
2598    ) -> Result<(), zx_status::Status> {
2599        use fidl::Peered;
2600        self.inner.channel().signal_peer(clear_mask, set_mask)
2601    }
2602}
2603
2604impl HciControlHandle {}
2605
2606#[must_use = "FIDL methods require a response to be sent"]
2607#[derive(Debug)]
2608pub struct HciOpenCommandChannelResponder {
2609    control_handle: std::mem::ManuallyDrop<HciControlHandle>,
2610    tx_id: u32,
2611}
2612
2613/// Set the the channel to be shutdown (see [`HciControlHandle::shutdown`])
2614/// if the responder is dropped without sending a response, so that the client
2615/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2616impl std::ops::Drop for HciOpenCommandChannelResponder {
2617    fn drop(&mut self) {
2618        self.control_handle.shutdown();
2619        // Safety: drops once, never accessed again
2620        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2621    }
2622}
2623
2624impl fidl::endpoints::Responder for HciOpenCommandChannelResponder {
2625    type ControlHandle = HciControlHandle;
2626
2627    fn control_handle(&self) -> &HciControlHandle {
2628        &self.control_handle
2629    }
2630
2631    fn drop_without_shutdown(mut self) {
2632        // Safety: drops once, never accessed again due to mem::forget
2633        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2634        // Prevent Drop from running (which would shut down the channel)
2635        std::mem::forget(self);
2636    }
2637}
2638
2639impl HciOpenCommandChannelResponder {
2640    /// Sends a response to the FIDL transaction.
2641    ///
2642    /// Sets the channel to shutdown if an error occurs.
2643    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2644        let _result = self.send_raw(result);
2645        if _result.is_err() {
2646            self.control_handle.shutdown();
2647        }
2648        self.drop_without_shutdown();
2649        _result
2650    }
2651
2652    /// Similar to "send" but does not shutdown the channel if an error occurs.
2653    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2654        let _result = self.send_raw(result);
2655        self.drop_without_shutdown();
2656        _result
2657    }
2658
2659    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2660        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2661            fidl::encoding::EmptyStruct,
2662            i32,
2663        >>(
2664            fidl::encoding::FlexibleResult::new(result),
2665            self.tx_id,
2666            0x2510b52ea3a51ce0,
2667            fidl::encoding::DynamicFlags::FLEXIBLE,
2668        )
2669    }
2670}
2671
2672#[must_use = "FIDL methods require a response to be sent"]
2673#[derive(Debug)]
2674pub struct HciOpenAclDataChannelResponder {
2675    control_handle: std::mem::ManuallyDrop<HciControlHandle>,
2676    tx_id: u32,
2677}
2678
2679/// Set the the channel to be shutdown (see [`HciControlHandle::shutdown`])
2680/// if the responder is dropped without sending a response, so that the client
2681/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2682impl std::ops::Drop for HciOpenAclDataChannelResponder {
2683    fn drop(&mut self) {
2684        self.control_handle.shutdown();
2685        // Safety: drops once, never accessed again
2686        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2687    }
2688}
2689
2690impl fidl::endpoints::Responder for HciOpenAclDataChannelResponder {
2691    type ControlHandle = HciControlHandle;
2692
2693    fn control_handle(&self) -> &HciControlHandle {
2694        &self.control_handle
2695    }
2696
2697    fn drop_without_shutdown(mut self) {
2698        // Safety: drops once, never accessed again due to mem::forget
2699        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2700        // Prevent Drop from running (which would shut down the channel)
2701        std::mem::forget(self);
2702    }
2703}
2704
2705impl HciOpenAclDataChannelResponder {
2706    /// Sends a response to the FIDL transaction.
2707    ///
2708    /// Sets the channel to shutdown if an error occurs.
2709    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2710        let _result = self.send_raw(result);
2711        if _result.is_err() {
2712            self.control_handle.shutdown();
2713        }
2714        self.drop_without_shutdown();
2715        _result
2716    }
2717
2718    /// Similar to "send" but does not shutdown the channel if an error occurs.
2719    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2720        let _result = self.send_raw(result);
2721        self.drop_without_shutdown();
2722        _result
2723    }
2724
2725    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2726        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2727            fidl::encoding::EmptyStruct,
2728            i32,
2729        >>(
2730            fidl::encoding::FlexibleResult::new(result),
2731            self.tx_id,
2732            0x210c3dd69156385a,
2733            fidl::encoding::DynamicFlags::FLEXIBLE,
2734        )
2735    }
2736}
2737
2738#[must_use = "FIDL methods require a response to be sent"]
2739#[derive(Debug)]
2740pub struct HciOpenScoDataChannelResponder {
2741    control_handle: std::mem::ManuallyDrop<HciControlHandle>,
2742    tx_id: u32,
2743}
2744
2745/// Set the the channel to be shutdown (see [`HciControlHandle::shutdown`])
2746/// if the responder is dropped without sending a response, so that the client
2747/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2748impl std::ops::Drop for HciOpenScoDataChannelResponder {
2749    fn drop(&mut self) {
2750        self.control_handle.shutdown();
2751        // Safety: drops once, never accessed again
2752        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2753    }
2754}
2755
2756impl fidl::endpoints::Responder for HciOpenScoDataChannelResponder {
2757    type ControlHandle = HciControlHandle;
2758
2759    fn control_handle(&self) -> &HciControlHandle {
2760        &self.control_handle
2761    }
2762
2763    fn drop_without_shutdown(mut self) {
2764        // Safety: drops once, never accessed again due to mem::forget
2765        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2766        // Prevent Drop from running (which would shut down the channel)
2767        std::mem::forget(self);
2768    }
2769}
2770
2771impl HciOpenScoDataChannelResponder {
2772    /// Sends a response to the FIDL transaction.
2773    ///
2774    /// Sets the channel to shutdown if an error occurs.
2775    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2776        let _result = self.send_raw(result);
2777        if _result.is_err() {
2778            self.control_handle.shutdown();
2779        }
2780        self.drop_without_shutdown();
2781        _result
2782    }
2783
2784    /// Similar to "send" but does not shutdown the channel if an error occurs.
2785    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2786        let _result = self.send_raw(result);
2787        self.drop_without_shutdown();
2788        _result
2789    }
2790
2791    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2792        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2793            fidl::encoding::EmptyStruct,
2794            i32,
2795        >>(
2796            fidl::encoding::FlexibleResult::new(result),
2797            self.tx_id,
2798            0x5bcb0bf2cbf35bdf,
2799            fidl::encoding::DynamicFlags::FLEXIBLE,
2800        )
2801    }
2802}
2803
2804#[must_use = "FIDL methods require a response to be sent"]
2805#[derive(Debug)]
2806pub struct HciConfigureScoResponder {
2807    control_handle: std::mem::ManuallyDrop<HciControlHandle>,
2808    tx_id: u32,
2809}
2810
2811/// Set the the channel to be shutdown (see [`HciControlHandle::shutdown`])
2812/// if the responder is dropped without sending a response, so that the client
2813/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2814impl std::ops::Drop for HciConfigureScoResponder {
2815    fn drop(&mut self) {
2816        self.control_handle.shutdown();
2817        // Safety: drops once, never accessed again
2818        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2819    }
2820}
2821
2822impl fidl::endpoints::Responder for HciConfigureScoResponder {
2823    type ControlHandle = HciControlHandle;
2824
2825    fn control_handle(&self) -> &HciControlHandle {
2826        &self.control_handle
2827    }
2828
2829    fn drop_without_shutdown(mut self) {
2830        // Safety: drops once, never accessed again due to mem::forget
2831        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2832        // Prevent Drop from running (which would shut down the channel)
2833        std::mem::forget(self);
2834    }
2835}
2836
2837impl HciConfigureScoResponder {
2838    /// Sends a response to the FIDL transaction.
2839    ///
2840    /// Sets the channel to shutdown if an error occurs.
2841    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2842        let _result = self.send_raw(result);
2843        if _result.is_err() {
2844            self.control_handle.shutdown();
2845        }
2846        self.drop_without_shutdown();
2847        _result
2848    }
2849
2850    /// Similar to "send" but does not shutdown the channel if an error occurs.
2851    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2852        let _result = self.send_raw(result);
2853        self.drop_without_shutdown();
2854        _result
2855    }
2856
2857    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2858        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2859            fidl::encoding::EmptyStruct,
2860            i32,
2861        >>(
2862            fidl::encoding::FlexibleResult::new(result),
2863            self.tx_id,
2864            0x499ec7edfd65fad7,
2865            fidl::encoding::DynamicFlags::FLEXIBLE,
2866        )
2867    }
2868}
2869
2870#[must_use = "FIDL methods require a response to be sent"]
2871#[derive(Debug)]
2872pub struct HciResetScoResponder {
2873    control_handle: std::mem::ManuallyDrop<HciControlHandle>,
2874    tx_id: u32,
2875}
2876
2877/// Set the the channel to be shutdown (see [`HciControlHandle::shutdown`])
2878/// if the responder is dropped without sending a response, so that the client
2879/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2880impl std::ops::Drop for HciResetScoResponder {
2881    fn drop(&mut self) {
2882        self.control_handle.shutdown();
2883        // Safety: drops once, never accessed again
2884        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2885    }
2886}
2887
2888impl fidl::endpoints::Responder for HciResetScoResponder {
2889    type ControlHandle = HciControlHandle;
2890
2891    fn control_handle(&self) -> &HciControlHandle {
2892        &self.control_handle
2893    }
2894
2895    fn drop_without_shutdown(mut self) {
2896        // Safety: drops once, never accessed again due to mem::forget
2897        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2898        // Prevent Drop from running (which would shut down the channel)
2899        std::mem::forget(self);
2900    }
2901}
2902
2903impl HciResetScoResponder {
2904    /// Sends a response to the FIDL transaction.
2905    ///
2906    /// Sets the channel to shutdown if an error occurs.
2907    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2908        let _result = self.send_raw(result);
2909        if _result.is_err() {
2910            self.control_handle.shutdown();
2911        }
2912        self.drop_without_shutdown();
2913        _result
2914    }
2915
2916    /// Similar to "send" but does not shutdown the channel if an error occurs.
2917    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2918        let _result = self.send_raw(result);
2919        self.drop_without_shutdown();
2920        _result
2921    }
2922
2923    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2924        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2925            fidl::encoding::EmptyStruct,
2926            i32,
2927        >>(
2928            fidl::encoding::FlexibleResult::new(result),
2929            self.tx_id,
2930            0x6ee56dcb2ce23fcb,
2931            fidl::encoding::DynamicFlags::FLEXIBLE,
2932        )
2933    }
2934}
2935
2936#[must_use = "FIDL methods require a response to be sent"]
2937#[derive(Debug)]
2938pub struct HciOpenIsoDataChannelResponder {
2939    control_handle: std::mem::ManuallyDrop<HciControlHandle>,
2940    tx_id: u32,
2941}
2942
2943/// Set the the channel to be shutdown (see [`HciControlHandle::shutdown`])
2944/// if the responder is dropped without sending a response, so that the client
2945/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2946impl std::ops::Drop for HciOpenIsoDataChannelResponder {
2947    fn drop(&mut self) {
2948        self.control_handle.shutdown();
2949        // Safety: drops once, never accessed again
2950        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2951    }
2952}
2953
2954impl fidl::endpoints::Responder for HciOpenIsoDataChannelResponder {
2955    type ControlHandle = HciControlHandle;
2956
2957    fn control_handle(&self) -> &HciControlHandle {
2958        &self.control_handle
2959    }
2960
2961    fn drop_without_shutdown(mut self) {
2962        // Safety: drops once, never accessed again due to mem::forget
2963        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2964        // Prevent Drop from running (which would shut down the channel)
2965        std::mem::forget(self);
2966    }
2967}
2968
2969impl HciOpenIsoDataChannelResponder {
2970    /// Sends a response to the FIDL transaction.
2971    ///
2972    /// Sets the channel to shutdown if an error occurs.
2973    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2974        let _result = self.send_raw(result);
2975        if _result.is_err() {
2976            self.control_handle.shutdown();
2977        }
2978        self.drop_without_shutdown();
2979        _result
2980    }
2981
2982    /// Similar to "send" but does not shutdown the channel if an error occurs.
2983    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2984        let _result = self.send_raw(result);
2985        self.drop_without_shutdown();
2986        _result
2987    }
2988
2989    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2990        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2991            fidl::encoding::EmptyStruct,
2992            i32,
2993        >>(
2994            fidl::encoding::FlexibleResult::new(result),
2995            self.tx_id,
2996            0x9adfa1d466cefd4,
2997            fidl::encoding::DynamicFlags::FLEXIBLE,
2998        )
2999    }
3000}
3001
3002#[must_use = "FIDL methods require a response to be sent"]
3003#[derive(Debug)]
3004pub struct HciOpenSnoopChannelResponder {
3005    control_handle: std::mem::ManuallyDrop<HciControlHandle>,
3006    tx_id: u32,
3007}
3008
3009/// Set the the channel to be shutdown (see [`HciControlHandle::shutdown`])
3010/// if the responder is dropped without sending a response, so that the client
3011/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3012impl std::ops::Drop for HciOpenSnoopChannelResponder {
3013    fn drop(&mut self) {
3014        self.control_handle.shutdown();
3015        // Safety: drops once, never accessed again
3016        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3017    }
3018}
3019
3020impl fidl::endpoints::Responder for HciOpenSnoopChannelResponder {
3021    type ControlHandle = HciControlHandle;
3022
3023    fn control_handle(&self) -> &HciControlHandle {
3024        &self.control_handle
3025    }
3026
3027    fn drop_without_shutdown(mut self) {
3028        // Safety: drops once, never accessed again due to mem::forget
3029        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3030        // Prevent Drop from running (which would shut down the channel)
3031        std::mem::forget(self);
3032    }
3033}
3034
3035impl HciOpenSnoopChannelResponder {
3036    /// Sends a response to the FIDL transaction.
3037    ///
3038    /// Sets the channel to shutdown if an error occurs.
3039    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3040        let _result = self.send_raw(result);
3041        if _result.is_err() {
3042            self.control_handle.shutdown();
3043        }
3044        self.drop_without_shutdown();
3045        _result
3046    }
3047
3048    /// Similar to "send" but does not shutdown the channel if an error occurs.
3049    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3050        let _result = self.send_raw(result);
3051        self.drop_without_shutdown();
3052        _result
3053    }
3054
3055    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3056        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3057            fidl::encoding::EmptyStruct,
3058            i32,
3059        >>(
3060            fidl::encoding::FlexibleResult::new(result),
3061            self.tx_id,
3062            0xd31c6d5cbc4e136,
3063            fidl::encoding::DynamicFlags::FLEXIBLE,
3064        )
3065    }
3066}
3067
3068#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3069pub struct HciTransportMarker;
3070
3071impl fidl::endpoints::ProtocolMarker for HciTransportMarker {
3072    type Proxy = HciTransportProxy;
3073    type RequestStream = HciTransportRequestStream;
3074    #[cfg(target_os = "fuchsia")]
3075    type SynchronousProxy = HciTransportSynchronousProxy;
3076
3077    const DEBUG_NAME: &'static str = "(anonymous) HciTransport";
3078}
3079
3080pub trait HciTransportProxyInterface: Send + Sync {
3081    type Send_ResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3082    fn r#send_(&self, payload: &SentPacket) -> Self::Send_ResponseFut;
3083    fn r#ack_receive(&self) -> Result<(), fidl::Error>;
3084    fn r#configure_sco(&self, payload: HciTransportConfigureScoRequest) -> Result<(), fidl::Error>;
3085}
3086#[derive(Debug)]
3087#[cfg(target_os = "fuchsia")]
3088pub struct HciTransportSynchronousProxy {
3089    client: fidl::client::sync::Client,
3090}
3091
3092#[cfg(target_os = "fuchsia")]
3093impl fidl::endpoints::SynchronousProxy for HciTransportSynchronousProxy {
3094    type Proxy = HciTransportProxy;
3095    type Protocol = HciTransportMarker;
3096
3097    fn from_channel(inner: fidl::Channel) -> Self {
3098        Self::new(inner)
3099    }
3100
3101    fn into_channel(self) -> fidl::Channel {
3102        self.client.into_channel()
3103    }
3104
3105    fn as_channel(&self) -> &fidl::Channel {
3106        self.client.as_channel()
3107    }
3108}
3109
3110#[cfg(target_os = "fuchsia")]
3111impl HciTransportSynchronousProxy {
3112    pub fn new(channel: fidl::Channel) -> Self {
3113        let protocol_name = <HciTransportMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3114        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3115    }
3116
3117    pub fn into_channel(self) -> fidl::Channel {
3118        self.client.into_channel()
3119    }
3120
3121    /// Waits until an event arrives and returns it. It is safe for other
3122    /// threads to make concurrent requests while waiting for an event.
3123    pub fn wait_for_event(
3124        &self,
3125        deadline: zx::MonotonicInstant,
3126    ) -> Result<HciTransportEvent, fidl::Error> {
3127        HciTransportEvent::decode(self.client.wait_for_event(deadline)?)
3128    }
3129
3130    /// More than one Send can be pending simultaneously.
3131    /// Prefer to limit the number of pending calls to avoid overflow.
3132    /// A maximum of 10 pending calls is suggested.
3133    /// If an event or SCO packet is received by the server, the server should close the protocol.
3134    pub fn r#send_(
3135        &self,
3136        mut payload: &SentPacket,
3137        ___deadline: zx::MonotonicInstant,
3138    ) -> Result<(), fidl::Error> {
3139        let _response = self
3140            .client
3141            .send_query::<SentPacket, fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
3142                payload,
3143                0x4793b5e66fd79e0b,
3144                fidl::encoding::DynamicFlags::FLEXIBLE,
3145                ___deadline,
3146            )?
3147            .into_result::<HciTransportMarker>("send_")?;
3148        Ok(_response)
3149    }
3150
3151    pub fn r#ack_receive(&self) -> Result<(), fidl::Error> {
3152        self.client.send::<fidl::encoding::EmptyPayload>(
3153            (),
3154            0x25de8c1f760f0c89,
3155            fidl::encoding::DynamicFlags::FLEXIBLE,
3156        )
3157    }
3158
3159    /// Establish a SCO connection. Only 1 SCO connection can be configured at a time.
3160    pub fn r#configure_sco(
3161        &self,
3162        mut payload: HciTransportConfigureScoRequest,
3163    ) -> Result<(), fidl::Error> {
3164        self.client.send::<HciTransportConfigureScoRequest>(
3165            &mut payload,
3166            0x4298072d0498b612,
3167            fidl::encoding::DynamicFlags::FLEXIBLE,
3168        )
3169    }
3170}
3171
3172#[cfg(target_os = "fuchsia")]
3173impl From<HciTransportSynchronousProxy> for zx::Handle {
3174    fn from(value: HciTransportSynchronousProxy) -> Self {
3175        value.into_channel().into()
3176    }
3177}
3178
3179#[cfg(target_os = "fuchsia")]
3180impl From<fidl::Channel> for HciTransportSynchronousProxy {
3181    fn from(value: fidl::Channel) -> Self {
3182        Self::new(value)
3183    }
3184}
3185
3186#[cfg(target_os = "fuchsia")]
3187impl fidl::endpoints::FromClient for HciTransportSynchronousProxy {
3188    type Protocol = HciTransportMarker;
3189
3190    fn from_client(value: fidl::endpoints::ClientEnd<HciTransportMarker>) -> Self {
3191        Self::new(value.into_channel())
3192    }
3193}
3194
3195#[derive(Debug, Clone)]
3196pub struct HciTransportProxy {
3197    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3198}
3199
3200impl fidl::endpoints::Proxy for HciTransportProxy {
3201    type Protocol = HciTransportMarker;
3202
3203    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3204        Self::new(inner)
3205    }
3206
3207    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3208        self.client.into_channel().map_err(|client| Self { client })
3209    }
3210
3211    fn as_channel(&self) -> &::fidl::AsyncChannel {
3212        self.client.as_channel()
3213    }
3214}
3215
3216impl HciTransportProxy {
3217    /// Create a new Proxy for fuchsia.hardware.bluetooth/HciTransport.
3218    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3219        let protocol_name = <HciTransportMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3220        Self { client: fidl::client::Client::new(channel, protocol_name) }
3221    }
3222
3223    /// Get a Stream of events from the remote end of the protocol.
3224    ///
3225    /// # Panics
3226    ///
3227    /// Panics if the event stream was already taken.
3228    pub fn take_event_stream(&self) -> HciTransportEventStream {
3229        HciTransportEventStream { event_receiver: self.client.take_event_receiver() }
3230    }
3231
3232    /// More than one Send can be pending simultaneously.
3233    /// Prefer to limit the number of pending calls to avoid overflow.
3234    /// A maximum of 10 pending calls is suggested.
3235    /// If an event or SCO packet is received by the server, the server should close the protocol.
3236    pub fn r#send_(
3237        &self,
3238        mut payload: &SentPacket,
3239    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3240        HciTransportProxyInterface::r#send_(self, payload)
3241    }
3242
3243    pub fn r#ack_receive(&self) -> Result<(), fidl::Error> {
3244        HciTransportProxyInterface::r#ack_receive(self)
3245    }
3246
3247    /// Establish a SCO connection. Only 1 SCO connection can be configured at a time.
3248    pub fn r#configure_sco(
3249        &self,
3250        mut payload: HciTransportConfigureScoRequest,
3251    ) -> Result<(), fidl::Error> {
3252        HciTransportProxyInterface::r#configure_sco(self, payload)
3253    }
3254}
3255
3256impl HciTransportProxyInterface for HciTransportProxy {
3257    type Send_ResponseFut =
3258        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3259    fn r#send_(&self, mut payload: &SentPacket) -> Self::Send_ResponseFut {
3260        fn _decode(
3261            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3262        ) -> Result<(), fidl::Error> {
3263            let _response = fidl::client::decode_transaction_body::<
3264                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3265                fidl::encoding::DefaultFuchsiaResourceDialect,
3266                0x4793b5e66fd79e0b,
3267            >(_buf?)?
3268            .into_result::<HciTransportMarker>("send_")?;
3269            Ok(_response)
3270        }
3271        self.client.send_query_and_decode::<SentPacket, ()>(
3272            payload,
3273            0x4793b5e66fd79e0b,
3274            fidl::encoding::DynamicFlags::FLEXIBLE,
3275            _decode,
3276        )
3277    }
3278
3279    fn r#ack_receive(&self) -> Result<(), fidl::Error> {
3280        self.client.send::<fidl::encoding::EmptyPayload>(
3281            (),
3282            0x25de8c1f760f0c89,
3283            fidl::encoding::DynamicFlags::FLEXIBLE,
3284        )
3285    }
3286
3287    fn r#configure_sco(
3288        &self,
3289        mut payload: HciTransportConfigureScoRequest,
3290    ) -> Result<(), fidl::Error> {
3291        self.client.send::<HciTransportConfigureScoRequest>(
3292            &mut payload,
3293            0x4298072d0498b612,
3294            fidl::encoding::DynamicFlags::FLEXIBLE,
3295        )
3296    }
3297}
3298
3299pub struct HciTransportEventStream {
3300    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3301}
3302
3303impl std::marker::Unpin for HciTransportEventStream {}
3304
3305impl futures::stream::FusedStream for HciTransportEventStream {
3306    fn is_terminated(&self) -> bool {
3307        self.event_receiver.is_terminated()
3308    }
3309}
3310
3311impl futures::Stream for HciTransportEventStream {
3312    type Item = Result<HciTransportEvent, fidl::Error>;
3313
3314    fn poll_next(
3315        mut self: std::pin::Pin<&mut Self>,
3316        cx: &mut std::task::Context<'_>,
3317    ) -> std::task::Poll<Option<Self::Item>> {
3318        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3319            &mut self.event_receiver,
3320            cx
3321        )?) {
3322            Some(buf) => std::task::Poll::Ready(Some(HciTransportEvent::decode(buf))),
3323            None => std::task::Poll::Ready(None),
3324        }
3325    }
3326}
3327
3328#[derive(Debug)]
3329pub enum HciTransportEvent {
3330    OnReceive {
3331        payload: ReceivedPacket,
3332    },
3333    #[non_exhaustive]
3334    _UnknownEvent {
3335        /// Ordinal of the event that was sent.
3336        ordinal: u64,
3337    },
3338}
3339
3340impl HciTransportEvent {
3341    #[allow(irrefutable_let_patterns)]
3342    pub fn into_on_receive(self) -> Option<ReceivedPacket> {
3343        if let HciTransportEvent::OnReceive { payload } = self { Some((payload)) } else { None }
3344    }
3345
3346    /// Decodes a message buffer as a [`HciTransportEvent`].
3347    fn decode(
3348        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3349    ) -> Result<HciTransportEvent, fidl::Error> {
3350        let (bytes, _handles) = buf.split_mut();
3351        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3352        debug_assert_eq!(tx_header.tx_id, 0);
3353        match tx_header.ordinal {
3354            0xcb102e573e5049c => {
3355                let mut out =
3356                    fidl::new_empty!(ReceivedPacket, fidl::encoding::DefaultFuchsiaResourceDialect);
3357                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ReceivedPacket>(&tx_header, _body_bytes, _handles, &mut out)?;
3358                Ok((HciTransportEvent::OnReceive { payload: out }))
3359            }
3360            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3361                Ok(HciTransportEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3362            }
3363            _ => Err(fidl::Error::UnknownOrdinal {
3364                ordinal: tx_header.ordinal,
3365                protocol_name: <HciTransportMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3366            }),
3367        }
3368    }
3369}
3370
3371/// A Stream of incoming requests for fuchsia.hardware.bluetooth/HciTransport.
3372pub struct HciTransportRequestStream {
3373    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3374    is_terminated: bool,
3375}
3376
3377impl std::marker::Unpin for HciTransportRequestStream {}
3378
3379impl futures::stream::FusedStream for HciTransportRequestStream {
3380    fn is_terminated(&self) -> bool {
3381        self.is_terminated
3382    }
3383}
3384
3385impl fidl::endpoints::RequestStream for HciTransportRequestStream {
3386    type Protocol = HciTransportMarker;
3387    type ControlHandle = HciTransportControlHandle;
3388
3389    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3390        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3391    }
3392
3393    fn control_handle(&self) -> Self::ControlHandle {
3394        HciTransportControlHandle { inner: self.inner.clone() }
3395    }
3396
3397    fn into_inner(
3398        self,
3399    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3400    {
3401        (self.inner, self.is_terminated)
3402    }
3403
3404    fn from_inner(
3405        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3406        is_terminated: bool,
3407    ) -> Self {
3408        Self { inner, is_terminated }
3409    }
3410}
3411
3412impl futures::Stream for HciTransportRequestStream {
3413    type Item = Result<HciTransportRequest, fidl::Error>;
3414
3415    fn poll_next(
3416        mut self: std::pin::Pin<&mut Self>,
3417        cx: &mut std::task::Context<'_>,
3418    ) -> std::task::Poll<Option<Self::Item>> {
3419        let this = &mut *self;
3420        if this.inner.check_shutdown(cx) {
3421            this.is_terminated = true;
3422            return std::task::Poll::Ready(None);
3423        }
3424        if this.is_terminated {
3425            panic!("polled HciTransportRequestStream after completion");
3426        }
3427        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3428            |bytes, handles| {
3429                match this.inner.channel().read_etc(cx, bytes, handles) {
3430                    std::task::Poll::Ready(Ok(())) => {}
3431                    std::task::Poll::Pending => return std::task::Poll::Pending,
3432                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3433                        this.is_terminated = true;
3434                        return std::task::Poll::Ready(None);
3435                    }
3436                    std::task::Poll::Ready(Err(e)) => {
3437                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3438                            e.into(),
3439                        ))));
3440                    }
3441                }
3442
3443                // A message has been received from the channel
3444                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3445
3446                std::task::Poll::Ready(Some(match header.ordinal {
3447                    0x4793b5e66fd79e0b => {
3448                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3449                        let mut req = fidl::new_empty!(
3450                            SentPacket,
3451                            fidl::encoding::DefaultFuchsiaResourceDialect
3452                        );
3453                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SentPacket>(&header, _body_bytes, handles, &mut req)?;
3454                        let control_handle =
3455                            HciTransportControlHandle { inner: this.inner.clone() };
3456                        Ok(HciTransportRequest::Send_ {
3457                            payload: req,
3458                            responder: HciTransportSend_Responder {
3459                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3460                                tx_id: header.tx_id,
3461                            },
3462                        })
3463                    }
3464                    0x25de8c1f760f0c89 => {
3465                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3466                        let mut req = fidl::new_empty!(
3467                            fidl::encoding::EmptyPayload,
3468                            fidl::encoding::DefaultFuchsiaResourceDialect
3469                        );
3470                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3471                        let control_handle =
3472                            HciTransportControlHandle { inner: this.inner.clone() };
3473                        Ok(HciTransportRequest::AckReceive { control_handle })
3474                    }
3475                    0x4298072d0498b612 => {
3476                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3477                        let mut req = fidl::new_empty!(
3478                            HciTransportConfigureScoRequest,
3479                            fidl::encoding::DefaultFuchsiaResourceDialect
3480                        );
3481                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<HciTransportConfigureScoRequest>(&header, _body_bytes, handles, &mut req)?;
3482                        let control_handle =
3483                            HciTransportControlHandle { inner: this.inner.clone() };
3484                        Ok(HciTransportRequest::ConfigureSco { payload: req, control_handle })
3485                    }
3486                    _ if header.tx_id == 0
3487                        && header
3488                            .dynamic_flags()
3489                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3490                    {
3491                        Ok(HciTransportRequest::_UnknownMethod {
3492                            ordinal: header.ordinal,
3493                            control_handle: HciTransportControlHandle { inner: this.inner.clone() },
3494                            method_type: fidl::MethodType::OneWay,
3495                        })
3496                    }
3497                    _ if header
3498                        .dynamic_flags()
3499                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3500                    {
3501                        this.inner.send_framework_err(
3502                            fidl::encoding::FrameworkErr::UnknownMethod,
3503                            header.tx_id,
3504                            header.ordinal,
3505                            header.dynamic_flags(),
3506                            (bytes, handles),
3507                        )?;
3508                        Ok(HciTransportRequest::_UnknownMethod {
3509                            ordinal: header.ordinal,
3510                            control_handle: HciTransportControlHandle { inner: this.inner.clone() },
3511                            method_type: fidl::MethodType::TwoWay,
3512                        })
3513                    }
3514                    _ => Err(fidl::Error::UnknownOrdinal {
3515                        ordinal: header.ordinal,
3516                        protocol_name:
3517                            <HciTransportMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3518                    }),
3519                }))
3520            },
3521        )
3522    }
3523}
3524
3525#[derive(Debug)]
3526pub enum HciTransportRequest {
3527    /// More than one Send can be pending simultaneously.
3528    /// Prefer to limit the number of pending calls to avoid overflow.
3529    /// A maximum of 10 pending calls is suggested.
3530    /// If an event or SCO packet is received by the server, the server should close the protocol.
3531    Send_ {
3532        payload: SentPacket,
3533        responder: HciTransportSend_Responder,
3534    },
3535    AckReceive {
3536        control_handle: HciTransportControlHandle,
3537    },
3538    /// Establish a SCO connection. Only 1 SCO connection can be configured at a time.
3539    ConfigureSco {
3540        payload: HciTransportConfigureScoRequest,
3541        control_handle: HciTransportControlHandle,
3542    },
3543    /// An interaction was received which does not match any known method.
3544    #[non_exhaustive]
3545    _UnknownMethod {
3546        /// Ordinal of the method that was called.
3547        ordinal: u64,
3548        control_handle: HciTransportControlHandle,
3549        method_type: fidl::MethodType,
3550    },
3551}
3552
3553impl HciTransportRequest {
3554    #[allow(irrefutable_let_patterns)]
3555    pub fn into_send_(self) -> Option<(SentPacket, HciTransportSend_Responder)> {
3556        if let HciTransportRequest::Send_ { payload, responder } = self {
3557            Some((payload, responder))
3558        } else {
3559            None
3560        }
3561    }
3562
3563    #[allow(irrefutable_let_patterns)]
3564    pub fn into_ack_receive(self) -> Option<(HciTransportControlHandle)> {
3565        if let HciTransportRequest::AckReceive { control_handle } = self {
3566            Some((control_handle))
3567        } else {
3568            None
3569        }
3570    }
3571
3572    #[allow(irrefutable_let_patterns)]
3573    pub fn into_configure_sco(
3574        self,
3575    ) -> Option<(HciTransportConfigureScoRequest, HciTransportControlHandle)> {
3576        if let HciTransportRequest::ConfigureSco { payload, control_handle } = self {
3577            Some((payload, control_handle))
3578        } else {
3579            None
3580        }
3581    }
3582
3583    /// Name of the method defined in FIDL
3584    pub fn method_name(&self) -> &'static str {
3585        match *self {
3586            HciTransportRequest::Send_ { .. } => "send_",
3587            HciTransportRequest::AckReceive { .. } => "ack_receive",
3588            HciTransportRequest::ConfigureSco { .. } => "configure_sco",
3589            HciTransportRequest::_UnknownMethod {
3590                method_type: fidl::MethodType::OneWay, ..
3591            } => "unknown one-way method",
3592            HciTransportRequest::_UnknownMethod {
3593                method_type: fidl::MethodType::TwoWay, ..
3594            } => "unknown two-way method",
3595        }
3596    }
3597}
3598
3599#[derive(Debug, Clone)]
3600pub struct HciTransportControlHandle {
3601    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3602}
3603
3604impl fidl::endpoints::ControlHandle for HciTransportControlHandle {
3605    fn shutdown(&self) {
3606        self.inner.shutdown()
3607    }
3608    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3609        self.inner.shutdown_with_epitaph(status)
3610    }
3611
3612    fn is_closed(&self) -> bool {
3613        self.inner.channel().is_closed()
3614    }
3615    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3616        self.inner.channel().on_closed()
3617    }
3618
3619    #[cfg(target_os = "fuchsia")]
3620    fn signal_peer(
3621        &self,
3622        clear_mask: zx::Signals,
3623        set_mask: zx::Signals,
3624    ) -> Result<(), zx_status::Status> {
3625        use fidl::Peered;
3626        self.inner.channel().signal_peer(clear_mask, set_mask)
3627    }
3628}
3629
3630impl HciTransportControlHandle {
3631    pub fn send_on_receive(&self, mut payload: &ReceivedPacket) -> Result<(), fidl::Error> {
3632        self.inner.send::<ReceivedPacket>(
3633            payload,
3634            0,
3635            0xcb102e573e5049c,
3636            fidl::encoding::DynamicFlags::FLEXIBLE,
3637        )
3638    }
3639}
3640
3641#[must_use = "FIDL methods require a response to be sent"]
3642#[derive(Debug)]
3643pub struct HciTransportSend_Responder {
3644    control_handle: std::mem::ManuallyDrop<HciTransportControlHandle>,
3645    tx_id: u32,
3646}
3647
3648/// Set the the channel to be shutdown (see [`HciTransportControlHandle::shutdown`])
3649/// if the responder is dropped without sending a response, so that the client
3650/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3651impl std::ops::Drop for HciTransportSend_Responder {
3652    fn drop(&mut self) {
3653        self.control_handle.shutdown();
3654        // Safety: drops once, never accessed again
3655        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3656    }
3657}
3658
3659impl fidl::endpoints::Responder for HciTransportSend_Responder {
3660    type ControlHandle = HciTransportControlHandle;
3661
3662    fn control_handle(&self) -> &HciTransportControlHandle {
3663        &self.control_handle
3664    }
3665
3666    fn drop_without_shutdown(mut self) {
3667        // Safety: drops once, never accessed again due to mem::forget
3668        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3669        // Prevent Drop from running (which would shut down the channel)
3670        std::mem::forget(self);
3671    }
3672}
3673
3674impl HciTransportSend_Responder {
3675    /// Sends a response to the FIDL transaction.
3676    ///
3677    /// Sets the channel to shutdown if an error occurs.
3678    pub fn send(self) -> Result<(), fidl::Error> {
3679        let _result = self.send_raw();
3680        if _result.is_err() {
3681            self.control_handle.shutdown();
3682        }
3683        self.drop_without_shutdown();
3684        _result
3685    }
3686
3687    /// Similar to "send" but does not shutdown the channel if an error occurs.
3688    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3689        let _result = self.send_raw();
3690        self.drop_without_shutdown();
3691        _result
3692    }
3693
3694    fn send_raw(&self) -> Result<(), fidl::Error> {
3695        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
3696            fidl::encoding::Flexible::new(()),
3697            self.tx_id,
3698            0x4793b5e66fd79e0b,
3699            fidl::encoding::DynamicFlags::FLEXIBLE,
3700        )
3701    }
3702}
3703
3704#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3705pub struct PeerMarker;
3706
3707impl fidl::endpoints::ProtocolMarker for PeerMarker {
3708    type Proxy = PeerProxy;
3709    type RequestStream = PeerRequestStream;
3710    #[cfg(target_os = "fuchsia")]
3711    type SynchronousProxy = PeerSynchronousProxy;
3712
3713    const DEBUG_NAME: &'static str = "(anonymous) Peer";
3714}
3715pub type PeerSetLeAdvertisementResult = Result<(), EmulatorPeerError>;
3716
3717pub trait PeerProxyInterface: Send + Sync {
3718    type AssignConnectionStatusResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
3719        + Send;
3720    fn r#assign_connection_status(
3721        &self,
3722        status: HciError,
3723    ) -> Self::AssignConnectionStatusResponseFut;
3724    fn r#emulate_le_connection_complete(
3725        &self,
3726        role: fidl_fuchsia_bluetooth::ConnectionRole,
3727    ) -> Result<(), fidl::Error>;
3728    fn r#emulate_disconnection_complete(&self) -> Result<(), fidl::Error>;
3729    type WatchConnectionStatesResponseFut: std::future::Future<Output = Result<Vec<ConnectionState>, fidl::Error>>
3730        + Send;
3731    fn r#watch_connection_states(&self) -> Self::WatchConnectionStatesResponseFut;
3732    type SetDeviceClassResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3733    fn r#set_device_class(&self, value: u32) -> Self::SetDeviceClassResponseFut;
3734    type SetServiceDefinitionsResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
3735        + Send;
3736    fn r#set_service_definitions(
3737        &self,
3738        service_definitions: &[fidl_fuchsia_bluetooth_bredr::ServiceDefinition],
3739    ) -> Self::SetServiceDefinitionsResponseFut;
3740    type SetLeAdvertisementResponseFut: std::future::Future<Output = Result<PeerSetLeAdvertisementResult, fidl::Error>>
3741        + Send;
3742    fn r#set_le_advertisement(
3743        &self,
3744        payload: &PeerSetLeAdvertisementRequest,
3745    ) -> Self::SetLeAdvertisementResponseFut;
3746}
3747#[derive(Debug)]
3748#[cfg(target_os = "fuchsia")]
3749pub struct PeerSynchronousProxy {
3750    client: fidl::client::sync::Client,
3751}
3752
3753#[cfg(target_os = "fuchsia")]
3754impl fidl::endpoints::SynchronousProxy for PeerSynchronousProxy {
3755    type Proxy = PeerProxy;
3756    type Protocol = PeerMarker;
3757
3758    fn from_channel(inner: fidl::Channel) -> Self {
3759        Self::new(inner)
3760    }
3761
3762    fn into_channel(self) -> fidl::Channel {
3763        self.client.into_channel()
3764    }
3765
3766    fn as_channel(&self) -> &fidl::Channel {
3767        self.client.as_channel()
3768    }
3769}
3770
3771#[cfg(target_os = "fuchsia")]
3772impl PeerSynchronousProxy {
3773    pub fn new(channel: fidl::Channel) -> Self {
3774        let protocol_name = <PeerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3775        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3776    }
3777
3778    pub fn into_channel(self) -> fidl::Channel {
3779        self.client.into_channel()
3780    }
3781
3782    /// Waits until an event arrives and returns it. It is safe for other
3783    /// threads to make concurrent requests while waiting for an event.
3784    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<PeerEvent, fidl::Error> {
3785        PeerEvent::decode(self.client.wait_for_event(deadline)?)
3786    }
3787
3788    /// Assign a HCI `status` for the controller to generate in response to connection requests.
3789    /// Applies to all successive HCI_Create_Connection and HCI_LE_Create_Connection commands. The
3790    /// procedure is acknowledged with an empty response.
3791    pub fn r#assign_connection_status(
3792        &self,
3793        mut status: HciError,
3794        ___deadline: zx::MonotonicInstant,
3795    ) -> Result<(), fidl::Error> {
3796        let _response = self.client.send_query::<
3797            PeerAssignConnectionStatusRequest,
3798            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3799        >(
3800            (status,),
3801            0x52810c5ba7a2555c,
3802            fidl::encoding::DynamicFlags::FLEXIBLE,
3803            ___deadline,
3804        )?
3805        .into_result::<PeerMarker>("assign_connection_status")?;
3806        Ok(_response)
3807    }
3808
3809    /// Emulates a LE connection event. Does nothing if the peer is already connected. The
3810    /// `role` parameter determines the link layer connection role.
3811    pub fn r#emulate_le_connection_complete(
3812        &self,
3813        mut role: fidl_fuchsia_bluetooth::ConnectionRole,
3814    ) -> Result<(), fidl::Error> {
3815        self.client.send::<PeerEmulateLeConnectionCompleteRequest>(
3816            (role,),
3817            0x3dfba319b8d2fc2a,
3818            fidl::encoding::DynamicFlags::FLEXIBLE,
3819        )
3820    }
3821
3822    /// Emulate disconnection. Does nothing if the peer is not connected.
3823    pub fn r#emulate_disconnection_complete(&self) -> Result<(), fidl::Error> {
3824        self.client.send::<fidl::encoding::EmptyPayload>(
3825            (),
3826            0x4d3955084d85a15c,
3827            fidl::encoding::DynamicFlags::FLEXIBLE,
3828        )
3829    }
3830
3831    /// Returns a vector of the least to most recent controller connection states.
3832    /// This method returns when there has been a state change since the last invocation of this
3833    /// method by this client.
3834    ///
3835    /// Multiple calls to this method can be outstanding at a given time. All calls will resolve in
3836    /// a response as soon as there is a change to the scan state.
3837    pub fn r#watch_connection_states(
3838        &self,
3839        ___deadline: zx::MonotonicInstant,
3840    ) -> Result<Vec<ConnectionState>, fidl::Error> {
3841        let _response = self.client.send_query::<
3842            fidl::encoding::EmptyPayload,
3843            fidl::encoding::FlexibleType<PeerWatchConnectionStatesResponse>,
3844        >(
3845            (),
3846            0x5a5190211980c70f,
3847            fidl::encoding::DynamicFlags::FLEXIBLE,
3848            ___deadline,
3849        )?
3850        .into_result::<PeerMarker>("watch_connection_states")?;
3851        Ok(_response.states)
3852    }
3853
3854    /// Sets the device class reported in the inquiry response for this peer during device
3855    /// discovery. If the peer is not BR/EDR, the server will close with the `ZX_ERR_NOT_SUPPORTED`
3856    /// epitaph.
3857    pub fn r#set_device_class(
3858        &self,
3859        mut value: u32,
3860        ___deadline: zx::MonotonicInstant,
3861    ) -> Result<(), fidl::Error> {
3862        let _response = self.client.send_query::<
3863            fidl_fuchsia_bluetooth::DeviceClass,
3864            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3865        >(
3866            (value,),
3867            0x3e52fa234758e1ea,
3868            fidl::encoding::DynamicFlags::FLEXIBLE,
3869            ___deadline,
3870        )?
3871        .into_result::<PeerMarker>("set_device_class")?;
3872        Ok(_response)
3873    }
3874
3875    /// Sets the peer's services that will be discoverable via Service Discovery Protocol. If the
3876    /// peer is not BR/EDR, the server will close with the `ZX_ERR_NOT_SUPPORTED` epitaph.
3877    pub fn r#set_service_definitions(
3878        &self,
3879        mut service_definitions: &[fidl_fuchsia_bluetooth_bredr::ServiceDefinition],
3880        ___deadline: zx::MonotonicInstant,
3881    ) -> Result<(), fidl::Error> {
3882        let _response = self.client.send_query::<
3883            PeerSetServiceDefinitionsRequest,
3884            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3885        >(
3886            (service_definitions,),
3887            0x58ce9f22fce272df,
3888            fidl::encoding::DynamicFlags::FLEXIBLE,
3889            ___deadline,
3890        )?
3891        .into_result::<PeerMarker>("set_service_definitions")?;
3892        Ok(_response)
3893    }
3894
3895    pub fn r#set_le_advertisement(
3896        &self,
3897        mut payload: &PeerSetLeAdvertisementRequest,
3898        ___deadline: zx::MonotonicInstant,
3899    ) -> Result<PeerSetLeAdvertisementResult, fidl::Error> {
3900        let _response = self.client.send_query::<
3901            PeerSetLeAdvertisementRequest,
3902            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, EmulatorPeerError>,
3903        >(
3904            payload,
3905            0x481b9aea1b39cfb4,
3906            fidl::encoding::DynamicFlags::FLEXIBLE,
3907            ___deadline,
3908        )?
3909        .into_result::<PeerMarker>("set_le_advertisement")?;
3910        Ok(_response.map(|x| x))
3911    }
3912}
3913
3914#[cfg(target_os = "fuchsia")]
3915impl From<PeerSynchronousProxy> for zx::Handle {
3916    fn from(value: PeerSynchronousProxy) -> Self {
3917        value.into_channel().into()
3918    }
3919}
3920
3921#[cfg(target_os = "fuchsia")]
3922impl From<fidl::Channel> for PeerSynchronousProxy {
3923    fn from(value: fidl::Channel) -> Self {
3924        Self::new(value)
3925    }
3926}
3927
3928#[cfg(target_os = "fuchsia")]
3929impl fidl::endpoints::FromClient for PeerSynchronousProxy {
3930    type Protocol = PeerMarker;
3931
3932    fn from_client(value: fidl::endpoints::ClientEnd<PeerMarker>) -> Self {
3933        Self::new(value.into_channel())
3934    }
3935}
3936
3937#[derive(Debug, Clone)]
3938pub struct PeerProxy {
3939    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3940}
3941
3942impl fidl::endpoints::Proxy for PeerProxy {
3943    type Protocol = PeerMarker;
3944
3945    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3946        Self::new(inner)
3947    }
3948
3949    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3950        self.client.into_channel().map_err(|client| Self { client })
3951    }
3952
3953    fn as_channel(&self) -> &::fidl::AsyncChannel {
3954        self.client.as_channel()
3955    }
3956}
3957
3958impl PeerProxy {
3959    /// Create a new Proxy for fuchsia.hardware.bluetooth/Peer.
3960    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3961        let protocol_name = <PeerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3962        Self { client: fidl::client::Client::new(channel, protocol_name) }
3963    }
3964
3965    /// Get a Stream of events from the remote end of the protocol.
3966    ///
3967    /// # Panics
3968    ///
3969    /// Panics if the event stream was already taken.
3970    pub fn take_event_stream(&self) -> PeerEventStream {
3971        PeerEventStream { event_receiver: self.client.take_event_receiver() }
3972    }
3973
3974    /// Assign a HCI `status` for the controller to generate in response to connection requests.
3975    /// Applies to all successive HCI_Create_Connection and HCI_LE_Create_Connection commands. The
3976    /// procedure is acknowledged with an empty response.
3977    pub fn r#assign_connection_status(
3978        &self,
3979        mut status: HciError,
3980    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3981        PeerProxyInterface::r#assign_connection_status(self, status)
3982    }
3983
3984    /// Emulates a LE connection event. Does nothing if the peer is already connected. The
3985    /// `role` parameter determines the link layer connection role.
3986    pub fn r#emulate_le_connection_complete(
3987        &self,
3988        mut role: fidl_fuchsia_bluetooth::ConnectionRole,
3989    ) -> Result<(), fidl::Error> {
3990        PeerProxyInterface::r#emulate_le_connection_complete(self, role)
3991    }
3992
3993    /// Emulate disconnection. Does nothing if the peer is not connected.
3994    pub fn r#emulate_disconnection_complete(&self) -> Result<(), fidl::Error> {
3995        PeerProxyInterface::r#emulate_disconnection_complete(self)
3996    }
3997
3998    /// Returns a vector of the least to most recent controller connection states.
3999    /// This method returns when there has been a state change since the last invocation of this
4000    /// method by this client.
4001    ///
4002    /// Multiple calls to this method can be outstanding at a given time. All calls will resolve in
4003    /// a response as soon as there is a change to the scan state.
4004    pub fn r#watch_connection_states(
4005        &self,
4006    ) -> fidl::client::QueryResponseFut<
4007        Vec<ConnectionState>,
4008        fidl::encoding::DefaultFuchsiaResourceDialect,
4009    > {
4010        PeerProxyInterface::r#watch_connection_states(self)
4011    }
4012
4013    /// Sets the device class reported in the inquiry response for this peer during device
4014    /// discovery. If the peer is not BR/EDR, the server will close with the `ZX_ERR_NOT_SUPPORTED`
4015    /// epitaph.
4016    pub fn r#set_device_class(
4017        &self,
4018        mut value: u32,
4019    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4020        PeerProxyInterface::r#set_device_class(self, value)
4021    }
4022
4023    /// Sets the peer's services that will be discoverable via Service Discovery Protocol. If the
4024    /// peer is not BR/EDR, the server will close with the `ZX_ERR_NOT_SUPPORTED` epitaph.
4025    pub fn r#set_service_definitions(
4026        &self,
4027        mut service_definitions: &[fidl_fuchsia_bluetooth_bredr::ServiceDefinition],
4028    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
4029        PeerProxyInterface::r#set_service_definitions(self, service_definitions)
4030    }
4031
4032    pub fn r#set_le_advertisement(
4033        &self,
4034        mut payload: &PeerSetLeAdvertisementRequest,
4035    ) -> fidl::client::QueryResponseFut<
4036        PeerSetLeAdvertisementResult,
4037        fidl::encoding::DefaultFuchsiaResourceDialect,
4038    > {
4039        PeerProxyInterface::r#set_le_advertisement(self, payload)
4040    }
4041}
4042
4043impl PeerProxyInterface for PeerProxy {
4044    type AssignConnectionStatusResponseFut =
4045        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4046    fn r#assign_connection_status(
4047        &self,
4048        mut status: HciError,
4049    ) -> Self::AssignConnectionStatusResponseFut {
4050        fn _decode(
4051            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4052        ) -> Result<(), fidl::Error> {
4053            let _response = fidl::client::decode_transaction_body::<
4054                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
4055                fidl::encoding::DefaultFuchsiaResourceDialect,
4056                0x52810c5ba7a2555c,
4057            >(_buf?)?
4058            .into_result::<PeerMarker>("assign_connection_status")?;
4059            Ok(_response)
4060        }
4061        self.client.send_query_and_decode::<PeerAssignConnectionStatusRequest, ()>(
4062            (status,),
4063            0x52810c5ba7a2555c,
4064            fidl::encoding::DynamicFlags::FLEXIBLE,
4065            _decode,
4066        )
4067    }
4068
4069    fn r#emulate_le_connection_complete(
4070        &self,
4071        mut role: fidl_fuchsia_bluetooth::ConnectionRole,
4072    ) -> Result<(), fidl::Error> {
4073        self.client.send::<PeerEmulateLeConnectionCompleteRequest>(
4074            (role,),
4075            0x3dfba319b8d2fc2a,
4076            fidl::encoding::DynamicFlags::FLEXIBLE,
4077        )
4078    }
4079
4080    fn r#emulate_disconnection_complete(&self) -> Result<(), fidl::Error> {
4081        self.client.send::<fidl::encoding::EmptyPayload>(
4082            (),
4083            0x4d3955084d85a15c,
4084            fidl::encoding::DynamicFlags::FLEXIBLE,
4085        )
4086    }
4087
4088    type WatchConnectionStatesResponseFut = fidl::client::QueryResponseFut<
4089        Vec<ConnectionState>,
4090        fidl::encoding::DefaultFuchsiaResourceDialect,
4091    >;
4092    fn r#watch_connection_states(&self) -> Self::WatchConnectionStatesResponseFut {
4093        fn _decode(
4094            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4095        ) -> Result<Vec<ConnectionState>, fidl::Error> {
4096            let _response = fidl::client::decode_transaction_body::<
4097                fidl::encoding::FlexibleType<PeerWatchConnectionStatesResponse>,
4098                fidl::encoding::DefaultFuchsiaResourceDialect,
4099                0x5a5190211980c70f,
4100            >(_buf?)?
4101            .into_result::<PeerMarker>("watch_connection_states")?;
4102            Ok(_response.states)
4103        }
4104        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<ConnectionState>>(
4105            (),
4106            0x5a5190211980c70f,
4107            fidl::encoding::DynamicFlags::FLEXIBLE,
4108            _decode,
4109        )
4110    }
4111
4112    type SetDeviceClassResponseFut =
4113        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4114    fn r#set_device_class(&self, mut value: u32) -> Self::SetDeviceClassResponseFut {
4115        fn _decode(
4116            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4117        ) -> Result<(), fidl::Error> {
4118            let _response = fidl::client::decode_transaction_body::<
4119                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
4120                fidl::encoding::DefaultFuchsiaResourceDialect,
4121                0x3e52fa234758e1ea,
4122            >(_buf?)?
4123            .into_result::<PeerMarker>("set_device_class")?;
4124            Ok(_response)
4125        }
4126        self.client.send_query_and_decode::<fidl_fuchsia_bluetooth::DeviceClass, ()>(
4127            (value,),
4128            0x3e52fa234758e1ea,
4129            fidl::encoding::DynamicFlags::FLEXIBLE,
4130            _decode,
4131        )
4132    }
4133
4134    type SetServiceDefinitionsResponseFut =
4135        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
4136    fn r#set_service_definitions(
4137        &self,
4138        mut service_definitions: &[fidl_fuchsia_bluetooth_bredr::ServiceDefinition],
4139    ) -> Self::SetServiceDefinitionsResponseFut {
4140        fn _decode(
4141            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4142        ) -> Result<(), fidl::Error> {
4143            let _response = fidl::client::decode_transaction_body::<
4144                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
4145                fidl::encoding::DefaultFuchsiaResourceDialect,
4146                0x58ce9f22fce272df,
4147            >(_buf?)?
4148            .into_result::<PeerMarker>("set_service_definitions")?;
4149            Ok(_response)
4150        }
4151        self.client.send_query_and_decode::<PeerSetServiceDefinitionsRequest, ()>(
4152            (service_definitions,),
4153            0x58ce9f22fce272df,
4154            fidl::encoding::DynamicFlags::FLEXIBLE,
4155            _decode,
4156        )
4157    }
4158
4159    type SetLeAdvertisementResponseFut = fidl::client::QueryResponseFut<
4160        PeerSetLeAdvertisementResult,
4161        fidl::encoding::DefaultFuchsiaResourceDialect,
4162    >;
4163    fn r#set_le_advertisement(
4164        &self,
4165        mut payload: &PeerSetLeAdvertisementRequest,
4166    ) -> Self::SetLeAdvertisementResponseFut {
4167        fn _decode(
4168            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4169        ) -> Result<PeerSetLeAdvertisementResult, fidl::Error> {
4170            let _response = fidl::client::decode_transaction_body::<
4171                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, EmulatorPeerError>,
4172                fidl::encoding::DefaultFuchsiaResourceDialect,
4173                0x481b9aea1b39cfb4,
4174            >(_buf?)?
4175            .into_result::<PeerMarker>("set_le_advertisement")?;
4176            Ok(_response.map(|x| x))
4177        }
4178        self.client
4179            .send_query_and_decode::<PeerSetLeAdvertisementRequest, PeerSetLeAdvertisementResult>(
4180                payload,
4181                0x481b9aea1b39cfb4,
4182                fidl::encoding::DynamicFlags::FLEXIBLE,
4183                _decode,
4184            )
4185    }
4186}
4187
4188pub struct PeerEventStream {
4189    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4190}
4191
4192impl std::marker::Unpin for PeerEventStream {}
4193
4194impl futures::stream::FusedStream for PeerEventStream {
4195    fn is_terminated(&self) -> bool {
4196        self.event_receiver.is_terminated()
4197    }
4198}
4199
4200impl futures::Stream for PeerEventStream {
4201    type Item = Result<PeerEvent, fidl::Error>;
4202
4203    fn poll_next(
4204        mut self: std::pin::Pin<&mut Self>,
4205        cx: &mut std::task::Context<'_>,
4206    ) -> std::task::Poll<Option<Self::Item>> {
4207        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4208            &mut self.event_receiver,
4209            cx
4210        )?) {
4211            Some(buf) => std::task::Poll::Ready(Some(PeerEvent::decode(buf))),
4212            None => std::task::Poll::Ready(None),
4213        }
4214    }
4215}
4216
4217#[derive(Debug)]
4218pub enum PeerEvent {
4219    #[non_exhaustive]
4220    _UnknownEvent {
4221        /// Ordinal of the event that was sent.
4222        ordinal: u64,
4223    },
4224}
4225
4226impl PeerEvent {
4227    /// Decodes a message buffer as a [`PeerEvent`].
4228    fn decode(
4229        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4230    ) -> Result<PeerEvent, fidl::Error> {
4231        let (bytes, _handles) = buf.split_mut();
4232        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4233        debug_assert_eq!(tx_header.tx_id, 0);
4234        match tx_header.ordinal {
4235            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4236                Ok(PeerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4237            }
4238            _ => Err(fidl::Error::UnknownOrdinal {
4239                ordinal: tx_header.ordinal,
4240                protocol_name: <PeerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4241            }),
4242        }
4243    }
4244}
4245
4246/// A Stream of incoming requests for fuchsia.hardware.bluetooth/Peer.
4247pub struct PeerRequestStream {
4248    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4249    is_terminated: bool,
4250}
4251
4252impl std::marker::Unpin for PeerRequestStream {}
4253
4254impl futures::stream::FusedStream for PeerRequestStream {
4255    fn is_terminated(&self) -> bool {
4256        self.is_terminated
4257    }
4258}
4259
4260impl fidl::endpoints::RequestStream for PeerRequestStream {
4261    type Protocol = PeerMarker;
4262    type ControlHandle = PeerControlHandle;
4263
4264    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4265        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4266    }
4267
4268    fn control_handle(&self) -> Self::ControlHandle {
4269        PeerControlHandle { inner: self.inner.clone() }
4270    }
4271
4272    fn into_inner(
4273        self,
4274    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4275    {
4276        (self.inner, self.is_terminated)
4277    }
4278
4279    fn from_inner(
4280        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4281        is_terminated: bool,
4282    ) -> Self {
4283        Self { inner, is_terminated }
4284    }
4285}
4286
4287impl futures::Stream for PeerRequestStream {
4288    type Item = Result<PeerRequest, fidl::Error>;
4289
4290    fn poll_next(
4291        mut self: std::pin::Pin<&mut Self>,
4292        cx: &mut std::task::Context<'_>,
4293    ) -> std::task::Poll<Option<Self::Item>> {
4294        let this = &mut *self;
4295        if this.inner.check_shutdown(cx) {
4296            this.is_terminated = true;
4297            return std::task::Poll::Ready(None);
4298        }
4299        if this.is_terminated {
4300            panic!("polled PeerRequestStream after completion");
4301        }
4302        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4303            |bytes, handles| {
4304                match this.inner.channel().read_etc(cx, bytes, handles) {
4305                    std::task::Poll::Ready(Ok(())) => {}
4306                    std::task::Poll::Pending => return std::task::Poll::Pending,
4307                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4308                        this.is_terminated = true;
4309                        return std::task::Poll::Ready(None);
4310                    }
4311                    std::task::Poll::Ready(Err(e)) => {
4312                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4313                            e.into(),
4314                        ))));
4315                    }
4316                }
4317
4318                // A message has been received from the channel
4319                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4320
4321                std::task::Poll::Ready(Some(match header.ordinal {
4322                    0x52810c5ba7a2555c => {
4323                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4324                        let mut req = fidl::new_empty!(
4325                            PeerAssignConnectionStatusRequest,
4326                            fidl::encoding::DefaultFuchsiaResourceDialect
4327                        );
4328                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerAssignConnectionStatusRequest>(&header, _body_bytes, handles, &mut req)?;
4329                        let control_handle = PeerControlHandle { inner: this.inner.clone() };
4330                        Ok(PeerRequest::AssignConnectionStatus {
4331                            status: req.status,
4332
4333                            responder: PeerAssignConnectionStatusResponder {
4334                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4335                                tx_id: header.tx_id,
4336                            },
4337                        })
4338                    }
4339                    0x3dfba319b8d2fc2a => {
4340                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4341                        let mut req = fidl::new_empty!(
4342                            PeerEmulateLeConnectionCompleteRequest,
4343                            fidl::encoding::DefaultFuchsiaResourceDialect
4344                        );
4345                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerEmulateLeConnectionCompleteRequest>(&header, _body_bytes, handles, &mut req)?;
4346                        let control_handle = PeerControlHandle { inner: this.inner.clone() };
4347                        Ok(PeerRequest::EmulateLeConnectionComplete {
4348                            role: req.role,
4349
4350                            control_handle,
4351                        })
4352                    }
4353                    0x4d3955084d85a15c => {
4354                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4355                        let mut req = fidl::new_empty!(
4356                            fidl::encoding::EmptyPayload,
4357                            fidl::encoding::DefaultFuchsiaResourceDialect
4358                        );
4359                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4360                        let control_handle = PeerControlHandle { inner: this.inner.clone() };
4361                        Ok(PeerRequest::EmulateDisconnectionComplete { control_handle })
4362                    }
4363                    0x5a5190211980c70f => {
4364                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4365                        let mut req = fidl::new_empty!(
4366                            fidl::encoding::EmptyPayload,
4367                            fidl::encoding::DefaultFuchsiaResourceDialect
4368                        );
4369                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4370                        let control_handle = PeerControlHandle { inner: this.inner.clone() };
4371                        Ok(PeerRequest::WatchConnectionStates {
4372                            responder: PeerWatchConnectionStatesResponder {
4373                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4374                                tx_id: header.tx_id,
4375                            },
4376                        })
4377                    }
4378                    0x3e52fa234758e1ea => {
4379                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4380                        let mut req = fidl::new_empty!(
4381                            fidl_fuchsia_bluetooth::DeviceClass,
4382                            fidl::encoding::DefaultFuchsiaResourceDialect
4383                        );
4384                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_bluetooth::DeviceClass>(&header, _body_bytes, handles, &mut req)?;
4385                        let control_handle = PeerControlHandle { inner: this.inner.clone() };
4386                        Ok(PeerRequest::SetDeviceClass {
4387                            value: req.value,
4388
4389                            responder: PeerSetDeviceClassResponder {
4390                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4391                                tx_id: header.tx_id,
4392                            },
4393                        })
4394                    }
4395                    0x58ce9f22fce272df => {
4396                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4397                        let mut req = fidl::new_empty!(
4398                            PeerSetServiceDefinitionsRequest,
4399                            fidl::encoding::DefaultFuchsiaResourceDialect
4400                        );
4401                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerSetServiceDefinitionsRequest>(&header, _body_bytes, handles, &mut req)?;
4402                        let control_handle = PeerControlHandle { inner: this.inner.clone() };
4403                        Ok(PeerRequest::SetServiceDefinitions {
4404                            service_definitions: req.service_definitions,
4405
4406                            responder: PeerSetServiceDefinitionsResponder {
4407                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4408                                tx_id: header.tx_id,
4409                            },
4410                        })
4411                    }
4412                    0x481b9aea1b39cfb4 => {
4413                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4414                        let mut req = fidl::new_empty!(
4415                            PeerSetLeAdvertisementRequest,
4416                            fidl::encoding::DefaultFuchsiaResourceDialect
4417                        );
4418                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeerSetLeAdvertisementRequest>(&header, _body_bytes, handles, &mut req)?;
4419                        let control_handle = PeerControlHandle { inner: this.inner.clone() };
4420                        Ok(PeerRequest::SetLeAdvertisement {
4421                            payload: req,
4422                            responder: PeerSetLeAdvertisementResponder {
4423                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4424                                tx_id: header.tx_id,
4425                            },
4426                        })
4427                    }
4428                    _ if header.tx_id == 0
4429                        && header
4430                            .dynamic_flags()
4431                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4432                    {
4433                        Ok(PeerRequest::_UnknownMethod {
4434                            ordinal: header.ordinal,
4435                            control_handle: PeerControlHandle { inner: this.inner.clone() },
4436                            method_type: fidl::MethodType::OneWay,
4437                        })
4438                    }
4439                    _ if header
4440                        .dynamic_flags()
4441                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4442                    {
4443                        this.inner.send_framework_err(
4444                            fidl::encoding::FrameworkErr::UnknownMethod,
4445                            header.tx_id,
4446                            header.ordinal,
4447                            header.dynamic_flags(),
4448                            (bytes, handles),
4449                        )?;
4450                        Ok(PeerRequest::_UnknownMethod {
4451                            ordinal: header.ordinal,
4452                            control_handle: PeerControlHandle { inner: this.inner.clone() },
4453                            method_type: fidl::MethodType::TwoWay,
4454                        })
4455                    }
4456                    _ => Err(fidl::Error::UnknownOrdinal {
4457                        ordinal: header.ordinal,
4458                        protocol_name: <PeerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4459                    }),
4460                }))
4461            },
4462        )
4463    }
4464}
4465
4466/// Protocol used to drive the state of a fake peer device.
4467#[derive(Debug)]
4468pub enum PeerRequest {
4469    /// Assign a HCI `status` for the controller to generate in response to connection requests.
4470    /// Applies to all successive HCI_Create_Connection and HCI_LE_Create_Connection commands. The
4471    /// procedure is acknowledged with an empty response.
4472    AssignConnectionStatus { status: HciError, responder: PeerAssignConnectionStatusResponder },
4473    /// Emulates a LE connection event. Does nothing if the peer is already connected. The
4474    /// `role` parameter determines the link layer connection role.
4475    EmulateLeConnectionComplete {
4476        role: fidl_fuchsia_bluetooth::ConnectionRole,
4477        control_handle: PeerControlHandle,
4478    },
4479    /// Emulate disconnection. Does nothing if the peer is not connected.
4480    EmulateDisconnectionComplete { control_handle: PeerControlHandle },
4481    /// Returns a vector of the least to most recent controller connection states.
4482    /// This method returns when there has been a state change since the last invocation of this
4483    /// method by this client.
4484    ///
4485    /// Multiple calls to this method can be outstanding at a given time. All calls will resolve in
4486    /// a response as soon as there is a change to the scan state.
4487    WatchConnectionStates { responder: PeerWatchConnectionStatesResponder },
4488    /// Sets the device class reported in the inquiry response for this peer during device
4489    /// discovery. If the peer is not BR/EDR, the server will close with the `ZX_ERR_NOT_SUPPORTED`
4490    /// epitaph.
4491    SetDeviceClass { value: u32, responder: PeerSetDeviceClassResponder },
4492    /// Sets the peer's services that will be discoverable via Service Discovery Protocol. If the
4493    /// peer is not BR/EDR, the server will close with the `ZX_ERR_NOT_SUPPORTED` epitaph.
4494    SetServiceDefinitions {
4495        service_definitions: Vec<fidl_fuchsia_bluetooth_bredr::ServiceDefinition>,
4496        responder: PeerSetServiceDefinitionsResponder,
4497    },
4498    SetLeAdvertisement {
4499        payload: PeerSetLeAdvertisementRequest,
4500        responder: PeerSetLeAdvertisementResponder,
4501    },
4502    /// An interaction was received which does not match any known method.
4503    #[non_exhaustive]
4504    _UnknownMethod {
4505        /// Ordinal of the method that was called.
4506        ordinal: u64,
4507        control_handle: PeerControlHandle,
4508        method_type: fidl::MethodType,
4509    },
4510}
4511
4512impl PeerRequest {
4513    #[allow(irrefutable_let_patterns)]
4514    pub fn into_assign_connection_status(
4515        self,
4516    ) -> Option<(HciError, PeerAssignConnectionStatusResponder)> {
4517        if let PeerRequest::AssignConnectionStatus { status, responder } = self {
4518            Some((status, responder))
4519        } else {
4520            None
4521        }
4522    }
4523
4524    #[allow(irrefutable_let_patterns)]
4525    pub fn into_emulate_le_connection_complete(
4526        self,
4527    ) -> Option<(fidl_fuchsia_bluetooth::ConnectionRole, PeerControlHandle)> {
4528        if let PeerRequest::EmulateLeConnectionComplete { role, control_handle } = self {
4529            Some((role, control_handle))
4530        } else {
4531            None
4532        }
4533    }
4534
4535    #[allow(irrefutable_let_patterns)]
4536    pub fn into_emulate_disconnection_complete(self) -> Option<(PeerControlHandle)> {
4537        if let PeerRequest::EmulateDisconnectionComplete { control_handle } = self {
4538            Some((control_handle))
4539        } else {
4540            None
4541        }
4542    }
4543
4544    #[allow(irrefutable_let_patterns)]
4545    pub fn into_watch_connection_states(self) -> Option<(PeerWatchConnectionStatesResponder)> {
4546        if let PeerRequest::WatchConnectionStates { responder } = self {
4547            Some((responder))
4548        } else {
4549            None
4550        }
4551    }
4552
4553    #[allow(irrefutable_let_patterns)]
4554    pub fn into_set_device_class(self) -> Option<(u32, PeerSetDeviceClassResponder)> {
4555        if let PeerRequest::SetDeviceClass { value, responder } = self {
4556            Some((value, responder))
4557        } else {
4558            None
4559        }
4560    }
4561
4562    #[allow(irrefutable_let_patterns)]
4563    pub fn into_set_service_definitions(
4564        self,
4565    ) -> Option<(
4566        Vec<fidl_fuchsia_bluetooth_bredr::ServiceDefinition>,
4567        PeerSetServiceDefinitionsResponder,
4568    )> {
4569        if let PeerRequest::SetServiceDefinitions { service_definitions, responder } = self {
4570            Some((service_definitions, responder))
4571        } else {
4572            None
4573        }
4574    }
4575
4576    #[allow(irrefutable_let_patterns)]
4577    pub fn into_set_le_advertisement(
4578        self,
4579    ) -> Option<(PeerSetLeAdvertisementRequest, PeerSetLeAdvertisementResponder)> {
4580        if let PeerRequest::SetLeAdvertisement { payload, responder } = self {
4581            Some((payload, responder))
4582        } else {
4583            None
4584        }
4585    }
4586
4587    /// Name of the method defined in FIDL
4588    pub fn method_name(&self) -> &'static str {
4589        match *self {
4590            PeerRequest::AssignConnectionStatus { .. } => "assign_connection_status",
4591            PeerRequest::EmulateLeConnectionComplete { .. } => "emulate_le_connection_complete",
4592            PeerRequest::EmulateDisconnectionComplete { .. } => "emulate_disconnection_complete",
4593            PeerRequest::WatchConnectionStates { .. } => "watch_connection_states",
4594            PeerRequest::SetDeviceClass { .. } => "set_device_class",
4595            PeerRequest::SetServiceDefinitions { .. } => "set_service_definitions",
4596            PeerRequest::SetLeAdvertisement { .. } => "set_le_advertisement",
4597            PeerRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
4598                "unknown one-way method"
4599            }
4600            PeerRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
4601                "unknown two-way method"
4602            }
4603        }
4604    }
4605}
4606
4607#[derive(Debug, Clone)]
4608pub struct PeerControlHandle {
4609    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4610}
4611
4612impl fidl::endpoints::ControlHandle for PeerControlHandle {
4613    fn shutdown(&self) {
4614        self.inner.shutdown()
4615    }
4616    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4617        self.inner.shutdown_with_epitaph(status)
4618    }
4619
4620    fn is_closed(&self) -> bool {
4621        self.inner.channel().is_closed()
4622    }
4623    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4624        self.inner.channel().on_closed()
4625    }
4626
4627    #[cfg(target_os = "fuchsia")]
4628    fn signal_peer(
4629        &self,
4630        clear_mask: zx::Signals,
4631        set_mask: zx::Signals,
4632    ) -> Result<(), zx_status::Status> {
4633        use fidl::Peered;
4634        self.inner.channel().signal_peer(clear_mask, set_mask)
4635    }
4636}
4637
4638impl PeerControlHandle {}
4639
4640#[must_use = "FIDL methods require a response to be sent"]
4641#[derive(Debug)]
4642pub struct PeerAssignConnectionStatusResponder {
4643    control_handle: std::mem::ManuallyDrop<PeerControlHandle>,
4644    tx_id: u32,
4645}
4646
4647/// Set the the channel to be shutdown (see [`PeerControlHandle::shutdown`])
4648/// if the responder is dropped without sending a response, so that the client
4649/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4650impl std::ops::Drop for PeerAssignConnectionStatusResponder {
4651    fn drop(&mut self) {
4652        self.control_handle.shutdown();
4653        // Safety: drops once, never accessed again
4654        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4655    }
4656}
4657
4658impl fidl::endpoints::Responder for PeerAssignConnectionStatusResponder {
4659    type ControlHandle = PeerControlHandle;
4660
4661    fn control_handle(&self) -> &PeerControlHandle {
4662        &self.control_handle
4663    }
4664
4665    fn drop_without_shutdown(mut self) {
4666        // Safety: drops once, never accessed again due to mem::forget
4667        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4668        // Prevent Drop from running (which would shut down the channel)
4669        std::mem::forget(self);
4670    }
4671}
4672
4673impl PeerAssignConnectionStatusResponder {
4674    /// Sends a response to the FIDL transaction.
4675    ///
4676    /// Sets the channel to shutdown if an error occurs.
4677    pub fn send(self) -> Result<(), fidl::Error> {
4678        let _result = self.send_raw();
4679        if _result.is_err() {
4680            self.control_handle.shutdown();
4681        }
4682        self.drop_without_shutdown();
4683        _result
4684    }
4685
4686    /// Similar to "send" but does not shutdown the channel if an error occurs.
4687    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4688        let _result = self.send_raw();
4689        self.drop_without_shutdown();
4690        _result
4691    }
4692
4693    fn send_raw(&self) -> Result<(), fidl::Error> {
4694        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
4695            fidl::encoding::Flexible::new(()),
4696            self.tx_id,
4697            0x52810c5ba7a2555c,
4698            fidl::encoding::DynamicFlags::FLEXIBLE,
4699        )
4700    }
4701}
4702
4703#[must_use = "FIDL methods require a response to be sent"]
4704#[derive(Debug)]
4705pub struct PeerWatchConnectionStatesResponder {
4706    control_handle: std::mem::ManuallyDrop<PeerControlHandle>,
4707    tx_id: u32,
4708}
4709
4710/// Set the the channel to be shutdown (see [`PeerControlHandle::shutdown`])
4711/// if the responder is dropped without sending a response, so that the client
4712/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4713impl std::ops::Drop for PeerWatchConnectionStatesResponder {
4714    fn drop(&mut self) {
4715        self.control_handle.shutdown();
4716        // Safety: drops once, never accessed again
4717        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4718    }
4719}
4720
4721impl fidl::endpoints::Responder for PeerWatchConnectionStatesResponder {
4722    type ControlHandle = PeerControlHandle;
4723
4724    fn control_handle(&self) -> &PeerControlHandle {
4725        &self.control_handle
4726    }
4727
4728    fn drop_without_shutdown(mut self) {
4729        // Safety: drops once, never accessed again due to mem::forget
4730        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4731        // Prevent Drop from running (which would shut down the channel)
4732        std::mem::forget(self);
4733    }
4734}
4735
4736impl PeerWatchConnectionStatesResponder {
4737    /// Sends a response to the FIDL transaction.
4738    ///
4739    /// Sets the channel to shutdown if an error occurs.
4740    pub fn send(self, mut states: &[ConnectionState]) -> Result<(), fidl::Error> {
4741        let _result = self.send_raw(states);
4742        if _result.is_err() {
4743            self.control_handle.shutdown();
4744        }
4745        self.drop_without_shutdown();
4746        _result
4747    }
4748
4749    /// Similar to "send" but does not shutdown the channel if an error occurs.
4750    pub fn send_no_shutdown_on_err(
4751        self,
4752        mut states: &[ConnectionState],
4753    ) -> Result<(), fidl::Error> {
4754        let _result = self.send_raw(states);
4755        self.drop_without_shutdown();
4756        _result
4757    }
4758
4759    fn send_raw(&self, mut states: &[ConnectionState]) -> Result<(), fidl::Error> {
4760        self.control_handle
4761            .inner
4762            .send::<fidl::encoding::FlexibleType<PeerWatchConnectionStatesResponse>>(
4763                fidl::encoding::Flexible::new((states,)),
4764                self.tx_id,
4765                0x5a5190211980c70f,
4766                fidl::encoding::DynamicFlags::FLEXIBLE,
4767            )
4768    }
4769}
4770
4771#[must_use = "FIDL methods require a response to be sent"]
4772#[derive(Debug)]
4773pub struct PeerSetDeviceClassResponder {
4774    control_handle: std::mem::ManuallyDrop<PeerControlHandle>,
4775    tx_id: u32,
4776}
4777
4778/// Set the the channel to be shutdown (see [`PeerControlHandle::shutdown`])
4779/// if the responder is dropped without sending a response, so that the client
4780/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4781impl std::ops::Drop for PeerSetDeviceClassResponder {
4782    fn drop(&mut self) {
4783        self.control_handle.shutdown();
4784        // Safety: drops once, never accessed again
4785        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4786    }
4787}
4788
4789impl fidl::endpoints::Responder for PeerSetDeviceClassResponder {
4790    type ControlHandle = PeerControlHandle;
4791
4792    fn control_handle(&self) -> &PeerControlHandle {
4793        &self.control_handle
4794    }
4795
4796    fn drop_without_shutdown(mut self) {
4797        // Safety: drops once, never accessed again due to mem::forget
4798        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4799        // Prevent Drop from running (which would shut down the channel)
4800        std::mem::forget(self);
4801    }
4802}
4803
4804impl PeerSetDeviceClassResponder {
4805    /// Sends a response to the FIDL transaction.
4806    ///
4807    /// Sets the channel to shutdown if an error occurs.
4808    pub fn send(self) -> Result<(), fidl::Error> {
4809        let _result = self.send_raw();
4810        if _result.is_err() {
4811            self.control_handle.shutdown();
4812        }
4813        self.drop_without_shutdown();
4814        _result
4815    }
4816
4817    /// Similar to "send" but does not shutdown the channel if an error occurs.
4818    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4819        let _result = self.send_raw();
4820        self.drop_without_shutdown();
4821        _result
4822    }
4823
4824    fn send_raw(&self) -> Result<(), fidl::Error> {
4825        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
4826            fidl::encoding::Flexible::new(()),
4827            self.tx_id,
4828            0x3e52fa234758e1ea,
4829            fidl::encoding::DynamicFlags::FLEXIBLE,
4830        )
4831    }
4832}
4833
4834#[must_use = "FIDL methods require a response to be sent"]
4835#[derive(Debug)]
4836pub struct PeerSetServiceDefinitionsResponder {
4837    control_handle: std::mem::ManuallyDrop<PeerControlHandle>,
4838    tx_id: u32,
4839}
4840
4841/// Set the the channel to be shutdown (see [`PeerControlHandle::shutdown`])
4842/// if the responder is dropped without sending a response, so that the client
4843/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4844impl std::ops::Drop for PeerSetServiceDefinitionsResponder {
4845    fn drop(&mut self) {
4846        self.control_handle.shutdown();
4847        // Safety: drops once, never accessed again
4848        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4849    }
4850}
4851
4852impl fidl::endpoints::Responder for PeerSetServiceDefinitionsResponder {
4853    type ControlHandle = PeerControlHandle;
4854
4855    fn control_handle(&self) -> &PeerControlHandle {
4856        &self.control_handle
4857    }
4858
4859    fn drop_without_shutdown(mut self) {
4860        // Safety: drops once, never accessed again due to mem::forget
4861        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4862        // Prevent Drop from running (which would shut down the channel)
4863        std::mem::forget(self);
4864    }
4865}
4866
4867impl PeerSetServiceDefinitionsResponder {
4868    /// Sends a response to the FIDL transaction.
4869    ///
4870    /// Sets the channel to shutdown if an error occurs.
4871    pub fn send(self) -> Result<(), fidl::Error> {
4872        let _result = self.send_raw();
4873        if _result.is_err() {
4874            self.control_handle.shutdown();
4875        }
4876        self.drop_without_shutdown();
4877        _result
4878    }
4879
4880    /// Similar to "send" but does not shutdown the channel if an error occurs.
4881    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4882        let _result = self.send_raw();
4883        self.drop_without_shutdown();
4884        _result
4885    }
4886
4887    fn send_raw(&self) -> Result<(), fidl::Error> {
4888        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
4889            fidl::encoding::Flexible::new(()),
4890            self.tx_id,
4891            0x58ce9f22fce272df,
4892            fidl::encoding::DynamicFlags::FLEXIBLE,
4893        )
4894    }
4895}
4896
4897#[must_use = "FIDL methods require a response to be sent"]
4898#[derive(Debug)]
4899pub struct PeerSetLeAdvertisementResponder {
4900    control_handle: std::mem::ManuallyDrop<PeerControlHandle>,
4901    tx_id: u32,
4902}
4903
4904/// Set the the channel to be shutdown (see [`PeerControlHandle::shutdown`])
4905/// if the responder is dropped without sending a response, so that the client
4906/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4907impl std::ops::Drop for PeerSetLeAdvertisementResponder {
4908    fn drop(&mut self) {
4909        self.control_handle.shutdown();
4910        // Safety: drops once, never accessed again
4911        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4912    }
4913}
4914
4915impl fidl::endpoints::Responder for PeerSetLeAdvertisementResponder {
4916    type ControlHandle = PeerControlHandle;
4917
4918    fn control_handle(&self) -> &PeerControlHandle {
4919        &self.control_handle
4920    }
4921
4922    fn drop_without_shutdown(mut self) {
4923        // Safety: drops once, never accessed again due to mem::forget
4924        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4925        // Prevent Drop from running (which would shut down the channel)
4926        std::mem::forget(self);
4927    }
4928}
4929
4930impl PeerSetLeAdvertisementResponder {
4931    /// Sends a response to the FIDL transaction.
4932    ///
4933    /// Sets the channel to shutdown if an error occurs.
4934    pub fn send(self, mut result: Result<(), EmulatorPeerError>) -> Result<(), fidl::Error> {
4935        let _result = self.send_raw(result);
4936        if _result.is_err() {
4937            self.control_handle.shutdown();
4938        }
4939        self.drop_without_shutdown();
4940        _result
4941    }
4942
4943    /// Similar to "send" but does not shutdown the channel if an error occurs.
4944    pub fn send_no_shutdown_on_err(
4945        self,
4946        mut result: Result<(), EmulatorPeerError>,
4947    ) -> Result<(), fidl::Error> {
4948        let _result = self.send_raw(result);
4949        self.drop_without_shutdown();
4950        _result
4951    }
4952
4953    fn send_raw(&self, mut result: Result<(), EmulatorPeerError>) -> Result<(), fidl::Error> {
4954        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4955            fidl::encoding::EmptyStruct,
4956            EmulatorPeerError,
4957        >>(
4958            fidl::encoding::FlexibleResult::new(result),
4959            self.tx_id,
4960            0x481b9aea1b39cfb4,
4961            fidl::encoding::DynamicFlags::FLEXIBLE,
4962        )
4963    }
4964}
4965
4966#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4967pub struct ScoConnectionMarker;
4968
4969impl fidl::endpoints::ProtocolMarker for ScoConnectionMarker {
4970    type Proxy = ScoConnectionProxy;
4971    type RequestStream = ScoConnectionRequestStream;
4972    #[cfg(target_os = "fuchsia")]
4973    type SynchronousProxy = ScoConnectionSynchronousProxy;
4974
4975    const DEBUG_NAME: &'static str = "(anonymous) ScoConnection";
4976}
4977
4978pub trait ScoConnectionProxyInterface: Send + Sync {
4979    type Send_ResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4980    fn r#send_(&self, packet: &[u8]) -> Self::Send_ResponseFut;
4981    fn r#ack_receive(&self) -> Result<(), fidl::Error>;
4982    fn r#stop(&self) -> Result<(), fidl::Error>;
4983}
4984#[derive(Debug)]
4985#[cfg(target_os = "fuchsia")]
4986pub struct ScoConnectionSynchronousProxy {
4987    client: fidl::client::sync::Client,
4988}
4989
4990#[cfg(target_os = "fuchsia")]
4991impl fidl::endpoints::SynchronousProxy for ScoConnectionSynchronousProxy {
4992    type Proxy = ScoConnectionProxy;
4993    type Protocol = ScoConnectionMarker;
4994
4995    fn from_channel(inner: fidl::Channel) -> Self {
4996        Self::new(inner)
4997    }
4998
4999    fn into_channel(self) -> fidl::Channel {
5000        self.client.into_channel()
5001    }
5002
5003    fn as_channel(&self) -> &fidl::Channel {
5004        self.client.as_channel()
5005    }
5006}
5007
5008#[cfg(target_os = "fuchsia")]
5009impl ScoConnectionSynchronousProxy {
5010    pub fn new(channel: fidl::Channel) -> Self {
5011        let protocol_name = <ScoConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5012        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5013    }
5014
5015    pub fn into_channel(self) -> fidl::Channel {
5016        self.client.into_channel()
5017    }
5018
5019    /// Waits until an event arrives and returns it. It is safe for other
5020    /// threads to make concurrent requests while waiting for an event.
5021    pub fn wait_for_event(
5022        &self,
5023        deadline: zx::MonotonicInstant,
5024    ) -> Result<ScoConnectionEvent, fidl::Error> {
5025        ScoConnectionEvent::decode(self.client.wait_for_event(deadline)?)
5026    }
5027
5028    /// More than one Send can be pending simultaneously.
5029    /// Prefer to limit the number of pending calls to avoid overflow.
5030    /// A maximum of 10 pending calls is suggested.
5031    pub fn r#send_(
5032        &self,
5033        mut packet: &[u8],
5034        ___deadline: zx::MonotonicInstant,
5035    ) -> Result<(), fidl::Error> {
5036        let _response = self
5037            .client
5038            .send_query::<ScoPacket, fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
5039                (packet,),
5040                0x6e0c000ccd50adec,
5041                fidl::encoding::DynamicFlags::FLEXIBLE,
5042                ___deadline,
5043            )?
5044            .into_result::<ScoConnectionMarker>("send_")?;
5045        Ok(_response)
5046    }
5047
5048    pub fn r#ack_receive(&self) -> Result<(), fidl::Error> {
5049        self.client.send::<fidl::encoding::EmptyPayload>(
5050            (),
5051            0x7e6af45151224a6a,
5052            fidl::encoding::DynamicFlags::FLEXIBLE,
5053        )
5054    }
5055
5056    /// The server will close the protocol when `Stop` is received. This is useful for
5057    /// synchronization (e.g. before configuring another `ScoConnection`).
5058    pub fn r#stop(&self) -> Result<(), fidl::Error> {
5059        self.client.send::<fidl::encoding::EmptyPayload>(
5060            (),
5061            0x5df8b0ab265b449d,
5062            fidl::encoding::DynamicFlags::FLEXIBLE,
5063        )
5064    }
5065}
5066
5067#[cfg(target_os = "fuchsia")]
5068impl From<ScoConnectionSynchronousProxy> for zx::Handle {
5069    fn from(value: ScoConnectionSynchronousProxy) -> Self {
5070        value.into_channel().into()
5071    }
5072}
5073
5074#[cfg(target_os = "fuchsia")]
5075impl From<fidl::Channel> for ScoConnectionSynchronousProxy {
5076    fn from(value: fidl::Channel) -> Self {
5077        Self::new(value)
5078    }
5079}
5080
5081#[cfg(target_os = "fuchsia")]
5082impl fidl::endpoints::FromClient for ScoConnectionSynchronousProxy {
5083    type Protocol = ScoConnectionMarker;
5084
5085    fn from_client(value: fidl::endpoints::ClientEnd<ScoConnectionMarker>) -> Self {
5086        Self::new(value.into_channel())
5087    }
5088}
5089
5090#[derive(Debug, Clone)]
5091pub struct ScoConnectionProxy {
5092    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5093}
5094
5095impl fidl::endpoints::Proxy for ScoConnectionProxy {
5096    type Protocol = ScoConnectionMarker;
5097
5098    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5099        Self::new(inner)
5100    }
5101
5102    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5103        self.client.into_channel().map_err(|client| Self { client })
5104    }
5105
5106    fn as_channel(&self) -> &::fidl::AsyncChannel {
5107        self.client.as_channel()
5108    }
5109}
5110
5111impl ScoConnectionProxy {
5112    /// Create a new Proxy for fuchsia.hardware.bluetooth/ScoConnection.
5113    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5114        let protocol_name = <ScoConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5115        Self { client: fidl::client::Client::new(channel, protocol_name) }
5116    }
5117
5118    /// Get a Stream of events from the remote end of the protocol.
5119    ///
5120    /// # Panics
5121    ///
5122    /// Panics if the event stream was already taken.
5123    pub fn take_event_stream(&self) -> ScoConnectionEventStream {
5124        ScoConnectionEventStream { event_receiver: self.client.take_event_receiver() }
5125    }
5126
5127    /// More than one Send can be pending simultaneously.
5128    /// Prefer to limit the number of pending calls to avoid overflow.
5129    /// A maximum of 10 pending calls is suggested.
5130    pub fn r#send_(
5131        &self,
5132        mut packet: &[u8],
5133    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5134        ScoConnectionProxyInterface::r#send_(self, packet)
5135    }
5136
5137    pub fn r#ack_receive(&self) -> Result<(), fidl::Error> {
5138        ScoConnectionProxyInterface::r#ack_receive(self)
5139    }
5140
5141    /// The server will close the protocol when `Stop` is received. This is useful for
5142    /// synchronization (e.g. before configuring another `ScoConnection`).
5143    pub fn r#stop(&self) -> Result<(), fidl::Error> {
5144        ScoConnectionProxyInterface::r#stop(self)
5145    }
5146}
5147
5148impl ScoConnectionProxyInterface for ScoConnectionProxy {
5149    type Send_ResponseFut =
5150        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5151    fn r#send_(&self, mut packet: &[u8]) -> Self::Send_ResponseFut {
5152        fn _decode(
5153            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5154        ) -> Result<(), fidl::Error> {
5155            let _response = fidl::client::decode_transaction_body::<
5156                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
5157                fidl::encoding::DefaultFuchsiaResourceDialect,
5158                0x6e0c000ccd50adec,
5159            >(_buf?)?
5160            .into_result::<ScoConnectionMarker>("send_")?;
5161            Ok(_response)
5162        }
5163        self.client.send_query_and_decode::<ScoPacket, ()>(
5164            (packet,),
5165            0x6e0c000ccd50adec,
5166            fidl::encoding::DynamicFlags::FLEXIBLE,
5167            _decode,
5168        )
5169    }
5170
5171    fn r#ack_receive(&self) -> Result<(), fidl::Error> {
5172        self.client.send::<fidl::encoding::EmptyPayload>(
5173            (),
5174            0x7e6af45151224a6a,
5175            fidl::encoding::DynamicFlags::FLEXIBLE,
5176        )
5177    }
5178
5179    fn r#stop(&self) -> Result<(), fidl::Error> {
5180        self.client.send::<fidl::encoding::EmptyPayload>(
5181            (),
5182            0x5df8b0ab265b449d,
5183            fidl::encoding::DynamicFlags::FLEXIBLE,
5184        )
5185    }
5186}
5187
5188pub struct ScoConnectionEventStream {
5189    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5190}
5191
5192impl std::marker::Unpin for ScoConnectionEventStream {}
5193
5194impl futures::stream::FusedStream for ScoConnectionEventStream {
5195    fn is_terminated(&self) -> bool {
5196        self.event_receiver.is_terminated()
5197    }
5198}
5199
5200impl futures::Stream for ScoConnectionEventStream {
5201    type Item = Result<ScoConnectionEvent, fidl::Error>;
5202
5203    fn poll_next(
5204        mut self: std::pin::Pin<&mut Self>,
5205        cx: &mut std::task::Context<'_>,
5206    ) -> std::task::Poll<Option<Self::Item>> {
5207        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5208            &mut self.event_receiver,
5209            cx
5210        )?) {
5211            Some(buf) => std::task::Poll::Ready(Some(ScoConnectionEvent::decode(buf))),
5212            None => std::task::Poll::Ready(None),
5213        }
5214    }
5215}
5216
5217#[derive(Debug)]
5218pub enum ScoConnectionEvent {
5219    OnReceive {
5220        packet: Vec<u8>,
5221    },
5222    #[non_exhaustive]
5223    _UnknownEvent {
5224        /// Ordinal of the event that was sent.
5225        ordinal: u64,
5226    },
5227}
5228
5229impl ScoConnectionEvent {
5230    #[allow(irrefutable_let_patterns)]
5231    pub fn into_on_receive(self) -> Option<Vec<u8>> {
5232        if let ScoConnectionEvent::OnReceive { packet } = self { Some((packet)) } else { None }
5233    }
5234
5235    /// Decodes a message buffer as a [`ScoConnectionEvent`].
5236    fn decode(
5237        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5238    ) -> Result<ScoConnectionEvent, fidl::Error> {
5239        let (bytes, _handles) = buf.split_mut();
5240        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5241        debug_assert_eq!(tx_header.tx_id, 0);
5242        match tx_header.ordinal {
5243            0x4d4e96f6f7d1aa12 => {
5244                let mut out =
5245                    fidl::new_empty!(ScoPacket, fidl::encoding::DefaultFuchsiaResourceDialect);
5246                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScoPacket>(&tx_header, _body_bytes, _handles, &mut out)?;
5247                Ok((ScoConnectionEvent::OnReceive { packet: out.packet }))
5248            }
5249            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5250                Ok(ScoConnectionEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5251            }
5252            _ => Err(fidl::Error::UnknownOrdinal {
5253                ordinal: tx_header.ordinal,
5254                protocol_name: <ScoConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5255            }),
5256        }
5257    }
5258}
5259
5260/// A Stream of incoming requests for fuchsia.hardware.bluetooth/ScoConnection.
5261pub struct ScoConnectionRequestStream {
5262    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5263    is_terminated: bool,
5264}
5265
5266impl std::marker::Unpin for ScoConnectionRequestStream {}
5267
5268impl futures::stream::FusedStream for ScoConnectionRequestStream {
5269    fn is_terminated(&self) -> bool {
5270        self.is_terminated
5271    }
5272}
5273
5274impl fidl::endpoints::RequestStream for ScoConnectionRequestStream {
5275    type Protocol = ScoConnectionMarker;
5276    type ControlHandle = ScoConnectionControlHandle;
5277
5278    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5279        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5280    }
5281
5282    fn control_handle(&self) -> Self::ControlHandle {
5283        ScoConnectionControlHandle { inner: self.inner.clone() }
5284    }
5285
5286    fn into_inner(
5287        self,
5288    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5289    {
5290        (self.inner, self.is_terminated)
5291    }
5292
5293    fn from_inner(
5294        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5295        is_terminated: bool,
5296    ) -> Self {
5297        Self { inner, is_terminated }
5298    }
5299}
5300
5301impl futures::Stream for ScoConnectionRequestStream {
5302    type Item = Result<ScoConnectionRequest, fidl::Error>;
5303
5304    fn poll_next(
5305        mut self: std::pin::Pin<&mut Self>,
5306        cx: &mut std::task::Context<'_>,
5307    ) -> std::task::Poll<Option<Self::Item>> {
5308        let this = &mut *self;
5309        if this.inner.check_shutdown(cx) {
5310            this.is_terminated = true;
5311            return std::task::Poll::Ready(None);
5312        }
5313        if this.is_terminated {
5314            panic!("polled ScoConnectionRequestStream after completion");
5315        }
5316        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5317            |bytes, handles| {
5318                match this.inner.channel().read_etc(cx, bytes, handles) {
5319                    std::task::Poll::Ready(Ok(())) => {}
5320                    std::task::Poll::Pending => return std::task::Poll::Pending,
5321                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5322                        this.is_terminated = true;
5323                        return std::task::Poll::Ready(None);
5324                    }
5325                    std::task::Poll::Ready(Err(e)) => {
5326                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5327                            e.into(),
5328                        ))));
5329                    }
5330                }
5331
5332                // A message has been received from the channel
5333                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5334
5335                std::task::Poll::Ready(Some(match header.ordinal {
5336                    0x6e0c000ccd50adec => {
5337                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5338                        let mut req = fidl::new_empty!(
5339                            ScoPacket,
5340                            fidl::encoding::DefaultFuchsiaResourceDialect
5341                        );
5342                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScoPacket>(&header, _body_bytes, handles, &mut req)?;
5343                        let control_handle =
5344                            ScoConnectionControlHandle { inner: this.inner.clone() };
5345                        Ok(ScoConnectionRequest::Send_ {
5346                            packet: req.packet,
5347
5348                            responder: ScoConnectionSend_Responder {
5349                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5350                                tx_id: header.tx_id,
5351                            },
5352                        })
5353                    }
5354                    0x7e6af45151224a6a => {
5355                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5356                        let mut req = fidl::new_empty!(
5357                            fidl::encoding::EmptyPayload,
5358                            fidl::encoding::DefaultFuchsiaResourceDialect
5359                        );
5360                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5361                        let control_handle =
5362                            ScoConnectionControlHandle { inner: this.inner.clone() };
5363                        Ok(ScoConnectionRequest::AckReceive { control_handle })
5364                    }
5365                    0x5df8b0ab265b449d => {
5366                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5367                        let mut req = fidl::new_empty!(
5368                            fidl::encoding::EmptyPayload,
5369                            fidl::encoding::DefaultFuchsiaResourceDialect
5370                        );
5371                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5372                        let control_handle =
5373                            ScoConnectionControlHandle { inner: this.inner.clone() };
5374                        Ok(ScoConnectionRequest::Stop { control_handle })
5375                    }
5376                    _ if header.tx_id == 0
5377                        && header
5378                            .dynamic_flags()
5379                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5380                    {
5381                        Ok(ScoConnectionRequest::_UnknownMethod {
5382                            ordinal: header.ordinal,
5383                            control_handle: ScoConnectionControlHandle {
5384                                inner: this.inner.clone(),
5385                            },
5386                            method_type: fidl::MethodType::OneWay,
5387                        })
5388                    }
5389                    _ if header
5390                        .dynamic_flags()
5391                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5392                    {
5393                        this.inner.send_framework_err(
5394                            fidl::encoding::FrameworkErr::UnknownMethod,
5395                            header.tx_id,
5396                            header.ordinal,
5397                            header.dynamic_flags(),
5398                            (bytes, handles),
5399                        )?;
5400                        Ok(ScoConnectionRequest::_UnknownMethod {
5401                            ordinal: header.ordinal,
5402                            control_handle: ScoConnectionControlHandle {
5403                                inner: this.inner.clone(),
5404                            },
5405                            method_type: fidl::MethodType::TwoWay,
5406                        })
5407                    }
5408                    _ => Err(fidl::Error::UnknownOrdinal {
5409                        ordinal: header.ordinal,
5410                        protocol_name:
5411                            <ScoConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5412                    }),
5413                }))
5414            },
5415        )
5416    }
5417}
5418
5419#[derive(Debug)]
5420pub enum ScoConnectionRequest {
5421    /// More than one Send can be pending simultaneously.
5422    /// Prefer to limit the number of pending calls to avoid overflow.
5423    /// A maximum of 10 pending calls is suggested.
5424    Send_ {
5425        packet: Vec<u8>,
5426        responder: ScoConnectionSend_Responder,
5427    },
5428    AckReceive {
5429        control_handle: ScoConnectionControlHandle,
5430    },
5431    /// The server will close the protocol when `Stop` is received. This is useful for
5432    /// synchronization (e.g. before configuring another `ScoConnection`).
5433    Stop {
5434        control_handle: ScoConnectionControlHandle,
5435    },
5436    /// An interaction was received which does not match any known method.
5437    #[non_exhaustive]
5438    _UnknownMethod {
5439        /// Ordinal of the method that was called.
5440        ordinal: u64,
5441        control_handle: ScoConnectionControlHandle,
5442        method_type: fidl::MethodType,
5443    },
5444}
5445
5446impl ScoConnectionRequest {
5447    #[allow(irrefutable_let_patterns)]
5448    pub fn into_send_(self) -> Option<(Vec<u8>, ScoConnectionSend_Responder)> {
5449        if let ScoConnectionRequest::Send_ { packet, responder } = self {
5450            Some((packet, responder))
5451        } else {
5452            None
5453        }
5454    }
5455
5456    #[allow(irrefutable_let_patterns)]
5457    pub fn into_ack_receive(self) -> Option<(ScoConnectionControlHandle)> {
5458        if let ScoConnectionRequest::AckReceive { control_handle } = self {
5459            Some((control_handle))
5460        } else {
5461            None
5462        }
5463    }
5464
5465    #[allow(irrefutable_let_patterns)]
5466    pub fn into_stop(self) -> Option<(ScoConnectionControlHandle)> {
5467        if let ScoConnectionRequest::Stop { control_handle } = self {
5468            Some((control_handle))
5469        } else {
5470            None
5471        }
5472    }
5473
5474    /// Name of the method defined in FIDL
5475    pub fn method_name(&self) -> &'static str {
5476        match *self {
5477            ScoConnectionRequest::Send_ { .. } => "send_",
5478            ScoConnectionRequest::AckReceive { .. } => "ack_receive",
5479            ScoConnectionRequest::Stop { .. } => "stop",
5480            ScoConnectionRequest::_UnknownMethod {
5481                method_type: fidl::MethodType::OneWay, ..
5482            } => "unknown one-way method",
5483            ScoConnectionRequest::_UnknownMethod {
5484                method_type: fidl::MethodType::TwoWay, ..
5485            } => "unknown two-way method",
5486        }
5487    }
5488}
5489
5490#[derive(Debug, Clone)]
5491pub struct ScoConnectionControlHandle {
5492    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5493}
5494
5495impl fidl::endpoints::ControlHandle for ScoConnectionControlHandle {
5496    fn shutdown(&self) {
5497        self.inner.shutdown()
5498    }
5499    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5500        self.inner.shutdown_with_epitaph(status)
5501    }
5502
5503    fn is_closed(&self) -> bool {
5504        self.inner.channel().is_closed()
5505    }
5506    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5507        self.inner.channel().on_closed()
5508    }
5509
5510    #[cfg(target_os = "fuchsia")]
5511    fn signal_peer(
5512        &self,
5513        clear_mask: zx::Signals,
5514        set_mask: zx::Signals,
5515    ) -> Result<(), zx_status::Status> {
5516        use fidl::Peered;
5517        self.inner.channel().signal_peer(clear_mask, set_mask)
5518    }
5519}
5520
5521impl ScoConnectionControlHandle {
5522    pub fn send_on_receive(&self, mut packet: &[u8]) -> Result<(), fidl::Error> {
5523        self.inner.send::<ScoPacket>(
5524            (packet,),
5525            0,
5526            0x4d4e96f6f7d1aa12,
5527            fidl::encoding::DynamicFlags::FLEXIBLE,
5528        )
5529    }
5530}
5531
5532#[must_use = "FIDL methods require a response to be sent"]
5533#[derive(Debug)]
5534pub struct ScoConnectionSend_Responder {
5535    control_handle: std::mem::ManuallyDrop<ScoConnectionControlHandle>,
5536    tx_id: u32,
5537}
5538
5539/// Set the the channel to be shutdown (see [`ScoConnectionControlHandle::shutdown`])
5540/// if the responder is dropped without sending a response, so that the client
5541/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5542impl std::ops::Drop for ScoConnectionSend_Responder {
5543    fn drop(&mut self) {
5544        self.control_handle.shutdown();
5545        // Safety: drops once, never accessed again
5546        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5547    }
5548}
5549
5550impl fidl::endpoints::Responder for ScoConnectionSend_Responder {
5551    type ControlHandle = ScoConnectionControlHandle;
5552
5553    fn control_handle(&self) -> &ScoConnectionControlHandle {
5554        &self.control_handle
5555    }
5556
5557    fn drop_without_shutdown(mut self) {
5558        // Safety: drops once, never accessed again due to mem::forget
5559        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5560        // Prevent Drop from running (which would shut down the channel)
5561        std::mem::forget(self);
5562    }
5563}
5564
5565impl ScoConnectionSend_Responder {
5566    /// Sends a response to the FIDL transaction.
5567    ///
5568    /// Sets the channel to shutdown if an error occurs.
5569    pub fn send(self) -> Result<(), fidl::Error> {
5570        let _result = self.send_raw();
5571        if _result.is_err() {
5572            self.control_handle.shutdown();
5573        }
5574        self.drop_without_shutdown();
5575        _result
5576    }
5577
5578    /// Similar to "send" but does not shutdown the channel if an error occurs.
5579    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
5580        let _result = self.send_raw();
5581        self.drop_without_shutdown();
5582        _result
5583    }
5584
5585    fn send_raw(&self) -> Result<(), fidl::Error> {
5586        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
5587            fidl::encoding::Flexible::new(()),
5588            self.tx_id,
5589            0x6e0c000ccd50adec,
5590            fidl::encoding::DynamicFlags::FLEXIBLE,
5591        )
5592    }
5593}
5594
5595#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5596pub struct SnoopMarker;
5597
5598impl fidl::endpoints::ProtocolMarker for SnoopMarker {
5599    type Proxy = SnoopProxy;
5600    type RequestStream = SnoopRequestStream;
5601    #[cfg(target_os = "fuchsia")]
5602    type SynchronousProxy = SnoopSynchronousProxy;
5603
5604    const DEBUG_NAME: &'static str = "(anonymous) Snoop";
5605}
5606
5607pub trait SnoopProxyInterface: Send + Sync {
5608    fn r#acknowledge_packets(&self, sequence: u64) -> Result<(), fidl::Error>;
5609}
5610#[derive(Debug)]
5611#[cfg(target_os = "fuchsia")]
5612pub struct SnoopSynchronousProxy {
5613    client: fidl::client::sync::Client,
5614}
5615
5616#[cfg(target_os = "fuchsia")]
5617impl fidl::endpoints::SynchronousProxy for SnoopSynchronousProxy {
5618    type Proxy = SnoopProxy;
5619    type Protocol = SnoopMarker;
5620
5621    fn from_channel(inner: fidl::Channel) -> Self {
5622        Self::new(inner)
5623    }
5624
5625    fn into_channel(self) -> fidl::Channel {
5626        self.client.into_channel()
5627    }
5628
5629    fn as_channel(&self) -> &fidl::Channel {
5630        self.client.as_channel()
5631    }
5632}
5633
5634#[cfg(target_os = "fuchsia")]
5635impl SnoopSynchronousProxy {
5636    pub fn new(channel: fidl::Channel) -> Self {
5637        let protocol_name = <SnoopMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5638        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5639    }
5640
5641    pub fn into_channel(self) -> fidl::Channel {
5642        self.client.into_channel()
5643    }
5644
5645    /// Waits until an event arrives and returns it. It is safe for other
5646    /// threads to make concurrent requests while waiting for an event.
5647    pub fn wait_for_event(
5648        &self,
5649        deadline: zx::MonotonicInstant,
5650    ) -> Result<SnoopEvent, fidl::Error> {
5651        SnoopEvent::decode(self.client.wait_for_event(deadline)?)
5652    }
5653
5654    /// Acknowledge packets have been received up to `sequence`.
5655    pub fn r#acknowledge_packets(&self, mut sequence: u64) -> Result<(), fidl::Error> {
5656        self.client.send::<SnoopAcknowledgePacketsRequest>(
5657            (sequence,),
5658            0x3336b5082c111286,
5659            fidl::encoding::DynamicFlags::FLEXIBLE,
5660        )
5661    }
5662}
5663
5664#[cfg(target_os = "fuchsia")]
5665impl From<SnoopSynchronousProxy> for zx::Handle {
5666    fn from(value: SnoopSynchronousProxy) -> Self {
5667        value.into_channel().into()
5668    }
5669}
5670
5671#[cfg(target_os = "fuchsia")]
5672impl From<fidl::Channel> for SnoopSynchronousProxy {
5673    fn from(value: fidl::Channel) -> Self {
5674        Self::new(value)
5675    }
5676}
5677
5678#[cfg(target_os = "fuchsia")]
5679impl fidl::endpoints::FromClient for SnoopSynchronousProxy {
5680    type Protocol = SnoopMarker;
5681
5682    fn from_client(value: fidl::endpoints::ClientEnd<SnoopMarker>) -> Self {
5683        Self::new(value.into_channel())
5684    }
5685}
5686
5687#[derive(Debug, Clone)]
5688pub struct SnoopProxy {
5689    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5690}
5691
5692impl fidl::endpoints::Proxy for SnoopProxy {
5693    type Protocol = SnoopMarker;
5694
5695    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5696        Self::new(inner)
5697    }
5698
5699    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5700        self.client.into_channel().map_err(|client| Self { client })
5701    }
5702
5703    fn as_channel(&self) -> &::fidl::AsyncChannel {
5704        self.client.as_channel()
5705    }
5706}
5707
5708impl SnoopProxy {
5709    /// Create a new Proxy for fuchsia.hardware.bluetooth/Snoop.
5710    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5711        let protocol_name = <SnoopMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5712        Self { client: fidl::client::Client::new(channel, protocol_name) }
5713    }
5714
5715    /// Get a Stream of events from the remote end of the protocol.
5716    ///
5717    /// # Panics
5718    ///
5719    /// Panics if the event stream was already taken.
5720    pub fn take_event_stream(&self) -> SnoopEventStream {
5721        SnoopEventStream { event_receiver: self.client.take_event_receiver() }
5722    }
5723
5724    /// Acknowledge packets have been received up to `sequence`.
5725    pub fn r#acknowledge_packets(&self, mut sequence: u64) -> Result<(), fidl::Error> {
5726        SnoopProxyInterface::r#acknowledge_packets(self, sequence)
5727    }
5728}
5729
5730impl SnoopProxyInterface for SnoopProxy {
5731    fn r#acknowledge_packets(&self, mut sequence: u64) -> Result<(), fidl::Error> {
5732        self.client.send::<SnoopAcknowledgePacketsRequest>(
5733            (sequence,),
5734            0x3336b5082c111286,
5735            fidl::encoding::DynamicFlags::FLEXIBLE,
5736        )
5737    }
5738}
5739
5740pub struct SnoopEventStream {
5741    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5742}
5743
5744impl std::marker::Unpin for SnoopEventStream {}
5745
5746impl futures::stream::FusedStream for SnoopEventStream {
5747    fn is_terminated(&self) -> bool {
5748        self.event_receiver.is_terminated()
5749    }
5750}
5751
5752impl futures::Stream for SnoopEventStream {
5753    type Item = Result<SnoopEvent, fidl::Error>;
5754
5755    fn poll_next(
5756        mut self: std::pin::Pin<&mut Self>,
5757        cx: &mut std::task::Context<'_>,
5758    ) -> std::task::Poll<Option<Self::Item>> {
5759        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5760            &mut self.event_receiver,
5761            cx
5762        )?) {
5763            Some(buf) => std::task::Poll::Ready(Some(SnoopEvent::decode(buf))),
5764            None => std::task::Poll::Ready(None),
5765        }
5766    }
5767}
5768
5769#[derive(Debug)]
5770pub enum SnoopEvent {
5771    OnObservePacket {
5772        payload: SnoopOnObservePacketRequest,
5773    },
5774    OnDroppedPackets {
5775        payload: SnoopOnDroppedPacketsRequest,
5776    },
5777    #[non_exhaustive]
5778    _UnknownEvent {
5779        /// Ordinal of the event that was sent.
5780        ordinal: u64,
5781    },
5782}
5783
5784impl SnoopEvent {
5785    #[allow(irrefutable_let_patterns)]
5786    pub fn into_on_observe_packet(self) -> Option<SnoopOnObservePacketRequest> {
5787        if let SnoopEvent::OnObservePacket { payload } = self { Some((payload)) } else { None }
5788    }
5789    #[allow(irrefutable_let_patterns)]
5790    pub fn into_on_dropped_packets(self) -> Option<SnoopOnDroppedPacketsRequest> {
5791        if let SnoopEvent::OnDroppedPackets { payload } = self { Some((payload)) } else { None }
5792    }
5793
5794    /// Decodes a message buffer as a [`SnoopEvent`].
5795    fn decode(
5796        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5797    ) -> Result<SnoopEvent, fidl::Error> {
5798        let (bytes, _handles) = buf.split_mut();
5799        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5800        debug_assert_eq!(tx_header.tx_id, 0);
5801        match tx_header.ordinal {
5802            0x34d9f4c9c6bc10ca => {
5803                let mut out = fidl::new_empty!(
5804                    SnoopOnObservePacketRequest,
5805                    fidl::encoding::DefaultFuchsiaResourceDialect
5806                );
5807                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SnoopOnObservePacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
5808                Ok((SnoopEvent::OnObservePacket { payload: out }))
5809            }
5810            0x102a8d21278578b9 => {
5811                let mut out = fidl::new_empty!(
5812                    SnoopOnDroppedPacketsRequest,
5813                    fidl::encoding::DefaultFuchsiaResourceDialect
5814                );
5815                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SnoopOnDroppedPacketsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
5816                Ok((SnoopEvent::OnDroppedPackets { payload: out }))
5817            }
5818            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5819                Ok(SnoopEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5820            }
5821            _ => Err(fidl::Error::UnknownOrdinal {
5822                ordinal: tx_header.ordinal,
5823                protocol_name: <SnoopMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5824            }),
5825        }
5826    }
5827}
5828
5829/// A Stream of incoming requests for fuchsia.hardware.bluetooth/Snoop.
5830pub struct SnoopRequestStream {
5831    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5832    is_terminated: bool,
5833}
5834
5835impl std::marker::Unpin for SnoopRequestStream {}
5836
5837impl futures::stream::FusedStream for SnoopRequestStream {
5838    fn is_terminated(&self) -> bool {
5839        self.is_terminated
5840    }
5841}
5842
5843impl fidl::endpoints::RequestStream for SnoopRequestStream {
5844    type Protocol = SnoopMarker;
5845    type ControlHandle = SnoopControlHandle;
5846
5847    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5848        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5849    }
5850
5851    fn control_handle(&self) -> Self::ControlHandle {
5852        SnoopControlHandle { inner: self.inner.clone() }
5853    }
5854
5855    fn into_inner(
5856        self,
5857    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5858    {
5859        (self.inner, self.is_terminated)
5860    }
5861
5862    fn from_inner(
5863        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5864        is_terminated: bool,
5865    ) -> Self {
5866        Self { inner, is_terminated }
5867    }
5868}
5869
5870impl futures::Stream for SnoopRequestStream {
5871    type Item = Result<SnoopRequest, fidl::Error>;
5872
5873    fn poll_next(
5874        mut self: std::pin::Pin<&mut Self>,
5875        cx: &mut std::task::Context<'_>,
5876    ) -> std::task::Poll<Option<Self::Item>> {
5877        let this = &mut *self;
5878        if this.inner.check_shutdown(cx) {
5879            this.is_terminated = true;
5880            return std::task::Poll::Ready(None);
5881        }
5882        if this.is_terminated {
5883            panic!("polled SnoopRequestStream after completion");
5884        }
5885        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5886            |bytes, handles| {
5887                match this.inner.channel().read_etc(cx, bytes, handles) {
5888                    std::task::Poll::Ready(Ok(())) => {}
5889                    std::task::Poll::Pending => return std::task::Poll::Pending,
5890                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5891                        this.is_terminated = true;
5892                        return std::task::Poll::Ready(None);
5893                    }
5894                    std::task::Poll::Ready(Err(e)) => {
5895                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5896                            e.into(),
5897                        ))));
5898                    }
5899                }
5900
5901                // A message has been received from the channel
5902                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5903
5904                std::task::Poll::Ready(Some(match header.ordinal {
5905                    0x3336b5082c111286 => {
5906                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5907                        let mut req = fidl::new_empty!(
5908                            SnoopAcknowledgePacketsRequest,
5909                            fidl::encoding::DefaultFuchsiaResourceDialect
5910                        );
5911                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SnoopAcknowledgePacketsRequest>(&header, _body_bytes, handles, &mut req)?;
5912                        let control_handle = SnoopControlHandle { inner: this.inner.clone() };
5913                        Ok(SnoopRequest::AcknowledgePackets {
5914                            sequence: req.sequence,
5915
5916                            control_handle,
5917                        })
5918                    }
5919                    _ if header.tx_id == 0
5920                        && header
5921                            .dynamic_flags()
5922                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5923                    {
5924                        Ok(SnoopRequest::_UnknownMethod {
5925                            ordinal: header.ordinal,
5926                            control_handle: SnoopControlHandle { inner: this.inner.clone() },
5927                            method_type: fidl::MethodType::OneWay,
5928                        })
5929                    }
5930                    _ if header
5931                        .dynamic_flags()
5932                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5933                    {
5934                        this.inner.send_framework_err(
5935                            fidl::encoding::FrameworkErr::UnknownMethod,
5936                            header.tx_id,
5937                            header.ordinal,
5938                            header.dynamic_flags(),
5939                            (bytes, handles),
5940                        )?;
5941                        Ok(SnoopRequest::_UnknownMethod {
5942                            ordinal: header.ordinal,
5943                            control_handle: SnoopControlHandle { inner: this.inner.clone() },
5944                            method_type: fidl::MethodType::TwoWay,
5945                        })
5946                    }
5947                    _ => Err(fidl::Error::UnknownOrdinal {
5948                        ordinal: header.ordinal,
5949                        protocol_name: <SnoopMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5950                    }),
5951                }))
5952            },
5953        )
5954    }
5955}
5956
5957#[derive(Debug)]
5958pub enum SnoopRequest {
5959    /// Acknowledge packets have been received up to `sequence`.
5960    AcknowledgePackets { sequence: u64, control_handle: SnoopControlHandle },
5961    /// An interaction was received which does not match any known method.
5962    #[non_exhaustive]
5963    _UnknownMethod {
5964        /// Ordinal of the method that was called.
5965        ordinal: u64,
5966        control_handle: SnoopControlHandle,
5967        method_type: fidl::MethodType,
5968    },
5969}
5970
5971impl SnoopRequest {
5972    #[allow(irrefutable_let_patterns)]
5973    pub fn into_acknowledge_packets(self) -> Option<(u64, SnoopControlHandle)> {
5974        if let SnoopRequest::AcknowledgePackets { sequence, control_handle } = self {
5975            Some((sequence, control_handle))
5976        } else {
5977            None
5978        }
5979    }
5980
5981    /// Name of the method defined in FIDL
5982    pub fn method_name(&self) -> &'static str {
5983        match *self {
5984            SnoopRequest::AcknowledgePackets { .. } => "acknowledge_packets",
5985            SnoopRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
5986                "unknown one-way method"
5987            }
5988            SnoopRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
5989                "unknown two-way method"
5990            }
5991        }
5992    }
5993}
5994
5995#[derive(Debug, Clone)]
5996pub struct SnoopControlHandle {
5997    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5998}
5999
6000impl fidl::endpoints::ControlHandle for SnoopControlHandle {
6001    fn shutdown(&self) {
6002        self.inner.shutdown()
6003    }
6004    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6005        self.inner.shutdown_with_epitaph(status)
6006    }
6007
6008    fn is_closed(&self) -> bool {
6009        self.inner.channel().is_closed()
6010    }
6011    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6012        self.inner.channel().on_closed()
6013    }
6014
6015    #[cfg(target_os = "fuchsia")]
6016    fn signal_peer(
6017        &self,
6018        clear_mask: zx::Signals,
6019        set_mask: zx::Signals,
6020    ) -> Result<(), zx_status::Status> {
6021        use fidl::Peered;
6022        self.inner.channel().signal_peer(clear_mask, set_mask)
6023    }
6024}
6025
6026impl SnoopControlHandle {
6027    pub fn send_on_observe_packet(
6028        &self,
6029        mut payload: &SnoopOnObservePacketRequest,
6030    ) -> Result<(), fidl::Error> {
6031        self.inner.send::<SnoopOnObservePacketRequest>(
6032            payload,
6033            0,
6034            0x34d9f4c9c6bc10ca,
6035            fidl::encoding::DynamicFlags::FLEXIBLE,
6036        )
6037    }
6038
6039    pub fn send_on_dropped_packets(
6040        &self,
6041        mut payload: &SnoopOnDroppedPacketsRequest,
6042    ) -> Result<(), fidl::Error> {
6043        self.inner.send::<SnoopOnDroppedPacketsRequest>(
6044            payload,
6045            0,
6046            0x102a8d21278578b9,
6047            fidl::encoding::DynamicFlags::FLEXIBLE,
6048        )
6049    }
6050}
6051
6052#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6053pub struct VendorMarker;
6054
6055impl fidl::endpoints::ProtocolMarker for VendorMarker {
6056    type Proxy = VendorProxy;
6057    type RequestStream = VendorRequestStream;
6058    #[cfg(target_os = "fuchsia")]
6059    type SynchronousProxy = VendorSynchronousProxy;
6060
6061    const DEBUG_NAME: &'static str = "(anonymous) Vendor";
6062}
6063pub type VendorEncodeCommandResult = Result<Vec<u8>, i32>;
6064pub type VendorOpenHciResult = Result<fidl::endpoints::ClientEnd<HciMarker>, i32>;
6065pub type VendorOpenHciTransportResult = Result<fidl::endpoints::ClientEnd<HciTransportMarker>, i32>;
6066pub type VendorOpenSnoopResult = Result<fidl::endpoints::ClientEnd<SnoopMarker>, i32>;
6067
6068pub trait VendorProxyInterface: Send + Sync {
6069    type GetFeaturesResponseFut: std::future::Future<Output = Result<VendorFeatures, fidl::Error>>
6070        + Send;
6071    fn r#get_features(&self) -> Self::GetFeaturesResponseFut;
6072    type EncodeCommandResponseFut: std::future::Future<Output = Result<VendorEncodeCommandResult, fidl::Error>>
6073        + Send;
6074    fn r#encode_command(&self, payload: &VendorCommand) -> Self::EncodeCommandResponseFut;
6075    type OpenHciResponseFut: std::future::Future<Output = Result<VendorOpenHciResult, fidl::Error>>
6076        + Send;
6077    fn r#open_hci(&self) -> Self::OpenHciResponseFut;
6078    type OpenHciTransportResponseFut: std::future::Future<Output = Result<VendorOpenHciTransportResult, fidl::Error>>
6079        + Send;
6080    fn r#open_hci_transport(&self) -> Self::OpenHciTransportResponseFut;
6081    type OpenSnoopResponseFut: std::future::Future<Output = Result<VendorOpenSnoopResult, fidl::Error>>
6082        + Send;
6083    fn r#open_snoop(&self) -> Self::OpenSnoopResponseFut;
6084}
6085#[derive(Debug)]
6086#[cfg(target_os = "fuchsia")]
6087pub struct VendorSynchronousProxy {
6088    client: fidl::client::sync::Client,
6089}
6090
6091#[cfg(target_os = "fuchsia")]
6092impl fidl::endpoints::SynchronousProxy for VendorSynchronousProxy {
6093    type Proxy = VendorProxy;
6094    type Protocol = VendorMarker;
6095
6096    fn from_channel(inner: fidl::Channel) -> Self {
6097        Self::new(inner)
6098    }
6099
6100    fn into_channel(self) -> fidl::Channel {
6101        self.client.into_channel()
6102    }
6103
6104    fn as_channel(&self) -> &fidl::Channel {
6105        self.client.as_channel()
6106    }
6107}
6108
6109#[cfg(target_os = "fuchsia")]
6110impl VendorSynchronousProxy {
6111    pub fn new(channel: fidl::Channel) -> Self {
6112        let protocol_name = <VendorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6113        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6114    }
6115
6116    pub fn into_channel(self) -> fidl::Channel {
6117        self.client.into_channel()
6118    }
6119
6120    /// Waits until an event arrives and returns it. It is safe for other
6121    /// threads to make concurrent requests while waiting for an event.
6122    pub fn wait_for_event(
6123        &self,
6124        deadline: zx::MonotonicInstant,
6125    ) -> Result<VendorEvent, fidl::Error> {
6126        VendorEvent::decode(self.client.wait_for_event(deadline)?)
6127    }
6128
6129    /// Returns the Vendor Features supported by this controller.
6130    pub fn r#get_features(
6131        &self,
6132        ___deadline: zx::MonotonicInstant,
6133    ) -> Result<VendorFeatures, fidl::Error> {
6134        let _response = self.client.send_query::<
6135            fidl::encoding::EmptyPayload,
6136            fidl::encoding::FlexibleType<VendorFeatures>,
6137        >(
6138            (),
6139            0x102e70164c1dc911,
6140            fidl::encoding::DynamicFlags::FLEXIBLE,
6141            ___deadline,
6142        )?
6143        .into_result::<VendorMarker>("get_features")?;
6144        Ok(_response)
6145    }
6146
6147    /// Encode the vendor HCI command and return the encoded command.
6148    /// See `VendorCommand` for possible commands and parameters.
6149    /// * error `ZX_ERR_NOT_SUPPORTED` The command is not supported.
6150    /// * error `ZX_ERR_INVALID_ARGS` The parameters of the command are invalid.
6151    pub fn r#encode_command(
6152        &self,
6153        mut payload: &VendorCommand,
6154        ___deadline: zx::MonotonicInstant,
6155    ) -> Result<VendorEncodeCommandResult, fidl::Error> {
6156        let _response = self.client.send_query::<
6157            VendorCommand,
6158            fidl::encoding::FlexibleResultType<VendorEncodeCommandResponse, i32>,
6159        >(
6160            payload,
6161            0x75430542c197cbe8,
6162            fidl::encoding::DynamicFlags::FLEXIBLE,
6163            ___deadline,
6164        )?
6165        .into_result::<VendorMarker>("encode_command")?;
6166        Ok(_response.map(|x| x.encoded))
6167    }
6168
6169    /// Deprecated.
6170    /// Open the HCI protocol to the controller.  This call may block until the
6171    /// controller has been initialized.
6172    /// Returns ALREADY_BOUND if another client has already connected.
6173    pub fn r#open_hci(
6174        &self,
6175        ___deadline: zx::MonotonicInstant,
6176    ) -> Result<VendorOpenHciResult, fidl::Error> {
6177        let _response = self.client.send_query::<
6178            fidl::encoding::EmptyPayload,
6179            fidl::encoding::FlexibleResultType<VendorOpenHciResponse, i32>,
6180        >(
6181            (),
6182            0x7f05862f7ef92ec8,
6183            fidl::encoding::DynamicFlags::FLEXIBLE,
6184            ___deadline,
6185        )?
6186        .into_result::<VendorMarker>("open_hci")?;
6187        Ok(_response.map(|x| x.channel))
6188    }
6189
6190    /// Open the HciTransport 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_transport(
6194        &self,
6195        ___deadline: zx::MonotonicInstant,
6196    ) -> Result<VendorOpenHciTransportResult, fidl::Error> {
6197        let _response = self.client.send_query::<
6198            fidl::encoding::EmptyPayload,
6199            fidl::encoding::FlexibleResultType<VendorOpenHciTransportResponse, i32>,
6200        >(
6201            (),
6202            0x1f785b656fb00834,
6203            fidl::encoding::DynamicFlags::FLEXIBLE,
6204            ___deadline,
6205        )?
6206        .into_result::<VendorMarker>("open_hci_transport")?;
6207        Ok(_response.map(|x| x.channel))
6208    }
6209
6210    /// Open the Snoop protocol to the transport driver.
6211    /// Returns ALREADY_BOUND if another client has already connected.
6212    pub fn r#open_snoop(
6213        &self,
6214        ___deadline: zx::MonotonicInstant,
6215    ) -> Result<VendorOpenSnoopResult, fidl::Error> {
6216        let _response = self.client.send_query::<
6217            fidl::encoding::EmptyPayload,
6218            fidl::encoding::FlexibleResultType<VendorOpenSnoopResponse, i32>,
6219        >(
6220            (),
6221            0xafeca0e3c789043,
6222            fidl::encoding::DynamicFlags::FLEXIBLE,
6223            ___deadline,
6224        )?
6225        .into_result::<VendorMarker>("open_snoop")?;
6226        Ok(_response.map(|x| x.channel))
6227    }
6228}
6229
6230#[cfg(target_os = "fuchsia")]
6231impl From<VendorSynchronousProxy> for zx::Handle {
6232    fn from(value: VendorSynchronousProxy) -> Self {
6233        value.into_channel().into()
6234    }
6235}
6236
6237#[cfg(target_os = "fuchsia")]
6238impl From<fidl::Channel> for VendorSynchronousProxy {
6239    fn from(value: fidl::Channel) -> Self {
6240        Self::new(value)
6241    }
6242}
6243
6244#[cfg(target_os = "fuchsia")]
6245impl fidl::endpoints::FromClient for VendorSynchronousProxy {
6246    type Protocol = VendorMarker;
6247
6248    fn from_client(value: fidl::endpoints::ClientEnd<VendorMarker>) -> Self {
6249        Self::new(value.into_channel())
6250    }
6251}
6252
6253#[derive(Debug, Clone)]
6254pub struct VendorProxy {
6255    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6256}
6257
6258impl fidl::endpoints::Proxy for VendorProxy {
6259    type Protocol = VendorMarker;
6260
6261    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6262        Self::new(inner)
6263    }
6264
6265    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6266        self.client.into_channel().map_err(|client| Self { client })
6267    }
6268
6269    fn as_channel(&self) -> &::fidl::AsyncChannel {
6270        self.client.as_channel()
6271    }
6272}
6273
6274impl VendorProxy {
6275    /// Create a new Proxy for fuchsia.hardware.bluetooth/Vendor.
6276    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6277        let protocol_name = <VendorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6278        Self { client: fidl::client::Client::new(channel, protocol_name) }
6279    }
6280
6281    /// Get a Stream of events from the remote end of the protocol.
6282    ///
6283    /// # Panics
6284    ///
6285    /// Panics if the event stream was already taken.
6286    pub fn take_event_stream(&self) -> VendorEventStream {
6287        VendorEventStream { event_receiver: self.client.take_event_receiver() }
6288    }
6289
6290    /// Returns the Vendor Features supported by this controller.
6291    pub fn r#get_features(
6292        &self,
6293    ) -> fidl::client::QueryResponseFut<VendorFeatures, fidl::encoding::DefaultFuchsiaResourceDialect>
6294    {
6295        VendorProxyInterface::r#get_features(self)
6296    }
6297
6298    /// Encode the vendor HCI command and return the encoded command.
6299    /// See `VendorCommand` for possible commands and parameters.
6300    /// * error `ZX_ERR_NOT_SUPPORTED` The command is not supported.
6301    /// * error `ZX_ERR_INVALID_ARGS` The parameters of the command are invalid.
6302    pub fn r#encode_command(
6303        &self,
6304        mut payload: &VendorCommand,
6305    ) -> fidl::client::QueryResponseFut<
6306        VendorEncodeCommandResult,
6307        fidl::encoding::DefaultFuchsiaResourceDialect,
6308    > {
6309        VendorProxyInterface::r#encode_command(self, payload)
6310    }
6311
6312    /// Deprecated.
6313    /// Open the HCI protocol to the controller.  This call may block until the
6314    /// controller has been initialized.
6315    /// Returns ALREADY_BOUND if another client has already connected.
6316    pub fn r#open_hci(
6317        &self,
6318    ) -> fidl::client::QueryResponseFut<
6319        VendorOpenHciResult,
6320        fidl::encoding::DefaultFuchsiaResourceDialect,
6321    > {
6322        VendorProxyInterface::r#open_hci(self)
6323    }
6324
6325    /// Open the HciTransport protocol to the controller. This call may block until the
6326    /// controller has been initialized.
6327    /// Returns ALREADY_BOUND if another client has already connected.
6328    pub fn r#open_hci_transport(
6329        &self,
6330    ) -> fidl::client::QueryResponseFut<
6331        VendorOpenHciTransportResult,
6332        fidl::encoding::DefaultFuchsiaResourceDialect,
6333    > {
6334        VendorProxyInterface::r#open_hci_transport(self)
6335    }
6336
6337    /// Open the Snoop protocol to the transport driver.
6338    /// Returns ALREADY_BOUND if another client has already connected.
6339    pub fn r#open_snoop(
6340        &self,
6341    ) -> fidl::client::QueryResponseFut<
6342        VendorOpenSnoopResult,
6343        fidl::encoding::DefaultFuchsiaResourceDialect,
6344    > {
6345        VendorProxyInterface::r#open_snoop(self)
6346    }
6347}
6348
6349impl VendorProxyInterface for VendorProxy {
6350    type GetFeaturesResponseFut = fidl::client::QueryResponseFut<
6351        VendorFeatures,
6352        fidl::encoding::DefaultFuchsiaResourceDialect,
6353    >;
6354    fn r#get_features(&self) -> Self::GetFeaturesResponseFut {
6355        fn _decode(
6356            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6357        ) -> Result<VendorFeatures, fidl::Error> {
6358            let _response = fidl::client::decode_transaction_body::<
6359                fidl::encoding::FlexibleType<VendorFeatures>,
6360                fidl::encoding::DefaultFuchsiaResourceDialect,
6361                0x102e70164c1dc911,
6362            >(_buf?)?
6363            .into_result::<VendorMarker>("get_features")?;
6364            Ok(_response)
6365        }
6366        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, VendorFeatures>(
6367            (),
6368            0x102e70164c1dc911,
6369            fidl::encoding::DynamicFlags::FLEXIBLE,
6370            _decode,
6371        )
6372    }
6373
6374    type EncodeCommandResponseFut = fidl::client::QueryResponseFut<
6375        VendorEncodeCommandResult,
6376        fidl::encoding::DefaultFuchsiaResourceDialect,
6377    >;
6378    fn r#encode_command(&self, mut payload: &VendorCommand) -> Self::EncodeCommandResponseFut {
6379        fn _decode(
6380            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6381        ) -> Result<VendorEncodeCommandResult, fidl::Error> {
6382            let _response = fidl::client::decode_transaction_body::<
6383                fidl::encoding::FlexibleResultType<VendorEncodeCommandResponse, i32>,
6384                fidl::encoding::DefaultFuchsiaResourceDialect,
6385                0x75430542c197cbe8,
6386            >(_buf?)?
6387            .into_result::<VendorMarker>("encode_command")?;
6388            Ok(_response.map(|x| x.encoded))
6389        }
6390        self.client.send_query_and_decode::<VendorCommand, VendorEncodeCommandResult>(
6391            payload,
6392            0x75430542c197cbe8,
6393            fidl::encoding::DynamicFlags::FLEXIBLE,
6394            _decode,
6395        )
6396    }
6397
6398    type OpenHciResponseFut = fidl::client::QueryResponseFut<
6399        VendorOpenHciResult,
6400        fidl::encoding::DefaultFuchsiaResourceDialect,
6401    >;
6402    fn r#open_hci(&self) -> Self::OpenHciResponseFut {
6403        fn _decode(
6404            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6405        ) -> Result<VendorOpenHciResult, fidl::Error> {
6406            let _response = fidl::client::decode_transaction_body::<
6407                fidl::encoding::FlexibleResultType<VendorOpenHciResponse, i32>,
6408                fidl::encoding::DefaultFuchsiaResourceDialect,
6409                0x7f05862f7ef92ec8,
6410            >(_buf?)?
6411            .into_result::<VendorMarker>("open_hci")?;
6412            Ok(_response.map(|x| x.channel))
6413        }
6414        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, VendorOpenHciResult>(
6415            (),
6416            0x7f05862f7ef92ec8,
6417            fidl::encoding::DynamicFlags::FLEXIBLE,
6418            _decode,
6419        )
6420    }
6421
6422    type OpenHciTransportResponseFut = fidl::client::QueryResponseFut<
6423        VendorOpenHciTransportResult,
6424        fidl::encoding::DefaultFuchsiaResourceDialect,
6425    >;
6426    fn r#open_hci_transport(&self) -> Self::OpenHciTransportResponseFut {
6427        fn _decode(
6428            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6429        ) -> Result<VendorOpenHciTransportResult, fidl::Error> {
6430            let _response = fidl::client::decode_transaction_body::<
6431                fidl::encoding::FlexibleResultType<VendorOpenHciTransportResponse, i32>,
6432                fidl::encoding::DefaultFuchsiaResourceDialect,
6433                0x1f785b656fb00834,
6434            >(_buf?)?
6435            .into_result::<VendorMarker>("open_hci_transport")?;
6436            Ok(_response.map(|x| x.channel))
6437        }
6438        self.client
6439            .send_query_and_decode::<fidl::encoding::EmptyPayload, VendorOpenHciTransportResult>(
6440                (),
6441                0x1f785b656fb00834,
6442                fidl::encoding::DynamicFlags::FLEXIBLE,
6443                _decode,
6444            )
6445    }
6446
6447    type OpenSnoopResponseFut = fidl::client::QueryResponseFut<
6448        VendorOpenSnoopResult,
6449        fidl::encoding::DefaultFuchsiaResourceDialect,
6450    >;
6451    fn r#open_snoop(&self) -> Self::OpenSnoopResponseFut {
6452        fn _decode(
6453            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6454        ) -> Result<VendorOpenSnoopResult, fidl::Error> {
6455            let _response = fidl::client::decode_transaction_body::<
6456                fidl::encoding::FlexibleResultType<VendorOpenSnoopResponse, i32>,
6457                fidl::encoding::DefaultFuchsiaResourceDialect,
6458                0xafeca0e3c789043,
6459            >(_buf?)?
6460            .into_result::<VendorMarker>("open_snoop")?;
6461            Ok(_response.map(|x| x.channel))
6462        }
6463        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, VendorOpenSnoopResult>(
6464            (),
6465            0xafeca0e3c789043,
6466            fidl::encoding::DynamicFlags::FLEXIBLE,
6467            _decode,
6468        )
6469    }
6470}
6471
6472pub struct VendorEventStream {
6473    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6474}
6475
6476impl std::marker::Unpin for VendorEventStream {}
6477
6478impl futures::stream::FusedStream for VendorEventStream {
6479    fn is_terminated(&self) -> bool {
6480        self.event_receiver.is_terminated()
6481    }
6482}
6483
6484impl futures::Stream for VendorEventStream {
6485    type Item = Result<VendorEvent, fidl::Error>;
6486
6487    fn poll_next(
6488        mut self: std::pin::Pin<&mut Self>,
6489        cx: &mut std::task::Context<'_>,
6490    ) -> std::task::Poll<Option<Self::Item>> {
6491        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6492            &mut self.event_receiver,
6493            cx
6494        )?) {
6495            Some(buf) => std::task::Poll::Ready(Some(VendorEvent::decode(buf))),
6496            None => std::task::Poll::Ready(None),
6497        }
6498    }
6499}
6500
6501#[derive(Debug)]
6502pub enum VendorEvent {
6503    #[non_exhaustive]
6504    _UnknownEvent {
6505        /// Ordinal of the event that was sent.
6506        ordinal: u64,
6507    },
6508}
6509
6510impl VendorEvent {
6511    /// Decodes a message buffer as a [`VendorEvent`].
6512    fn decode(
6513        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6514    ) -> Result<VendorEvent, fidl::Error> {
6515        let (bytes, _handles) = buf.split_mut();
6516        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6517        debug_assert_eq!(tx_header.tx_id, 0);
6518        match tx_header.ordinal {
6519            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
6520                Ok(VendorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
6521            }
6522            _ => Err(fidl::Error::UnknownOrdinal {
6523                ordinal: tx_header.ordinal,
6524                protocol_name: <VendorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6525            }),
6526        }
6527    }
6528}
6529
6530/// A Stream of incoming requests for fuchsia.hardware.bluetooth/Vendor.
6531pub struct VendorRequestStream {
6532    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6533    is_terminated: bool,
6534}
6535
6536impl std::marker::Unpin for VendorRequestStream {}
6537
6538impl futures::stream::FusedStream for VendorRequestStream {
6539    fn is_terminated(&self) -> bool {
6540        self.is_terminated
6541    }
6542}
6543
6544impl fidl::endpoints::RequestStream for VendorRequestStream {
6545    type Protocol = VendorMarker;
6546    type ControlHandle = VendorControlHandle;
6547
6548    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6549        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6550    }
6551
6552    fn control_handle(&self) -> Self::ControlHandle {
6553        VendorControlHandle { inner: self.inner.clone() }
6554    }
6555
6556    fn into_inner(
6557        self,
6558    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6559    {
6560        (self.inner, self.is_terminated)
6561    }
6562
6563    fn from_inner(
6564        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6565        is_terminated: bool,
6566    ) -> Self {
6567        Self { inner, is_terminated }
6568    }
6569}
6570
6571impl futures::Stream for VendorRequestStream {
6572    type Item = Result<VendorRequest, fidl::Error>;
6573
6574    fn poll_next(
6575        mut self: std::pin::Pin<&mut Self>,
6576        cx: &mut std::task::Context<'_>,
6577    ) -> std::task::Poll<Option<Self::Item>> {
6578        let this = &mut *self;
6579        if this.inner.check_shutdown(cx) {
6580            this.is_terminated = true;
6581            return std::task::Poll::Ready(None);
6582        }
6583        if this.is_terminated {
6584            panic!("polled VendorRequestStream after completion");
6585        }
6586        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6587            |bytes, handles| {
6588                match this.inner.channel().read_etc(cx, bytes, handles) {
6589                    std::task::Poll::Ready(Ok(())) => {}
6590                    std::task::Poll::Pending => return std::task::Poll::Pending,
6591                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6592                        this.is_terminated = true;
6593                        return std::task::Poll::Ready(None);
6594                    }
6595                    std::task::Poll::Ready(Err(e)) => {
6596                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6597                            e.into(),
6598                        ))));
6599                    }
6600                }
6601
6602                // A message has been received from the channel
6603                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6604
6605                std::task::Poll::Ready(Some(match header.ordinal {
6606                    0x102e70164c1dc911 => {
6607                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6608                        let mut req = fidl::new_empty!(
6609                            fidl::encoding::EmptyPayload,
6610                            fidl::encoding::DefaultFuchsiaResourceDialect
6611                        );
6612                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6613                        let control_handle = VendorControlHandle { inner: this.inner.clone() };
6614                        Ok(VendorRequest::GetFeatures {
6615                            responder: VendorGetFeaturesResponder {
6616                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6617                                tx_id: header.tx_id,
6618                            },
6619                        })
6620                    }
6621                    0x75430542c197cbe8 => {
6622                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6623                        let mut req = fidl::new_empty!(
6624                            VendorCommand,
6625                            fidl::encoding::DefaultFuchsiaResourceDialect
6626                        );
6627                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VendorCommand>(&header, _body_bytes, handles, &mut req)?;
6628                        let control_handle = VendorControlHandle { inner: this.inner.clone() };
6629                        Ok(VendorRequest::EncodeCommand {
6630                            payload: req,
6631                            responder: VendorEncodeCommandResponder {
6632                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6633                                tx_id: header.tx_id,
6634                            },
6635                        })
6636                    }
6637                    0x7f05862f7ef92ec8 => {
6638                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6639                        let mut req = fidl::new_empty!(
6640                            fidl::encoding::EmptyPayload,
6641                            fidl::encoding::DefaultFuchsiaResourceDialect
6642                        );
6643                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6644                        let control_handle = VendorControlHandle { inner: this.inner.clone() };
6645                        Ok(VendorRequest::OpenHci {
6646                            responder: VendorOpenHciResponder {
6647                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6648                                tx_id: header.tx_id,
6649                            },
6650                        })
6651                    }
6652                    0x1f785b656fb00834 => {
6653                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6654                        let mut req = fidl::new_empty!(
6655                            fidl::encoding::EmptyPayload,
6656                            fidl::encoding::DefaultFuchsiaResourceDialect
6657                        );
6658                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6659                        let control_handle = VendorControlHandle { inner: this.inner.clone() };
6660                        Ok(VendorRequest::OpenHciTransport {
6661                            responder: VendorOpenHciTransportResponder {
6662                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6663                                tx_id: header.tx_id,
6664                            },
6665                        })
6666                    }
6667                    0xafeca0e3c789043 => {
6668                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6669                        let mut req = fidl::new_empty!(
6670                            fidl::encoding::EmptyPayload,
6671                            fidl::encoding::DefaultFuchsiaResourceDialect
6672                        );
6673                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6674                        let control_handle = VendorControlHandle { inner: this.inner.clone() };
6675                        Ok(VendorRequest::OpenSnoop {
6676                            responder: VendorOpenSnoopResponder {
6677                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6678                                tx_id: header.tx_id,
6679                            },
6680                        })
6681                    }
6682                    _ if header.tx_id == 0
6683                        && header
6684                            .dynamic_flags()
6685                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6686                    {
6687                        Ok(VendorRequest::_UnknownMethod {
6688                            ordinal: header.ordinal,
6689                            control_handle: VendorControlHandle { inner: this.inner.clone() },
6690                            method_type: fidl::MethodType::OneWay,
6691                        })
6692                    }
6693                    _ if header
6694                        .dynamic_flags()
6695                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6696                    {
6697                        this.inner.send_framework_err(
6698                            fidl::encoding::FrameworkErr::UnknownMethod,
6699                            header.tx_id,
6700                            header.ordinal,
6701                            header.dynamic_flags(),
6702                            (bytes, handles),
6703                        )?;
6704                        Ok(VendorRequest::_UnknownMethod {
6705                            ordinal: header.ordinal,
6706                            control_handle: VendorControlHandle { inner: this.inner.clone() },
6707                            method_type: fidl::MethodType::TwoWay,
6708                        })
6709                    }
6710                    _ => Err(fidl::Error::UnknownOrdinal {
6711                        ordinal: header.ordinal,
6712                        protocol_name:
6713                            <VendorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6714                    }),
6715                }))
6716            },
6717        )
6718    }
6719}
6720
6721/// The BtVendor protocol may be implemented by vendor drivers to support feature interrogation
6722/// and vendor command encoding.
6723#[derive(Debug)]
6724pub enum VendorRequest {
6725    /// Returns the Vendor Features supported by this controller.
6726    GetFeatures { responder: VendorGetFeaturesResponder },
6727    /// Encode the vendor HCI command and return the encoded command.
6728    /// See `VendorCommand` for possible commands and parameters.
6729    /// * error `ZX_ERR_NOT_SUPPORTED` The command is not supported.
6730    /// * error `ZX_ERR_INVALID_ARGS` The parameters of the command are invalid.
6731    EncodeCommand { payload: VendorCommand, responder: VendorEncodeCommandResponder },
6732    /// Deprecated.
6733    /// Open the HCI protocol to the controller.  This call may block until the
6734    /// controller has been initialized.
6735    /// Returns ALREADY_BOUND if another client has already connected.
6736    OpenHci { responder: VendorOpenHciResponder },
6737    /// Open the HciTransport protocol to the controller. This call may block until the
6738    /// controller has been initialized.
6739    /// Returns ALREADY_BOUND if another client has already connected.
6740    OpenHciTransport { responder: VendorOpenHciTransportResponder },
6741    /// Open the Snoop protocol to the transport driver.
6742    /// Returns ALREADY_BOUND if another client has already connected.
6743    OpenSnoop { responder: VendorOpenSnoopResponder },
6744    /// An interaction was received which does not match any known method.
6745    #[non_exhaustive]
6746    _UnknownMethod {
6747        /// Ordinal of the method that was called.
6748        ordinal: u64,
6749        control_handle: VendorControlHandle,
6750        method_type: fidl::MethodType,
6751    },
6752}
6753
6754impl VendorRequest {
6755    #[allow(irrefutable_let_patterns)]
6756    pub fn into_get_features(self) -> Option<(VendorGetFeaturesResponder)> {
6757        if let VendorRequest::GetFeatures { responder } = self { Some((responder)) } else { None }
6758    }
6759
6760    #[allow(irrefutable_let_patterns)]
6761    pub fn into_encode_command(self) -> Option<(VendorCommand, VendorEncodeCommandResponder)> {
6762        if let VendorRequest::EncodeCommand { payload, responder } = self {
6763            Some((payload, responder))
6764        } else {
6765            None
6766        }
6767    }
6768
6769    #[allow(irrefutable_let_patterns)]
6770    pub fn into_open_hci(self) -> Option<(VendorOpenHciResponder)> {
6771        if let VendorRequest::OpenHci { responder } = self { Some((responder)) } else { None }
6772    }
6773
6774    #[allow(irrefutable_let_patterns)]
6775    pub fn into_open_hci_transport(self) -> Option<(VendorOpenHciTransportResponder)> {
6776        if let VendorRequest::OpenHciTransport { responder } = self {
6777            Some((responder))
6778        } else {
6779            None
6780        }
6781    }
6782
6783    #[allow(irrefutable_let_patterns)]
6784    pub fn into_open_snoop(self) -> Option<(VendorOpenSnoopResponder)> {
6785        if let VendorRequest::OpenSnoop { responder } = self { Some((responder)) } else { None }
6786    }
6787
6788    /// Name of the method defined in FIDL
6789    pub fn method_name(&self) -> &'static str {
6790        match *self {
6791            VendorRequest::GetFeatures { .. } => "get_features",
6792            VendorRequest::EncodeCommand { .. } => "encode_command",
6793            VendorRequest::OpenHci { .. } => "open_hci",
6794            VendorRequest::OpenHciTransport { .. } => "open_hci_transport",
6795            VendorRequest::OpenSnoop { .. } => "open_snoop",
6796            VendorRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
6797                "unknown one-way method"
6798            }
6799            VendorRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
6800                "unknown two-way method"
6801            }
6802        }
6803    }
6804}
6805
6806#[derive(Debug, Clone)]
6807pub struct VendorControlHandle {
6808    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6809}
6810
6811impl fidl::endpoints::ControlHandle for VendorControlHandle {
6812    fn shutdown(&self) {
6813        self.inner.shutdown()
6814    }
6815    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6816        self.inner.shutdown_with_epitaph(status)
6817    }
6818
6819    fn is_closed(&self) -> bool {
6820        self.inner.channel().is_closed()
6821    }
6822    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6823        self.inner.channel().on_closed()
6824    }
6825
6826    #[cfg(target_os = "fuchsia")]
6827    fn signal_peer(
6828        &self,
6829        clear_mask: zx::Signals,
6830        set_mask: zx::Signals,
6831    ) -> Result<(), zx_status::Status> {
6832        use fidl::Peered;
6833        self.inner.channel().signal_peer(clear_mask, set_mask)
6834    }
6835}
6836
6837impl VendorControlHandle {}
6838
6839#[must_use = "FIDL methods require a response to be sent"]
6840#[derive(Debug)]
6841pub struct VendorGetFeaturesResponder {
6842    control_handle: std::mem::ManuallyDrop<VendorControlHandle>,
6843    tx_id: u32,
6844}
6845
6846/// Set the the channel to be shutdown (see [`VendorControlHandle::shutdown`])
6847/// if the responder is dropped without sending a response, so that the client
6848/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6849impl std::ops::Drop for VendorGetFeaturesResponder {
6850    fn drop(&mut self) {
6851        self.control_handle.shutdown();
6852        // Safety: drops once, never accessed again
6853        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6854    }
6855}
6856
6857impl fidl::endpoints::Responder for VendorGetFeaturesResponder {
6858    type ControlHandle = VendorControlHandle;
6859
6860    fn control_handle(&self) -> &VendorControlHandle {
6861        &self.control_handle
6862    }
6863
6864    fn drop_without_shutdown(mut self) {
6865        // Safety: drops once, never accessed again due to mem::forget
6866        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6867        // Prevent Drop from running (which would shut down the channel)
6868        std::mem::forget(self);
6869    }
6870}
6871
6872impl VendorGetFeaturesResponder {
6873    /// Sends a response to the FIDL transaction.
6874    ///
6875    /// Sets the channel to shutdown if an error occurs.
6876    pub fn send(self, mut payload: &VendorFeatures) -> Result<(), fidl::Error> {
6877        let _result = self.send_raw(payload);
6878        if _result.is_err() {
6879            self.control_handle.shutdown();
6880        }
6881        self.drop_without_shutdown();
6882        _result
6883    }
6884
6885    /// Similar to "send" but does not shutdown the channel if an error occurs.
6886    pub fn send_no_shutdown_on_err(self, mut payload: &VendorFeatures) -> Result<(), fidl::Error> {
6887        let _result = self.send_raw(payload);
6888        self.drop_without_shutdown();
6889        _result
6890    }
6891
6892    fn send_raw(&self, mut payload: &VendorFeatures) -> Result<(), fidl::Error> {
6893        self.control_handle.inner.send::<fidl::encoding::FlexibleType<VendorFeatures>>(
6894            fidl::encoding::Flexible::new(payload),
6895            self.tx_id,
6896            0x102e70164c1dc911,
6897            fidl::encoding::DynamicFlags::FLEXIBLE,
6898        )
6899    }
6900}
6901
6902#[must_use = "FIDL methods require a response to be sent"]
6903#[derive(Debug)]
6904pub struct VendorEncodeCommandResponder {
6905    control_handle: std::mem::ManuallyDrop<VendorControlHandle>,
6906    tx_id: u32,
6907}
6908
6909/// Set the the channel to be shutdown (see [`VendorControlHandle::shutdown`])
6910/// if the responder is dropped without sending a response, so that the client
6911/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6912impl std::ops::Drop for VendorEncodeCommandResponder {
6913    fn drop(&mut self) {
6914        self.control_handle.shutdown();
6915        // Safety: drops once, never accessed again
6916        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6917    }
6918}
6919
6920impl fidl::endpoints::Responder for VendorEncodeCommandResponder {
6921    type ControlHandle = VendorControlHandle;
6922
6923    fn control_handle(&self) -> &VendorControlHandle {
6924        &self.control_handle
6925    }
6926
6927    fn drop_without_shutdown(mut self) {
6928        // Safety: drops once, never accessed again due to mem::forget
6929        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6930        // Prevent Drop from running (which would shut down the channel)
6931        std::mem::forget(self);
6932    }
6933}
6934
6935impl VendorEncodeCommandResponder {
6936    /// Sends a response to the FIDL transaction.
6937    ///
6938    /// Sets the channel to shutdown if an error occurs.
6939    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
6940        let _result = self.send_raw(result);
6941        if _result.is_err() {
6942            self.control_handle.shutdown();
6943        }
6944        self.drop_without_shutdown();
6945        _result
6946    }
6947
6948    /// Similar to "send" but does not shutdown the channel if an error occurs.
6949    pub fn send_no_shutdown_on_err(
6950        self,
6951        mut result: Result<&[u8], i32>,
6952    ) -> Result<(), fidl::Error> {
6953        let _result = self.send_raw(result);
6954        self.drop_without_shutdown();
6955        _result
6956    }
6957
6958    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
6959        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6960            VendorEncodeCommandResponse,
6961            i32,
6962        >>(
6963            fidl::encoding::FlexibleResult::new(result.map(|encoded| (encoded,))),
6964            self.tx_id,
6965            0x75430542c197cbe8,
6966            fidl::encoding::DynamicFlags::FLEXIBLE,
6967        )
6968    }
6969}
6970
6971#[must_use = "FIDL methods require a response to be sent"]
6972#[derive(Debug)]
6973pub struct VendorOpenHciResponder {
6974    control_handle: std::mem::ManuallyDrop<VendorControlHandle>,
6975    tx_id: u32,
6976}
6977
6978/// Set the the channel to be shutdown (see [`VendorControlHandle::shutdown`])
6979/// if the responder is dropped without sending a response, so that the client
6980/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6981impl std::ops::Drop for VendorOpenHciResponder {
6982    fn drop(&mut self) {
6983        self.control_handle.shutdown();
6984        // Safety: drops once, never accessed again
6985        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6986    }
6987}
6988
6989impl fidl::endpoints::Responder for VendorOpenHciResponder {
6990    type ControlHandle = VendorControlHandle;
6991
6992    fn control_handle(&self) -> &VendorControlHandle {
6993        &self.control_handle
6994    }
6995
6996    fn drop_without_shutdown(mut self) {
6997        // Safety: drops once, never accessed again due to mem::forget
6998        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6999        // Prevent Drop from running (which would shut down the channel)
7000        std::mem::forget(self);
7001    }
7002}
7003
7004impl VendorOpenHciResponder {
7005    /// Sends a response to the FIDL transaction.
7006    ///
7007    /// Sets the channel to shutdown if an error occurs.
7008    pub fn send(
7009        self,
7010        mut result: Result<fidl::endpoints::ClientEnd<HciMarker>, i32>,
7011    ) -> Result<(), fidl::Error> {
7012        let _result = self.send_raw(result);
7013        if _result.is_err() {
7014            self.control_handle.shutdown();
7015        }
7016        self.drop_without_shutdown();
7017        _result
7018    }
7019
7020    /// Similar to "send" but does not shutdown the channel if an error occurs.
7021    pub fn send_no_shutdown_on_err(
7022        self,
7023        mut result: Result<fidl::endpoints::ClientEnd<HciMarker>, i32>,
7024    ) -> Result<(), fidl::Error> {
7025        let _result = self.send_raw(result);
7026        self.drop_without_shutdown();
7027        _result
7028    }
7029
7030    fn send_raw(
7031        &self,
7032        mut result: Result<fidl::endpoints::ClientEnd<HciMarker>, i32>,
7033    ) -> Result<(), fidl::Error> {
7034        self.control_handle
7035            .inner
7036            .send::<fidl::encoding::FlexibleResultType<VendorOpenHciResponse, i32>>(
7037                fidl::encoding::FlexibleResult::new(result.map(|channel| (channel,))),
7038                self.tx_id,
7039                0x7f05862f7ef92ec8,
7040                fidl::encoding::DynamicFlags::FLEXIBLE,
7041            )
7042    }
7043}
7044
7045#[must_use = "FIDL methods require a response to be sent"]
7046#[derive(Debug)]
7047pub struct VendorOpenHciTransportResponder {
7048    control_handle: std::mem::ManuallyDrop<VendorControlHandle>,
7049    tx_id: u32,
7050}
7051
7052/// Set the the channel to be shutdown (see [`VendorControlHandle::shutdown`])
7053/// if the responder is dropped without sending a response, so that the client
7054/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7055impl std::ops::Drop for VendorOpenHciTransportResponder {
7056    fn drop(&mut self) {
7057        self.control_handle.shutdown();
7058        // Safety: drops once, never accessed again
7059        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7060    }
7061}
7062
7063impl fidl::endpoints::Responder for VendorOpenHciTransportResponder {
7064    type ControlHandle = VendorControlHandle;
7065
7066    fn control_handle(&self) -> &VendorControlHandle {
7067        &self.control_handle
7068    }
7069
7070    fn drop_without_shutdown(mut self) {
7071        // Safety: drops once, never accessed again due to mem::forget
7072        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7073        // Prevent Drop from running (which would shut down the channel)
7074        std::mem::forget(self);
7075    }
7076}
7077
7078impl VendorOpenHciTransportResponder {
7079    /// Sends a response to the FIDL transaction.
7080    ///
7081    /// Sets the channel to shutdown if an error occurs.
7082    pub fn send(
7083        self,
7084        mut result: Result<fidl::endpoints::ClientEnd<HciTransportMarker>, i32>,
7085    ) -> Result<(), fidl::Error> {
7086        let _result = self.send_raw(result);
7087        if _result.is_err() {
7088            self.control_handle.shutdown();
7089        }
7090        self.drop_without_shutdown();
7091        _result
7092    }
7093
7094    /// Similar to "send" but does not shutdown the channel if an error occurs.
7095    pub fn send_no_shutdown_on_err(
7096        self,
7097        mut result: Result<fidl::endpoints::ClientEnd<HciTransportMarker>, i32>,
7098    ) -> Result<(), fidl::Error> {
7099        let _result = self.send_raw(result);
7100        self.drop_without_shutdown();
7101        _result
7102    }
7103
7104    fn send_raw(
7105        &self,
7106        mut result: Result<fidl::endpoints::ClientEnd<HciTransportMarker>, i32>,
7107    ) -> Result<(), fidl::Error> {
7108        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7109            VendorOpenHciTransportResponse,
7110            i32,
7111        >>(
7112            fidl::encoding::FlexibleResult::new(result.map(|channel| (channel,))),
7113            self.tx_id,
7114            0x1f785b656fb00834,
7115            fidl::encoding::DynamicFlags::FLEXIBLE,
7116        )
7117    }
7118}
7119
7120#[must_use = "FIDL methods require a response to be sent"]
7121#[derive(Debug)]
7122pub struct VendorOpenSnoopResponder {
7123    control_handle: std::mem::ManuallyDrop<VendorControlHandle>,
7124    tx_id: u32,
7125}
7126
7127/// Set the the channel to be shutdown (see [`VendorControlHandle::shutdown`])
7128/// if the responder is dropped without sending a response, so that the client
7129/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7130impl std::ops::Drop for VendorOpenSnoopResponder {
7131    fn drop(&mut self) {
7132        self.control_handle.shutdown();
7133        // Safety: drops once, never accessed again
7134        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7135    }
7136}
7137
7138impl fidl::endpoints::Responder for VendorOpenSnoopResponder {
7139    type ControlHandle = VendorControlHandle;
7140
7141    fn control_handle(&self) -> &VendorControlHandle {
7142        &self.control_handle
7143    }
7144
7145    fn drop_without_shutdown(mut self) {
7146        // Safety: drops once, never accessed again due to mem::forget
7147        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7148        // Prevent Drop from running (which would shut down the channel)
7149        std::mem::forget(self);
7150    }
7151}
7152
7153impl VendorOpenSnoopResponder {
7154    /// Sends a response to the FIDL transaction.
7155    ///
7156    /// Sets the channel to shutdown if an error occurs.
7157    pub fn send(
7158        self,
7159        mut result: Result<fidl::endpoints::ClientEnd<SnoopMarker>, i32>,
7160    ) -> Result<(), fidl::Error> {
7161        let _result = self.send_raw(result);
7162        if _result.is_err() {
7163            self.control_handle.shutdown();
7164        }
7165        self.drop_without_shutdown();
7166        _result
7167    }
7168
7169    /// Similar to "send" but does not shutdown the channel if an error occurs.
7170    pub fn send_no_shutdown_on_err(
7171        self,
7172        mut result: Result<fidl::endpoints::ClientEnd<SnoopMarker>, i32>,
7173    ) -> Result<(), fidl::Error> {
7174        let _result = self.send_raw(result);
7175        self.drop_without_shutdown();
7176        _result
7177    }
7178
7179    fn send_raw(
7180        &self,
7181        mut result: Result<fidl::endpoints::ClientEnd<SnoopMarker>, i32>,
7182    ) -> Result<(), fidl::Error> {
7183        self.control_handle
7184            .inner
7185            .send::<fidl::encoding::FlexibleResultType<VendorOpenSnoopResponse, i32>>(
7186                fidl::encoding::FlexibleResult::new(result.map(|channel| (channel,))),
7187                self.tx_id,
7188                0xafeca0e3c789043,
7189                fidl::encoding::DynamicFlags::FLEXIBLE,
7190            )
7191    }
7192}
7193
7194#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7195pub struct VirtualControllerMarker;
7196
7197impl fidl::endpoints::ProtocolMarker for VirtualControllerMarker {
7198    type Proxy = VirtualControllerProxy;
7199    type RequestStream = VirtualControllerRequestStream;
7200    #[cfg(target_os = "fuchsia")]
7201    type SynchronousProxy = VirtualControllerSynchronousProxy;
7202
7203    const DEBUG_NAME: &'static str = "(anonymous) VirtualController";
7204}
7205pub type VirtualControllerCreateEmulatorResult = Result<Option<String>, i32>;
7206
7207pub trait VirtualControllerProxyInterface: Send + Sync {
7208    type CreateEmulatorResponseFut: std::future::Future<Output = Result<VirtualControllerCreateEmulatorResult, fidl::Error>>
7209        + Send;
7210    fn r#create_emulator(&self) -> Self::CreateEmulatorResponseFut;
7211    fn r#create_loopback_device(
7212        &self,
7213        payload: VirtualControllerCreateLoopbackDeviceRequest,
7214    ) -> Result<(), fidl::Error>;
7215}
7216#[derive(Debug)]
7217#[cfg(target_os = "fuchsia")]
7218pub struct VirtualControllerSynchronousProxy {
7219    client: fidl::client::sync::Client,
7220}
7221
7222#[cfg(target_os = "fuchsia")]
7223impl fidl::endpoints::SynchronousProxy for VirtualControllerSynchronousProxy {
7224    type Proxy = VirtualControllerProxy;
7225    type Protocol = VirtualControllerMarker;
7226
7227    fn from_channel(inner: fidl::Channel) -> Self {
7228        Self::new(inner)
7229    }
7230
7231    fn into_channel(self) -> fidl::Channel {
7232        self.client.into_channel()
7233    }
7234
7235    fn as_channel(&self) -> &fidl::Channel {
7236        self.client.as_channel()
7237    }
7238}
7239
7240#[cfg(target_os = "fuchsia")]
7241impl VirtualControllerSynchronousProxy {
7242    pub fn new(channel: fidl::Channel) -> Self {
7243        let protocol_name =
7244            <VirtualControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7245        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7246    }
7247
7248    pub fn into_channel(self) -> fidl::Channel {
7249        self.client.into_channel()
7250    }
7251
7252    /// Waits until an event arrives and returns it. It is safe for other
7253    /// threads to make concurrent requests while waiting for an event.
7254    pub fn wait_for_event(
7255        &self,
7256        deadline: zx::MonotonicInstant,
7257    ) -> Result<VirtualControllerEvent, fidl::Error> {
7258        VirtualControllerEvent::decode(self.client.wait_for_event(deadline)?)
7259    }
7260
7261    /// Creates a child device, and returns the name of the child created.
7262    pub fn r#create_emulator(
7263        &self,
7264        ___deadline: zx::MonotonicInstant,
7265    ) -> Result<VirtualControllerCreateEmulatorResult, fidl::Error> {
7266        let _response = self.client.send_query::<
7267            fidl::encoding::EmptyPayload,
7268            fidl::encoding::FlexibleResultType<VirtualControllerCreateEmulatorResponse, i32>,
7269        >(
7270            (),
7271            0x130273fc0a35cedb,
7272            fidl::encoding::DynamicFlags::FLEXIBLE,
7273            ___deadline,
7274        )?
7275        .into_result::<VirtualControllerMarker>("create_emulator")?;
7276        Ok(_response.map(|x| x.name))
7277    }
7278
7279    /// Creates a virtual Bluetooth serial device, speaking the BT HCI UART
7280    /// protocol on the provided handle.
7281    /// The zircon channel is closed in the event of an error.
7282    pub fn r#create_loopback_device(
7283        &self,
7284        mut payload: VirtualControllerCreateLoopbackDeviceRequest,
7285    ) -> Result<(), fidl::Error> {
7286        self.client.send::<VirtualControllerCreateLoopbackDeviceRequest>(
7287            &mut payload,
7288            0x7525af8edecb6c0c,
7289            fidl::encoding::DynamicFlags::FLEXIBLE,
7290        )
7291    }
7292}
7293
7294#[cfg(target_os = "fuchsia")]
7295impl From<VirtualControllerSynchronousProxy> for zx::Handle {
7296    fn from(value: VirtualControllerSynchronousProxy) -> Self {
7297        value.into_channel().into()
7298    }
7299}
7300
7301#[cfg(target_os = "fuchsia")]
7302impl From<fidl::Channel> for VirtualControllerSynchronousProxy {
7303    fn from(value: fidl::Channel) -> Self {
7304        Self::new(value)
7305    }
7306}
7307
7308#[cfg(target_os = "fuchsia")]
7309impl fidl::endpoints::FromClient for VirtualControllerSynchronousProxy {
7310    type Protocol = VirtualControllerMarker;
7311
7312    fn from_client(value: fidl::endpoints::ClientEnd<VirtualControllerMarker>) -> Self {
7313        Self::new(value.into_channel())
7314    }
7315}
7316
7317#[derive(Debug, Clone)]
7318pub struct VirtualControllerProxy {
7319    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7320}
7321
7322impl fidl::endpoints::Proxy for VirtualControllerProxy {
7323    type Protocol = VirtualControllerMarker;
7324
7325    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7326        Self::new(inner)
7327    }
7328
7329    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7330        self.client.into_channel().map_err(|client| Self { client })
7331    }
7332
7333    fn as_channel(&self) -> &::fidl::AsyncChannel {
7334        self.client.as_channel()
7335    }
7336}
7337
7338impl VirtualControllerProxy {
7339    /// Create a new Proxy for fuchsia.hardware.bluetooth/VirtualController.
7340    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7341        let protocol_name =
7342            <VirtualControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7343        Self { client: fidl::client::Client::new(channel, protocol_name) }
7344    }
7345
7346    /// Get a Stream of events from the remote end of the protocol.
7347    ///
7348    /// # Panics
7349    ///
7350    /// Panics if the event stream was already taken.
7351    pub fn take_event_stream(&self) -> VirtualControllerEventStream {
7352        VirtualControllerEventStream { event_receiver: self.client.take_event_receiver() }
7353    }
7354
7355    /// Creates a child device, and returns the name of the child created.
7356    pub fn r#create_emulator(
7357        &self,
7358    ) -> fidl::client::QueryResponseFut<
7359        VirtualControllerCreateEmulatorResult,
7360        fidl::encoding::DefaultFuchsiaResourceDialect,
7361    > {
7362        VirtualControllerProxyInterface::r#create_emulator(self)
7363    }
7364
7365    /// Creates a virtual Bluetooth serial device, speaking the BT HCI UART
7366    /// protocol on the provided handle.
7367    /// The zircon channel is closed in the event of an error.
7368    pub fn r#create_loopback_device(
7369        &self,
7370        mut payload: VirtualControllerCreateLoopbackDeviceRequest,
7371    ) -> Result<(), fidl::Error> {
7372        VirtualControllerProxyInterface::r#create_loopback_device(self, payload)
7373    }
7374}
7375
7376impl VirtualControllerProxyInterface for VirtualControllerProxy {
7377    type CreateEmulatorResponseFut = fidl::client::QueryResponseFut<
7378        VirtualControllerCreateEmulatorResult,
7379        fidl::encoding::DefaultFuchsiaResourceDialect,
7380    >;
7381    fn r#create_emulator(&self) -> Self::CreateEmulatorResponseFut {
7382        fn _decode(
7383            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7384        ) -> Result<VirtualControllerCreateEmulatorResult, fidl::Error> {
7385            let _response = fidl::client::decode_transaction_body::<
7386                fidl::encoding::FlexibleResultType<VirtualControllerCreateEmulatorResponse, i32>,
7387                fidl::encoding::DefaultFuchsiaResourceDialect,
7388                0x130273fc0a35cedb,
7389            >(_buf?)?
7390            .into_result::<VirtualControllerMarker>("create_emulator")?;
7391            Ok(_response.map(|x| x.name))
7392        }
7393        self.client.send_query_and_decode::<
7394            fidl::encoding::EmptyPayload,
7395            VirtualControllerCreateEmulatorResult,
7396        >(
7397            (),
7398            0x130273fc0a35cedb,
7399            fidl::encoding::DynamicFlags::FLEXIBLE,
7400            _decode,
7401        )
7402    }
7403
7404    fn r#create_loopback_device(
7405        &self,
7406        mut payload: VirtualControllerCreateLoopbackDeviceRequest,
7407    ) -> Result<(), fidl::Error> {
7408        self.client.send::<VirtualControllerCreateLoopbackDeviceRequest>(
7409            &mut payload,
7410            0x7525af8edecb6c0c,
7411            fidl::encoding::DynamicFlags::FLEXIBLE,
7412        )
7413    }
7414}
7415
7416pub struct VirtualControllerEventStream {
7417    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7418}
7419
7420impl std::marker::Unpin for VirtualControllerEventStream {}
7421
7422impl futures::stream::FusedStream for VirtualControllerEventStream {
7423    fn is_terminated(&self) -> bool {
7424        self.event_receiver.is_terminated()
7425    }
7426}
7427
7428impl futures::Stream for VirtualControllerEventStream {
7429    type Item = Result<VirtualControllerEvent, fidl::Error>;
7430
7431    fn poll_next(
7432        mut self: std::pin::Pin<&mut Self>,
7433        cx: &mut std::task::Context<'_>,
7434    ) -> std::task::Poll<Option<Self::Item>> {
7435        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7436            &mut self.event_receiver,
7437            cx
7438        )?) {
7439            Some(buf) => std::task::Poll::Ready(Some(VirtualControllerEvent::decode(buf))),
7440            None => std::task::Poll::Ready(None),
7441        }
7442    }
7443}
7444
7445#[derive(Debug)]
7446pub enum VirtualControllerEvent {
7447    #[non_exhaustive]
7448    _UnknownEvent {
7449        /// Ordinal of the event that was sent.
7450        ordinal: u64,
7451    },
7452}
7453
7454impl VirtualControllerEvent {
7455    /// Decodes a message buffer as a [`VirtualControllerEvent`].
7456    fn decode(
7457        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7458    ) -> Result<VirtualControllerEvent, fidl::Error> {
7459        let (bytes, _handles) = buf.split_mut();
7460        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7461        debug_assert_eq!(tx_header.tx_id, 0);
7462        match tx_header.ordinal {
7463            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7464                Ok(VirtualControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
7465            }
7466            _ => Err(fidl::Error::UnknownOrdinal {
7467                ordinal: tx_header.ordinal,
7468                protocol_name:
7469                    <VirtualControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7470            }),
7471        }
7472    }
7473}
7474
7475/// A Stream of incoming requests for fuchsia.hardware.bluetooth/VirtualController.
7476pub struct VirtualControllerRequestStream {
7477    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7478    is_terminated: bool,
7479}
7480
7481impl std::marker::Unpin for VirtualControllerRequestStream {}
7482
7483impl futures::stream::FusedStream for VirtualControllerRequestStream {
7484    fn is_terminated(&self) -> bool {
7485        self.is_terminated
7486    }
7487}
7488
7489impl fidl::endpoints::RequestStream for VirtualControllerRequestStream {
7490    type Protocol = VirtualControllerMarker;
7491    type ControlHandle = VirtualControllerControlHandle;
7492
7493    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7494        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7495    }
7496
7497    fn control_handle(&self) -> Self::ControlHandle {
7498        VirtualControllerControlHandle { inner: self.inner.clone() }
7499    }
7500
7501    fn into_inner(
7502        self,
7503    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7504    {
7505        (self.inner, self.is_terminated)
7506    }
7507
7508    fn from_inner(
7509        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7510        is_terminated: bool,
7511    ) -> Self {
7512        Self { inner, is_terminated }
7513    }
7514}
7515
7516impl futures::Stream for VirtualControllerRequestStream {
7517    type Item = Result<VirtualControllerRequest, fidl::Error>;
7518
7519    fn poll_next(
7520        mut self: std::pin::Pin<&mut Self>,
7521        cx: &mut std::task::Context<'_>,
7522    ) -> std::task::Poll<Option<Self::Item>> {
7523        let this = &mut *self;
7524        if this.inner.check_shutdown(cx) {
7525            this.is_terminated = true;
7526            return std::task::Poll::Ready(None);
7527        }
7528        if this.is_terminated {
7529            panic!("polled VirtualControllerRequestStream after completion");
7530        }
7531        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7532            |bytes, handles| {
7533                match this.inner.channel().read_etc(cx, bytes, handles) {
7534                    std::task::Poll::Ready(Ok(())) => {}
7535                    std::task::Poll::Pending => return std::task::Poll::Pending,
7536                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7537                        this.is_terminated = true;
7538                        return std::task::Poll::Ready(None);
7539                    }
7540                    std::task::Poll::Ready(Err(e)) => {
7541                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7542                            e.into(),
7543                        ))));
7544                    }
7545                }
7546
7547                // A message has been received from the channel
7548                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7549
7550                std::task::Poll::Ready(Some(match header.ordinal {
7551                    0x130273fc0a35cedb => {
7552                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7553                        let mut req = fidl::new_empty!(
7554                            fidl::encoding::EmptyPayload,
7555                            fidl::encoding::DefaultFuchsiaResourceDialect
7556                        );
7557                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7558                        let control_handle =
7559                            VirtualControllerControlHandle { inner: this.inner.clone() };
7560                        Ok(VirtualControllerRequest::CreateEmulator {
7561                            responder: VirtualControllerCreateEmulatorResponder {
7562                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7563                                tx_id: header.tx_id,
7564                            },
7565                        })
7566                    }
7567                    0x7525af8edecb6c0c => {
7568                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7569                        let mut req = fidl::new_empty!(
7570                            VirtualControllerCreateLoopbackDeviceRequest,
7571                            fidl::encoding::DefaultFuchsiaResourceDialect
7572                        );
7573                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VirtualControllerCreateLoopbackDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
7574                        let control_handle =
7575                            VirtualControllerControlHandle { inner: this.inner.clone() };
7576                        Ok(VirtualControllerRequest::CreateLoopbackDevice {
7577                            payload: req,
7578                            control_handle,
7579                        })
7580                    }
7581                    _ if header.tx_id == 0
7582                        && header
7583                            .dynamic_flags()
7584                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
7585                    {
7586                        Ok(VirtualControllerRequest::_UnknownMethod {
7587                            ordinal: header.ordinal,
7588                            control_handle: VirtualControllerControlHandle {
7589                                inner: this.inner.clone(),
7590                            },
7591                            method_type: fidl::MethodType::OneWay,
7592                        })
7593                    }
7594                    _ if header
7595                        .dynamic_flags()
7596                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
7597                    {
7598                        this.inner.send_framework_err(
7599                            fidl::encoding::FrameworkErr::UnknownMethod,
7600                            header.tx_id,
7601                            header.ordinal,
7602                            header.dynamic_flags(),
7603                            (bytes, handles),
7604                        )?;
7605                        Ok(VirtualControllerRequest::_UnknownMethod {
7606                            ordinal: header.ordinal,
7607                            control_handle: VirtualControllerControlHandle {
7608                                inner: this.inner.clone(),
7609                            },
7610                            method_type: fidl::MethodType::TwoWay,
7611                        })
7612                    }
7613                    _ => Err(fidl::Error::UnknownOrdinal {
7614                        ordinal: header.ordinal,
7615                        protocol_name:
7616                            <VirtualControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7617                    }),
7618                }))
7619            },
7620        )
7621    }
7622}
7623
7624/// Used for spawning virtual Bluetooth devices.
7625#[derive(Debug)]
7626pub enum VirtualControllerRequest {
7627    /// Creates a child device, and returns the name of the child created.
7628    CreateEmulator { responder: VirtualControllerCreateEmulatorResponder },
7629    /// Creates a virtual Bluetooth serial device, speaking the BT HCI UART
7630    /// protocol on the provided handle.
7631    /// The zircon channel is closed in the event of an error.
7632    CreateLoopbackDevice {
7633        payload: VirtualControllerCreateLoopbackDeviceRequest,
7634        control_handle: VirtualControllerControlHandle,
7635    },
7636    /// An interaction was received which does not match any known method.
7637    #[non_exhaustive]
7638    _UnknownMethod {
7639        /// Ordinal of the method that was called.
7640        ordinal: u64,
7641        control_handle: VirtualControllerControlHandle,
7642        method_type: fidl::MethodType,
7643    },
7644}
7645
7646impl VirtualControllerRequest {
7647    #[allow(irrefutable_let_patterns)]
7648    pub fn into_create_emulator(self) -> Option<(VirtualControllerCreateEmulatorResponder)> {
7649        if let VirtualControllerRequest::CreateEmulator { responder } = self {
7650            Some((responder))
7651        } else {
7652            None
7653        }
7654    }
7655
7656    #[allow(irrefutable_let_patterns)]
7657    pub fn into_create_loopback_device(
7658        self,
7659    ) -> Option<(VirtualControllerCreateLoopbackDeviceRequest, VirtualControllerControlHandle)>
7660    {
7661        if let VirtualControllerRequest::CreateLoopbackDevice { payload, control_handle } = self {
7662            Some((payload, control_handle))
7663        } else {
7664            None
7665        }
7666    }
7667
7668    /// Name of the method defined in FIDL
7669    pub fn method_name(&self) -> &'static str {
7670        match *self {
7671            VirtualControllerRequest::CreateEmulator { .. } => "create_emulator",
7672            VirtualControllerRequest::CreateLoopbackDevice { .. } => "create_loopback_device",
7673            VirtualControllerRequest::_UnknownMethod {
7674                method_type: fidl::MethodType::OneWay,
7675                ..
7676            } => "unknown one-way method",
7677            VirtualControllerRequest::_UnknownMethod {
7678                method_type: fidl::MethodType::TwoWay,
7679                ..
7680            } => "unknown two-way method",
7681        }
7682    }
7683}
7684
7685#[derive(Debug, Clone)]
7686pub struct VirtualControllerControlHandle {
7687    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7688}
7689
7690impl fidl::endpoints::ControlHandle for VirtualControllerControlHandle {
7691    fn shutdown(&self) {
7692        self.inner.shutdown()
7693    }
7694    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7695        self.inner.shutdown_with_epitaph(status)
7696    }
7697
7698    fn is_closed(&self) -> bool {
7699        self.inner.channel().is_closed()
7700    }
7701    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7702        self.inner.channel().on_closed()
7703    }
7704
7705    #[cfg(target_os = "fuchsia")]
7706    fn signal_peer(
7707        &self,
7708        clear_mask: zx::Signals,
7709        set_mask: zx::Signals,
7710    ) -> Result<(), zx_status::Status> {
7711        use fidl::Peered;
7712        self.inner.channel().signal_peer(clear_mask, set_mask)
7713    }
7714}
7715
7716impl VirtualControllerControlHandle {}
7717
7718#[must_use = "FIDL methods require a response to be sent"]
7719#[derive(Debug)]
7720pub struct VirtualControllerCreateEmulatorResponder {
7721    control_handle: std::mem::ManuallyDrop<VirtualControllerControlHandle>,
7722    tx_id: u32,
7723}
7724
7725/// Set the the channel to be shutdown (see [`VirtualControllerControlHandle::shutdown`])
7726/// if the responder is dropped without sending a response, so that the client
7727/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7728impl std::ops::Drop for VirtualControllerCreateEmulatorResponder {
7729    fn drop(&mut self) {
7730        self.control_handle.shutdown();
7731        // Safety: drops once, never accessed again
7732        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7733    }
7734}
7735
7736impl fidl::endpoints::Responder for VirtualControllerCreateEmulatorResponder {
7737    type ControlHandle = VirtualControllerControlHandle;
7738
7739    fn control_handle(&self) -> &VirtualControllerControlHandle {
7740        &self.control_handle
7741    }
7742
7743    fn drop_without_shutdown(mut self) {
7744        // Safety: drops once, never accessed again due to mem::forget
7745        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7746        // Prevent Drop from running (which would shut down the channel)
7747        std::mem::forget(self);
7748    }
7749}
7750
7751impl VirtualControllerCreateEmulatorResponder {
7752    /// Sends a response to the FIDL transaction.
7753    ///
7754    /// Sets the channel to shutdown if an error occurs.
7755    pub fn send(self, mut result: Result<Option<&str>, i32>) -> Result<(), fidl::Error> {
7756        let _result = self.send_raw(result);
7757        if _result.is_err() {
7758            self.control_handle.shutdown();
7759        }
7760        self.drop_without_shutdown();
7761        _result
7762    }
7763
7764    /// Similar to "send" but does not shutdown the channel if an error occurs.
7765    pub fn send_no_shutdown_on_err(
7766        self,
7767        mut result: Result<Option<&str>, i32>,
7768    ) -> Result<(), fidl::Error> {
7769        let _result = self.send_raw(result);
7770        self.drop_without_shutdown();
7771        _result
7772    }
7773
7774    fn send_raw(&self, mut result: Result<Option<&str>, i32>) -> Result<(), fidl::Error> {
7775        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7776            VirtualControllerCreateEmulatorResponse,
7777            i32,
7778        >>(
7779            fidl::encoding::FlexibleResult::new(result.map(|name| (name,))),
7780            self.tx_id,
7781            0x130273fc0a35cedb,
7782            fidl::encoding::DynamicFlags::FLEXIBLE,
7783        )
7784    }
7785}
7786
7787#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7788pub struct EmulatorServiceMarker;
7789
7790#[cfg(target_os = "fuchsia")]
7791impl fidl::endpoints::ServiceMarker for EmulatorServiceMarker {
7792    type Proxy = EmulatorServiceProxy;
7793    type Request = EmulatorServiceRequest;
7794    const SERVICE_NAME: &'static str = "fuchsia.hardware.bluetooth.EmulatorService";
7795}
7796
7797/// A request for one of the member protocols of EmulatorService.
7798///
7799#[cfg(target_os = "fuchsia")]
7800pub enum EmulatorServiceRequest {
7801    Device(EmulatorRequestStream),
7802}
7803
7804#[cfg(target_os = "fuchsia")]
7805impl fidl::endpoints::ServiceRequest for EmulatorServiceRequest {
7806    type Service = EmulatorServiceMarker;
7807
7808    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
7809        match name {
7810            "device" => Self::Device(
7811                <EmulatorRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
7812            ),
7813            _ => panic!("no such member protocol name for service EmulatorService"),
7814        }
7815    }
7816
7817    fn member_names() -> &'static [&'static str] {
7818        &["device"]
7819    }
7820}
7821#[cfg(target_os = "fuchsia")]
7822pub struct EmulatorServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
7823
7824#[cfg(target_os = "fuchsia")]
7825impl fidl::endpoints::ServiceProxy for EmulatorServiceProxy {
7826    type Service = EmulatorServiceMarker;
7827
7828    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
7829        Self(opener)
7830    }
7831}
7832
7833#[cfg(target_os = "fuchsia")]
7834impl EmulatorServiceProxy {
7835    pub fn connect_to_device(&self) -> Result<EmulatorProxy, fidl::Error> {
7836        let (proxy, server_end) = fidl::endpoints::create_proxy::<EmulatorMarker>();
7837        self.connect_channel_to_device(server_end)?;
7838        Ok(proxy)
7839    }
7840
7841    /// Like `connect_to_device`, but returns a sync proxy.
7842    /// See [`Self::connect_to_device`] for more details.
7843    pub fn connect_to_device_sync(&self) -> Result<EmulatorSynchronousProxy, fidl::Error> {
7844        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<EmulatorMarker>();
7845        self.connect_channel_to_device(server_end)?;
7846        Ok(proxy)
7847    }
7848
7849    /// Like `connect_to_device`, but accepts a server end.
7850    /// See [`Self::connect_to_device`] for more details.
7851    pub fn connect_channel_to_device(
7852        &self,
7853        server_end: fidl::endpoints::ServerEnd<EmulatorMarker>,
7854    ) -> Result<(), fidl::Error> {
7855        self.0.open_member("device", server_end.into_channel())
7856    }
7857
7858    pub fn instance_name(&self) -> &str {
7859        self.0.instance_name()
7860    }
7861}
7862
7863#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7864pub struct HciServiceMarker;
7865
7866#[cfg(target_os = "fuchsia")]
7867impl fidl::endpoints::ServiceMarker for HciServiceMarker {
7868    type Proxy = HciServiceProxy;
7869    type Request = HciServiceRequest;
7870    const SERVICE_NAME: &'static str = "fuchsia.hardware.bluetooth.HciService";
7871}
7872
7873/// A request for one of the member protocols of HciService.
7874///
7875/// Wrap the protocol in a service that will be exposed to the child driver.
7876#[cfg(target_os = "fuchsia")]
7877pub enum HciServiceRequest {
7878    Hci(HciRequestStream),
7879    HciTransport(HciTransportRequestStream),
7880    Snoop(SnoopRequestStream),
7881}
7882
7883#[cfg(target_os = "fuchsia")]
7884impl fidl::endpoints::ServiceRequest for HciServiceRequest {
7885    type Service = HciServiceMarker;
7886
7887    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
7888        match name {
7889            "hci" => Self::Hci(<HciRequestStream as fidl::endpoints::RequestStream>::from_channel(
7890                _channel,
7891            )),
7892            "hci_transport" => Self::HciTransport(
7893                <HciTransportRequestStream as fidl::endpoints::RequestStream>::from_channel(
7894                    _channel,
7895                ),
7896            ),
7897            "snoop" => Self::Snoop(
7898                <SnoopRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
7899            ),
7900            _ => panic!("no such member protocol name for service HciService"),
7901        }
7902    }
7903
7904    fn member_names() -> &'static [&'static str] {
7905        &["hci", "hci_transport", "snoop"]
7906    }
7907}
7908/// Wrap the protocol in a service that will be exposed to the child driver.
7909#[cfg(target_os = "fuchsia")]
7910pub struct HciServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
7911
7912#[cfg(target_os = "fuchsia")]
7913impl fidl::endpoints::ServiceProxy for HciServiceProxy {
7914    type Service = HciServiceMarker;
7915
7916    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
7917        Self(opener)
7918    }
7919}
7920
7921#[cfg(target_os = "fuchsia")]
7922impl HciServiceProxy {
7923    pub fn connect_to_hci(&self) -> Result<HciProxy, fidl::Error> {
7924        let (proxy, server_end) = fidl::endpoints::create_proxy::<HciMarker>();
7925        self.connect_channel_to_hci(server_end)?;
7926        Ok(proxy)
7927    }
7928
7929    /// Like `connect_to_hci`, but returns a sync proxy.
7930    /// See [`Self::connect_to_hci`] for more details.
7931    pub fn connect_to_hci_sync(&self) -> Result<HciSynchronousProxy, fidl::Error> {
7932        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<HciMarker>();
7933        self.connect_channel_to_hci(server_end)?;
7934        Ok(proxy)
7935    }
7936
7937    /// Like `connect_to_hci`, but accepts a server end.
7938    /// See [`Self::connect_to_hci`] for more details.
7939    pub fn connect_channel_to_hci(
7940        &self,
7941        server_end: fidl::endpoints::ServerEnd<HciMarker>,
7942    ) -> Result<(), fidl::Error> {
7943        self.0.open_member("hci", server_end.into_channel())
7944    }
7945    pub fn connect_to_hci_transport(&self) -> Result<HciTransportProxy, fidl::Error> {
7946        let (proxy, server_end) = fidl::endpoints::create_proxy::<HciTransportMarker>();
7947        self.connect_channel_to_hci_transport(server_end)?;
7948        Ok(proxy)
7949    }
7950
7951    /// Like `connect_to_hci_transport`, but returns a sync proxy.
7952    /// See [`Self::connect_to_hci_transport`] for more details.
7953    pub fn connect_to_hci_transport_sync(
7954        &self,
7955    ) -> Result<HciTransportSynchronousProxy, fidl::Error> {
7956        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<HciTransportMarker>();
7957        self.connect_channel_to_hci_transport(server_end)?;
7958        Ok(proxy)
7959    }
7960
7961    /// Like `connect_to_hci_transport`, but accepts a server end.
7962    /// See [`Self::connect_to_hci_transport`] for more details.
7963    pub fn connect_channel_to_hci_transport(
7964        &self,
7965        server_end: fidl::endpoints::ServerEnd<HciTransportMarker>,
7966    ) -> Result<(), fidl::Error> {
7967        self.0.open_member("hci_transport", server_end.into_channel())
7968    }
7969    pub fn connect_to_snoop(&self) -> Result<SnoopProxy, fidl::Error> {
7970        let (proxy, server_end) = fidl::endpoints::create_proxy::<SnoopMarker>();
7971        self.connect_channel_to_snoop(server_end)?;
7972        Ok(proxy)
7973    }
7974
7975    /// Like `connect_to_snoop`, but returns a sync proxy.
7976    /// See [`Self::connect_to_snoop`] for more details.
7977    pub fn connect_to_snoop_sync(&self) -> Result<SnoopSynchronousProxy, fidl::Error> {
7978        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<SnoopMarker>();
7979        self.connect_channel_to_snoop(server_end)?;
7980        Ok(proxy)
7981    }
7982
7983    /// Like `connect_to_snoop`, but accepts a server end.
7984    /// See [`Self::connect_to_snoop`] for more details.
7985    pub fn connect_channel_to_snoop(
7986        &self,
7987        server_end: fidl::endpoints::ServerEnd<SnoopMarker>,
7988    ) -> Result<(), fidl::Error> {
7989        self.0.open_member("snoop", server_end.into_channel())
7990    }
7991
7992    pub fn instance_name(&self) -> &str {
7993        self.0.instance_name()
7994    }
7995}
7996
7997#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7998pub struct ServiceMarker;
7999
8000#[cfg(target_os = "fuchsia")]
8001impl fidl::endpoints::ServiceMarker for ServiceMarker {
8002    type Proxy = ServiceProxy;
8003    type Request = ServiceRequest;
8004    const SERVICE_NAME: &'static str = "fuchsia.hardware.bluetooth.Service";
8005}
8006
8007/// A request for one of the member protocols of Service.
8008///
8009#[cfg(target_os = "fuchsia")]
8010pub enum ServiceRequest {
8011    Vendor(VendorRequestStream),
8012}
8013
8014#[cfg(target_os = "fuchsia")]
8015impl fidl::endpoints::ServiceRequest for ServiceRequest {
8016    type Service = ServiceMarker;
8017
8018    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
8019        match name {
8020            "vendor" => Self::Vendor(
8021                <VendorRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
8022            ),
8023            _ => panic!("no such member protocol name for service Service"),
8024        }
8025    }
8026
8027    fn member_names() -> &'static [&'static str] {
8028        &["vendor"]
8029    }
8030}
8031#[cfg(target_os = "fuchsia")]
8032pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
8033
8034#[cfg(target_os = "fuchsia")]
8035impl fidl::endpoints::ServiceProxy for ServiceProxy {
8036    type Service = ServiceMarker;
8037
8038    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
8039        Self(opener)
8040    }
8041}
8042
8043#[cfg(target_os = "fuchsia")]
8044impl ServiceProxy {
8045    pub fn connect_to_vendor(&self) -> Result<VendorProxy, fidl::Error> {
8046        let (proxy, server_end) = fidl::endpoints::create_proxy::<VendorMarker>();
8047        self.connect_channel_to_vendor(server_end)?;
8048        Ok(proxy)
8049    }
8050
8051    /// Like `connect_to_vendor`, but returns a sync proxy.
8052    /// See [`Self::connect_to_vendor`] for more details.
8053    pub fn connect_to_vendor_sync(&self) -> Result<VendorSynchronousProxy, fidl::Error> {
8054        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<VendorMarker>();
8055        self.connect_channel_to_vendor(server_end)?;
8056        Ok(proxy)
8057    }
8058
8059    /// Like `connect_to_vendor`, but accepts a server end.
8060    /// See [`Self::connect_to_vendor`] for more details.
8061    pub fn connect_channel_to_vendor(
8062        &self,
8063        server_end: fidl::endpoints::ServerEnd<VendorMarker>,
8064    ) -> Result<(), fidl::Error> {
8065        self.0.open_member("vendor", server_end.into_channel())
8066    }
8067
8068    pub fn instance_name(&self) -> &str {
8069        self.0.instance_name()
8070    }
8071}
8072
8073mod internal {
8074    use super::*;
8075
8076    impl fidl::encoding::ResourceTypeMarker for HciOpenAclDataChannelRequest {
8077        type Borrowed<'a> = &'a mut Self;
8078        fn take_or_borrow<'a>(
8079            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8080        ) -> Self::Borrowed<'a> {
8081            value
8082        }
8083    }
8084
8085    unsafe impl fidl::encoding::TypeMarker for HciOpenAclDataChannelRequest {
8086        type Owned = Self;
8087
8088        #[inline(always)]
8089        fn inline_align(_context: fidl::encoding::Context) -> usize {
8090            4
8091        }
8092
8093        #[inline(always)]
8094        fn inline_size(_context: fidl::encoding::Context) -> usize {
8095            4
8096        }
8097    }
8098
8099    unsafe impl
8100        fidl::encoding::Encode<
8101            HciOpenAclDataChannelRequest,
8102            fidl::encoding::DefaultFuchsiaResourceDialect,
8103        > for &mut HciOpenAclDataChannelRequest
8104    {
8105        #[inline]
8106        unsafe fn encode(
8107            self,
8108            encoder: &mut fidl::encoding::Encoder<
8109                '_,
8110                fidl::encoding::DefaultFuchsiaResourceDialect,
8111            >,
8112            offset: usize,
8113            _depth: fidl::encoding::Depth,
8114        ) -> fidl::Result<()> {
8115            encoder.debug_check_bounds::<HciOpenAclDataChannelRequest>(offset);
8116            // Delegate to tuple encoding.
8117            fidl::encoding::Encode::<
8118                HciOpenAclDataChannelRequest,
8119                fidl::encoding::DefaultFuchsiaResourceDialect,
8120            >::encode(
8121                (<fidl::encoding::HandleType<
8122                    fidl::Channel,
8123                    { fidl::ObjectType::CHANNEL.into_raw() },
8124                    2147483648,
8125                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8126                    &mut self.channel
8127                ),),
8128                encoder,
8129                offset,
8130                _depth,
8131            )
8132        }
8133    }
8134    unsafe impl<
8135        T0: fidl::encoding::Encode<
8136                fidl::encoding::HandleType<
8137                    fidl::Channel,
8138                    { fidl::ObjectType::CHANNEL.into_raw() },
8139                    2147483648,
8140                >,
8141                fidl::encoding::DefaultFuchsiaResourceDialect,
8142            >,
8143    >
8144        fidl::encoding::Encode<
8145            HciOpenAclDataChannelRequest,
8146            fidl::encoding::DefaultFuchsiaResourceDialect,
8147        > for (T0,)
8148    {
8149        #[inline]
8150        unsafe fn encode(
8151            self,
8152            encoder: &mut fidl::encoding::Encoder<
8153                '_,
8154                fidl::encoding::DefaultFuchsiaResourceDialect,
8155            >,
8156            offset: usize,
8157            depth: fidl::encoding::Depth,
8158        ) -> fidl::Result<()> {
8159            encoder.debug_check_bounds::<HciOpenAclDataChannelRequest>(offset);
8160            // Zero out padding regions. There's no need to apply masks
8161            // because the unmasked parts will be overwritten by fields.
8162            // Write the fields.
8163            self.0.encode(encoder, offset + 0, depth)?;
8164            Ok(())
8165        }
8166    }
8167
8168    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8169        for HciOpenAclDataChannelRequest
8170    {
8171        #[inline(always)]
8172        fn new_empty() -> Self {
8173            Self {
8174                channel: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8175            }
8176        }
8177
8178        #[inline]
8179        unsafe fn decode(
8180            &mut self,
8181            decoder: &mut fidl::encoding::Decoder<
8182                '_,
8183                fidl::encoding::DefaultFuchsiaResourceDialect,
8184            >,
8185            offset: usize,
8186            _depth: fidl::encoding::Depth,
8187        ) -> fidl::Result<()> {
8188            decoder.debug_check_bounds::<Self>(offset);
8189            // Verify that padding bytes are zero.
8190            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.channel, decoder, offset + 0, _depth)?;
8191            Ok(())
8192        }
8193    }
8194
8195    impl fidl::encoding::ResourceTypeMarker for HciOpenCommandChannelRequest {
8196        type Borrowed<'a> = &'a mut Self;
8197        fn take_or_borrow<'a>(
8198            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8199        ) -> Self::Borrowed<'a> {
8200            value
8201        }
8202    }
8203
8204    unsafe impl fidl::encoding::TypeMarker for HciOpenCommandChannelRequest {
8205        type Owned = Self;
8206
8207        #[inline(always)]
8208        fn inline_align(_context: fidl::encoding::Context) -> usize {
8209            4
8210        }
8211
8212        #[inline(always)]
8213        fn inline_size(_context: fidl::encoding::Context) -> usize {
8214            4
8215        }
8216    }
8217
8218    unsafe impl
8219        fidl::encoding::Encode<
8220            HciOpenCommandChannelRequest,
8221            fidl::encoding::DefaultFuchsiaResourceDialect,
8222        > for &mut HciOpenCommandChannelRequest
8223    {
8224        #[inline]
8225        unsafe fn encode(
8226            self,
8227            encoder: &mut fidl::encoding::Encoder<
8228                '_,
8229                fidl::encoding::DefaultFuchsiaResourceDialect,
8230            >,
8231            offset: usize,
8232            _depth: fidl::encoding::Depth,
8233        ) -> fidl::Result<()> {
8234            encoder.debug_check_bounds::<HciOpenCommandChannelRequest>(offset);
8235            // Delegate to tuple encoding.
8236            fidl::encoding::Encode::<
8237                HciOpenCommandChannelRequest,
8238                fidl::encoding::DefaultFuchsiaResourceDialect,
8239            >::encode(
8240                (<fidl::encoding::HandleType<
8241                    fidl::Channel,
8242                    { fidl::ObjectType::CHANNEL.into_raw() },
8243                    2147483648,
8244                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8245                    &mut self.channel
8246                ),),
8247                encoder,
8248                offset,
8249                _depth,
8250            )
8251        }
8252    }
8253    unsafe impl<
8254        T0: fidl::encoding::Encode<
8255                fidl::encoding::HandleType<
8256                    fidl::Channel,
8257                    { fidl::ObjectType::CHANNEL.into_raw() },
8258                    2147483648,
8259                >,
8260                fidl::encoding::DefaultFuchsiaResourceDialect,
8261            >,
8262    >
8263        fidl::encoding::Encode<
8264            HciOpenCommandChannelRequest,
8265            fidl::encoding::DefaultFuchsiaResourceDialect,
8266        > for (T0,)
8267    {
8268        #[inline]
8269        unsafe fn encode(
8270            self,
8271            encoder: &mut fidl::encoding::Encoder<
8272                '_,
8273                fidl::encoding::DefaultFuchsiaResourceDialect,
8274            >,
8275            offset: usize,
8276            depth: fidl::encoding::Depth,
8277        ) -> fidl::Result<()> {
8278            encoder.debug_check_bounds::<HciOpenCommandChannelRequest>(offset);
8279            // Zero out padding regions. There's no need to apply masks
8280            // because the unmasked parts will be overwritten by fields.
8281            // Write the fields.
8282            self.0.encode(encoder, offset + 0, depth)?;
8283            Ok(())
8284        }
8285    }
8286
8287    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8288        for HciOpenCommandChannelRequest
8289    {
8290        #[inline(always)]
8291        fn new_empty() -> Self {
8292            Self {
8293                channel: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8294            }
8295        }
8296
8297        #[inline]
8298        unsafe fn decode(
8299            &mut self,
8300            decoder: &mut fidl::encoding::Decoder<
8301                '_,
8302                fidl::encoding::DefaultFuchsiaResourceDialect,
8303            >,
8304            offset: usize,
8305            _depth: fidl::encoding::Depth,
8306        ) -> fidl::Result<()> {
8307            decoder.debug_check_bounds::<Self>(offset);
8308            // Verify that padding bytes are zero.
8309            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.channel, decoder, offset + 0, _depth)?;
8310            Ok(())
8311        }
8312    }
8313
8314    impl fidl::encoding::ResourceTypeMarker for HciOpenIsoDataChannelRequest {
8315        type Borrowed<'a> = &'a mut Self;
8316        fn take_or_borrow<'a>(
8317            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8318        ) -> Self::Borrowed<'a> {
8319            value
8320        }
8321    }
8322
8323    unsafe impl fidl::encoding::TypeMarker for HciOpenIsoDataChannelRequest {
8324        type Owned = Self;
8325
8326        #[inline(always)]
8327        fn inline_align(_context: fidl::encoding::Context) -> usize {
8328            4
8329        }
8330
8331        #[inline(always)]
8332        fn inline_size(_context: fidl::encoding::Context) -> usize {
8333            4
8334        }
8335    }
8336
8337    unsafe impl
8338        fidl::encoding::Encode<
8339            HciOpenIsoDataChannelRequest,
8340            fidl::encoding::DefaultFuchsiaResourceDialect,
8341        > for &mut HciOpenIsoDataChannelRequest
8342    {
8343        #[inline]
8344        unsafe fn encode(
8345            self,
8346            encoder: &mut fidl::encoding::Encoder<
8347                '_,
8348                fidl::encoding::DefaultFuchsiaResourceDialect,
8349            >,
8350            offset: usize,
8351            _depth: fidl::encoding::Depth,
8352        ) -> fidl::Result<()> {
8353            encoder.debug_check_bounds::<HciOpenIsoDataChannelRequest>(offset);
8354            // Delegate to tuple encoding.
8355            fidl::encoding::Encode::<
8356                HciOpenIsoDataChannelRequest,
8357                fidl::encoding::DefaultFuchsiaResourceDialect,
8358            >::encode(
8359                (<fidl::encoding::HandleType<
8360                    fidl::Channel,
8361                    { fidl::ObjectType::CHANNEL.into_raw() },
8362                    2147483648,
8363                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8364                    &mut self.channel
8365                ),),
8366                encoder,
8367                offset,
8368                _depth,
8369            )
8370        }
8371    }
8372    unsafe impl<
8373        T0: fidl::encoding::Encode<
8374                fidl::encoding::HandleType<
8375                    fidl::Channel,
8376                    { fidl::ObjectType::CHANNEL.into_raw() },
8377                    2147483648,
8378                >,
8379                fidl::encoding::DefaultFuchsiaResourceDialect,
8380            >,
8381    >
8382        fidl::encoding::Encode<
8383            HciOpenIsoDataChannelRequest,
8384            fidl::encoding::DefaultFuchsiaResourceDialect,
8385        > for (T0,)
8386    {
8387        #[inline]
8388        unsafe fn encode(
8389            self,
8390            encoder: &mut fidl::encoding::Encoder<
8391                '_,
8392                fidl::encoding::DefaultFuchsiaResourceDialect,
8393            >,
8394            offset: usize,
8395            depth: fidl::encoding::Depth,
8396        ) -> fidl::Result<()> {
8397            encoder.debug_check_bounds::<HciOpenIsoDataChannelRequest>(offset);
8398            // Zero out padding regions. There's no need to apply masks
8399            // because the unmasked parts will be overwritten by fields.
8400            // Write the fields.
8401            self.0.encode(encoder, offset + 0, depth)?;
8402            Ok(())
8403        }
8404    }
8405
8406    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8407        for HciOpenIsoDataChannelRequest
8408    {
8409        #[inline(always)]
8410        fn new_empty() -> Self {
8411            Self {
8412                channel: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8413            }
8414        }
8415
8416        #[inline]
8417        unsafe fn decode(
8418            &mut self,
8419            decoder: &mut fidl::encoding::Decoder<
8420                '_,
8421                fidl::encoding::DefaultFuchsiaResourceDialect,
8422            >,
8423            offset: usize,
8424            _depth: fidl::encoding::Depth,
8425        ) -> fidl::Result<()> {
8426            decoder.debug_check_bounds::<Self>(offset);
8427            // Verify that padding bytes are zero.
8428            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.channel, decoder, offset + 0, _depth)?;
8429            Ok(())
8430        }
8431    }
8432
8433    impl fidl::encoding::ResourceTypeMarker for HciOpenScoDataChannelRequest {
8434        type Borrowed<'a> = &'a mut Self;
8435        fn take_or_borrow<'a>(
8436            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8437        ) -> Self::Borrowed<'a> {
8438            value
8439        }
8440    }
8441
8442    unsafe impl fidl::encoding::TypeMarker for HciOpenScoDataChannelRequest {
8443        type Owned = Self;
8444
8445        #[inline(always)]
8446        fn inline_align(_context: fidl::encoding::Context) -> usize {
8447            4
8448        }
8449
8450        #[inline(always)]
8451        fn inline_size(_context: fidl::encoding::Context) -> usize {
8452            4
8453        }
8454    }
8455
8456    unsafe impl
8457        fidl::encoding::Encode<
8458            HciOpenScoDataChannelRequest,
8459            fidl::encoding::DefaultFuchsiaResourceDialect,
8460        > for &mut HciOpenScoDataChannelRequest
8461    {
8462        #[inline]
8463        unsafe fn encode(
8464            self,
8465            encoder: &mut fidl::encoding::Encoder<
8466                '_,
8467                fidl::encoding::DefaultFuchsiaResourceDialect,
8468            >,
8469            offset: usize,
8470            _depth: fidl::encoding::Depth,
8471        ) -> fidl::Result<()> {
8472            encoder.debug_check_bounds::<HciOpenScoDataChannelRequest>(offset);
8473            // Delegate to tuple encoding.
8474            fidl::encoding::Encode::<
8475                HciOpenScoDataChannelRequest,
8476                fidl::encoding::DefaultFuchsiaResourceDialect,
8477            >::encode(
8478                (<fidl::encoding::HandleType<
8479                    fidl::Channel,
8480                    { fidl::ObjectType::CHANNEL.into_raw() },
8481                    2147483648,
8482                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8483                    &mut self.channel
8484                ),),
8485                encoder,
8486                offset,
8487                _depth,
8488            )
8489        }
8490    }
8491    unsafe impl<
8492        T0: fidl::encoding::Encode<
8493                fidl::encoding::HandleType<
8494                    fidl::Channel,
8495                    { fidl::ObjectType::CHANNEL.into_raw() },
8496                    2147483648,
8497                >,
8498                fidl::encoding::DefaultFuchsiaResourceDialect,
8499            >,
8500    >
8501        fidl::encoding::Encode<
8502            HciOpenScoDataChannelRequest,
8503            fidl::encoding::DefaultFuchsiaResourceDialect,
8504        > for (T0,)
8505    {
8506        #[inline]
8507        unsafe fn encode(
8508            self,
8509            encoder: &mut fidl::encoding::Encoder<
8510                '_,
8511                fidl::encoding::DefaultFuchsiaResourceDialect,
8512            >,
8513            offset: usize,
8514            depth: fidl::encoding::Depth,
8515        ) -> fidl::Result<()> {
8516            encoder.debug_check_bounds::<HciOpenScoDataChannelRequest>(offset);
8517            // Zero out padding regions. There's no need to apply masks
8518            // because the unmasked parts will be overwritten by fields.
8519            // Write the fields.
8520            self.0.encode(encoder, offset + 0, depth)?;
8521            Ok(())
8522        }
8523    }
8524
8525    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8526        for HciOpenScoDataChannelRequest
8527    {
8528        #[inline(always)]
8529        fn new_empty() -> Self {
8530            Self {
8531                channel: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8532            }
8533        }
8534
8535        #[inline]
8536        unsafe fn decode(
8537            &mut self,
8538            decoder: &mut fidl::encoding::Decoder<
8539                '_,
8540                fidl::encoding::DefaultFuchsiaResourceDialect,
8541            >,
8542            offset: usize,
8543            _depth: fidl::encoding::Depth,
8544        ) -> fidl::Result<()> {
8545            decoder.debug_check_bounds::<Self>(offset);
8546            // Verify that padding bytes are zero.
8547            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.channel, decoder, offset + 0, _depth)?;
8548            Ok(())
8549        }
8550    }
8551
8552    impl fidl::encoding::ResourceTypeMarker for HciOpenSnoopChannelRequest {
8553        type Borrowed<'a> = &'a mut Self;
8554        fn take_or_borrow<'a>(
8555            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8556        ) -> Self::Borrowed<'a> {
8557            value
8558        }
8559    }
8560
8561    unsafe impl fidl::encoding::TypeMarker for HciOpenSnoopChannelRequest {
8562        type Owned = Self;
8563
8564        #[inline(always)]
8565        fn inline_align(_context: fidl::encoding::Context) -> usize {
8566            4
8567        }
8568
8569        #[inline(always)]
8570        fn inline_size(_context: fidl::encoding::Context) -> usize {
8571            4
8572        }
8573    }
8574
8575    unsafe impl
8576        fidl::encoding::Encode<
8577            HciOpenSnoopChannelRequest,
8578            fidl::encoding::DefaultFuchsiaResourceDialect,
8579        > for &mut HciOpenSnoopChannelRequest
8580    {
8581        #[inline]
8582        unsafe fn encode(
8583            self,
8584            encoder: &mut fidl::encoding::Encoder<
8585                '_,
8586                fidl::encoding::DefaultFuchsiaResourceDialect,
8587            >,
8588            offset: usize,
8589            _depth: fidl::encoding::Depth,
8590        ) -> fidl::Result<()> {
8591            encoder.debug_check_bounds::<HciOpenSnoopChannelRequest>(offset);
8592            // Delegate to tuple encoding.
8593            fidl::encoding::Encode::<
8594                HciOpenSnoopChannelRequest,
8595                fidl::encoding::DefaultFuchsiaResourceDialect,
8596            >::encode(
8597                (<fidl::encoding::HandleType<
8598                    fidl::Channel,
8599                    { fidl::ObjectType::CHANNEL.into_raw() },
8600                    2147483648,
8601                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8602                    &mut self.channel
8603                ),),
8604                encoder,
8605                offset,
8606                _depth,
8607            )
8608        }
8609    }
8610    unsafe impl<
8611        T0: fidl::encoding::Encode<
8612                fidl::encoding::HandleType<
8613                    fidl::Channel,
8614                    { fidl::ObjectType::CHANNEL.into_raw() },
8615                    2147483648,
8616                >,
8617                fidl::encoding::DefaultFuchsiaResourceDialect,
8618            >,
8619    >
8620        fidl::encoding::Encode<
8621            HciOpenSnoopChannelRequest,
8622            fidl::encoding::DefaultFuchsiaResourceDialect,
8623        > for (T0,)
8624    {
8625        #[inline]
8626        unsafe fn encode(
8627            self,
8628            encoder: &mut fidl::encoding::Encoder<
8629                '_,
8630                fidl::encoding::DefaultFuchsiaResourceDialect,
8631            >,
8632            offset: usize,
8633            depth: fidl::encoding::Depth,
8634        ) -> fidl::Result<()> {
8635            encoder.debug_check_bounds::<HciOpenSnoopChannelRequest>(offset);
8636            // Zero out padding regions. There's no need to apply masks
8637            // because the unmasked parts will be overwritten by fields.
8638            // Write the fields.
8639            self.0.encode(encoder, offset + 0, depth)?;
8640            Ok(())
8641        }
8642    }
8643
8644    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8645        for HciOpenSnoopChannelRequest
8646    {
8647        #[inline(always)]
8648        fn new_empty() -> Self {
8649            Self {
8650                channel: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8651            }
8652        }
8653
8654        #[inline]
8655        unsafe fn decode(
8656            &mut self,
8657            decoder: &mut fidl::encoding::Decoder<
8658                '_,
8659                fidl::encoding::DefaultFuchsiaResourceDialect,
8660            >,
8661            offset: usize,
8662            _depth: fidl::encoding::Depth,
8663        ) -> fidl::Result<()> {
8664            decoder.debug_check_bounds::<Self>(offset);
8665            // Verify that padding bytes are zero.
8666            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.channel, decoder, offset + 0, _depth)?;
8667            Ok(())
8668        }
8669    }
8670
8671    impl fidl::encoding::ResourceTypeMarker for VendorOpenHciTransportResponse {
8672        type Borrowed<'a> = &'a mut Self;
8673        fn take_or_borrow<'a>(
8674            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8675        ) -> Self::Borrowed<'a> {
8676            value
8677        }
8678    }
8679
8680    unsafe impl fidl::encoding::TypeMarker for VendorOpenHciTransportResponse {
8681        type Owned = Self;
8682
8683        #[inline(always)]
8684        fn inline_align(_context: fidl::encoding::Context) -> usize {
8685            4
8686        }
8687
8688        #[inline(always)]
8689        fn inline_size(_context: fidl::encoding::Context) -> usize {
8690            4
8691        }
8692    }
8693
8694    unsafe impl
8695        fidl::encoding::Encode<
8696            VendorOpenHciTransportResponse,
8697            fidl::encoding::DefaultFuchsiaResourceDialect,
8698        > for &mut VendorOpenHciTransportResponse
8699    {
8700        #[inline]
8701        unsafe fn encode(
8702            self,
8703            encoder: &mut fidl::encoding::Encoder<
8704                '_,
8705                fidl::encoding::DefaultFuchsiaResourceDialect,
8706            >,
8707            offset: usize,
8708            _depth: fidl::encoding::Depth,
8709        ) -> fidl::Result<()> {
8710            encoder.debug_check_bounds::<VendorOpenHciTransportResponse>(offset);
8711            // Delegate to tuple encoding.
8712            fidl::encoding::Encode::<VendorOpenHciTransportResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
8713                (
8714                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HciTransportMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.channel),
8715                ),
8716                encoder, offset, _depth
8717            )
8718        }
8719    }
8720    unsafe impl<
8721        T0: fidl::encoding::Encode<
8722                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HciTransportMarker>>,
8723                fidl::encoding::DefaultFuchsiaResourceDialect,
8724            >,
8725    >
8726        fidl::encoding::Encode<
8727            VendorOpenHciTransportResponse,
8728            fidl::encoding::DefaultFuchsiaResourceDialect,
8729        > for (T0,)
8730    {
8731        #[inline]
8732        unsafe fn encode(
8733            self,
8734            encoder: &mut fidl::encoding::Encoder<
8735                '_,
8736                fidl::encoding::DefaultFuchsiaResourceDialect,
8737            >,
8738            offset: usize,
8739            depth: fidl::encoding::Depth,
8740        ) -> fidl::Result<()> {
8741            encoder.debug_check_bounds::<VendorOpenHciTransportResponse>(offset);
8742            // Zero out padding regions. There's no need to apply masks
8743            // because the unmasked parts will be overwritten by fields.
8744            // Write the fields.
8745            self.0.encode(encoder, offset + 0, depth)?;
8746            Ok(())
8747        }
8748    }
8749
8750    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8751        for VendorOpenHciTransportResponse
8752    {
8753        #[inline(always)]
8754        fn new_empty() -> Self {
8755            Self {
8756                channel: fidl::new_empty!(
8757                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HciTransportMarker>>,
8758                    fidl::encoding::DefaultFuchsiaResourceDialect
8759                ),
8760            }
8761        }
8762
8763        #[inline]
8764        unsafe fn decode(
8765            &mut self,
8766            decoder: &mut fidl::encoding::Decoder<
8767                '_,
8768                fidl::encoding::DefaultFuchsiaResourceDialect,
8769            >,
8770            offset: usize,
8771            _depth: fidl::encoding::Depth,
8772        ) -> fidl::Result<()> {
8773            decoder.debug_check_bounds::<Self>(offset);
8774            // Verify that padding bytes are zero.
8775            fidl::decode!(
8776                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HciTransportMarker>>,
8777                fidl::encoding::DefaultFuchsiaResourceDialect,
8778                &mut self.channel,
8779                decoder,
8780                offset + 0,
8781                _depth
8782            )?;
8783            Ok(())
8784        }
8785    }
8786
8787    impl fidl::encoding::ResourceTypeMarker for VendorOpenHciResponse {
8788        type Borrowed<'a> = &'a mut Self;
8789        fn take_or_borrow<'a>(
8790            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8791        ) -> Self::Borrowed<'a> {
8792            value
8793        }
8794    }
8795
8796    unsafe impl fidl::encoding::TypeMarker for VendorOpenHciResponse {
8797        type Owned = Self;
8798
8799        #[inline(always)]
8800        fn inline_align(_context: fidl::encoding::Context) -> usize {
8801            4
8802        }
8803
8804        #[inline(always)]
8805        fn inline_size(_context: fidl::encoding::Context) -> usize {
8806            4
8807        }
8808    }
8809
8810    unsafe impl
8811        fidl::encoding::Encode<VendorOpenHciResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
8812        for &mut VendorOpenHciResponse
8813    {
8814        #[inline]
8815        unsafe fn encode(
8816            self,
8817            encoder: &mut fidl::encoding::Encoder<
8818                '_,
8819                fidl::encoding::DefaultFuchsiaResourceDialect,
8820            >,
8821            offset: usize,
8822            _depth: fidl::encoding::Depth,
8823        ) -> fidl::Result<()> {
8824            encoder.debug_check_bounds::<VendorOpenHciResponse>(offset);
8825            // Delegate to tuple encoding.
8826            fidl::encoding::Encode::<VendorOpenHciResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
8827                (
8828                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HciMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.channel),
8829                ),
8830                encoder, offset, _depth
8831            )
8832        }
8833    }
8834    unsafe impl<
8835        T0: fidl::encoding::Encode<
8836                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HciMarker>>,
8837                fidl::encoding::DefaultFuchsiaResourceDialect,
8838            >,
8839    >
8840        fidl::encoding::Encode<VendorOpenHciResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
8841        for (T0,)
8842    {
8843        #[inline]
8844        unsafe fn encode(
8845            self,
8846            encoder: &mut fidl::encoding::Encoder<
8847                '_,
8848                fidl::encoding::DefaultFuchsiaResourceDialect,
8849            >,
8850            offset: usize,
8851            depth: fidl::encoding::Depth,
8852        ) -> fidl::Result<()> {
8853            encoder.debug_check_bounds::<VendorOpenHciResponse>(offset);
8854            // Zero out padding regions. There's no need to apply masks
8855            // because the unmasked parts will be overwritten by fields.
8856            // Write the fields.
8857            self.0.encode(encoder, offset + 0, depth)?;
8858            Ok(())
8859        }
8860    }
8861
8862    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8863        for VendorOpenHciResponse
8864    {
8865        #[inline(always)]
8866        fn new_empty() -> Self {
8867            Self {
8868                channel: fidl::new_empty!(
8869                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HciMarker>>,
8870                    fidl::encoding::DefaultFuchsiaResourceDialect
8871                ),
8872            }
8873        }
8874
8875        #[inline]
8876        unsafe fn decode(
8877            &mut self,
8878            decoder: &mut fidl::encoding::Decoder<
8879                '_,
8880                fidl::encoding::DefaultFuchsiaResourceDialect,
8881            >,
8882            offset: usize,
8883            _depth: fidl::encoding::Depth,
8884        ) -> fidl::Result<()> {
8885            decoder.debug_check_bounds::<Self>(offset);
8886            // Verify that padding bytes are zero.
8887            fidl::decode!(
8888                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<HciMarker>>,
8889                fidl::encoding::DefaultFuchsiaResourceDialect,
8890                &mut self.channel,
8891                decoder,
8892                offset + 0,
8893                _depth
8894            )?;
8895            Ok(())
8896        }
8897    }
8898
8899    impl fidl::encoding::ResourceTypeMarker for VendorOpenSnoopResponse {
8900        type Borrowed<'a> = &'a mut Self;
8901        fn take_or_borrow<'a>(
8902            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8903        ) -> Self::Borrowed<'a> {
8904            value
8905        }
8906    }
8907
8908    unsafe impl fidl::encoding::TypeMarker for VendorOpenSnoopResponse {
8909        type Owned = Self;
8910
8911        #[inline(always)]
8912        fn inline_align(_context: fidl::encoding::Context) -> usize {
8913            4
8914        }
8915
8916        #[inline(always)]
8917        fn inline_size(_context: fidl::encoding::Context) -> usize {
8918            4
8919        }
8920    }
8921
8922    unsafe impl
8923        fidl::encoding::Encode<
8924            VendorOpenSnoopResponse,
8925            fidl::encoding::DefaultFuchsiaResourceDialect,
8926        > for &mut VendorOpenSnoopResponse
8927    {
8928        #[inline]
8929        unsafe fn encode(
8930            self,
8931            encoder: &mut fidl::encoding::Encoder<
8932                '_,
8933                fidl::encoding::DefaultFuchsiaResourceDialect,
8934            >,
8935            offset: usize,
8936            _depth: fidl::encoding::Depth,
8937        ) -> fidl::Result<()> {
8938            encoder.debug_check_bounds::<VendorOpenSnoopResponse>(offset);
8939            // Delegate to tuple encoding.
8940            fidl::encoding::Encode::<VendorOpenSnoopResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
8941                (
8942                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnoopMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.channel),
8943                ),
8944                encoder, offset, _depth
8945            )
8946        }
8947    }
8948    unsafe impl<
8949        T0: fidl::encoding::Encode<
8950                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnoopMarker>>,
8951                fidl::encoding::DefaultFuchsiaResourceDialect,
8952            >,
8953    >
8954        fidl::encoding::Encode<
8955            VendorOpenSnoopResponse,
8956            fidl::encoding::DefaultFuchsiaResourceDialect,
8957        > for (T0,)
8958    {
8959        #[inline]
8960        unsafe fn encode(
8961            self,
8962            encoder: &mut fidl::encoding::Encoder<
8963                '_,
8964                fidl::encoding::DefaultFuchsiaResourceDialect,
8965            >,
8966            offset: usize,
8967            depth: fidl::encoding::Depth,
8968        ) -> fidl::Result<()> {
8969            encoder.debug_check_bounds::<VendorOpenSnoopResponse>(offset);
8970            // Zero out padding regions. There's no need to apply masks
8971            // because the unmasked parts will be overwritten by fields.
8972            // Write the fields.
8973            self.0.encode(encoder, offset + 0, depth)?;
8974            Ok(())
8975        }
8976    }
8977
8978    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8979        for VendorOpenSnoopResponse
8980    {
8981        #[inline(always)]
8982        fn new_empty() -> Self {
8983            Self {
8984                channel: fidl::new_empty!(
8985                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnoopMarker>>,
8986                    fidl::encoding::DefaultFuchsiaResourceDialect
8987                ),
8988            }
8989        }
8990
8991        #[inline]
8992        unsafe fn decode(
8993            &mut self,
8994            decoder: &mut fidl::encoding::Decoder<
8995                '_,
8996                fidl::encoding::DefaultFuchsiaResourceDialect,
8997            >,
8998            offset: usize,
8999            _depth: fidl::encoding::Depth,
9000        ) -> fidl::Result<()> {
9001            decoder.debug_check_bounds::<Self>(offset);
9002            // Verify that padding bytes are zero.
9003            fidl::decode!(
9004                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SnoopMarker>>,
9005                fidl::encoding::DefaultFuchsiaResourceDialect,
9006                &mut self.channel,
9007                decoder,
9008                offset + 0,
9009                _depth
9010            )?;
9011            Ok(())
9012        }
9013    }
9014
9015    impl HciTransportConfigureScoRequest {
9016        #[inline(always)]
9017        fn max_ordinal_present(&self) -> u64 {
9018            if let Some(_) = self.connection {
9019                return 4;
9020            }
9021            if let Some(_) = self.sample_rate {
9022                return 3;
9023            }
9024            if let Some(_) = self.encoding {
9025                return 2;
9026            }
9027            if let Some(_) = self.coding_format {
9028                return 1;
9029            }
9030            0
9031        }
9032    }
9033
9034    impl fidl::encoding::ResourceTypeMarker for HciTransportConfigureScoRequest {
9035        type Borrowed<'a> = &'a mut Self;
9036        fn take_or_borrow<'a>(
9037            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9038        ) -> Self::Borrowed<'a> {
9039            value
9040        }
9041    }
9042
9043    unsafe impl fidl::encoding::TypeMarker for HciTransportConfigureScoRequest {
9044        type Owned = Self;
9045
9046        #[inline(always)]
9047        fn inline_align(_context: fidl::encoding::Context) -> usize {
9048            8
9049        }
9050
9051        #[inline(always)]
9052        fn inline_size(_context: fidl::encoding::Context) -> usize {
9053            16
9054        }
9055    }
9056
9057    unsafe impl
9058        fidl::encoding::Encode<
9059            HciTransportConfigureScoRequest,
9060            fidl::encoding::DefaultFuchsiaResourceDialect,
9061        > for &mut HciTransportConfigureScoRequest
9062    {
9063        unsafe fn encode(
9064            self,
9065            encoder: &mut fidl::encoding::Encoder<
9066                '_,
9067                fidl::encoding::DefaultFuchsiaResourceDialect,
9068            >,
9069            offset: usize,
9070            mut depth: fidl::encoding::Depth,
9071        ) -> fidl::Result<()> {
9072            encoder.debug_check_bounds::<HciTransportConfigureScoRequest>(offset);
9073            // Vector header
9074            let max_ordinal: u64 = self.max_ordinal_present();
9075            encoder.write_num(max_ordinal, offset);
9076            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9077            // Calling encoder.out_of_line_offset(0) is not allowed.
9078            if max_ordinal == 0 {
9079                return Ok(());
9080            }
9081            depth.increment()?;
9082            let envelope_size = 8;
9083            let bytes_len = max_ordinal as usize * envelope_size;
9084            #[allow(unused_variables)]
9085            let offset = encoder.out_of_line_offset(bytes_len);
9086            let mut _prev_end_offset: usize = 0;
9087            if 1 > max_ordinal {
9088                return Ok(());
9089            }
9090
9091            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9092            // are envelope_size bytes.
9093            let cur_offset: usize = (1 - 1) * envelope_size;
9094
9095            // Zero reserved fields.
9096            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9097
9098            // Safety:
9099            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9100            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9101            //   envelope_size bytes, there is always sufficient room.
9102            fidl::encoding::encode_in_envelope_optional::<
9103                ScoCodingFormat,
9104                fidl::encoding::DefaultFuchsiaResourceDialect,
9105            >(
9106                self.coding_format
9107                    .as_ref()
9108                    .map(<ScoCodingFormat as fidl::encoding::ValueTypeMarker>::borrow),
9109                encoder,
9110                offset + cur_offset,
9111                depth,
9112            )?;
9113
9114            _prev_end_offset = cur_offset + envelope_size;
9115            if 2 > max_ordinal {
9116                return Ok(());
9117            }
9118
9119            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9120            // are envelope_size bytes.
9121            let cur_offset: usize = (2 - 1) * envelope_size;
9122
9123            // Zero reserved fields.
9124            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9125
9126            // Safety:
9127            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9128            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9129            //   envelope_size bytes, there is always sufficient room.
9130            fidl::encoding::encode_in_envelope_optional::<
9131                ScoEncoding,
9132                fidl::encoding::DefaultFuchsiaResourceDialect,
9133            >(
9134                self.encoding
9135                    .as_ref()
9136                    .map(<ScoEncoding as fidl::encoding::ValueTypeMarker>::borrow),
9137                encoder,
9138                offset + cur_offset,
9139                depth,
9140            )?;
9141
9142            _prev_end_offset = cur_offset + envelope_size;
9143            if 3 > max_ordinal {
9144                return Ok(());
9145            }
9146
9147            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9148            // are envelope_size bytes.
9149            let cur_offset: usize = (3 - 1) * envelope_size;
9150
9151            // Zero reserved fields.
9152            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9153
9154            // Safety:
9155            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9156            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9157            //   envelope_size bytes, there is always sufficient room.
9158            fidl::encoding::encode_in_envelope_optional::<
9159                ScoSampleRate,
9160                fidl::encoding::DefaultFuchsiaResourceDialect,
9161            >(
9162                self.sample_rate
9163                    .as_ref()
9164                    .map(<ScoSampleRate as fidl::encoding::ValueTypeMarker>::borrow),
9165                encoder,
9166                offset + cur_offset,
9167                depth,
9168            )?;
9169
9170            _prev_end_offset = cur_offset + envelope_size;
9171            if 4 > max_ordinal {
9172                return Ok(());
9173            }
9174
9175            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9176            // are envelope_size bytes.
9177            let cur_offset: usize = (4 - 1) * envelope_size;
9178
9179            // Zero reserved fields.
9180            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9181
9182            // Safety:
9183            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9184            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9185            //   envelope_size bytes, there is always sufficient room.
9186            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScoConnectionMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
9187            self.connection.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScoConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
9188            encoder, offset + cur_offset, depth
9189        )?;
9190
9191            _prev_end_offset = cur_offset + envelope_size;
9192
9193            Ok(())
9194        }
9195    }
9196
9197    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9198        for HciTransportConfigureScoRequest
9199    {
9200        #[inline(always)]
9201        fn new_empty() -> Self {
9202            Self::default()
9203        }
9204
9205        unsafe fn decode(
9206            &mut self,
9207            decoder: &mut fidl::encoding::Decoder<
9208                '_,
9209                fidl::encoding::DefaultFuchsiaResourceDialect,
9210            >,
9211            offset: usize,
9212            mut depth: fidl::encoding::Depth,
9213        ) -> fidl::Result<()> {
9214            decoder.debug_check_bounds::<Self>(offset);
9215            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9216                None => return Err(fidl::Error::NotNullable),
9217                Some(len) => len,
9218            };
9219            // Calling decoder.out_of_line_offset(0) is not allowed.
9220            if len == 0 {
9221                return Ok(());
9222            };
9223            depth.increment()?;
9224            let envelope_size = 8;
9225            let bytes_len = len * envelope_size;
9226            let offset = decoder.out_of_line_offset(bytes_len)?;
9227            // Decode the envelope for each type.
9228            let mut _next_ordinal_to_read = 0;
9229            let mut next_offset = offset;
9230            let end_offset = offset + bytes_len;
9231            _next_ordinal_to_read += 1;
9232            if next_offset >= end_offset {
9233                return Ok(());
9234            }
9235
9236            // Decode unknown envelopes for gaps in ordinals.
9237            while _next_ordinal_to_read < 1 {
9238                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9239                _next_ordinal_to_read += 1;
9240                next_offset += envelope_size;
9241            }
9242
9243            let next_out_of_line = decoder.next_out_of_line();
9244            let handles_before = decoder.remaining_handles();
9245            if let Some((inlined, num_bytes, num_handles)) =
9246                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9247            {
9248                let member_inline_size =
9249                    <ScoCodingFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9250                if inlined != (member_inline_size <= 4) {
9251                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9252                }
9253                let inner_offset;
9254                let mut inner_depth = depth.clone();
9255                if inlined {
9256                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9257                    inner_offset = next_offset;
9258                } else {
9259                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9260                    inner_depth.increment()?;
9261                }
9262                let val_ref = self.coding_format.get_or_insert_with(|| {
9263                    fidl::new_empty!(ScoCodingFormat, fidl::encoding::DefaultFuchsiaResourceDialect)
9264                });
9265                fidl::decode!(
9266                    ScoCodingFormat,
9267                    fidl::encoding::DefaultFuchsiaResourceDialect,
9268                    val_ref,
9269                    decoder,
9270                    inner_offset,
9271                    inner_depth
9272                )?;
9273                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9274                {
9275                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9276                }
9277                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9278                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9279                }
9280            }
9281
9282            next_offset += envelope_size;
9283            _next_ordinal_to_read += 1;
9284            if next_offset >= end_offset {
9285                return Ok(());
9286            }
9287
9288            // Decode unknown envelopes for gaps in ordinals.
9289            while _next_ordinal_to_read < 2 {
9290                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9291                _next_ordinal_to_read += 1;
9292                next_offset += envelope_size;
9293            }
9294
9295            let next_out_of_line = decoder.next_out_of_line();
9296            let handles_before = decoder.remaining_handles();
9297            if let Some((inlined, num_bytes, num_handles)) =
9298                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9299            {
9300                let member_inline_size =
9301                    <ScoEncoding as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9302                if inlined != (member_inline_size <= 4) {
9303                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9304                }
9305                let inner_offset;
9306                let mut inner_depth = depth.clone();
9307                if inlined {
9308                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9309                    inner_offset = next_offset;
9310                } else {
9311                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9312                    inner_depth.increment()?;
9313                }
9314                let val_ref = self.encoding.get_or_insert_with(|| {
9315                    fidl::new_empty!(ScoEncoding, fidl::encoding::DefaultFuchsiaResourceDialect)
9316                });
9317                fidl::decode!(
9318                    ScoEncoding,
9319                    fidl::encoding::DefaultFuchsiaResourceDialect,
9320                    val_ref,
9321                    decoder,
9322                    inner_offset,
9323                    inner_depth
9324                )?;
9325                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9326                {
9327                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9328                }
9329                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9330                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9331                }
9332            }
9333
9334            next_offset += envelope_size;
9335            _next_ordinal_to_read += 1;
9336            if next_offset >= end_offset {
9337                return Ok(());
9338            }
9339
9340            // Decode unknown envelopes for gaps in ordinals.
9341            while _next_ordinal_to_read < 3 {
9342                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9343                _next_ordinal_to_read += 1;
9344                next_offset += envelope_size;
9345            }
9346
9347            let next_out_of_line = decoder.next_out_of_line();
9348            let handles_before = decoder.remaining_handles();
9349            if let Some((inlined, num_bytes, num_handles)) =
9350                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9351            {
9352                let member_inline_size =
9353                    <ScoSampleRate as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9354                if inlined != (member_inline_size <= 4) {
9355                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9356                }
9357                let inner_offset;
9358                let mut inner_depth = depth.clone();
9359                if inlined {
9360                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9361                    inner_offset = next_offset;
9362                } else {
9363                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9364                    inner_depth.increment()?;
9365                }
9366                let val_ref = self.sample_rate.get_or_insert_with(|| {
9367                    fidl::new_empty!(ScoSampleRate, fidl::encoding::DefaultFuchsiaResourceDialect)
9368                });
9369                fidl::decode!(
9370                    ScoSampleRate,
9371                    fidl::encoding::DefaultFuchsiaResourceDialect,
9372                    val_ref,
9373                    decoder,
9374                    inner_offset,
9375                    inner_depth
9376                )?;
9377                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9378                {
9379                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9380                }
9381                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9382                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9383                }
9384            }
9385
9386            next_offset += envelope_size;
9387            _next_ordinal_to_read += 1;
9388            if next_offset >= end_offset {
9389                return Ok(());
9390            }
9391
9392            // Decode unknown envelopes for gaps in ordinals.
9393            while _next_ordinal_to_read < 4 {
9394                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9395                _next_ordinal_to_read += 1;
9396                next_offset += envelope_size;
9397            }
9398
9399            let next_out_of_line = decoder.next_out_of_line();
9400            let handles_before = decoder.remaining_handles();
9401            if let Some((inlined, num_bytes, num_handles)) =
9402                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9403            {
9404                let member_inline_size = <fidl::encoding::Endpoint<
9405                    fidl::endpoints::ServerEnd<ScoConnectionMarker>,
9406                > as fidl::encoding::TypeMarker>::inline_size(
9407                    decoder.context
9408                );
9409                if inlined != (member_inline_size <= 4) {
9410                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9411                }
9412                let inner_offset;
9413                let mut inner_depth = depth.clone();
9414                if inlined {
9415                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9416                    inner_offset = next_offset;
9417                } else {
9418                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9419                    inner_depth.increment()?;
9420                }
9421                let val_ref = self.connection.get_or_insert_with(|| {
9422                    fidl::new_empty!(
9423                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScoConnectionMarker>>,
9424                        fidl::encoding::DefaultFuchsiaResourceDialect
9425                    )
9426                });
9427                fidl::decode!(
9428                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScoConnectionMarker>>,
9429                    fidl::encoding::DefaultFuchsiaResourceDialect,
9430                    val_ref,
9431                    decoder,
9432                    inner_offset,
9433                    inner_depth
9434                )?;
9435                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9436                {
9437                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9438                }
9439                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9440                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9441                }
9442            }
9443
9444            next_offset += envelope_size;
9445
9446            // Decode the remaining unknown envelopes.
9447            while next_offset < end_offset {
9448                _next_ordinal_to_read += 1;
9449                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9450                next_offset += envelope_size;
9451            }
9452
9453            Ok(())
9454        }
9455    }
9456
9457    impl PeerParameters {
9458        #[inline(always)]
9459        fn max_ordinal_present(&self) -> u64 {
9460            if let Some(_) = self.channel {
9461                return 3;
9462            }
9463            if let Some(_) = self.connectable {
9464                return 2;
9465            }
9466            if let Some(_) = self.address {
9467                return 1;
9468            }
9469            0
9470        }
9471    }
9472
9473    impl fidl::encoding::ResourceTypeMarker for PeerParameters {
9474        type Borrowed<'a> = &'a mut Self;
9475        fn take_or_borrow<'a>(
9476            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9477        ) -> Self::Borrowed<'a> {
9478            value
9479        }
9480    }
9481
9482    unsafe impl fidl::encoding::TypeMarker for PeerParameters {
9483        type Owned = Self;
9484
9485        #[inline(always)]
9486        fn inline_align(_context: fidl::encoding::Context) -> usize {
9487            8
9488        }
9489
9490        #[inline(always)]
9491        fn inline_size(_context: fidl::encoding::Context) -> usize {
9492            16
9493        }
9494    }
9495
9496    unsafe impl
9497        fidl::encoding::Encode<PeerParameters, fidl::encoding::DefaultFuchsiaResourceDialect>
9498        for &mut PeerParameters
9499    {
9500        unsafe fn encode(
9501            self,
9502            encoder: &mut fidl::encoding::Encoder<
9503                '_,
9504                fidl::encoding::DefaultFuchsiaResourceDialect,
9505            >,
9506            offset: usize,
9507            mut depth: fidl::encoding::Depth,
9508        ) -> fidl::Result<()> {
9509            encoder.debug_check_bounds::<PeerParameters>(offset);
9510            // Vector header
9511            let max_ordinal: u64 = self.max_ordinal_present();
9512            encoder.write_num(max_ordinal, offset);
9513            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9514            // Calling encoder.out_of_line_offset(0) is not allowed.
9515            if max_ordinal == 0 {
9516                return Ok(());
9517            }
9518            depth.increment()?;
9519            let envelope_size = 8;
9520            let bytes_len = max_ordinal as usize * envelope_size;
9521            #[allow(unused_variables)]
9522            let offset = encoder.out_of_line_offset(bytes_len);
9523            let mut _prev_end_offset: usize = 0;
9524            if 1 > max_ordinal {
9525                return Ok(());
9526            }
9527
9528            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9529            // are envelope_size bytes.
9530            let cur_offset: usize = (1 - 1) * envelope_size;
9531
9532            // Zero reserved fields.
9533            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9534
9535            // Safety:
9536            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9537            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9538            //   envelope_size bytes, there is always sufficient room.
9539            fidl::encoding::encode_in_envelope_optional::<
9540                fidl_fuchsia_bluetooth::Address,
9541                fidl::encoding::DefaultFuchsiaResourceDialect,
9542            >(
9543                self.address.as_ref().map(
9544                    <fidl_fuchsia_bluetooth::Address as fidl::encoding::ValueTypeMarker>::borrow,
9545                ),
9546                encoder,
9547                offset + cur_offset,
9548                depth,
9549            )?;
9550
9551            _prev_end_offset = cur_offset + envelope_size;
9552            if 2 > max_ordinal {
9553                return Ok(());
9554            }
9555
9556            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9557            // are envelope_size bytes.
9558            let cur_offset: usize = (2 - 1) * envelope_size;
9559
9560            // Zero reserved fields.
9561            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9562
9563            // Safety:
9564            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9565            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9566            //   envelope_size bytes, there is always sufficient room.
9567            fidl::encoding::encode_in_envelope_optional::<
9568                bool,
9569                fidl::encoding::DefaultFuchsiaResourceDialect,
9570            >(
9571                self.connectable.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
9572                encoder,
9573                offset + cur_offset,
9574                depth,
9575            )?;
9576
9577            _prev_end_offset = cur_offset + envelope_size;
9578            if 3 > max_ordinal {
9579                return Ok(());
9580            }
9581
9582            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9583            // are envelope_size bytes.
9584            let cur_offset: usize = (3 - 1) * envelope_size;
9585
9586            // Zero reserved fields.
9587            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9588
9589            // Safety:
9590            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9591            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9592            //   envelope_size bytes, there is always sufficient room.
9593            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
9594            self.channel.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
9595            encoder, offset + cur_offset, depth
9596        )?;
9597
9598            _prev_end_offset = cur_offset + envelope_size;
9599
9600            Ok(())
9601        }
9602    }
9603
9604    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9605        for PeerParameters
9606    {
9607        #[inline(always)]
9608        fn new_empty() -> Self {
9609            Self::default()
9610        }
9611
9612        unsafe fn decode(
9613            &mut self,
9614            decoder: &mut fidl::encoding::Decoder<
9615                '_,
9616                fidl::encoding::DefaultFuchsiaResourceDialect,
9617            >,
9618            offset: usize,
9619            mut depth: fidl::encoding::Depth,
9620        ) -> fidl::Result<()> {
9621            decoder.debug_check_bounds::<Self>(offset);
9622            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9623                None => return Err(fidl::Error::NotNullable),
9624                Some(len) => len,
9625            };
9626            // Calling decoder.out_of_line_offset(0) is not allowed.
9627            if len == 0 {
9628                return Ok(());
9629            };
9630            depth.increment()?;
9631            let envelope_size = 8;
9632            let bytes_len = len * envelope_size;
9633            let offset = decoder.out_of_line_offset(bytes_len)?;
9634            // Decode the envelope for each type.
9635            let mut _next_ordinal_to_read = 0;
9636            let mut next_offset = offset;
9637            let end_offset = offset + bytes_len;
9638            _next_ordinal_to_read += 1;
9639            if next_offset >= end_offset {
9640                return Ok(());
9641            }
9642
9643            // Decode unknown envelopes for gaps in ordinals.
9644            while _next_ordinal_to_read < 1 {
9645                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9646                _next_ordinal_to_read += 1;
9647                next_offset += envelope_size;
9648            }
9649
9650            let next_out_of_line = decoder.next_out_of_line();
9651            let handles_before = decoder.remaining_handles();
9652            if let Some((inlined, num_bytes, num_handles)) =
9653                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9654            {
9655                let member_inline_size =
9656                    <fidl_fuchsia_bluetooth::Address as fidl::encoding::TypeMarker>::inline_size(
9657                        decoder.context,
9658                    );
9659                if inlined != (member_inline_size <= 4) {
9660                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9661                }
9662                let inner_offset;
9663                let mut inner_depth = depth.clone();
9664                if inlined {
9665                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9666                    inner_offset = next_offset;
9667                } else {
9668                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9669                    inner_depth.increment()?;
9670                }
9671                let val_ref = self.address.get_or_insert_with(|| {
9672                    fidl::new_empty!(
9673                        fidl_fuchsia_bluetooth::Address,
9674                        fidl::encoding::DefaultFuchsiaResourceDialect
9675                    )
9676                });
9677                fidl::decode!(
9678                    fidl_fuchsia_bluetooth::Address,
9679                    fidl::encoding::DefaultFuchsiaResourceDialect,
9680                    val_ref,
9681                    decoder,
9682                    inner_offset,
9683                    inner_depth
9684                )?;
9685                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9686                {
9687                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9688                }
9689                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9690                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9691                }
9692            }
9693
9694            next_offset += envelope_size;
9695            _next_ordinal_to_read += 1;
9696            if next_offset >= end_offset {
9697                return Ok(());
9698            }
9699
9700            // Decode unknown envelopes for gaps in ordinals.
9701            while _next_ordinal_to_read < 2 {
9702                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9703                _next_ordinal_to_read += 1;
9704                next_offset += envelope_size;
9705            }
9706
9707            let next_out_of_line = decoder.next_out_of_line();
9708            let handles_before = decoder.remaining_handles();
9709            if let Some((inlined, num_bytes, num_handles)) =
9710                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9711            {
9712                let member_inline_size =
9713                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9714                if inlined != (member_inline_size <= 4) {
9715                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9716                }
9717                let inner_offset;
9718                let mut inner_depth = depth.clone();
9719                if inlined {
9720                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9721                    inner_offset = next_offset;
9722                } else {
9723                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9724                    inner_depth.increment()?;
9725                }
9726                let val_ref = self.connectable.get_or_insert_with(|| {
9727                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
9728                });
9729                fidl::decode!(
9730                    bool,
9731                    fidl::encoding::DefaultFuchsiaResourceDialect,
9732                    val_ref,
9733                    decoder,
9734                    inner_offset,
9735                    inner_depth
9736                )?;
9737                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9738                {
9739                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9740                }
9741                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9742                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9743                }
9744            }
9745
9746            next_offset += envelope_size;
9747            _next_ordinal_to_read += 1;
9748            if next_offset >= end_offset {
9749                return Ok(());
9750            }
9751
9752            // Decode unknown envelopes for gaps in ordinals.
9753            while _next_ordinal_to_read < 3 {
9754                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9755                _next_ordinal_to_read += 1;
9756                next_offset += envelope_size;
9757            }
9758
9759            let next_out_of_line = decoder.next_out_of_line();
9760            let handles_before = decoder.remaining_handles();
9761            if let Some((inlined, num_bytes, num_handles)) =
9762                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9763            {
9764                let member_inline_size = <fidl::encoding::Endpoint<
9765                    fidl::endpoints::ServerEnd<PeerMarker>,
9766                > as fidl::encoding::TypeMarker>::inline_size(
9767                    decoder.context
9768                );
9769                if inlined != (member_inline_size <= 4) {
9770                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9771                }
9772                let inner_offset;
9773                let mut inner_depth = depth.clone();
9774                if inlined {
9775                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9776                    inner_offset = next_offset;
9777                } else {
9778                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9779                    inner_depth.increment()?;
9780                }
9781                let val_ref = self.channel.get_or_insert_with(|| {
9782                    fidl::new_empty!(
9783                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerMarker>>,
9784                        fidl::encoding::DefaultFuchsiaResourceDialect
9785                    )
9786                });
9787                fidl::decode!(
9788                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerMarker>>,
9789                    fidl::encoding::DefaultFuchsiaResourceDialect,
9790                    val_ref,
9791                    decoder,
9792                    inner_offset,
9793                    inner_depth
9794                )?;
9795                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9796                {
9797                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9798                }
9799                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9800                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9801                }
9802            }
9803
9804            next_offset += envelope_size;
9805
9806            // Decode the remaining unknown envelopes.
9807            while next_offset < end_offset {
9808                _next_ordinal_to_read += 1;
9809                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9810                next_offset += envelope_size;
9811            }
9812
9813            Ok(())
9814        }
9815    }
9816
9817    impl VirtualControllerCreateLoopbackDeviceRequest {
9818        #[inline(always)]
9819        fn max_ordinal_present(&self) -> u64 {
9820            if let Some(_) = self.uart_channel {
9821                return 1;
9822            }
9823            0
9824        }
9825    }
9826
9827    impl fidl::encoding::ResourceTypeMarker for VirtualControllerCreateLoopbackDeviceRequest {
9828        type Borrowed<'a> = &'a mut Self;
9829        fn take_or_borrow<'a>(
9830            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9831        ) -> Self::Borrowed<'a> {
9832            value
9833        }
9834    }
9835
9836    unsafe impl fidl::encoding::TypeMarker for VirtualControllerCreateLoopbackDeviceRequest {
9837        type Owned = Self;
9838
9839        #[inline(always)]
9840        fn inline_align(_context: fidl::encoding::Context) -> usize {
9841            8
9842        }
9843
9844        #[inline(always)]
9845        fn inline_size(_context: fidl::encoding::Context) -> usize {
9846            16
9847        }
9848    }
9849
9850    unsafe impl
9851        fidl::encoding::Encode<
9852            VirtualControllerCreateLoopbackDeviceRequest,
9853            fidl::encoding::DefaultFuchsiaResourceDialect,
9854        > for &mut VirtualControllerCreateLoopbackDeviceRequest
9855    {
9856        unsafe fn encode(
9857            self,
9858            encoder: &mut fidl::encoding::Encoder<
9859                '_,
9860                fidl::encoding::DefaultFuchsiaResourceDialect,
9861            >,
9862            offset: usize,
9863            mut depth: fidl::encoding::Depth,
9864        ) -> fidl::Result<()> {
9865            encoder.debug_check_bounds::<VirtualControllerCreateLoopbackDeviceRequest>(offset);
9866            // Vector header
9867            let max_ordinal: u64 = self.max_ordinal_present();
9868            encoder.write_num(max_ordinal, offset);
9869            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9870            // Calling encoder.out_of_line_offset(0) is not allowed.
9871            if max_ordinal == 0 {
9872                return Ok(());
9873            }
9874            depth.increment()?;
9875            let envelope_size = 8;
9876            let bytes_len = max_ordinal as usize * envelope_size;
9877            #[allow(unused_variables)]
9878            let offset = encoder.out_of_line_offset(bytes_len);
9879            let mut _prev_end_offset: usize = 0;
9880            if 1 > max_ordinal {
9881                return Ok(());
9882            }
9883
9884            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9885            // are envelope_size bytes.
9886            let cur_offset: usize = (1 - 1) * envelope_size;
9887
9888            // Zero reserved fields.
9889            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9890
9891            // Safety:
9892            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9893            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9894            //   envelope_size bytes, there is always sufficient room.
9895            fidl::encoding::encode_in_envelope_optional::<
9896                fidl::encoding::HandleType<
9897                    fidl::Channel,
9898                    { fidl::ObjectType::CHANNEL.into_raw() },
9899                    2147483648,
9900                >,
9901                fidl::encoding::DefaultFuchsiaResourceDialect,
9902            >(
9903                self.uart_channel.as_mut().map(
9904                    <fidl::encoding::HandleType<
9905                        fidl::Channel,
9906                        { fidl::ObjectType::CHANNEL.into_raw() },
9907                        2147483648,
9908                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
9909                ),
9910                encoder,
9911                offset + cur_offset,
9912                depth,
9913            )?;
9914
9915            _prev_end_offset = cur_offset + envelope_size;
9916
9917            Ok(())
9918        }
9919    }
9920
9921    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9922        for VirtualControllerCreateLoopbackDeviceRequest
9923    {
9924        #[inline(always)]
9925        fn new_empty() -> Self {
9926            Self::default()
9927        }
9928
9929        unsafe fn decode(
9930            &mut self,
9931            decoder: &mut fidl::encoding::Decoder<
9932                '_,
9933                fidl::encoding::DefaultFuchsiaResourceDialect,
9934            >,
9935            offset: usize,
9936            mut depth: fidl::encoding::Depth,
9937        ) -> fidl::Result<()> {
9938            decoder.debug_check_bounds::<Self>(offset);
9939            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9940                None => return Err(fidl::Error::NotNullable),
9941                Some(len) => len,
9942            };
9943            // Calling decoder.out_of_line_offset(0) is not allowed.
9944            if len == 0 {
9945                return Ok(());
9946            };
9947            depth.increment()?;
9948            let envelope_size = 8;
9949            let bytes_len = len * envelope_size;
9950            let offset = decoder.out_of_line_offset(bytes_len)?;
9951            // Decode the envelope for each type.
9952            let mut _next_ordinal_to_read = 0;
9953            let mut next_offset = offset;
9954            let end_offset = offset + bytes_len;
9955            _next_ordinal_to_read += 1;
9956            if next_offset >= end_offset {
9957                return Ok(());
9958            }
9959
9960            // Decode unknown envelopes for gaps in ordinals.
9961            while _next_ordinal_to_read < 1 {
9962                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9963                _next_ordinal_to_read += 1;
9964                next_offset += envelope_size;
9965            }
9966
9967            let next_out_of_line = decoder.next_out_of_line();
9968            let handles_before = decoder.remaining_handles();
9969            if let Some((inlined, num_bytes, num_handles)) =
9970                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9971            {
9972                let member_inline_size = <fidl::encoding::HandleType<
9973                    fidl::Channel,
9974                    { fidl::ObjectType::CHANNEL.into_raw() },
9975                    2147483648,
9976                > as fidl::encoding::TypeMarker>::inline_size(
9977                    decoder.context
9978                );
9979                if inlined != (member_inline_size <= 4) {
9980                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9981                }
9982                let inner_offset;
9983                let mut inner_depth = depth.clone();
9984                if inlined {
9985                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9986                    inner_offset = next_offset;
9987                } else {
9988                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9989                    inner_depth.increment()?;
9990                }
9991                let val_ref =
9992                self.uart_channel.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
9993                fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
9994                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9995                {
9996                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9997                }
9998                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9999                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10000                }
10001            }
10002
10003            next_offset += envelope_size;
10004
10005            // Decode the remaining unknown envelopes.
10006            while next_offset < end_offset {
10007                _next_ordinal_to_read += 1;
10008                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10009                next_offset += envelope_size;
10010            }
10011
10012            Ok(())
10013        }
10014    }
10015}