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