Skip to main content

fidl_fuchsia_bluetooth_le/
fidl_fuchsia_bluetooth_le.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_bluetooth_le_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct AdvertisedPeripheralOnConnectedRequest {
16    pub peer: Peer,
17    pub connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for AdvertisedPeripheralOnConnectedRequest
22{
23}
24
25#[derive(Debug, PartialEq)]
26pub struct CentralConnectPeripheralRequest {
27    pub identifier: String,
28    pub options: ConnectionOptions,
29    pub gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
33    for CentralConnectPeripheralRequest
34{
35}
36
37#[derive(Debug, PartialEq)]
38pub struct CentralConnectRequest {
39    pub id: fidl_fuchsia_bluetooth::PeerId,
40    pub options: ConnectionOptions,
41    pub handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
42}
43
44impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CentralConnectRequest {}
45
46#[derive(Debug, PartialEq)]
47pub struct CentralScanRequest {
48    pub options: ScanOptions,
49    pub result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
50}
51
52impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CentralScanRequest {}
53
54#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
55pub struct ChannelListenerAcceptRequest {
56    pub channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
57}
58
59impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
60    for ChannelListenerAcceptRequest
61{
62}
63
64#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
65pub struct ConnectionRequestGattClientRequest {
66    pub client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
67}
68
69impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
70    for ConnectionRequestGattClientRequest
71{
72}
73
74#[derive(Debug, PartialEq)]
75pub struct PeripheralAdvertiseRequest {
76    pub parameters: AdvertisingParameters,
77    pub advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
78}
79
80impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
81    for PeripheralAdvertiseRequest
82{
83}
84
85#[derive(Debug, PartialEq)]
86pub struct PeripheralOnPeerConnectedRequest {
87    pub peer: Peer,
88    pub connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
89}
90
91impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
92    for PeripheralOnPeerConnectedRequest
93{
94}
95
96#[derive(Debug, PartialEq)]
97pub struct PeripheralStartAdvertisingRequest {
98    pub parameters: AdvertisingParameters,
99    pub handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
100}
101
102impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
103    for PeripheralStartAdvertisingRequest
104{
105}
106
107#[derive(Debug, Default, PartialEq)]
108pub struct CentralCreateConnectedIsochronousGroupRequest {
109    /// Required. Parameters for the CIG.
110    pub cig_parameters: Option<CigParameters>,
111    /// Required. At least one CIS must be included.
112    pub cis_requested_parameters: Option<Vec<CisRequestedParameters>>,
113    /// Required. ConnectedIsochronousGroup protocol to connect.
114    pub cig: Option<fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>>,
115    #[doc(hidden)]
116    pub __source_breaking: fidl::marker::SourceBreaking,
117}
118
119impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
120    for CentralCreateConnectedIsochronousGroupRequest
121{
122}
123
124#[derive(Debug, Default, PartialEq)]
125pub struct CentralSyncToPeriodicAdvertisingRequest {
126    /// Identifier of the peer transmitting the periodic advertisement, as indicated via
127    /// `Peer.periodic_advertising_interval`.
128    /// Required.
129    pub peer_id: Option<fidl_fuchsia_bluetooth::PeerId>,
130    /// The Advertising SID of the advertisement used to synchronize. This is found in a
131    /// standard scan result (`Peer.advertising_sid`).
132    /// Required.
133    pub advertising_sid: Option<u8>,
134    /// Upon successful synchronization, the `PeriodicAdvertisingSync.OnEstablished` event will
135    /// be sent. See `PeriodicAdvertisingSync` for failure epitaphs.
136    /// Required.
137    pub sync: Option<fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>>,
138    pub config: Option<PeriodicAdvertisingSyncConfiguration>,
139    #[doc(hidden)]
140    pub __source_breaking: fidl::marker::SourceBreaking,
141}
142
143impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
144    for CentralSyncToPeriodicAdvertisingRequest
145{
146}
147
148#[derive(Debug, Default, PartialEq)]
149pub struct ChannelListenerConnectedRequest {
150    /// Required.
151    pub channel: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>>,
152    /// Channel offload extension. See ChannelOffloadExt.
153    /// Only present for privileged clients, enabling them to initiate
154    /// channel offloading.
155    pub ext_offload: Option<fidl::endpoints::ClientEnd<ChannelOffloadExtMarker>>,
156    #[doc(hidden)]
157    pub __source_breaking: fidl::marker::SourceBreaking,
158}
159
160impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
161    for ChannelListenerConnectedRequest
162{
163}
164
165#[derive(Debug, Default, PartialEq)]
166pub struct ChannelListenerRegistryListenL2capRequest {
167    /// Accepted parameters for the local side of the channel.
168    pub parameters: Option<AcceptedChannelParameters>,
169    /// The channel listener protocol to open.
170    pub listener: Option<fidl::endpoints::ClientEnd<ChannelListenerMarker>>,
171    #[doc(hidden)]
172    pub __source_breaking: fidl::marker::SourceBreaking,
173}
174
175impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
176    for ChannelListenerRegistryListenL2capRequest
177{
178}
179
180#[derive(Debug, Default, PartialEq)]
181pub struct CisRequestedParameters {
182    /// ID selected to uniquely identify a stream within a CIG. All `cis_id`s
183    /// must be distinct within a single creation request.
184    /// Required.
185    pub cis_id: Option<u8>,
186    /// The channel that will be used for operations on the stream.
187    /// Required.
188    pub connection_stream: Option<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>,
189    /// Maximum SDU size (central => peripheral). This is a function of the
190    /// codec being used. Unidirectional streams should set the unused
191    /// direction to 0.
192    /// Optional. If not provided, a value of 0 will be used (unidirectional)
193    pub max_sdu_size_outgoing: Option<u16>,
194    /// Maximum SDU size (peripheral => central). This is a function of the
195    /// codec being used. Unidirectional streams should set the unused
196    /// direction to 0.
197    /// Optional. If not provided, a value of 0 will be used (unidirectional)
198    pub max_sdu_size_incoming: Option<u16>,
199    #[doc(hidden)]
200    pub __source_breaking: fidl::marker::SourceBreaking,
201}
202
203impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CisRequestedParameters {}
204
205#[derive(Debug, Default, PartialEq)]
206pub struct ConnectionAcceptCisRequest {
207    /// Identifier of the CIG that contains the requested CIS. Required.
208    pub cig_id: Option<u8>,
209    /// Identifier of the requested CIS. Required.
210    pub cis_id: Option<u8>,
211    /// When the stream is established, the server will invoke
212    /// IsochronousStream::OnCisEstablished() on this channel. Required.
213    ///
214    /// If the client end of this channel is closed, requests of the corresponding CIG/CIS
215    /// combination will be rejected until/unless another call is made to AcceptCis() with
216    /// the same CIG/CIS parameters.
217    pub connection_stream: Option<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>,
218    #[doc(hidden)]
219    pub __source_breaking: fidl::marker::SourceBreaking,
220}
221
222impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
223    for ConnectionAcceptCisRequest
224{
225}
226
227#[derive(Debug, Default, PartialEq)]
228pub struct ConnectionAcceptPeriodicAdvertisingSyncTransferRequest {
229    /// When the sync is established, the `PeriodicAdvertisingSync.OnEstablished` event will be
230    /// sent containing the service data received with the transfer. Closing the client end will
231    /// cancel the transfer.
232    pub sync: Option<fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>>,
233    pub config: Option<PeriodicAdvertisingSyncConfiguration>,
234    #[doc(hidden)]
235    pub __source_breaking: fidl::marker::SourceBreaking,
236}
237
238impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
239    for ConnectionAcceptPeriodicAdvertisingSyncTransferRequest
240{
241}
242
243#[derive(Debug, Default, PartialEq)]
244pub struct ConnectionConnectL2capRequest {
245    /// Parameters for the local side of the channel.
246    pub parameters: Option<fidl_fuchsia_bluetooth::ChannelParameters>,
247    /// The channel protocol to open.
248    pub channel: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>>,
249    /// The PSM of the remote side to connect to.
250    pub psm: Option<u16>,
251    /// Channel offload extension. See [`fuchsia.bluetooth.le/ChannelOffloadExt`].
252    /// Only privileged clients are allowed to offload channels. This
253    /// protocol will be closed for other clients. The client must
254    /// additionally call `ChannelOffloadExt.StartOffload` to start offloading.
255    pub ext_offload: Option<fidl::endpoints::ServerEnd<ChannelOffloadExtMarker>>,
256    #[doc(hidden)]
257    pub __source_breaking: fidl::marker::SourceBreaking,
258}
259
260impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
261    for ConnectionConnectL2capRequest
262{
263}
264
265#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
266pub struct AdvertisedPeripheralMarker;
267
268impl fidl::endpoints::ProtocolMarker for AdvertisedPeripheralMarker {
269    type Proxy = AdvertisedPeripheralProxy;
270    type RequestStream = AdvertisedPeripheralRequestStream;
271    #[cfg(target_os = "fuchsia")]
272    type SynchronousProxy = AdvertisedPeripheralSynchronousProxy;
273
274    const DEBUG_NAME: &'static str = "(anonymous) AdvertisedPeripheral";
275}
276
277pub trait AdvertisedPeripheralProxyInterface: Send + Sync {
278    type OnConnectedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
279    fn r#on_connected(
280        &self,
281        peer: &Peer,
282        connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
283    ) -> Self::OnConnectedResponseFut;
284}
285#[derive(Debug)]
286#[cfg(target_os = "fuchsia")]
287pub struct AdvertisedPeripheralSynchronousProxy {
288    client: fidl::client::sync::Client,
289}
290
291#[cfg(target_os = "fuchsia")]
292impl fidl::endpoints::SynchronousProxy for AdvertisedPeripheralSynchronousProxy {
293    type Proxy = AdvertisedPeripheralProxy;
294    type Protocol = AdvertisedPeripheralMarker;
295
296    fn from_channel(inner: fidl::Channel) -> Self {
297        Self::new(inner)
298    }
299
300    fn into_channel(self) -> fidl::Channel {
301        self.client.into_channel()
302    }
303
304    fn as_channel(&self) -> &fidl::Channel {
305        self.client.as_channel()
306    }
307}
308
309#[cfg(target_os = "fuchsia")]
310impl AdvertisedPeripheralSynchronousProxy {
311    pub fn new(channel: fidl::Channel) -> Self {
312        Self { client: fidl::client::sync::Client::new(channel) }
313    }
314
315    pub fn into_channel(self) -> fidl::Channel {
316        self.client.into_channel()
317    }
318
319    /// Waits until an event arrives and returns it. It is safe for other
320    /// threads to make concurrent requests while waiting for an event.
321    pub fn wait_for_event(
322        &self,
323        deadline: zx::MonotonicInstant,
324    ) -> Result<AdvertisedPeripheralEvent, fidl::Error> {
325        AdvertisedPeripheralEvent::decode(
326            self.client.wait_for_event::<AdvertisedPeripheralMarker>(deadline)?,
327        )
328    }
329
330    /// Called when a remote LE central connects to this peripheral when
331    /// connectable advertising is enabled via
332    /// [`fuchsia.bluetooth.le/Peripheral.Advertise`]. When this call is made,
333    /// the system has paused advertising, and will not continue until it
334    /// receives a response.
335    ///
336    /// The returned [`fuchsia.bluetooth.le/Connection`] protocol can be used to
337    /// interact with the peer. It also represents a peripheral's ownership over
338    /// the connection: the client can drop the protocol to request a
339    /// disconnection. Similarly, the protocol is closed by the system to
340    /// indicate that the connection to the peer has been lost.
341    ///
342    /// + request `peer` Information about the central that initiated the
343    ///   connection.
344    /// + request `connection` Represents the connection.
345    /// - response An empty response should be sent to acknowledge the
346    ///   connection and resume advertising (for flow control).
347    pub fn r#on_connected(
348        &self,
349        mut peer: &Peer,
350        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
351        ___deadline: zx::MonotonicInstant,
352    ) -> Result<(), fidl::Error> {
353        let _response = self.client.send_query::<
354            AdvertisedPeripheralOnConnectedRequest,
355            fidl::encoding::EmptyPayload,
356            AdvertisedPeripheralMarker,
357        >(
358            (peer, connection,),
359            0x607b7716457eb178,
360            fidl::encoding::DynamicFlags::empty(),
361            ___deadline,
362        )?;
363        Ok(_response)
364    }
365}
366
367#[cfg(target_os = "fuchsia")]
368impl From<AdvertisedPeripheralSynchronousProxy> for zx::NullableHandle {
369    fn from(value: AdvertisedPeripheralSynchronousProxy) -> Self {
370        value.into_channel().into()
371    }
372}
373
374#[cfg(target_os = "fuchsia")]
375impl From<fidl::Channel> for AdvertisedPeripheralSynchronousProxy {
376    fn from(value: fidl::Channel) -> Self {
377        Self::new(value)
378    }
379}
380
381#[cfg(target_os = "fuchsia")]
382impl fidl::endpoints::FromClient for AdvertisedPeripheralSynchronousProxy {
383    type Protocol = AdvertisedPeripheralMarker;
384
385    fn from_client(value: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>) -> Self {
386        Self::new(value.into_channel())
387    }
388}
389
390#[derive(Debug, Clone)]
391pub struct AdvertisedPeripheralProxy {
392    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
393}
394
395impl fidl::endpoints::Proxy for AdvertisedPeripheralProxy {
396    type Protocol = AdvertisedPeripheralMarker;
397
398    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
399        Self::new(inner)
400    }
401
402    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
403        self.client.into_channel().map_err(|client| Self { client })
404    }
405
406    fn as_channel(&self) -> &::fidl::AsyncChannel {
407        self.client.as_channel()
408    }
409}
410
411impl AdvertisedPeripheralProxy {
412    /// Create a new Proxy for fuchsia.bluetooth.le/AdvertisedPeripheral.
413    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
414        let protocol_name =
415            <AdvertisedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
416        Self { client: fidl::client::Client::new(channel, protocol_name) }
417    }
418
419    /// Get a Stream of events from the remote end of the protocol.
420    ///
421    /// # Panics
422    ///
423    /// Panics if the event stream was already taken.
424    pub fn take_event_stream(&self) -> AdvertisedPeripheralEventStream {
425        AdvertisedPeripheralEventStream { event_receiver: self.client.take_event_receiver() }
426    }
427
428    /// Called when a remote LE central connects to this peripheral when
429    /// connectable advertising is enabled via
430    /// [`fuchsia.bluetooth.le/Peripheral.Advertise`]. When this call is made,
431    /// the system has paused advertising, and will not continue until it
432    /// receives a response.
433    ///
434    /// The returned [`fuchsia.bluetooth.le/Connection`] protocol can be used to
435    /// interact with the peer. It also represents a peripheral's ownership over
436    /// the connection: the client can drop the protocol to request a
437    /// disconnection. Similarly, the protocol is closed by the system to
438    /// indicate that the connection to the peer has been lost.
439    ///
440    /// + request `peer` Information about the central that initiated the
441    ///   connection.
442    /// + request `connection` Represents the connection.
443    /// - response An empty response should be sent to acknowledge the
444    ///   connection and resume advertising (for flow control).
445    pub fn r#on_connected(
446        &self,
447        mut peer: &Peer,
448        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
449    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
450        AdvertisedPeripheralProxyInterface::r#on_connected(self, peer, connection)
451    }
452}
453
454impl AdvertisedPeripheralProxyInterface for AdvertisedPeripheralProxy {
455    type OnConnectedResponseFut =
456        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
457    fn r#on_connected(
458        &self,
459        mut peer: &Peer,
460        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
461    ) -> Self::OnConnectedResponseFut {
462        fn _decode(
463            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
464        ) -> Result<(), fidl::Error> {
465            let _response = fidl::client::decode_transaction_body::<
466                fidl::encoding::EmptyPayload,
467                fidl::encoding::DefaultFuchsiaResourceDialect,
468                0x607b7716457eb178,
469            >(_buf?)?;
470            Ok(_response)
471        }
472        self.client.send_query_and_decode::<AdvertisedPeripheralOnConnectedRequest, ()>(
473            (peer, connection),
474            0x607b7716457eb178,
475            fidl::encoding::DynamicFlags::empty(),
476            _decode,
477        )
478    }
479}
480
481pub struct AdvertisedPeripheralEventStream {
482    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
483}
484
485impl std::marker::Unpin for AdvertisedPeripheralEventStream {}
486
487impl futures::stream::FusedStream for AdvertisedPeripheralEventStream {
488    fn is_terminated(&self) -> bool {
489        self.event_receiver.is_terminated()
490    }
491}
492
493impl futures::Stream for AdvertisedPeripheralEventStream {
494    type Item = Result<AdvertisedPeripheralEvent, fidl::Error>;
495
496    fn poll_next(
497        mut self: std::pin::Pin<&mut Self>,
498        cx: &mut std::task::Context<'_>,
499    ) -> std::task::Poll<Option<Self::Item>> {
500        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
501            &mut self.event_receiver,
502            cx
503        )?) {
504            Some(buf) => std::task::Poll::Ready(Some(AdvertisedPeripheralEvent::decode(buf))),
505            None => std::task::Poll::Ready(None),
506        }
507    }
508}
509
510#[derive(Debug)]
511pub enum AdvertisedPeripheralEvent {}
512
513impl AdvertisedPeripheralEvent {
514    /// Decodes a message buffer as a [`AdvertisedPeripheralEvent`].
515    fn decode(
516        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
517    ) -> Result<AdvertisedPeripheralEvent, fidl::Error> {
518        let (bytes, _handles) = buf.split_mut();
519        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
520        debug_assert_eq!(tx_header.tx_id, 0);
521        match tx_header.ordinal {
522            _ => Err(fidl::Error::UnknownOrdinal {
523                ordinal: tx_header.ordinal,
524                protocol_name:
525                    <AdvertisedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
526            }),
527        }
528    }
529}
530
531/// A Stream of incoming requests for fuchsia.bluetooth.le/AdvertisedPeripheral.
532pub struct AdvertisedPeripheralRequestStream {
533    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
534    is_terminated: bool,
535}
536
537impl std::marker::Unpin for AdvertisedPeripheralRequestStream {}
538
539impl futures::stream::FusedStream for AdvertisedPeripheralRequestStream {
540    fn is_terminated(&self) -> bool {
541        self.is_terminated
542    }
543}
544
545impl fidl::endpoints::RequestStream for AdvertisedPeripheralRequestStream {
546    type Protocol = AdvertisedPeripheralMarker;
547    type ControlHandle = AdvertisedPeripheralControlHandle;
548
549    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
550        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
551    }
552
553    fn control_handle(&self) -> Self::ControlHandle {
554        AdvertisedPeripheralControlHandle { inner: self.inner.clone() }
555    }
556
557    fn into_inner(
558        self,
559    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
560    {
561        (self.inner, self.is_terminated)
562    }
563
564    fn from_inner(
565        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
566        is_terminated: bool,
567    ) -> Self {
568        Self { inner, is_terminated }
569    }
570}
571
572impl futures::Stream for AdvertisedPeripheralRequestStream {
573    type Item = Result<AdvertisedPeripheralRequest, fidl::Error>;
574
575    fn poll_next(
576        mut self: std::pin::Pin<&mut Self>,
577        cx: &mut std::task::Context<'_>,
578    ) -> std::task::Poll<Option<Self::Item>> {
579        let this = &mut *self;
580        if this.inner.check_shutdown(cx) {
581            this.is_terminated = true;
582            return std::task::Poll::Ready(None);
583        }
584        if this.is_terminated {
585            panic!("polled AdvertisedPeripheralRequestStream after completion");
586        }
587        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
588            |bytes, handles| {
589                match this.inner.channel().read_etc(cx, bytes, handles) {
590                    std::task::Poll::Ready(Ok(())) => {}
591                    std::task::Poll::Pending => return std::task::Poll::Pending,
592                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
593                        this.is_terminated = true;
594                        return std::task::Poll::Ready(None);
595                    }
596                    std::task::Poll::Ready(Err(e)) => {
597                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
598                            e.into(),
599                        ))));
600                    }
601                }
602
603                // A message has been received from the channel
604                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
605
606                std::task::Poll::Ready(Some(match header.ordinal {
607                0x607b7716457eb178 => {
608                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
609                    let mut req = fidl::new_empty!(AdvertisedPeripheralOnConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
610                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AdvertisedPeripheralOnConnectedRequest>(&header, _body_bytes, handles, &mut req)?;
611                    let control_handle = AdvertisedPeripheralControlHandle {
612                        inner: this.inner.clone(),
613                    };
614                    Ok(AdvertisedPeripheralRequest::OnConnected {peer: req.peer,
615connection: req.connection,
616
617                        responder: AdvertisedPeripheralOnConnectedResponder {
618                            control_handle: std::mem::ManuallyDrop::new(control_handle),
619                            tx_id: header.tx_id,
620                        },
621                    })
622                }
623                _ => Err(fidl::Error::UnknownOrdinal {
624                    ordinal: header.ordinal,
625                    protocol_name: <AdvertisedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
626                }),
627            }))
628            },
629        )
630    }
631}
632
633/// Protocol that is valid for the duration of advertising. The caller can close
634/// the protocol to stop advertising. If the system internally stops advertising
635/// for any reason, the protocol will be closed to communicate this to the
636/// client.
637#[derive(Debug)]
638pub enum AdvertisedPeripheralRequest {
639    /// Called when a remote LE central connects to this peripheral when
640    /// connectable advertising is enabled via
641    /// [`fuchsia.bluetooth.le/Peripheral.Advertise`]. When this call is made,
642    /// the system has paused advertising, and will not continue until it
643    /// receives a response.
644    ///
645    /// The returned [`fuchsia.bluetooth.le/Connection`] protocol can be used to
646    /// interact with the peer. It also represents a peripheral's ownership over
647    /// the connection: the client can drop the protocol to request a
648    /// disconnection. Similarly, the protocol is closed by the system to
649    /// indicate that the connection to the peer has been lost.
650    ///
651    /// + request `peer` Information about the central that initiated the
652    ///   connection.
653    /// + request `connection` Represents the connection.
654    /// - response An empty response should be sent to acknowledge the
655    ///   connection and resume advertising (for flow control).
656    OnConnected {
657        peer: Peer,
658        connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
659        responder: AdvertisedPeripheralOnConnectedResponder,
660    },
661}
662
663impl AdvertisedPeripheralRequest {
664    #[allow(irrefutable_let_patterns)]
665    pub fn into_on_connected(
666        self,
667    ) -> Option<(
668        Peer,
669        fidl::endpoints::ClientEnd<ConnectionMarker>,
670        AdvertisedPeripheralOnConnectedResponder,
671    )> {
672        if let AdvertisedPeripheralRequest::OnConnected { peer, connection, responder } = self {
673            Some((peer, connection, responder))
674        } else {
675            None
676        }
677    }
678
679    /// Name of the method defined in FIDL
680    pub fn method_name(&self) -> &'static str {
681        match *self {
682            AdvertisedPeripheralRequest::OnConnected { .. } => "on_connected",
683        }
684    }
685}
686
687#[derive(Debug, Clone)]
688pub struct AdvertisedPeripheralControlHandle {
689    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
690}
691
692impl fidl::endpoints::ControlHandle for AdvertisedPeripheralControlHandle {
693    fn shutdown(&self) {
694        self.inner.shutdown()
695    }
696
697    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
698        self.inner.shutdown_with_epitaph(status)
699    }
700
701    fn is_closed(&self) -> bool {
702        self.inner.channel().is_closed()
703    }
704    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
705        self.inner.channel().on_closed()
706    }
707
708    #[cfg(target_os = "fuchsia")]
709    fn signal_peer(
710        &self,
711        clear_mask: zx::Signals,
712        set_mask: zx::Signals,
713    ) -> Result<(), zx_status::Status> {
714        use fidl::Peered;
715        self.inner.channel().signal_peer(clear_mask, set_mask)
716    }
717}
718
719impl AdvertisedPeripheralControlHandle {}
720
721#[must_use = "FIDL methods require a response to be sent"]
722#[derive(Debug)]
723pub struct AdvertisedPeripheralOnConnectedResponder {
724    control_handle: std::mem::ManuallyDrop<AdvertisedPeripheralControlHandle>,
725    tx_id: u32,
726}
727
728/// Set the the channel to be shutdown (see [`AdvertisedPeripheralControlHandle::shutdown`])
729/// if the responder is dropped without sending a response, so that the client
730/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
731impl std::ops::Drop for AdvertisedPeripheralOnConnectedResponder {
732    fn drop(&mut self) {
733        self.control_handle.shutdown();
734        // Safety: drops once, never accessed again
735        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
736    }
737}
738
739impl fidl::endpoints::Responder for AdvertisedPeripheralOnConnectedResponder {
740    type ControlHandle = AdvertisedPeripheralControlHandle;
741
742    fn control_handle(&self) -> &AdvertisedPeripheralControlHandle {
743        &self.control_handle
744    }
745
746    fn drop_without_shutdown(mut self) {
747        // Safety: drops once, never accessed again due to mem::forget
748        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
749        // Prevent Drop from running (which would shut down the channel)
750        std::mem::forget(self);
751    }
752}
753
754impl AdvertisedPeripheralOnConnectedResponder {
755    /// Sends a response to the FIDL transaction.
756    ///
757    /// Sets the channel to shutdown if an error occurs.
758    pub fn send(self) -> Result<(), fidl::Error> {
759        let _result = self.send_raw();
760        if _result.is_err() {
761            self.control_handle.shutdown();
762        }
763        self.drop_without_shutdown();
764        _result
765    }
766
767    /// Similar to "send" but does not shutdown the channel if an error occurs.
768    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
769        let _result = self.send_raw();
770        self.drop_without_shutdown();
771        _result
772    }
773
774    fn send_raw(&self) -> Result<(), fidl::Error> {
775        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
776            (),
777            self.tx_id,
778            0x607b7716457eb178,
779            fidl::encoding::DynamicFlags::empty(),
780        )
781    }
782}
783
784#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
785pub struct AdvertisingHandleMarker;
786
787impl fidl::endpoints::ProtocolMarker for AdvertisingHandleMarker {
788    type Proxy = AdvertisingHandleProxy;
789    type RequestStream = AdvertisingHandleRequestStream;
790    #[cfg(target_os = "fuchsia")]
791    type SynchronousProxy = AdvertisingHandleSynchronousProxy;
792
793    const DEBUG_NAME: &'static str = "(anonymous) AdvertisingHandle";
794}
795
796pub trait AdvertisingHandleProxyInterface: Send + Sync {}
797#[derive(Debug)]
798#[cfg(target_os = "fuchsia")]
799pub struct AdvertisingHandleSynchronousProxy {
800    client: fidl::client::sync::Client,
801}
802
803#[cfg(target_os = "fuchsia")]
804impl fidl::endpoints::SynchronousProxy for AdvertisingHandleSynchronousProxy {
805    type Proxy = AdvertisingHandleProxy;
806    type Protocol = AdvertisingHandleMarker;
807
808    fn from_channel(inner: fidl::Channel) -> Self {
809        Self::new(inner)
810    }
811
812    fn into_channel(self) -> fidl::Channel {
813        self.client.into_channel()
814    }
815
816    fn as_channel(&self) -> &fidl::Channel {
817        self.client.as_channel()
818    }
819}
820
821#[cfg(target_os = "fuchsia")]
822impl AdvertisingHandleSynchronousProxy {
823    pub fn new(channel: fidl::Channel) -> Self {
824        Self { client: fidl::client::sync::Client::new(channel) }
825    }
826
827    pub fn into_channel(self) -> fidl::Channel {
828        self.client.into_channel()
829    }
830
831    /// Waits until an event arrives and returns it. It is safe for other
832    /// threads to make concurrent requests while waiting for an event.
833    pub fn wait_for_event(
834        &self,
835        deadline: zx::MonotonicInstant,
836    ) -> Result<AdvertisingHandleEvent, fidl::Error> {
837        AdvertisingHandleEvent::decode(
838            self.client.wait_for_event::<AdvertisingHandleMarker>(deadline)?,
839        )
840    }
841}
842
843#[cfg(target_os = "fuchsia")]
844impl From<AdvertisingHandleSynchronousProxy> for zx::NullableHandle {
845    fn from(value: AdvertisingHandleSynchronousProxy) -> Self {
846        value.into_channel().into()
847    }
848}
849
850#[cfg(target_os = "fuchsia")]
851impl From<fidl::Channel> for AdvertisingHandleSynchronousProxy {
852    fn from(value: fidl::Channel) -> Self {
853        Self::new(value)
854    }
855}
856
857#[cfg(target_os = "fuchsia")]
858impl fidl::endpoints::FromClient for AdvertisingHandleSynchronousProxy {
859    type Protocol = AdvertisingHandleMarker;
860
861    fn from_client(value: fidl::endpoints::ClientEnd<AdvertisingHandleMarker>) -> Self {
862        Self::new(value.into_channel())
863    }
864}
865
866#[derive(Debug, Clone)]
867pub struct AdvertisingHandleProxy {
868    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
869}
870
871impl fidl::endpoints::Proxy for AdvertisingHandleProxy {
872    type Protocol = AdvertisingHandleMarker;
873
874    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
875        Self::new(inner)
876    }
877
878    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
879        self.client.into_channel().map_err(|client| Self { client })
880    }
881
882    fn as_channel(&self) -> &::fidl::AsyncChannel {
883        self.client.as_channel()
884    }
885}
886
887impl AdvertisingHandleProxy {
888    /// Create a new Proxy for fuchsia.bluetooth.le/AdvertisingHandle.
889    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
890        let protocol_name =
891            <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
892        Self { client: fidl::client::Client::new(channel, protocol_name) }
893    }
894
895    /// Get a Stream of events from the remote end of the protocol.
896    ///
897    /// # Panics
898    ///
899    /// Panics if the event stream was already taken.
900    pub fn take_event_stream(&self) -> AdvertisingHandleEventStream {
901        AdvertisingHandleEventStream { event_receiver: self.client.take_event_receiver() }
902    }
903}
904
905impl AdvertisingHandleProxyInterface for AdvertisingHandleProxy {}
906
907pub struct AdvertisingHandleEventStream {
908    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
909}
910
911impl std::marker::Unpin for AdvertisingHandleEventStream {}
912
913impl futures::stream::FusedStream for AdvertisingHandleEventStream {
914    fn is_terminated(&self) -> bool {
915        self.event_receiver.is_terminated()
916    }
917}
918
919impl futures::Stream for AdvertisingHandleEventStream {
920    type Item = Result<AdvertisingHandleEvent, fidl::Error>;
921
922    fn poll_next(
923        mut self: std::pin::Pin<&mut Self>,
924        cx: &mut std::task::Context<'_>,
925    ) -> std::task::Poll<Option<Self::Item>> {
926        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
927            &mut self.event_receiver,
928            cx
929        )?) {
930            Some(buf) => std::task::Poll::Ready(Some(AdvertisingHandleEvent::decode(buf))),
931            None => std::task::Poll::Ready(None),
932        }
933    }
934}
935
936#[derive(Debug)]
937pub enum AdvertisingHandleEvent {}
938
939impl AdvertisingHandleEvent {
940    /// Decodes a message buffer as a [`AdvertisingHandleEvent`].
941    fn decode(
942        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
943    ) -> Result<AdvertisingHandleEvent, fidl::Error> {
944        let (bytes, _handles) = buf.split_mut();
945        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
946        debug_assert_eq!(tx_header.tx_id, 0);
947        match tx_header.ordinal {
948            _ => Err(fidl::Error::UnknownOrdinal {
949                ordinal: tx_header.ordinal,
950                protocol_name:
951                    <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
952            }),
953        }
954    }
955}
956
957/// A Stream of incoming requests for fuchsia.bluetooth.le/AdvertisingHandle.
958pub struct AdvertisingHandleRequestStream {
959    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
960    is_terminated: bool,
961}
962
963impl std::marker::Unpin for AdvertisingHandleRequestStream {}
964
965impl futures::stream::FusedStream for AdvertisingHandleRequestStream {
966    fn is_terminated(&self) -> bool {
967        self.is_terminated
968    }
969}
970
971impl fidl::endpoints::RequestStream for AdvertisingHandleRequestStream {
972    type Protocol = AdvertisingHandleMarker;
973    type ControlHandle = AdvertisingHandleControlHandle;
974
975    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
976        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
977    }
978
979    fn control_handle(&self) -> Self::ControlHandle {
980        AdvertisingHandleControlHandle { inner: self.inner.clone() }
981    }
982
983    fn into_inner(
984        self,
985    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
986    {
987        (self.inner, self.is_terminated)
988    }
989
990    fn from_inner(
991        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
992        is_terminated: bool,
993    ) -> Self {
994        Self { inner, is_terminated }
995    }
996}
997
998impl futures::Stream for AdvertisingHandleRequestStream {
999    type Item = Result<AdvertisingHandleRequest, fidl::Error>;
1000
1001    fn poll_next(
1002        mut self: std::pin::Pin<&mut Self>,
1003        cx: &mut std::task::Context<'_>,
1004    ) -> std::task::Poll<Option<Self::Item>> {
1005        let this = &mut *self;
1006        if this.inner.check_shutdown(cx) {
1007            this.is_terminated = true;
1008            return std::task::Poll::Ready(None);
1009        }
1010        if this.is_terminated {
1011            panic!("polled AdvertisingHandleRequestStream after completion");
1012        }
1013        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1014            |bytes, handles| {
1015                match this.inner.channel().read_etc(cx, bytes, handles) {
1016                    std::task::Poll::Ready(Ok(())) => {}
1017                    std::task::Poll::Pending => return std::task::Poll::Pending,
1018                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1019                        this.is_terminated = true;
1020                        return std::task::Poll::Ready(None);
1021                    }
1022                    std::task::Poll::Ready(Err(e)) => {
1023                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1024                            e.into(),
1025                        ))));
1026                    }
1027                }
1028
1029                // A message has been received from the channel
1030                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1031
1032                std::task::Poll::Ready(Some(match header.ordinal {
1033                    _ => Err(fidl::Error::UnknownOrdinal {
1034                        ordinal: header.ordinal,
1035                        protocol_name:
1036                            <AdvertisingHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1037                    }),
1038                }))
1039            },
1040        )
1041    }
1042}
1043
1044/// Capability that is valid for the duration of advertising. The caller can close the handle to
1045/// stop advertising. If the system internally stops advertising for any reason, the handle will be
1046/// closed to communicate this to the client.
1047#[derive(Debug)]
1048pub enum AdvertisingHandleRequest {}
1049
1050impl AdvertisingHandleRequest {
1051    /// Name of the method defined in FIDL
1052    pub fn method_name(&self) -> &'static str {
1053        match *self {}
1054    }
1055}
1056
1057#[derive(Debug, Clone)]
1058pub struct AdvertisingHandleControlHandle {
1059    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1060}
1061
1062impl fidl::endpoints::ControlHandle for AdvertisingHandleControlHandle {
1063    fn shutdown(&self) {
1064        self.inner.shutdown()
1065    }
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 AdvertisingHandleControlHandle {}
1090
1091#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1092pub struct CentralMarker;
1093
1094impl fidl::endpoints::ProtocolMarker for CentralMarker {
1095    type Proxy = CentralProxy;
1096    type RequestStream = CentralRequestStream;
1097    #[cfg(target_os = "fuchsia")]
1098    type SynchronousProxy = CentralSynchronousProxy;
1099
1100    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.Central";
1101}
1102impl fidl::endpoints::DiscoverableProtocolMarker for CentralMarker {}
1103pub type CentralCreateConnectedIsochronousGroupResult =
1104    Result<CentralCreateConnectedIsochronousGroupResponse, CreateCigError>;
1105
1106pub trait CentralProxyInterface: Send + Sync {
1107    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
1108        + Send;
1109    fn r#listen_l2cap(
1110        &self,
1111        payload: ChannelListenerRegistryListenL2capRequest,
1112    ) -> Self::ListenL2capResponseFut;
1113    type ScanResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1114    fn r#scan(
1115        &self,
1116        options: &ScanOptions,
1117        result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1118    ) -> Self::ScanResponseFut;
1119    fn r#connect(
1120        &self,
1121        id: &fidl_fuchsia_bluetooth::PeerId,
1122        options: &ConnectionOptions,
1123        handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1124    ) -> Result<(), fidl::Error>;
1125    fn r#sync_to_periodic_advertising(
1126        &self,
1127        payload: CentralSyncToPeriodicAdvertisingRequest,
1128    ) -> Result<(), fidl::Error>;
1129    type CreateConnectedIsochronousGroupResponseFut: std::future::Future<
1130            Output = Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error>,
1131        > + Send;
1132    fn r#create_connected_isochronous_group(
1133        &self,
1134        payload: CentralCreateConnectedIsochronousGroupRequest,
1135    ) -> Self::CreateConnectedIsochronousGroupResponseFut;
1136    type GetPeripheralsResponseFut: std::future::Future<Output = Result<Vec<RemoteDevice>, fidl::Error>>
1137        + Send;
1138    fn r#get_peripherals(
1139        &self,
1140        service_uuids: Option<&[String]>,
1141    ) -> Self::GetPeripheralsResponseFut;
1142    type GetPeripheralResponseFut: std::future::Future<Output = Result<Option<Box<RemoteDevice>>, fidl::Error>>
1143        + Send;
1144    fn r#get_peripheral(&self, identifier: &str) -> Self::GetPeripheralResponseFut;
1145    type StartScanResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
1146        + Send;
1147    fn r#start_scan(&self, filter: Option<&ScanFilter>) -> Self::StartScanResponseFut;
1148    fn r#stop_scan(&self) -> Result<(), fidl::Error>;
1149    type ConnectPeripheralResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
1150        + Send;
1151    fn r#connect_peripheral(
1152        &self,
1153        identifier: &str,
1154        options: &ConnectionOptions,
1155        gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1156    ) -> Self::ConnectPeripheralResponseFut;
1157    type DisconnectPeripheralResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
1158        + Send;
1159    fn r#disconnect_peripheral(&self, identifier: &str) -> Self::DisconnectPeripheralResponseFut;
1160}
1161#[derive(Debug)]
1162#[cfg(target_os = "fuchsia")]
1163pub struct CentralSynchronousProxy {
1164    client: fidl::client::sync::Client,
1165}
1166
1167#[cfg(target_os = "fuchsia")]
1168impl fidl::endpoints::SynchronousProxy for CentralSynchronousProxy {
1169    type Proxy = CentralProxy;
1170    type Protocol = CentralMarker;
1171
1172    fn from_channel(inner: fidl::Channel) -> Self {
1173        Self::new(inner)
1174    }
1175
1176    fn into_channel(self) -> fidl::Channel {
1177        self.client.into_channel()
1178    }
1179
1180    fn as_channel(&self) -> &fidl::Channel {
1181        self.client.as_channel()
1182    }
1183}
1184
1185#[cfg(target_os = "fuchsia")]
1186impl CentralSynchronousProxy {
1187    pub fn new(channel: fidl::Channel) -> Self {
1188        Self { client: fidl::client::sync::Client::new(channel) }
1189    }
1190
1191    pub fn into_channel(self) -> fidl::Channel {
1192        self.client.into_channel()
1193    }
1194
1195    /// Waits until an event arrives and returns it. It is safe for other
1196    /// threads to make concurrent requests while waiting for an event.
1197    pub fn wait_for_event(
1198        &self,
1199        deadline: zx::MonotonicInstant,
1200    ) -> Result<CentralEvent, fidl::Error> {
1201        CentralEvent::decode(self.client.wait_for_event::<CentralMarker>(deadline)?)
1202    }
1203
1204    /// Register a listener for incoming channels. The registry will assign a
1205    /// PSM value that is unique for the local device, as well as open a
1206    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
1207    /// event that all PSMs have been assigned, this call will fail with
1208    /// `ZX_ERR_NO_RESOURCES`.
1209    ///
1210    /// Note that the method of service discovery or advertising is defined by
1211    /// the service or protocol, so it is the responsibility of the caller to
1212    /// communicate the assigned PSM to any clients.
1213    pub fn r#listen_l2cap(
1214        &self,
1215        mut payload: ChannelListenerRegistryListenL2capRequest,
1216        ___deadline: zx::MonotonicInstant,
1217    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
1218        let _response = self.client.send_query::<
1219            ChannelListenerRegistryListenL2capRequest,
1220            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
1221            CentralMarker,
1222        >(
1223            &mut payload,
1224            0x39c6e9001d102338,
1225            fidl::encoding::DynamicFlags::empty(),
1226            ___deadline,
1227        )?;
1228        Ok(_response.map(|x| x))
1229    }
1230
1231    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
1232    /// initiated, then `result_watcher` will be closed with an epitaph.
1233    ///
1234    /// A Central client is allowed to have only one active scan at a time.
1235    /// Accordingly, only one Scan request can be outstanding at a time.
1236    /// Additional calls to Scan will fail.
1237    ///
1238    /// The lifetime of the scan session is tied to the `result_watcher`
1239    /// protocol provided. The scan will be stopped if the channel is closed.
1240    ///
1241    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
1242    /// can be used to watch for scan results.
1243    ///
1244    /// + request `options` Options used to configure the scan session.
1245    /// + request `result_watcher` Protocol that remains valid for the duration
1246    ///   of this scan session.
1247    /// - response An empty response will be sent to acknowledge the scan has
1248    ///   stopped.
1249    ///
1250    /// The following epitaphs may be sent by the server on error:
1251    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
1252    ///   protocol is only allowed 1 active scan.
1253    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
1254    ///   `ScanOptions` documentation.
1255    /// * error `INTERNAL`: An internal error occurred and a scan could not be
1256    ///   started.
1257    pub fn r#scan(
1258        &self,
1259        mut options: &ScanOptions,
1260        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1261        ___deadline: zx::MonotonicInstant,
1262    ) -> Result<(), fidl::Error> {
1263        let _response = self
1264            .client
1265            .send_query::<CentralScanRequest, fidl::encoding::EmptyPayload, CentralMarker>(
1266                (options, result_watcher),
1267                0x41f7121798dfe15f,
1268                fidl::encoding::DynamicFlags::empty(),
1269                ___deadline,
1270            )?;
1271        Ok(_response)
1272    }
1273
1274    /// Connect to the peer with the given identifier.
1275    ///
1276    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
1277    /// client's interest on the LE connection to the peer. Closing the channel
1278    /// removes interest, but may not result in disconnection if another client
1279    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
1280    ///
1281    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
1282    /// system if the connection to the peer is lost or an error occurs.
1283    ///
1284    /// The following epitaphs may be sent by the server on error:
1285    /// + `INVALID_ARGS`: Some of the parameters are invalid.
1286    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
1287    ///                    Connection should be used.
1288    /// + `NOT_CONNECTED`: A connection could not be established.
1289    /// + `CONNECTION_RESET`: The peer disconnected.
1290    ///
1291    /// + request `id` Identifier of the peer to initiate a connection to.
1292    /// + request `options` Options used to configure the connection.
1293    /// + request `handle` Handle that remains valid for the duration of this
1294    ///   connection.
1295    pub fn r#connect(
1296        &self,
1297        mut id: &fidl_fuchsia_bluetooth::PeerId,
1298        mut options: &ConnectionOptions,
1299        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1300    ) -> Result<(), fidl::Error> {
1301        self.client.send::<CentralConnectRequest>(
1302            (id, options, handle),
1303            0x31a3065f2a6913c4,
1304            fidl::encoding::DynamicFlags::empty(),
1305        )
1306    }
1307
1308    /// Synchronize to a periodic advertising train. Reports will be delivered via the
1309    /// `PeriodicAdvertisingSync` protocol.
1310    pub fn r#sync_to_periodic_advertising(
1311        &self,
1312        mut payload: CentralSyncToPeriodicAdvertisingRequest,
1313    ) -> Result<(), fidl::Error> {
1314        self.client.send::<CentralSyncToPeriodicAdvertisingRequest>(
1315            &mut payload,
1316            0x1db6df126a00c5b9,
1317            fidl::encoding::DynamicFlags::empty(),
1318        )
1319    }
1320
1321    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
1322    /// operation is only valid when operating in the Central role for a connection.
1323    ///
1324    /// If the Central channel is closed before the CIG is explicitly removed, the group will
1325    /// be removed and disconnected.
1326    ///
1327    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
1328    /// id allocated by the host.
1329    pub fn r#create_connected_isochronous_group(
1330        &self,
1331        mut payload: CentralCreateConnectedIsochronousGroupRequest,
1332        ___deadline: zx::MonotonicInstant,
1333    ) -> Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error> {
1334        let _response = self
1335            .client
1336            .send_query::<CentralCreateConnectedIsochronousGroupRequest, fidl::encoding::ResultType<
1337                CentralCreateConnectedIsochronousGroupResponse,
1338                CreateCigError,
1339            >, CentralMarker>(
1340                &mut payload,
1341                0x60323e70ae22e13,
1342                fidl::encoding::DynamicFlags::empty(),
1343                ___deadline,
1344            )?;
1345        Ok(_response.map(|x| x))
1346    }
1347
1348    /// Returns the list of peripherals that are known to the system from previous scan, connection,
1349    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
1350    /// be present on the peripheral.
1351    ///
1352    /// This method only returns peripherals (i.e. connectable devices).
1353    pub fn r#get_peripherals(
1354        &self,
1355        mut service_uuids: Option<&[String]>,
1356        ___deadline: zx::MonotonicInstant,
1357    ) -> Result<Vec<RemoteDevice>, fidl::Error> {
1358        let _response = self.client.send_query::<
1359            CentralGetPeripheralsRequest,
1360            CentralGetPeripheralsResponse,
1361            CentralMarker,
1362        >(
1363            (service_uuids,),
1364            0x37ba777499c683a8,
1365            fidl::encoding::DynamicFlags::empty(),
1366            ___deadline,
1367        )?;
1368        Ok(_response.peripherals)
1369    }
1370
1371    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
1372    ///
1373    /// Returns information about a single peripheral that is known to the system from previous scan,
1374    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
1375    /// `identifier` is not recognized.
1376    pub fn r#get_peripheral(
1377        &self,
1378        mut identifier: &str,
1379        ___deadline: zx::MonotonicInstant,
1380    ) -> Result<Option<Box<RemoteDevice>>, fidl::Error> {
1381        let _response = self
1382            .client
1383            .send_query::<CentralGetPeripheralRequest, CentralGetPeripheralResponse, CentralMarker>(
1384                (identifier,),
1385                0x97f5a2f2d9c13da,
1386                fidl::encoding::DynamicFlags::empty(),
1387                ___deadline,
1388            )?;
1389        Ok(_response.peripheral)
1390    }
1391
1392    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
1393    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
1394    /// `filter` will replace the existing session's filter.
1395    ///
1396    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
1397    /// will be notified for all discoverable devices that are found. This is not recommended; clients
1398    /// should generally filter results by at least one of `filter.service_uuids`,
1399    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
1400    pub fn r#start_scan(
1401        &self,
1402        mut filter: Option<&ScanFilter>,
1403        ___deadline: zx::MonotonicInstant,
1404    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1405        let _response = self
1406            .client
1407            .send_query::<CentralStartScanRequest, CentralStartScanResponse, CentralMarker>(
1408                (filter,),
1409                0xeb4cf0cd0e1132b,
1410                fidl::encoding::DynamicFlags::empty(),
1411                ___deadline,
1412            )?;
1413        Ok(_response.status)
1414    }
1415
1416    /// Terminate a previously started scan session.
1417    pub fn r#stop_scan(&self) -> Result<(), fidl::Error> {
1418        self.client.send::<fidl::encoding::EmptyPayload>(
1419            (),
1420            0x5f79ee6a0bb037a0,
1421            fidl::encoding::DynamicFlags::empty(),
1422        )
1423    }
1424
1425    /// Creates a connection to the peripheral device with the given identifier.
1426    /// Returns the status of the operation in `status`.
1427    ///
1428    /// On success, `gatt_client` will be bound and can be used for GATT client
1429    /// role procedures. On failure, `gatt_client` will be closed and `status` will
1430    /// indicate an error.
1431    pub fn r#connect_peripheral(
1432        &self,
1433        mut identifier: &str,
1434        mut options: &ConnectionOptions,
1435        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1436        ___deadline: zx::MonotonicInstant,
1437    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1438        let _response = self.client.send_query::<
1439            CentralConnectPeripheralRequest,
1440            CentralConnectPeripheralResponse,
1441            CentralMarker,
1442        >(
1443            (identifier, options, gatt_client,),
1444            0x714d6c32d066d75a,
1445            fidl::encoding::DynamicFlags::empty(),
1446            ___deadline,
1447        )?;
1448        Ok(_response.status)
1449    }
1450
1451    /// Disconnects this Central's connection to the peripheral with the given identifier.
1452    pub fn r#disconnect_peripheral(
1453        &self,
1454        mut identifier: &str,
1455        ___deadline: zx::MonotonicInstant,
1456    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1457        let _response = self.client.send_query::<
1458            CentralDisconnectPeripheralRequest,
1459            CentralDisconnectPeripheralResponse,
1460            CentralMarker,
1461        >(
1462            (identifier,),
1463            0xa9430da197362fd,
1464            fidl::encoding::DynamicFlags::empty(),
1465            ___deadline,
1466        )?;
1467        Ok(_response.status)
1468    }
1469}
1470
1471#[cfg(target_os = "fuchsia")]
1472impl From<CentralSynchronousProxy> for zx::NullableHandle {
1473    fn from(value: CentralSynchronousProxy) -> Self {
1474        value.into_channel().into()
1475    }
1476}
1477
1478#[cfg(target_os = "fuchsia")]
1479impl From<fidl::Channel> for CentralSynchronousProxy {
1480    fn from(value: fidl::Channel) -> Self {
1481        Self::new(value)
1482    }
1483}
1484
1485#[cfg(target_os = "fuchsia")]
1486impl fidl::endpoints::FromClient for CentralSynchronousProxy {
1487    type Protocol = CentralMarker;
1488
1489    fn from_client(value: fidl::endpoints::ClientEnd<CentralMarker>) -> Self {
1490        Self::new(value.into_channel())
1491    }
1492}
1493
1494#[derive(Debug, Clone)]
1495pub struct CentralProxy {
1496    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1497}
1498
1499impl fidl::endpoints::Proxy for CentralProxy {
1500    type Protocol = CentralMarker;
1501
1502    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1503        Self::new(inner)
1504    }
1505
1506    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1507        self.client.into_channel().map_err(|client| Self { client })
1508    }
1509
1510    fn as_channel(&self) -> &::fidl::AsyncChannel {
1511        self.client.as_channel()
1512    }
1513}
1514
1515impl CentralProxy {
1516    /// Create a new Proxy for fuchsia.bluetooth.le/Central.
1517    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1518        let protocol_name = <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1519        Self { client: fidl::client::Client::new(channel, protocol_name) }
1520    }
1521
1522    /// Get a Stream of events from the remote end of the protocol.
1523    ///
1524    /// # Panics
1525    ///
1526    /// Panics if the event stream was already taken.
1527    pub fn take_event_stream(&self) -> CentralEventStream {
1528        CentralEventStream { event_receiver: self.client.take_event_receiver() }
1529    }
1530
1531    /// Register a listener for incoming channels. The registry will assign a
1532    /// PSM value that is unique for the local device, as well as open a
1533    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
1534    /// event that all PSMs have been assigned, this call will fail with
1535    /// `ZX_ERR_NO_RESOURCES`.
1536    ///
1537    /// Note that the method of service discovery or advertising is defined by
1538    /// the service or protocol, so it is the responsibility of the caller to
1539    /// communicate the assigned PSM to any clients.
1540    pub fn r#listen_l2cap(
1541        &self,
1542        mut payload: ChannelListenerRegistryListenL2capRequest,
1543    ) -> fidl::client::QueryResponseFut<
1544        ChannelListenerRegistryListenL2capResult,
1545        fidl::encoding::DefaultFuchsiaResourceDialect,
1546    > {
1547        CentralProxyInterface::r#listen_l2cap(self, payload)
1548    }
1549
1550    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
1551    /// initiated, then `result_watcher` will be closed with an epitaph.
1552    ///
1553    /// A Central client is allowed to have only one active scan at a time.
1554    /// Accordingly, only one Scan request can be outstanding at a time.
1555    /// Additional calls to Scan will fail.
1556    ///
1557    /// The lifetime of the scan session is tied to the `result_watcher`
1558    /// protocol provided. The scan will be stopped if the channel is closed.
1559    ///
1560    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
1561    /// can be used to watch for scan results.
1562    ///
1563    /// + request `options` Options used to configure the scan session.
1564    /// + request `result_watcher` Protocol that remains valid for the duration
1565    ///   of this scan session.
1566    /// - response An empty response will be sent to acknowledge the scan has
1567    ///   stopped.
1568    ///
1569    /// The following epitaphs may be sent by the server on error:
1570    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
1571    ///   protocol is only allowed 1 active scan.
1572    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
1573    ///   `ScanOptions` documentation.
1574    /// * error `INTERNAL`: An internal error occurred and a scan could not be
1575    ///   started.
1576    pub fn r#scan(
1577        &self,
1578        mut options: &ScanOptions,
1579        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1580    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1581        CentralProxyInterface::r#scan(self, options, result_watcher)
1582    }
1583
1584    /// Connect to the peer with the given identifier.
1585    ///
1586    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
1587    /// client's interest on the LE connection to the peer. Closing the channel
1588    /// removes interest, but may not result in disconnection if another client
1589    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
1590    ///
1591    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
1592    /// system if the connection to the peer is lost or an error occurs.
1593    ///
1594    /// The following epitaphs may be sent by the server on error:
1595    /// + `INVALID_ARGS`: Some of the parameters are invalid.
1596    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
1597    ///                    Connection should be used.
1598    /// + `NOT_CONNECTED`: A connection could not be established.
1599    /// + `CONNECTION_RESET`: The peer disconnected.
1600    ///
1601    /// + request `id` Identifier of the peer to initiate a connection to.
1602    /// + request `options` Options used to configure the connection.
1603    /// + request `handle` Handle that remains valid for the duration of this
1604    ///   connection.
1605    pub fn r#connect(
1606        &self,
1607        mut id: &fidl_fuchsia_bluetooth::PeerId,
1608        mut options: &ConnectionOptions,
1609        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1610    ) -> Result<(), fidl::Error> {
1611        CentralProxyInterface::r#connect(self, id, options, handle)
1612    }
1613
1614    /// Synchronize to a periodic advertising train. Reports will be delivered via the
1615    /// `PeriodicAdvertisingSync` protocol.
1616    pub fn r#sync_to_periodic_advertising(
1617        &self,
1618        mut payload: CentralSyncToPeriodicAdvertisingRequest,
1619    ) -> Result<(), fidl::Error> {
1620        CentralProxyInterface::r#sync_to_periodic_advertising(self, payload)
1621    }
1622
1623    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
1624    /// operation is only valid when operating in the Central role for a connection.
1625    ///
1626    /// If the Central channel is closed before the CIG is explicitly removed, the group will
1627    /// be removed and disconnected.
1628    ///
1629    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
1630    /// id allocated by the host.
1631    pub fn r#create_connected_isochronous_group(
1632        &self,
1633        mut payload: CentralCreateConnectedIsochronousGroupRequest,
1634    ) -> fidl::client::QueryResponseFut<
1635        CentralCreateConnectedIsochronousGroupResult,
1636        fidl::encoding::DefaultFuchsiaResourceDialect,
1637    > {
1638        CentralProxyInterface::r#create_connected_isochronous_group(self, payload)
1639    }
1640
1641    /// Returns the list of peripherals that are known to the system from previous scan, connection,
1642    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
1643    /// be present on the peripheral.
1644    ///
1645    /// This method only returns peripherals (i.e. connectable devices).
1646    pub fn r#get_peripherals(
1647        &self,
1648        mut service_uuids: Option<&[String]>,
1649    ) -> fidl::client::QueryResponseFut<
1650        Vec<RemoteDevice>,
1651        fidl::encoding::DefaultFuchsiaResourceDialect,
1652    > {
1653        CentralProxyInterface::r#get_peripherals(self, service_uuids)
1654    }
1655
1656    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
1657    ///
1658    /// Returns information about a single peripheral that is known to the system from previous scan,
1659    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
1660    /// `identifier` is not recognized.
1661    pub fn r#get_peripheral(
1662        &self,
1663        mut identifier: &str,
1664    ) -> fidl::client::QueryResponseFut<
1665        Option<Box<RemoteDevice>>,
1666        fidl::encoding::DefaultFuchsiaResourceDialect,
1667    > {
1668        CentralProxyInterface::r#get_peripheral(self, identifier)
1669    }
1670
1671    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
1672    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
1673    /// `filter` will replace the existing session's filter.
1674    ///
1675    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
1676    /// will be notified for all discoverable devices that are found. This is not recommended; clients
1677    /// should generally filter results by at least one of `filter.service_uuids`,
1678    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
1679    pub fn r#start_scan(
1680        &self,
1681        mut filter: Option<&ScanFilter>,
1682    ) -> fidl::client::QueryResponseFut<
1683        fidl_fuchsia_bluetooth::Status,
1684        fidl::encoding::DefaultFuchsiaResourceDialect,
1685    > {
1686        CentralProxyInterface::r#start_scan(self, filter)
1687    }
1688
1689    /// Terminate a previously started scan session.
1690    pub fn r#stop_scan(&self) -> Result<(), fidl::Error> {
1691        CentralProxyInterface::r#stop_scan(self)
1692    }
1693
1694    /// Creates a connection to the peripheral device with the given identifier.
1695    /// Returns the status of the operation in `status`.
1696    ///
1697    /// On success, `gatt_client` will be bound and can be used for GATT client
1698    /// role procedures. On failure, `gatt_client` will be closed and `status` will
1699    /// indicate an error.
1700    pub fn r#connect_peripheral(
1701        &self,
1702        mut identifier: &str,
1703        mut options: &ConnectionOptions,
1704        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1705    ) -> fidl::client::QueryResponseFut<
1706        fidl_fuchsia_bluetooth::Status,
1707        fidl::encoding::DefaultFuchsiaResourceDialect,
1708    > {
1709        CentralProxyInterface::r#connect_peripheral(self, identifier, options, gatt_client)
1710    }
1711
1712    /// Disconnects this Central's connection to the peripheral with the given identifier.
1713    pub fn r#disconnect_peripheral(
1714        &self,
1715        mut identifier: &str,
1716    ) -> fidl::client::QueryResponseFut<
1717        fidl_fuchsia_bluetooth::Status,
1718        fidl::encoding::DefaultFuchsiaResourceDialect,
1719    > {
1720        CentralProxyInterface::r#disconnect_peripheral(self, identifier)
1721    }
1722}
1723
1724impl CentralProxyInterface for CentralProxy {
1725    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
1726        ChannelListenerRegistryListenL2capResult,
1727        fidl::encoding::DefaultFuchsiaResourceDialect,
1728    >;
1729    fn r#listen_l2cap(
1730        &self,
1731        mut payload: ChannelListenerRegistryListenL2capRequest,
1732    ) -> Self::ListenL2capResponseFut {
1733        fn _decode(
1734            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1735        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
1736            let _response = fidl::client::decode_transaction_body::<
1737                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
1738                fidl::encoding::DefaultFuchsiaResourceDialect,
1739                0x39c6e9001d102338,
1740            >(_buf?)?;
1741            Ok(_response.map(|x| x))
1742        }
1743        self.client.send_query_and_decode::<
1744            ChannelListenerRegistryListenL2capRequest,
1745            ChannelListenerRegistryListenL2capResult,
1746        >(
1747            &mut payload,
1748            0x39c6e9001d102338,
1749            fidl::encoding::DynamicFlags::empty(),
1750            _decode,
1751        )
1752    }
1753
1754    type ScanResponseFut =
1755        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1756    fn r#scan(
1757        &self,
1758        mut options: &ScanOptions,
1759        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
1760    ) -> Self::ScanResponseFut {
1761        fn _decode(
1762            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1763        ) -> Result<(), fidl::Error> {
1764            let _response = fidl::client::decode_transaction_body::<
1765                fidl::encoding::EmptyPayload,
1766                fidl::encoding::DefaultFuchsiaResourceDialect,
1767                0x41f7121798dfe15f,
1768            >(_buf?)?;
1769            Ok(_response)
1770        }
1771        self.client.send_query_and_decode::<CentralScanRequest, ()>(
1772            (options, result_watcher),
1773            0x41f7121798dfe15f,
1774            fidl::encoding::DynamicFlags::empty(),
1775            _decode,
1776        )
1777    }
1778
1779    fn r#connect(
1780        &self,
1781        mut id: &fidl_fuchsia_bluetooth::PeerId,
1782        mut options: &ConnectionOptions,
1783        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
1784    ) -> Result<(), fidl::Error> {
1785        self.client.send::<CentralConnectRequest>(
1786            (id, options, handle),
1787            0x31a3065f2a6913c4,
1788            fidl::encoding::DynamicFlags::empty(),
1789        )
1790    }
1791
1792    fn r#sync_to_periodic_advertising(
1793        &self,
1794        mut payload: CentralSyncToPeriodicAdvertisingRequest,
1795    ) -> Result<(), fidl::Error> {
1796        self.client.send::<CentralSyncToPeriodicAdvertisingRequest>(
1797            &mut payload,
1798            0x1db6df126a00c5b9,
1799            fidl::encoding::DynamicFlags::empty(),
1800        )
1801    }
1802
1803    type CreateConnectedIsochronousGroupResponseFut = fidl::client::QueryResponseFut<
1804        CentralCreateConnectedIsochronousGroupResult,
1805        fidl::encoding::DefaultFuchsiaResourceDialect,
1806    >;
1807    fn r#create_connected_isochronous_group(
1808        &self,
1809        mut payload: CentralCreateConnectedIsochronousGroupRequest,
1810    ) -> Self::CreateConnectedIsochronousGroupResponseFut {
1811        fn _decode(
1812            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1813        ) -> Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error> {
1814            let _response = fidl::client::decode_transaction_body::<
1815                fidl::encoding::ResultType<
1816                    CentralCreateConnectedIsochronousGroupResponse,
1817                    CreateCigError,
1818                >,
1819                fidl::encoding::DefaultFuchsiaResourceDialect,
1820                0x60323e70ae22e13,
1821            >(_buf?)?;
1822            Ok(_response.map(|x| x))
1823        }
1824        self.client.send_query_and_decode::<
1825            CentralCreateConnectedIsochronousGroupRequest,
1826            CentralCreateConnectedIsochronousGroupResult,
1827        >(
1828            &mut payload,
1829            0x60323e70ae22e13,
1830            fidl::encoding::DynamicFlags::empty(),
1831            _decode,
1832        )
1833    }
1834
1835    type GetPeripheralsResponseFut = fidl::client::QueryResponseFut<
1836        Vec<RemoteDevice>,
1837        fidl::encoding::DefaultFuchsiaResourceDialect,
1838    >;
1839    fn r#get_peripherals(
1840        &self,
1841        mut service_uuids: Option<&[String]>,
1842    ) -> Self::GetPeripheralsResponseFut {
1843        fn _decode(
1844            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1845        ) -> Result<Vec<RemoteDevice>, fidl::Error> {
1846            let _response = fidl::client::decode_transaction_body::<
1847                CentralGetPeripheralsResponse,
1848                fidl::encoding::DefaultFuchsiaResourceDialect,
1849                0x37ba777499c683a8,
1850            >(_buf?)?;
1851            Ok(_response.peripherals)
1852        }
1853        self.client.send_query_and_decode::<CentralGetPeripheralsRequest, Vec<RemoteDevice>>(
1854            (service_uuids,),
1855            0x37ba777499c683a8,
1856            fidl::encoding::DynamicFlags::empty(),
1857            _decode,
1858        )
1859    }
1860
1861    type GetPeripheralResponseFut = fidl::client::QueryResponseFut<
1862        Option<Box<RemoteDevice>>,
1863        fidl::encoding::DefaultFuchsiaResourceDialect,
1864    >;
1865    fn r#get_peripheral(&self, mut identifier: &str) -> Self::GetPeripheralResponseFut {
1866        fn _decode(
1867            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1868        ) -> Result<Option<Box<RemoteDevice>>, fidl::Error> {
1869            let _response = fidl::client::decode_transaction_body::<
1870                CentralGetPeripheralResponse,
1871                fidl::encoding::DefaultFuchsiaResourceDialect,
1872                0x97f5a2f2d9c13da,
1873            >(_buf?)?;
1874            Ok(_response.peripheral)
1875        }
1876        self.client.send_query_and_decode::<CentralGetPeripheralRequest, Option<Box<RemoteDevice>>>(
1877            (identifier,),
1878            0x97f5a2f2d9c13da,
1879            fidl::encoding::DynamicFlags::empty(),
1880            _decode,
1881        )
1882    }
1883
1884    type StartScanResponseFut = fidl::client::QueryResponseFut<
1885        fidl_fuchsia_bluetooth::Status,
1886        fidl::encoding::DefaultFuchsiaResourceDialect,
1887    >;
1888    fn r#start_scan(&self, mut filter: Option<&ScanFilter>) -> Self::StartScanResponseFut {
1889        fn _decode(
1890            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1891        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1892            let _response = fidl::client::decode_transaction_body::<
1893                CentralStartScanResponse,
1894                fidl::encoding::DefaultFuchsiaResourceDialect,
1895                0xeb4cf0cd0e1132b,
1896            >(_buf?)?;
1897            Ok(_response.status)
1898        }
1899        self.client
1900            .send_query_and_decode::<CentralStartScanRequest, fidl_fuchsia_bluetooth::Status>(
1901                (filter,),
1902                0xeb4cf0cd0e1132b,
1903                fidl::encoding::DynamicFlags::empty(),
1904                _decode,
1905            )
1906    }
1907
1908    fn r#stop_scan(&self) -> Result<(), fidl::Error> {
1909        self.client.send::<fidl::encoding::EmptyPayload>(
1910            (),
1911            0x5f79ee6a0bb037a0,
1912            fidl::encoding::DynamicFlags::empty(),
1913        )
1914    }
1915
1916    type ConnectPeripheralResponseFut = fidl::client::QueryResponseFut<
1917        fidl_fuchsia_bluetooth::Status,
1918        fidl::encoding::DefaultFuchsiaResourceDialect,
1919    >;
1920    fn r#connect_peripheral(
1921        &self,
1922        mut identifier: &str,
1923        mut options: &ConnectionOptions,
1924        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
1925    ) -> Self::ConnectPeripheralResponseFut {
1926        fn _decode(
1927            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1928        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1929            let _response = fidl::client::decode_transaction_body::<
1930                CentralConnectPeripheralResponse,
1931                fidl::encoding::DefaultFuchsiaResourceDialect,
1932                0x714d6c32d066d75a,
1933            >(_buf?)?;
1934            Ok(_response.status)
1935        }
1936        self.client.send_query_and_decode::<
1937            CentralConnectPeripheralRequest,
1938            fidl_fuchsia_bluetooth::Status,
1939        >(
1940            (identifier, options, gatt_client,),
1941            0x714d6c32d066d75a,
1942            fidl::encoding::DynamicFlags::empty(),
1943            _decode,
1944        )
1945    }
1946
1947    type DisconnectPeripheralResponseFut = fidl::client::QueryResponseFut<
1948        fidl_fuchsia_bluetooth::Status,
1949        fidl::encoding::DefaultFuchsiaResourceDialect,
1950    >;
1951    fn r#disconnect_peripheral(
1952        &self,
1953        mut identifier: &str,
1954    ) -> Self::DisconnectPeripheralResponseFut {
1955        fn _decode(
1956            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1957        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
1958            let _response = fidl::client::decode_transaction_body::<
1959                CentralDisconnectPeripheralResponse,
1960                fidl::encoding::DefaultFuchsiaResourceDialect,
1961                0xa9430da197362fd,
1962            >(_buf?)?;
1963            Ok(_response.status)
1964        }
1965        self.client.send_query_and_decode::<
1966            CentralDisconnectPeripheralRequest,
1967            fidl_fuchsia_bluetooth::Status,
1968        >(
1969            (identifier,),
1970            0xa9430da197362fd,
1971            fidl::encoding::DynamicFlags::empty(),
1972            _decode,
1973        )
1974    }
1975}
1976
1977pub struct CentralEventStream {
1978    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1979}
1980
1981impl std::marker::Unpin for CentralEventStream {}
1982
1983impl futures::stream::FusedStream for CentralEventStream {
1984    fn is_terminated(&self) -> bool {
1985        self.event_receiver.is_terminated()
1986    }
1987}
1988
1989impl futures::Stream for CentralEventStream {
1990    type Item = Result<CentralEvent, fidl::Error>;
1991
1992    fn poll_next(
1993        mut self: std::pin::Pin<&mut Self>,
1994        cx: &mut std::task::Context<'_>,
1995    ) -> std::task::Poll<Option<Self::Item>> {
1996        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1997            &mut self.event_receiver,
1998            cx
1999        )?) {
2000            Some(buf) => std::task::Poll::Ready(Some(CentralEvent::decode(buf))),
2001            None => std::task::Poll::Ready(None),
2002        }
2003    }
2004}
2005
2006#[derive(Debug)]
2007pub enum CentralEvent {
2008    OnScanStateChanged { scanning: bool },
2009    OnDeviceDiscovered { device: RemoteDevice },
2010    OnPeripheralDisconnected { identifier: String },
2011}
2012
2013impl CentralEvent {
2014    #[allow(irrefutable_let_patterns)]
2015    pub fn into_on_scan_state_changed(self) -> Option<bool> {
2016        if let CentralEvent::OnScanStateChanged { scanning } = self {
2017            Some((scanning))
2018        } else {
2019            None
2020        }
2021    }
2022    #[allow(irrefutable_let_patterns)]
2023    pub fn into_on_device_discovered(self) -> Option<RemoteDevice> {
2024        if let CentralEvent::OnDeviceDiscovered { device } = self { Some((device)) } else { None }
2025    }
2026    #[allow(irrefutable_let_patterns)]
2027    pub fn into_on_peripheral_disconnected(self) -> Option<String> {
2028        if let CentralEvent::OnPeripheralDisconnected { identifier } = self {
2029            Some((identifier))
2030        } else {
2031            None
2032        }
2033    }
2034
2035    /// Decodes a message buffer as a [`CentralEvent`].
2036    fn decode(
2037        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2038    ) -> Result<CentralEvent, fidl::Error> {
2039        let (bytes, _handles) = buf.split_mut();
2040        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2041        debug_assert_eq!(tx_header.tx_id, 0);
2042        match tx_header.ordinal {
2043            0x5f8edc23cad04d3f => {
2044                let mut out = fidl::new_empty!(
2045                    CentralOnScanStateChangedRequest,
2046                    fidl::encoding::DefaultFuchsiaResourceDialect
2047                );
2048                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnScanStateChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2049                Ok((CentralEvent::OnScanStateChanged { scanning: out.scanning }))
2050            }
2051            0x708dadf20d66db6 => {
2052                let mut out = fidl::new_empty!(
2053                    CentralOnDeviceDiscoveredRequest,
2054                    fidl::encoding::DefaultFuchsiaResourceDialect
2055                );
2056                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnDeviceDiscoveredRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2057                Ok((CentralEvent::OnDeviceDiscovered { device: out.device }))
2058            }
2059            0x4e4c6b979b2126df => {
2060                let mut out = fidl::new_empty!(
2061                    CentralOnPeripheralDisconnectedRequest,
2062                    fidl::encoding::DefaultFuchsiaResourceDialect
2063                );
2064                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnPeripheralDisconnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2065                Ok((CentralEvent::OnPeripheralDisconnected { identifier: out.identifier }))
2066            }
2067            _ => Err(fidl::Error::UnknownOrdinal {
2068                ordinal: tx_header.ordinal,
2069                protocol_name: <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2070            }),
2071        }
2072    }
2073}
2074
2075/// A Stream of incoming requests for fuchsia.bluetooth.le/Central.
2076pub struct CentralRequestStream {
2077    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2078    is_terminated: bool,
2079}
2080
2081impl std::marker::Unpin for CentralRequestStream {}
2082
2083impl futures::stream::FusedStream for CentralRequestStream {
2084    fn is_terminated(&self) -> bool {
2085        self.is_terminated
2086    }
2087}
2088
2089impl fidl::endpoints::RequestStream for CentralRequestStream {
2090    type Protocol = CentralMarker;
2091    type ControlHandle = CentralControlHandle;
2092
2093    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2094        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2095    }
2096
2097    fn control_handle(&self) -> Self::ControlHandle {
2098        CentralControlHandle { inner: self.inner.clone() }
2099    }
2100
2101    fn into_inner(
2102        self,
2103    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2104    {
2105        (self.inner, self.is_terminated)
2106    }
2107
2108    fn from_inner(
2109        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2110        is_terminated: bool,
2111    ) -> Self {
2112        Self { inner, is_terminated }
2113    }
2114}
2115
2116impl futures::Stream for CentralRequestStream {
2117    type Item = Result<CentralRequest, fidl::Error>;
2118
2119    fn poll_next(
2120        mut self: std::pin::Pin<&mut Self>,
2121        cx: &mut std::task::Context<'_>,
2122    ) -> std::task::Poll<Option<Self::Item>> {
2123        let this = &mut *self;
2124        if this.inner.check_shutdown(cx) {
2125            this.is_terminated = true;
2126            return std::task::Poll::Ready(None);
2127        }
2128        if this.is_terminated {
2129            panic!("polled CentralRequestStream after completion");
2130        }
2131        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2132            |bytes, handles| {
2133                match this.inner.channel().read_etc(cx, bytes, handles) {
2134                    std::task::Poll::Ready(Ok(())) => {}
2135                    std::task::Poll::Pending => return std::task::Poll::Pending,
2136                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2137                        this.is_terminated = true;
2138                        return std::task::Poll::Ready(None);
2139                    }
2140                    std::task::Poll::Ready(Err(e)) => {
2141                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2142                            e.into(),
2143                        ))));
2144                    }
2145                }
2146
2147                // A message has been received from the channel
2148                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2149
2150                std::task::Poll::Ready(Some(match header.ordinal {
2151                    0x39c6e9001d102338 => {
2152                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2153                        let mut req = fidl::new_empty!(
2154                            ChannelListenerRegistryListenL2capRequest,
2155                            fidl::encoding::DefaultFuchsiaResourceDialect
2156                        );
2157                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
2158                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2159                        Ok(CentralRequest::ListenL2cap {
2160                            payload: req,
2161                            responder: CentralListenL2capResponder {
2162                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2163                                tx_id: header.tx_id,
2164                            },
2165                        })
2166                    }
2167                    0x41f7121798dfe15f => {
2168                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2169                        let mut req = fidl::new_empty!(
2170                            CentralScanRequest,
2171                            fidl::encoding::DefaultFuchsiaResourceDialect
2172                        );
2173                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralScanRequest>(&header, _body_bytes, handles, &mut req)?;
2174                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2175                        Ok(CentralRequest::Scan {
2176                            options: req.options,
2177                            result_watcher: req.result_watcher,
2178
2179                            responder: CentralScanResponder {
2180                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2181                                tx_id: header.tx_id,
2182                            },
2183                        })
2184                    }
2185                    0x31a3065f2a6913c4 => {
2186                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2187                        let mut req = fidl::new_empty!(
2188                            CentralConnectRequest,
2189                            fidl::encoding::DefaultFuchsiaResourceDialect
2190                        );
2191                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralConnectRequest>(&header, _body_bytes, handles, &mut req)?;
2192                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2193                        Ok(CentralRequest::Connect {
2194                            id: req.id,
2195                            options: req.options,
2196                            handle: req.handle,
2197
2198                            control_handle,
2199                        })
2200                    }
2201                    0x1db6df126a00c5b9 => {
2202                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2203                        let mut req = fidl::new_empty!(
2204                            CentralSyncToPeriodicAdvertisingRequest,
2205                            fidl::encoding::DefaultFuchsiaResourceDialect
2206                        );
2207                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralSyncToPeriodicAdvertisingRequest>(&header, _body_bytes, handles, &mut req)?;
2208                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2209                        Ok(CentralRequest::SyncToPeriodicAdvertising {
2210                            payload: req,
2211                            control_handle,
2212                        })
2213                    }
2214                    0x60323e70ae22e13 => {
2215                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2216                        let mut req = fidl::new_empty!(
2217                            CentralCreateConnectedIsochronousGroupRequest,
2218                            fidl::encoding::DefaultFuchsiaResourceDialect
2219                        );
2220                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralCreateConnectedIsochronousGroupRequest>(&header, _body_bytes, handles, &mut req)?;
2221                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2222                        Ok(CentralRequest::CreateConnectedIsochronousGroup {
2223                            payload: req,
2224                            responder: CentralCreateConnectedIsochronousGroupResponder {
2225                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2226                                tx_id: header.tx_id,
2227                            },
2228                        })
2229                    }
2230                    0x37ba777499c683a8 => {
2231                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2232                        let mut req = fidl::new_empty!(
2233                            CentralGetPeripheralsRequest,
2234                            fidl::encoding::DefaultFuchsiaResourceDialect
2235                        );
2236                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralGetPeripheralsRequest>(&header, _body_bytes, handles, &mut req)?;
2237                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2238                        Ok(CentralRequest::GetPeripherals {
2239                            service_uuids: req.service_uuids,
2240
2241                            responder: CentralGetPeripheralsResponder {
2242                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2243                                tx_id: header.tx_id,
2244                            },
2245                        })
2246                    }
2247                    0x97f5a2f2d9c13da => {
2248                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2249                        let mut req = fidl::new_empty!(
2250                            CentralGetPeripheralRequest,
2251                            fidl::encoding::DefaultFuchsiaResourceDialect
2252                        );
2253                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralGetPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
2254                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2255                        Ok(CentralRequest::GetPeripheral {
2256                            identifier: req.identifier,
2257
2258                            responder: CentralGetPeripheralResponder {
2259                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2260                                tx_id: header.tx_id,
2261                            },
2262                        })
2263                    }
2264                    0xeb4cf0cd0e1132b => {
2265                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2266                        let mut req = fidl::new_empty!(
2267                            CentralStartScanRequest,
2268                            fidl::encoding::DefaultFuchsiaResourceDialect
2269                        );
2270                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralStartScanRequest>(&header, _body_bytes, handles, &mut req)?;
2271                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2272                        Ok(CentralRequest::StartScan {
2273                            filter: req.filter,
2274
2275                            responder: CentralStartScanResponder {
2276                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2277                                tx_id: header.tx_id,
2278                            },
2279                        })
2280                    }
2281                    0x5f79ee6a0bb037a0 => {
2282                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2283                        let mut req = fidl::new_empty!(
2284                            fidl::encoding::EmptyPayload,
2285                            fidl::encoding::DefaultFuchsiaResourceDialect
2286                        );
2287                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2288                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2289                        Ok(CentralRequest::StopScan { control_handle })
2290                    }
2291                    0x714d6c32d066d75a => {
2292                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2293                        let mut req = fidl::new_empty!(
2294                            CentralConnectPeripheralRequest,
2295                            fidl::encoding::DefaultFuchsiaResourceDialect
2296                        );
2297                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralConnectPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
2298                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2299                        Ok(CentralRequest::ConnectPeripheral {
2300                            identifier: req.identifier,
2301                            options: req.options,
2302                            gatt_client: req.gatt_client,
2303
2304                            responder: CentralConnectPeripheralResponder {
2305                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2306                                tx_id: header.tx_id,
2307                            },
2308                        })
2309                    }
2310                    0xa9430da197362fd => {
2311                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2312                        let mut req = fidl::new_empty!(
2313                            CentralDisconnectPeripheralRequest,
2314                            fidl::encoding::DefaultFuchsiaResourceDialect
2315                        );
2316                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralDisconnectPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
2317                        let control_handle = CentralControlHandle { inner: this.inner.clone() };
2318                        Ok(CentralRequest::DisconnectPeripheral {
2319                            identifier: req.identifier,
2320
2321                            responder: CentralDisconnectPeripheralResponder {
2322                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2323                                tx_id: header.tx_id,
2324                            },
2325                        })
2326                    }
2327                    _ => Err(fidl::Error::UnknownOrdinal {
2328                        ordinal: header.ordinal,
2329                        protocol_name:
2330                            <CentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2331                    }),
2332                }))
2333            },
2334        )
2335    }
2336}
2337
2338#[derive(Debug)]
2339pub enum CentralRequest {
2340    /// Register a listener for incoming channels. The registry will assign a
2341    /// PSM value that is unique for the local device, as well as open a
2342    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
2343    /// event that all PSMs have been assigned, this call will fail with
2344    /// `ZX_ERR_NO_RESOURCES`.
2345    ///
2346    /// Note that the method of service discovery or advertising is defined by
2347    /// the service or protocol, so it is the responsibility of the caller to
2348    /// communicate the assigned PSM to any clients.
2349    ListenL2cap {
2350        payload: ChannelListenerRegistryListenL2capRequest,
2351        responder: CentralListenL2capResponder,
2352    },
2353    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
2354    /// initiated, then `result_watcher` will be closed with an epitaph.
2355    ///
2356    /// A Central client is allowed to have only one active scan at a time.
2357    /// Accordingly, only one Scan request can be outstanding at a time.
2358    /// Additional calls to Scan will fail.
2359    ///
2360    /// The lifetime of the scan session is tied to the `result_watcher`
2361    /// protocol provided. The scan will be stopped if the channel is closed.
2362    ///
2363    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
2364    /// can be used to watch for scan results.
2365    ///
2366    /// + request `options` Options used to configure the scan session.
2367    /// + request `result_watcher` Protocol that remains valid for the duration
2368    ///   of this scan session.
2369    /// - response An empty response will be sent to acknowledge the scan has
2370    ///   stopped.
2371    ///
2372    /// The following epitaphs may be sent by the server on error:
2373    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
2374    ///   protocol is only allowed 1 active scan.
2375    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
2376    ///   `ScanOptions` documentation.
2377    /// * error `INTERNAL`: An internal error occurred and a scan could not be
2378    ///   started.
2379    Scan {
2380        options: ScanOptions,
2381        result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
2382        responder: CentralScanResponder,
2383    },
2384    /// Connect to the peer with the given identifier.
2385    ///
2386    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
2387    /// client's interest on the LE connection to the peer. Closing the channel
2388    /// removes interest, but may not result in disconnection if another client
2389    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
2390    ///
2391    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
2392    /// system if the connection to the peer is lost or an error occurs.
2393    ///
2394    /// The following epitaphs may be sent by the server on error:
2395    /// + `INVALID_ARGS`: Some of the parameters are invalid.
2396    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
2397    ///                    Connection should be used.
2398    /// + `NOT_CONNECTED`: A connection could not be established.
2399    /// + `CONNECTION_RESET`: The peer disconnected.
2400    ///
2401    /// + request `id` Identifier of the peer to initiate a connection to.
2402    /// + request `options` Options used to configure the connection.
2403    /// + request `handle` Handle that remains valid for the duration of this
2404    ///   connection.
2405    Connect {
2406        id: fidl_fuchsia_bluetooth::PeerId,
2407        options: ConnectionOptions,
2408        handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
2409        control_handle: CentralControlHandle,
2410    },
2411    /// Synchronize to a periodic advertising train. Reports will be delivered via the
2412    /// `PeriodicAdvertisingSync` protocol.
2413    SyncToPeriodicAdvertising {
2414        payload: CentralSyncToPeriodicAdvertisingRequest,
2415        control_handle: CentralControlHandle,
2416    },
2417    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
2418    /// operation is only valid when operating in the Central role for a connection.
2419    ///
2420    /// If the Central channel is closed before the CIG is explicitly removed, the group will
2421    /// be removed and disconnected.
2422    ///
2423    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
2424    /// id allocated by the host.
2425    CreateConnectedIsochronousGroup {
2426        payload: CentralCreateConnectedIsochronousGroupRequest,
2427        responder: CentralCreateConnectedIsochronousGroupResponder,
2428    },
2429    /// Returns the list of peripherals that are known to the system from previous scan, connection,
2430    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
2431    /// be present on the peripheral.
2432    ///
2433    /// This method only returns peripherals (i.e. connectable devices).
2434    GetPeripherals { service_uuids: Option<Vec<String>>, responder: CentralGetPeripheralsResponder },
2435    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
2436    ///
2437    /// Returns information about a single peripheral that is known to the system from previous scan,
2438    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
2439    /// `identifier` is not recognized.
2440    GetPeripheral { identifier: String, responder: CentralGetPeripheralResponder },
2441    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
2442    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
2443    /// `filter` will replace the existing session's filter.
2444    ///
2445    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
2446    /// will be notified for all discoverable devices that are found. This is not recommended; clients
2447    /// should generally filter results by at least one of `filter.service_uuids`,
2448    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
2449    StartScan { filter: Option<Box<ScanFilter>>, responder: CentralStartScanResponder },
2450    /// Terminate a previously started scan session.
2451    StopScan { control_handle: CentralControlHandle },
2452    /// Creates a connection to the peripheral device with the given identifier.
2453    /// Returns the status of the operation in `status`.
2454    ///
2455    /// On success, `gatt_client` will be bound and can be used for GATT client
2456    /// role procedures. On failure, `gatt_client` will be closed and `status` will
2457    /// indicate an error.
2458    ConnectPeripheral {
2459        identifier: String,
2460        options: ConnectionOptions,
2461        gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
2462        responder: CentralConnectPeripheralResponder,
2463    },
2464    /// Disconnects this Central's connection to the peripheral with the given identifier.
2465    DisconnectPeripheral { identifier: String, responder: CentralDisconnectPeripheralResponder },
2466}
2467
2468impl CentralRequest {
2469    #[allow(irrefutable_let_patterns)]
2470    pub fn into_listen_l2cap(
2471        self,
2472    ) -> Option<(ChannelListenerRegistryListenL2capRequest, CentralListenL2capResponder)> {
2473        if let CentralRequest::ListenL2cap { payload, responder } = self {
2474            Some((payload, responder))
2475        } else {
2476            None
2477        }
2478    }
2479
2480    #[allow(irrefutable_let_patterns)]
2481    pub fn into_scan(
2482        self,
2483    ) -> Option<(
2484        ScanOptions,
2485        fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
2486        CentralScanResponder,
2487    )> {
2488        if let CentralRequest::Scan { options, result_watcher, responder } = self {
2489            Some((options, result_watcher, responder))
2490        } else {
2491            None
2492        }
2493    }
2494
2495    #[allow(irrefutable_let_patterns)]
2496    pub fn into_connect(
2497        self,
2498    ) -> Option<(
2499        fidl_fuchsia_bluetooth::PeerId,
2500        ConnectionOptions,
2501        fidl::endpoints::ServerEnd<ConnectionMarker>,
2502        CentralControlHandle,
2503    )> {
2504        if let CentralRequest::Connect { id, options, handle, control_handle } = self {
2505            Some((id, options, handle, control_handle))
2506        } else {
2507            None
2508        }
2509    }
2510
2511    #[allow(irrefutable_let_patterns)]
2512    pub fn into_sync_to_periodic_advertising(
2513        self,
2514    ) -> Option<(CentralSyncToPeriodicAdvertisingRequest, CentralControlHandle)> {
2515        if let CentralRequest::SyncToPeriodicAdvertising { payload, control_handle } = self {
2516            Some((payload, control_handle))
2517        } else {
2518            None
2519        }
2520    }
2521
2522    #[allow(irrefutable_let_patterns)]
2523    pub fn into_create_connected_isochronous_group(
2524        self,
2525    ) -> Option<(
2526        CentralCreateConnectedIsochronousGroupRequest,
2527        CentralCreateConnectedIsochronousGroupResponder,
2528    )> {
2529        if let CentralRequest::CreateConnectedIsochronousGroup { payload, responder } = self {
2530            Some((payload, responder))
2531        } else {
2532            None
2533        }
2534    }
2535
2536    #[allow(irrefutable_let_patterns)]
2537    pub fn into_get_peripherals(
2538        self,
2539    ) -> Option<(Option<Vec<String>>, CentralGetPeripheralsResponder)> {
2540        if let CentralRequest::GetPeripherals { service_uuids, responder } = self {
2541            Some((service_uuids, responder))
2542        } else {
2543            None
2544        }
2545    }
2546
2547    #[allow(irrefutable_let_patterns)]
2548    pub fn into_get_peripheral(self) -> Option<(String, CentralGetPeripheralResponder)> {
2549        if let CentralRequest::GetPeripheral { identifier, responder } = self {
2550            Some((identifier, responder))
2551        } else {
2552            None
2553        }
2554    }
2555
2556    #[allow(irrefutable_let_patterns)]
2557    pub fn into_start_scan(self) -> Option<(Option<Box<ScanFilter>>, CentralStartScanResponder)> {
2558        if let CentralRequest::StartScan { filter, responder } = self {
2559            Some((filter, responder))
2560        } else {
2561            None
2562        }
2563    }
2564
2565    #[allow(irrefutable_let_patterns)]
2566    pub fn into_stop_scan(self) -> Option<(CentralControlHandle)> {
2567        if let CentralRequest::StopScan { control_handle } = self {
2568            Some((control_handle))
2569        } else {
2570            None
2571        }
2572    }
2573
2574    #[allow(irrefutable_let_patterns)]
2575    pub fn into_connect_peripheral(
2576        self,
2577    ) -> Option<(
2578        String,
2579        ConnectionOptions,
2580        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
2581        CentralConnectPeripheralResponder,
2582    )> {
2583        if let CentralRequest::ConnectPeripheral { identifier, options, gatt_client, responder } =
2584            self
2585        {
2586            Some((identifier, options, gatt_client, responder))
2587        } else {
2588            None
2589        }
2590    }
2591
2592    #[allow(irrefutable_let_patterns)]
2593    pub fn into_disconnect_peripheral(
2594        self,
2595    ) -> Option<(String, CentralDisconnectPeripheralResponder)> {
2596        if let CentralRequest::DisconnectPeripheral { identifier, responder } = self {
2597            Some((identifier, responder))
2598        } else {
2599            None
2600        }
2601    }
2602
2603    /// Name of the method defined in FIDL
2604    pub fn method_name(&self) -> &'static str {
2605        match *self {
2606            CentralRequest::ListenL2cap { .. } => "listen_l2cap",
2607            CentralRequest::Scan { .. } => "scan",
2608            CentralRequest::Connect { .. } => "connect",
2609            CentralRequest::SyncToPeriodicAdvertising { .. } => "sync_to_periodic_advertising",
2610            CentralRequest::CreateConnectedIsochronousGroup { .. } => {
2611                "create_connected_isochronous_group"
2612            }
2613            CentralRequest::GetPeripherals { .. } => "get_peripherals",
2614            CentralRequest::GetPeripheral { .. } => "get_peripheral",
2615            CentralRequest::StartScan { .. } => "start_scan",
2616            CentralRequest::StopScan { .. } => "stop_scan",
2617            CentralRequest::ConnectPeripheral { .. } => "connect_peripheral",
2618            CentralRequest::DisconnectPeripheral { .. } => "disconnect_peripheral",
2619        }
2620    }
2621}
2622
2623#[derive(Debug, Clone)]
2624pub struct CentralControlHandle {
2625    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2626}
2627
2628impl fidl::endpoints::ControlHandle for CentralControlHandle {
2629    fn shutdown(&self) {
2630        self.inner.shutdown()
2631    }
2632
2633    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2634        self.inner.shutdown_with_epitaph(status)
2635    }
2636
2637    fn is_closed(&self) -> bool {
2638        self.inner.channel().is_closed()
2639    }
2640    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2641        self.inner.channel().on_closed()
2642    }
2643
2644    #[cfg(target_os = "fuchsia")]
2645    fn signal_peer(
2646        &self,
2647        clear_mask: zx::Signals,
2648        set_mask: zx::Signals,
2649    ) -> Result<(), zx_status::Status> {
2650        use fidl::Peered;
2651        self.inner.channel().signal_peer(clear_mask, set_mask)
2652    }
2653}
2654
2655impl CentralControlHandle {
2656    pub fn send_on_scan_state_changed(&self, mut scanning: bool) -> Result<(), fidl::Error> {
2657        self.inner.send::<CentralOnScanStateChangedRequest>(
2658            (scanning,),
2659            0,
2660            0x5f8edc23cad04d3f,
2661            fidl::encoding::DynamicFlags::empty(),
2662        )
2663    }
2664
2665    pub fn send_on_device_discovered(&self, mut device: &RemoteDevice) -> Result<(), fidl::Error> {
2666        self.inner.send::<CentralOnDeviceDiscoveredRequest>(
2667            (device,),
2668            0,
2669            0x708dadf20d66db6,
2670            fidl::encoding::DynamicFlags::empty(),
2671        )
2672    }
2673
2674    pub fn send_on_peripheral_disconnected(&self, mut identifier: &str) -> Result<(), fidl::Error> {
2675        self.inner.send::<CentralOnPeripheralDisconnectedRequest>(
2676            (identifier,),
2677            0,
2678            0x4e4c6b979b2126df,
2679            fidl::encoding::DynamicFlags::empty(),
2680        )
2681    }
2682}
2683
2684#[must_use = "FIDL methods require a response to be sent"]
2685#[derive(Debug)]
2686pub struct CentralListenL2capResponder {
2687    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2688    tx_id: u32,
2689}
2690
2691/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2692/// if the responder is dropped without sending a response, so that the client
2693/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2694impl std::ops::Drop for CentralListenL2capResponder {
2695    fn drop(&mut self) {
2696        self.control_handle.shutdown();
2697        // Safety: drops once, never accessed again
2698        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2699    }
2700}
2701
2702impl fidl::endpoints::Responder for CentralListenL2capResponder {
2703    type ControlHandle = CentralControlHandle;
2704
2705    fn control_handle(&self) -> &CentralControlHandle {
2706        &self.control_handle
2707    }
2708
2709    fn drop_without_shutdown(mut self) {
2710        // Safety: drops once, never accessed again due to mem::forget
2711        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2712        // Prevent Drop from running (which would shut down the channel)
2713        std::mem::forget(self);
2714    }
2715}
2716
2717impl CentralListenL2capResponder {
2718    /// Sends a response to the FIDL transaction.
2719    ///
2720    /// Sets the channel to shutdown if an error occurs.
2721    pub fn send(
2722        self,
2723        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
2724    ) -> Result<(), fidl::Error> {
2725        let _result = self.send_raw(result);
2726        if _result.is_err() {
2727            self.control_handle.shutdown();
2728        }
2729        self.drop_without_shutdown();
2730        _result
2731    }
2732
2733    /// Similar to "send" but does not shutdown the channel if an error occurs.
2734    pub fn send_no_shutdown_on_err(
2735        self,
2736        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
2737    ) -> Result<(), fidl::Error> {
2738        let _result = self.send_raw(result);
2739        self.drop_without_shutdown();
2740        _result
2741    }
2742
2743    fn send_raw(
2744        &self,
2745        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
2746    ) -> Result<(), fidl::Error> {
2747        self.control_handle.inner.send::<fidl::encoding::ResultType<
2748            ChannelListenerRegistryListenL2capResponse,
2749            i32,
2750        >>(
2751            result,
2752            self.tx_id,
2753            0x39c6e9001d102338,
2754            fidl::encoding::DynamicFlags::empty(),
2755        )
2756    }
2757}
2758
2759#[must_use = "FIDL methods require a response to be sent"]
2760#[derive(Debug)]
2761pub struct CentralScanResponder {
2762    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2763    tx_id: u32,
2764}
2765
2766/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2767/// if the responder is dropped without sending a response, so that the client
2768/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2769impl std::ops::Drop for CentralScanResponder {
2770    fn drop(&mut self) {
2771        self.control_handle.shutdown();
2772        // Safety: drops once, never accessed again
2773        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2774    }
2775}
2776
2777impl fidl::endpoints::Responder for CentralScanResponder {
2778    type ControlHandle = CentralControlHandle;
2779
2780    fn control_handle(&self) -> &CentralControlHandle {
2781        &self.control_handle
2782    }
2783
2784    fn drop_without_shutdown(mut self) {
2785        // Safety: drops once, never accessed again due to mem::forget
2786        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2787        // Prevent Drop from running (which would shut down the channel)
2788        std::mem::forget(self);
2789    }
2790}
2791
2792impl CentralScanResponder {
2793    /// Sends a response to the FIDL transaction.
2794    ///
2795    /// Sets the channel to shutdown if an error occurs.
2796    pub fn send(self) -> Result<(), fidl::Error> {
2797        let _result = self.send_raw();
2798        if _result.is_err() {
2799            self.control_handle.shutdown();
2800        }
2801        self.drop_without_shutdown();
2802        _result
2803    }
2804
2805    /// Similar to "send" but does not shutdown the channel if an error occurs.
2806    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2807        let _result = self.send_raw();
2808        self.drop_without_shutdown();
2809        _result
2810    }
2811
2812    fn send_raw(&self) -> Result<(), fidl::Error> {
2813        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2814            (),
2815            self.tx_id,
2816            0x41f7121798dfe15f,
2817            fidl::encoding::DynamicFlags::empty(),
2818        )
2819    }
2820}
2821
2822#[must_use = "FIDL methods require a response to be sent"]
2823#[derive(Debug)]
2824pub struct CentralCreateConnectedIsochronousGroupResponder {
2825    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2826    tx_id: u32,
2827}
2828
2829/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2830/// if the responder is dropped without sending a response, so that the client
2831/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2832impl std::ops::Drop for CentralCreateConnectedIsochronousGroupResponder {
2833    fn drop(&mut self) {
2834        self.control_handle.shutdown();
2835        // Safety: drops once, never accessed again
2836        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2837    }
2838}
2839
2840impl fidl::endpoints::Responder for CentralCreateConnectedIsochronousGroupResponder {
2841    type ControlHandle = CentralControlHandle;
2842
2843    fn control_handle(&self) -> &CentralControlHandle {
2844        &self.control_handle
2845    }
2846
2847    fn drop_without_shutdown(mut self) {
2848        // Safety: drops once, never accessed again due to mem::forget
2849        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2850        // Prevent Drop from running (which would shut down the channel)
2851        std::mem::forget(self);
2852    }
2853}
2854
2855impl CentralCreateConnectedIsochronousGroupResponder {
2856    /// Sends a response to the FIDL transaction.
2857    ///
2858    /// Sets the channel to shutdown if an error occurs.
2859    pub fn send(
2860        self,
2861        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
2862    ) -> Result<(), fidl::Error> {
2863        let _result = self.send_raw(result);
2864        if _result.is_err() {
2865            self.control_handle.shutdown();
2866        }
2867        self.drop_without_shutdown();
2868        _result
2869    }
2870
2871    /// Similar to "send" but does not shutdown the channel if an error occurs.
2872    pub fn send_no_shutdown_on_err(
2873        self,
2874        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
2875    ) -> Result<(), fidl::Error> {
2876        let _result = self.send_raw(result);
2877        self.drop_without_shutdown();
2878        _result
2879    }
2880
2881    fn send_raw(
2882        &self,
2883        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
2884    ) -> Result<(), fidl::Error> {
2885        self.control_handle.inner.send::<fidl::encoding::ResultType<
2886            CentralCreateConnectedIsochronousGroupResponse,
2887            CreateCigError,
2888        >>(
2889            result,
2890            self.tx_id,
2891            0x60323e70ae22e13,
2892            fidl::encoding::DynamicFlags::empty(),
2893        )
2894    }
2895}
2896
2897#[must_use = "FIDL methods require a response to be sent"]
2898#[derive(Debug)]
2899pub struct CentralGetPeripheralsResponder {
2900    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2901    tx_id: u32,
2902}
2903
2904/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2905/// if the responder is dropped without sending a response, so that the client
2906/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2907impl std::ops::Drop for CentralGetPeripheralsResponder {
2908    fn drop(&mut self) {
2909        self.control_handle.shutdown();
2910        // Safety: drops once, never accessed again
2911        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2912    }
2913}
2914
2915impl fidl::endpoints::Responder for CentralGetPeripheralsResponder {
2916    type ControlHandle = CentralControlHandle;
2917
2918    fn control_handle(&self) -> &CentralControlHandle {
2919        &self.control_handle
2920    }
2921
2922    fn drop_without_shutdown(mut self) {
2923        // Safety: drops once, never accessed again due to mem::forget
2924        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2925        // Prevent Drop from running (which would shut down the channel)
2926        std::mem::forget(self);
2927    }
2928}
2929
2930impl CentralGetPeripheralsResponder {
2931    /// Sends a response to the FIDL transaction.
2932    ///
2933    /// Sets the channel to shutdown if an error occurs.
2934    pub fn send(self, mut peripherals: &[RemoteDevice]) -> Result<(), fidl::Error> {
2935        let _result = self.send_raw(peripherals);
2936        if _result.is_err() {
2937            self.control_handle.shutdown();
2938        }
2939        self.drop_without_shutdown();
2940        _result
2941    }
2942
2943    /// Similar to "send" but does not shutdown the channel if an error occurs.
2944    pub fn send_no_shutdown_on_err(
2945        self,
2946        mut peripherals: &[RemoteDevice],
2947    ) -> Result<(), fidl::Error> {
2948        let _result = self.send_raw(peripherals);
2949        self.drop_without_shutdown();
2950        _result
2951    }
2952
2953    fn send_raw(&self, mut peripherals: &[RemoteDevice]) -> Result<(), fidl::Error> {
2954        self.control_handle.inner.send::<CentralGetPeripheralsResponse>(
2955            (peripherals,),
2956            self.tx_id,
2957            0x37ba777499c683a8,
2958            fidl::encoding::DynamicFlags::empty(),
2959        )
2960    }
2961}
2962
2963#[must_use = "FIDL methods require a response to be sent"]
2964#[derive(Debug)]
2965pub struct CentralGetPeripheralResponder {
2966    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
2967    tx_id: u32,
2968}
2969
2970/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
2971/// if the responder is dropped without sending a response, so that the client
2972/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2973impl std::ops::Drop for CentralGetPeripheralResponder {
2974    fn drop(&mut self) {
2975        self.control_handle.shutdown();
2976        // Safety: drops once, never accessed again
2977        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2978    }
2979}
2980
2981impl fidl::endpoints::Responder for CentralGetPeripheralResponder {
2982    type ControlHandle = CentralControlHandle;
2983
2984    fn control_handle(&self) -> &CentralControlHandle {
2985        &self.control_handle
2986    }
2987
2988    fn drop_without_shutdown(mut self) {
2989        // Safety: drops once, never accessed again due to mem::forget
2990        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2991        // Prevent Drop from running (which would shut down the channel)
2992        std::mem::forget(self);
2993    }
2994}
2995
2996impl CentralGetPeripheralResponder {
2997    /// Sends a response to the FIDL transaction.
2998    ///
2999    /// Sets the channel to shutdown if an error occurs.
3000    pub fn send(self, mut peripheral: Option<&RemoteDevice>) -> Result<(), fidl::Error> {
3001        let _result = self.send_raw(peripheral);
3002        if _result.is_err() {
3003            self.control_handle.shutdown();
3004        }
3005        self.drop_without_shutdown();
3006        _result
3007    }
3008
3009    /// Similar to "send" but does not shutdown the channel if an error occurs.
3010    pub fn send_no_shutdown_on_err(
3011        self,
3012        mut peripheral: Option<&RemoteDevice>,
3013    ) -> Result<(), fidl::Error> {
3014        let _result = self.send_raw(peripheral);
3015        self.drop_without_shutdown();
3016        _result
3017    }
3018
3019    fn send_raw(&self, mut peripheral: Option<&RemoteDevice>) -> Result<(), fidl::Error> {
3020        self.control_handle.inner.send::<CentralGetPeripheralResponse>(
3021            (peripheral,),
3022            self.tx_id,
3023            0x97f5a2f2d9c13da,
3024            fidl::encoding::DynamicFlags::empty(),
3025        )
3026    }
3027}
3028
3029#[must_use = "FIDL methods require a response to be sent"]
3030#[derive(Debug)]
3031pub struct CentralStartScanResponder {
3032    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
3033    tx_id: u32,
3034}
3035
3036/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
3037/// if the responder is dropped without sending a response, so that the client
3038/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3039impl std::ops::Drop for CentralStartScanResponder {
3040    fn drop(&mut self) {
3041        self.control_handle.shutdown();
3042        // Safety: drops once, never accessed again
3043        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3044    }
3045}
3046
3047impl fidl::endpoints::Responder for CentralStartScanResponder {
3048    type ControlHandle = CentralControlHandle;
3049
3050    fn control_handle(&self) -> &CentralControlHandle {
3051        &self.control_handle
3052    }
3053
3054    fn drop_without_shutdown(mut self) {
3055        // Safety: drops once, never accessed again due to mem::forget
3056        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3057        // Prevent Drop from running (which would shut down the channel)
3058        std::mem::forget(self);
3059    }
3060}
3061
3062impl CentralStartScanResponder {
3063    /// Sends a response to the FIDL transaction.
3064    ///
3065    /// Sets the channel to shutdown if an error occurs.
3066    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3067        let _result = self.send_raw(status);
3068        if _result.is_err() {
3069            self.control_handle.shutdown();
3070        }
3071        self.drop_without_shutdown();
3072        _result
3073    }
3074
3075    /// Similar to "send" but does not shutdown the channel if an error occurs.
3076    pub fn send_no_shutdown_on_err(
3077        self,
3078        mut status: &fidl_fuchsia_bluetooth::Status,
3079    ) -> Result<(), fidl::Error> {
3080        let _result = self.send_raw(status);
3081        self.drop_without_shutdown();
3082        _result
3083    }
3084
3085    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3086        self.control_handle.inner.send::<CentralStartScanResponse>(
3087            (status,),
3088            self.tx_id,
3089            0xeb4cf0cd0e1132b,
3090            fidl::encoding::DynamicFlags::empty(),
3091        )
3092    }
3093}
3094
3095#[must_use = "FIDL methods require a response to be sent"]
3096#[derive(Debug)]
3097pub struct CentralConnectPeripheralResponder {
3098    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
3099    tx_id: u32,
3100}
3101
3102/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
3103/// if the responder is dropped without sending a response, so that the client
3104/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3105impl std::ops::Drop for CentralConnectPeripheralResponder {
3106    fn drop(&mut self) {
3107        self.control_handle.shutdown();
3108        // Safety: drops once, never accessed again
3109        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3110    }
3111}
3112
3113impl fidl::endpoints::Responder for CentralConnectPeripheralResponder {
3114    type ControlHandle = CentralControlHandle;
3115
3116    fn control_handle(&self) -> &CentralControlHandle {
3117        &self.control_handle
3118    }
3119
3120    fn drop_without_shutdown(mut self) {
3121        // Safety: drops once, never accessed again due to mem::forget
3122        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3123        // Prevent Drop from running (which would shut down the channel)
3124        std::mem::forget(self);
3125    }
3126}
3127
3128impl CentralConnectPeripheralResponder {
3129    /// Sends a response to the FIDL transaction.
3130    ///
3131    /// Sets the channel to shutdown if an error occurs.
3132    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3133        let _result = self.send_raw(status);
3134        if _result.is_err() {
3135            self.control_handle.shutdown();
3136        }
3137        self.drop_without_shutdown();
3138        _result
3139    }
3140
3141    /// Similar to "send" but does not shutdown the channel if an error occurs.
3142    pub fn send_no_shutdown_on_err(
3143        self,
3144        mut status: &fidl_fuchsia_bluetooth::Status,
3145    ) -> Result<(), fidl::Error> {
3146        let _result = self.send_raw(status);
3147        self.drop_without_shutdown();
3148        _result
3149    }
3150
3151    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3152        self.control_handle.inner.send::<CentralConnectPeripheralResponse>(
3153            (status,),
3154            self.tx_id,
3155            0x714d6c32d066d75a,
3156            fidl::encoding::DynamicFlags::empty(),
3157        )
3158    }
3159}
3160
3161#[must_use = "FIDL methods require a response to be sent"]
3162#[derive(Debug)]
3163pub struct CentralDisconnectPeripheralResponder {
3164    control_handle: std::mem::ManuallyDrop<CentralControlHandle>,
3165    tx_id: u32,
3166}
3167
3168/// Set the the channel to be shutdown (see [`CentralControlHandle::shutdown`])
3169/// if the responder is dropped without sending a response, so that the client
3170/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3171impl std::ops::Drop for CentralDisconnectPeripheralResponder {
3172    fn drop(&mut self) {
3173        self.control_handle.shutdown();
3174        // Safety: drops once, never accessed again
3175        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3176    }
3177}
3178
3179impl fidl::endpoints::Responder for CentralDisconnectPeripheralResponder {
3180    type ControlHandle = CentralControlHandle;
3181
3182    fn control_handle(&self) -> &CentralControlHandle {
3183        &self.control_handle
3184    }
3185
3186    fn drop_without_shutdown(mut self) {
3187        // Safety: drops once, never accessed again due to mem::forget
3188        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3189        // Prevent Drop from running (which would shut down the channel)
3190        std::mem::forget(self);
3191    }
3192}
3193
3194impl CentralDisconnectPeripheralResponder {
3195    /// Sends a response to the FIDL transaction.
3196    ///
3197    /// Sets the channel to shutdown if an error occurs.
3198    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3199        let _result = self.send_raw(status);
3200        if _result.is_err() {
3201            self.control_handle.shutdown();
3202        }
3203        self.drop_without_shutdown();
3204        _result
3205    }
3206
3207    /// Similar to "send" but does not shutdown the channel if an error occurs.
3208    pub fn send_no_shutdown_on_err(
3209        self,
3210        mut status: &fidl_fuchsia_bluetooth::Status,
3211    ) -> Result<(), fidl::Error> {
3212        let _result = self.send_raw(status);
3213        self.drop_without_shutdown();
3214        _result
3215    }
3216
3217    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
3218        self.control_handle.inner.send::<CentralDisconnectPeripheralResponse>(
3219            (status,),
3220            self.tx_id,
3221            0xa9430da197362fd,
3222            fidl::encoding::DynamicFlags::empty(),
3223        )
3224    }
3225}
3226
3227#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3228pub struct ChannelListenerMarker;
3229
3230impl fidl::endpoints::ProtocolMarker for ChannelListenerMarker {
3231    type Proxy = ChannelListenerProxy;
3232    type RequestStream = ChannelListenerRequestStream;
3233    #[cfg(target_os = "fuchsia")]
3234    type SynchronousProxy = ChannelListenerSynchronousProxy;
3235
3236    const DEBUG_NAME: &'static str = "(anonymous) ChannelListener";
3237}
3238
3239pub trait ChannelListenerProxyInterface: Send + Sync {
3240    type AcceptResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3241    fn r#accept(
3242        &self,
3243        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3244    ) -> Self::AcceptResponseFut;
3245    type ConnectedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3246    fn r#connected(&self, payload: ChannelListenerConnectedRequest) -> Self::ConnectedResponseFut;
3247}
3248#[derive(Debug)]
3249#[cfg(target_os = "fuchsia")]
3250pub struct ChannelListenerSynchronousProxy {
3251    client: fidl::client::sync::Client,
3252}
3253
3254#[cfg(target_os = "fuchsia")]
3255impl fidl::endpoints::SynchronousProxy for ChannelListenerSynchronousProxy {
3256    type Proxy = ChannelListenerProxy;
3257    type Protocol = ChannelListenerMarker;
3258
3259    fn from_channel(inner: fidl::Channel) -> Self {
3260        Self::new(inner)
3261    }
3262
3263    fn into_channel(self) -> fidl::Channel {
3264        self.client.into_channel()
3265    }
3266
3267    fn as_channel(&self) -> &fidl::Channel {
3268        self.client.as_channel()
3269    }
3270}
3271
3272#[cfg(target_os = "fuchsia")]
3273impl ChannelListenerSynchronousProxy {
3274    pub fn new(channel: fidl::Channel) -> Self {
3275        Self { client: fidl::client::sync::Client::new(channel) }
3276    }
3277
3278    pub fn into_channel(self) -> fidl::Channel {
3279        self.client.into_channel()
3280    }
3281
3282    /// Waits until an event arrives and returns it. It is safe for other
3283    /// threads to make concurrent requests while waiting for an event.
3284    pub fn wait_for_event(
3285        &self,
3286        deadline: zx::MonotonicInstant,
3287    ) -> Result<ChannelListenerEvent, fidl::Error> {
3288        ChannelListenerEvent::decode(self.client.wait_for_event::<ChannelListenerMarker>(deadline)?)
3289    }
3290
3291    pub fn r#accept(
3292        &self,
3293        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3294        ___deadline: zx::MonotonicInstant,
3295    ) -> Result<(), fidl::Error> {
3296        let _response = self.client.send_query::<
3297            ChannelListenerAcceptRequest,
3298            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3299            ChannelListenerMarker,
3300        >(
3301            (channel,),
3302            0x6f535bd36b20fc7b,
3303            fidl::encoding::DynamicFlags::FLEXIBLE,
3304            ___deadline,
3305        )?
3306        .into_result::<ChannelListenerMarker>("accept")?;
3307        Ok(_response)
3308    }
3309
3310    /// Called for each successful incoming channel connection.
3311    pub fn r#connected(
3312        &self,
3313        mut payload: ChannelListenerConnectedRequest,
3314        ___deadline: zx::MonotonicInstant,
3315    ) -> Result<(), fidl::Error> {
3316        let _response = self.client.send_query::<
3317            ChannelListenerConnectedRequest,
3318            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3319            ChannelListenerMarker,
3320        >(
3321            &mut payload,
3322            0xf40756858f21866,
3323            fidl::encoding::DynamicFlags::FLEXIBLE,
3324            ___deadline,
3325        )?
3326        .into_result::<ChannelListenerMarker>("connected")?;
3327        Ok(_response)
3328    }
3329}
3330
3331#[cfg(target_os = "fuchsia")]
3332impl From<ChannelListenerSynchronousProxy> for zx::NullableHandle {
3333    fn from(value: ChannelListenerSynchronousProxy) -> Self {
3334        value.into_channel().into()
3335    }
3336}
3337
3338#[cfg(target_os = "fuchsia")]
3339impl From<fidl::Channel> for ChannelListenerSynchronousProxy {
3340    fn from(value: fidl::Channel) -> Self {
3341        Self::new(value)
3342    }
3343}
3344
3345#[cfg(target_os = "fuchsia")]
3346impl fidl::endpoints::FromClient for ChannelListenerSynchronousProxy {
3347    type Protocol = ChannelListenerMarker;
3348
3349    fn from_client(value: fidl::endpoints::ClientEnd<ChannelListenerMarker>) -> Self {
3350        Self::new(value.into_channel())
3351    }
3352}
3353
3354#[derive(Debug, Clone)]
3355pub struct ChannelListenerProxy {
3356    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3357}
3358
3359impl fidl::endpoints::Proxy for ChannelListenerProxy {
3360    type Protocol = ChannelListenerMarker;
3361
3362    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3363        Self::new(inner)
3364    }
3365
3366    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3367        self.client.into_channel().map_err(|client| Self { client })
3368    }
3369
3370    fn as_channel(&self) -> &::fidl::AsyncChannel {
3371        self.client.as_channel()
3372    }
3373}
3374
3375impl ChannelListenerProxy {
3376    /// Create a new Proxy for fuchsia.bluetooth.le/ChannelListener.
3377    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3378        let protocol_name = <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3379        Self { client: fidl::client::Client::new(channel, protocol_name) }
3380    }
3381
3382    /// Get a Stream of events from the remote end of the protocol.
3383    ///
3384    /// # Panics
3385    ///
3386    /// Panics if the event stream was already taken.
3387    pub fn take_event_stream(&self) -> ChannelListenerEventStream {
3388        ChannelListenerEventStream { event_receiver: self.client.take_event_receiver() }
3389    }
3390
3391    pub fn r#accept(
3392        &self,
3393        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3394    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3395        ChannelListenerProxyInterface::r#accept(self, channel)
3396    }
3397
3398    /// Called for each successful incoming channel connection.
3399    pub fn r#connected(
3400        &self,
3401        mut payload: ChannelListenerConnectedRequest,
3402    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3403        ChannelListenerProxyInterface::r#connected(self, payload)
3404    }
3405}
3406
3407impl ChannelListenerProxyInterface for ChannelListenerProxy {
3408    type AcceptResponseFut =
3409        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3410    fn r#accept(
3411        &self,
3412        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3413    ) -> Self::AcceptResponseFut {
3414        fn _decode(
3415            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3416        ) -> Result<(), fidl::Error> {
3417            let _response = fidl::client::decode_transaction_body::<
3418                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3419                fidl::encoding::DefaultFuchsiaResourceDialect,
3420                0x6f535bd36b20fc7b,
3421            >(_buf?)?
3422            .into_result::<ChannelListenerMarker>("accept")?;
3423            Ok(_response)
3424        }
3425        self.client.send_query_and_decode::<ChannelListenerAcceptRequest, ()>(
3426            (channel,),
3427            0x6f535bd36b20fc7b,
3428            fidl::encoding::DynamicFlags::FLEXIBLE,
3429            _decode,
3430        )
3431    }
3432
3433    type ConnectedResponseFut =
3434        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3435    fn r#connected(
3436        &self,
3437        mut payload: ChannelListenerConnectedRequest,
3438    ) -> Self::ConnectedResponseFut {
3439        fn _decode(
3440            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3441        ) -> Result<(), fidl::Error> {
3442            let _response = fidl::client::decode_transaction_body::<
3443                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3444                fidl::encoding::DefaultFuchsiaResourceDialect,
3445                0xf40756858f21866,
3446            >(_buf?)?
3447            .into_result::<ChannelListenerMarker>("connected")?;
3448            Ok(_response)
3449        }
3450        self.client.send_query_and_decode::<ChannelListenerConnectedRequest, ()>(
3451            &mut payload,
3452            0xf40756858f21866,
3453            fidl::encoding::DynamicFlags::FLEXIBLE,
3454            _decode,
3455        )
3456    }
3457}
3458
3459pub struct ChannelListenerEventStream {
3460    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3461}
3462
3463impl std::marker::Unpin for ChannelListenerEventStream {}
3464
3465impl futures::stream::FusedStream for ChannelListenerEventStream {
3466    fn is_terminated(&self) -> bool {
3467        self.event_receiver.is_terminated()
3468    }
3469}
3470
3471impl futures::Stream for ChannelListenerEventStream {
3472    type Item = Result<ChannelListenerEvent, fidl::Error>;
3473
3474    fn poll_next(
3475        mut self: std::pin::Pin<&mut Self>,
3476        cx: &mut std::task::Context<'_>,
3477    ) -> std::task::Poll<Option<Self::Item>> {
3478        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3479            &mut self.event_receiver,
3480            cx
3481        )?) {
3482            Some(buf) => std::task::Poll::Ready(Some(ChannelListenerEvent::decode(buf))),
3483            None => std::task::Poll::Ready(None),
3484        }
3485    }
3486}
3487
3488#[derive(Debug)]
3489pub enum ChannelListenerEvent {
3490    #[non_exhaustive]
3491    _UnknownEvent {
3492        /// Ordinal of the event that was sent.
3493        ordinal: u64,
3494    },
3495}
3496
3497impl ChannelListenerEvent {
3498    /// Decodes a message buffer as a [`ChannelListenerEvent`].
3499    fn decode(
3500        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3501    ) -> Result<ChannelListenerEvent, fidl::Error> {
3502        let (bytes, _handles) = buf.split_mut();
3503        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3504        debug_assert_eq!(tx_header.tx_id, 0);
3505        match tx_header.ordinal {
3506            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3507                Ok(ChannelListenerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3508            }
3509            _ => Err(fidl::Error::UnknownOrdinal {
3510                ordinal: tx_header.ordinal,
3511                protocol_name:
3512                    <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3513            }),
3514        }
3515    }
3516}
3517
3518/// A Stream of incoming requests for fuchsia.bluetooth.le/ChannelListener.
3519pub struct ChannelListenerRequestStream {
3520    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3521    is_terminated: bool,
3522}
3523
3524impl std::marker::Unpin for ChannelListenerRequestStream {}
3525
3526impl futures::stream::FusedStream for ChannelListenerRequestStream {
3527    fn is_terminated(&self) -> bool {
3528        self.is_terminated
3529    }
3530}
3531
3532impl fidl::endpoints::RequestStream for ChannelListenerRequestStream {
3533    type Protocol = ChannelListenerMarker;
3534    type ControlHandle = ChannelListenerControlHandle;
3535
3536    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3537        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3538    }
3539
3540    fn control_handle(&self) -> Self::ControlHandle {
3541        ChannelListenerControlHandle { inner: self.inner.clone() }
3542    }
3543
3544    fn into_inner(
3545        self,
3546    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3547    {
3548        (self.inner, self.is_terminated)
3549    }
3550
3551    fn from_inner(
3552        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3553        is_terminated: bool,
3554    ) -> Self {
3555        Self { inner, is_terminated }
3556    }
3557}
3558
3559impl futures::Stream for ChannelListenerRequestStream {
3560    type Item = Result<ChannelListenerRequest, fidl::Error>;
3561
3562    fn poll_next(
3563        mut self: std::pin::Pin<&mut Self>,
3564        cx: &mut std::task::Context<'_>,
3565    ) -> std::task::Poll<Option<Self::Item>> {
3566        let this = &mut *self;
3567        if this.inner.check_shutdown(cx) {
3568            this.is_terminated = true;
3569            return std::task::Poll::Ready(None);
3570        }
3571        if this.is_terminated {
3572            panic!("polled ChannelListenerRequestStream after completion");
3573        }
3574        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3575            |bytes, handles| {
3576                match this.inner.channel().read_etc(cx, bytes, handles) {
3577                    std::task::Poll::Ready(Ok(())) => {}
3578                    std::task::Poll::Pending => return std::task::Poll::Pending,
3579                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3580                        this.is_terminated = true;
3581                        return std::task::Poll::Ready(None);
3582                    }
3583                    std::task::Poll::Ready(Err(e)) => {
3584                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3585                            e.into(),
3586                        ))));
3587                    }
3588                }
3589
3590                // A message has been received from the channel
3591                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3592
3593                std::task::Poll::Ready(Some(match header.ordinal {
3594                    0x6f535bd36b20fc7b => {
3595                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3596                        let mut req = fidl::new_empty!(
3597                            ChannelListenerAcceptRequest,
3598                            fidl::encoding::DefaultFuchsiaResourceDialect
3599                        );
3600                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerAcceptRequest>(&header, _body_bytes, handles, &mut req)?;
3601                        let control_handle =
3602                            ChannelListenerControlHandle { inner: this.inner.clone() };
3603                        Ok(ChannelListenerRequest::Accept {
3604                            channel: req.channel,
3605
3606                            responder: ChannelListenerAcceptResponder {
3607                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3608                                tx_id: header.tx_id,
3609                            },
3610                        })
3611                    }
3612                    0xf40756858f21866 => {
3613                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3614                        let mut req = fidl::new_empty!(
3615                            ChannelListenerConnectedRequest,
3616                            fidl::encoding::DefaultFuchsiaResourceDialect
3617                        );
3618                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerConnectedRequest>(&header, _body_bytes, handles, &mut req)?;
3619                        let control_handle =
3620                            ChannelListenerControlHandle { inner: this.inner.clone() };
3621                        Ok(ChannelListenerRequest::Connected {
3622                            payload: req,
3623                            responder: ChannelListenerConnectedResponder {
3624                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3625                                tx_id: header.tx_id,
3626                            },
3627                        })
3628                    }
3629                    _ if header.tx_id == 0
3630                        && header
3631                            .dynamic_flags()
3632                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3633                    {
3634                        Ok(ChannelListenerRequest::_UnknownMethod {
3635                            ordinal: header.ordinal,
3636                            control_handle: ChannelListenerControlHandle {
3637                                inner: this.inner.clone(),
3638                            },
3639                            method_type: fidl::MethodType::OneWay,
3640                        })
3641                    }
3642                    _ if header
3643                        .dynamic_flags()
3644                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3645                    {
3646                        this.inner.send_framework_err(
3647                            fidl::encoding::FrameworkErr::UnknownMethod,
3648                            header.tx_id,
3649                            header.ordinal,
3650                            header.dynamic_flags(),
3651                            (bytes, handles),
3652                        )?;
3653                        Ok(ChannelListenerRequest::_UnknownMethod {
3654                            ordinal: header.ordinal,
3655                            control_handle: ChannelListenerControlHandle {
3656                                inner: this.inner.clone(),
3657                            },
3658                            method_type: fidl::MethodType::TwoWay,
3659                        })
3660                    }
3661                    _ => Err(fidl::Error::UnknownOrdinal {
3662                        ordinal: header.ordinal,
3663                        protocol_name:
3664                            <ChannelListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3665                    }),
3666                }))
3667            },
3668        )
3669    }
3670}
3671
3672/// Represents a service or protocol that accepts incoming channel requests.
3673/// Incoming channel requests for the associated PSM will be connected via this
3674/// protocol. Closing this protocol will also cease accepting any incoming
3675/// channel requests, but existing established channels will not be affected.
3676/// Additionally, once this protocol is closed the implementation is free to
3677/// reuse the PSM that was previously assigned for this instance.
3678#[derive(Debug)]
3679pub enum ChannelListenerRequest {
3680    Accept {
3681        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3682        responder: ChannelListenerAcceptResponder,
3683    },
3684    /// Called for each successful incoming channel connection.
3685    Connected {
3686        payload: ChannelListenerConnectedRequest,
3687        responder: ChannelListenerConnectedResponder,
3688    },
3689    /// An interaction was received which does not match any known method.
3690    #[non_exhaustive]
3691    _UnknownMethod {
3692        /// Ordinal of the method that was called.
3693        ordinal: u64,
3694        control_handle: ChannelListenerControlHandle,
3695        method_type: fidl::MethodType,
3696    },
3697}
3698
3699impl ChannelListenerRequest {
3700    #[allow(irrefutable_let_patterns)]
3701    pub fn into_accept(
3702        self,
3703    ) -> Option<(
3704        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
3705        ChannelListenerAcceptResponder,
3706    )> {
3707        if let ChannelListenerRequest::Accept { channel, responder } = self {
3708            Some((channel, responder))
3709        } else {
3710            None
3711        }
3712    }
3713
3714    #[allow(irrefutable_let_patterns)]
3715    pub fn into_connected(
3716        self,
3717    ) -> Option<(ChannelListenerConnectedRequest, ChannelListenerConnectedResponder)> {
3718        if let ChannelListenerRequest::Connected { payload, responder } = self {
3719            Some((payload, responder))
3720        } else {
3721            None
3722        }
3723    }
3724
3725    /// Name of the method defined in FIDL
3726    pub fn method_name(&self) -> &'static str {
3727        match *self {
3728            ChannelListenerRequest::Accept { .. } => "accept",
3729            ChannelListenerRequest::Connected { .. } => "connected",
3730            ChannelListenerRequest::_UnknownMethod {
3731                method_type: fidl::MethodType::OneWay,
3732                ..
3733            } => "unknown one-way method",
3734            ChannelListenerRequest::_UnknownMethod {
3735                method_type: fidl::MethodType::TwoWay,
3736                ..
3737            } => "unknown two-way method",
3738        }
3739    }
3740}
3741
3742#[derive(Debug, Clone)]
3743pub struct ChannelListenerControlHandle {
3744    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3745}
3746
3747impl fidl::endpoints::ControlHandle for ChannelListenerControlHandle {
3748    fn shutdown(&self) {
3749        self.inner.shutdown()
3750    }
3751
3752    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3753        self.inner.shutdown_with_epitaph(status)
3754    }
3755
3756    fn is_closed(&self) -> bool {
3757        self.inner.channel().is_closed()
3758    }
3759    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3760        self.inner.channel().on_closed()
3761    }
3762
3763    #[cfg(target_os = "fuchsia")]
3764    fn signal_peer(
3765        &self,
3766        clear_mask: zx::Signals,
3767        set_mask: zx::Signals,
3768    ) -> Result<(), zx_status::Status> {
3769        use fidl::Peered;
3770        self.inner.channel().signal_peer(clear_mask, set_mask)
3771    }
3772}
3773
3774impl ChannelListenerControlHandle {}
3775
3776#[must_use = "FIDL methods require a response to be sent"]
3777#[derive(Debug)]
3778pub struct ChannelListenerAcceptResponder {
3779    control_handle: std::mem::ManuallyDrop<ChannelListenerControlHandle>,
3780    tx_id: u32,
3781}
3782
3783/// Set the the channel to be shutdown (see [`ChannelListenerControlHandle::shutdown`])
3784/// if the responder is dropped without sending a response, so that the client
3785/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3786impl std::ops::Drop for ChannelListenerAcceptResponder {
3787    fn drop(&mut self) {
3788        self.control_handle.shutdown();
3789        // Safety: drops once, never accessed again
3790        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3791    }
3792}
3793
3794impl fidl::endpoints::Responder for ChannelListenerAcceptResponder {
3795    type ControlHandle = ChannelListenerControlHandle;
3796
3797    fn control_handle(&self) -> &ChannelListenerControlHandle {
3798        &self.control_handle
3799    }
3800
3801    fn drop_without_shutdown(mut self) {
3802        // Safety: drops once, never accessed again due to mem::forget
3803        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3804        // Prevent Drop from running (which would shut down the channel)
3805        std::mem::forget(self);
3806    }
3807}
3808
3809impl ChannelListenerAcceptResponder {
3810    /// Sends a response to the FIDL transaction.
3811    ///
3812    /// Sets the channel to shutdown if an error occurs.
3813    pub fn send(self) -> Result<(), fidl::Error> {
3814        let _result = self.send_raw();
3815        if _result.is_err() {
3816            self.control_handle.shutdown();
3817        }
3818        self.drop_without_shutdown();
3819        _result
3820    }
3821
3822    /// Similar to "send" but does not shutdown the channel if an error occurs.
3823    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3824        let _result = self.send_raw();
3825        self.drop_without_shutdown();
3826        _result
3827    }
3828
3829    fn send_raw(&self) -> Result<(), fidl::Error> {
3830        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
3831            fidl::encoding::Flexible::new(()),
3832            self.tx_id,
3833            0x6f535bd36b20fc7b,
3834            fidl::encoding::DynamicFlags::FLEXIBLE,
3835        )
3836    }
3837}
3838
3839#[must_use = "FIDL methods require a response to be sent"]
3840#[derive(Debug)]
3841pub struct ChannelListenerConnectedResponder {
3842    control_handle: std::mem::ManuallyDrop<ChannelListenerControlHandle>,
3843    tx_id: u32,
3844}
3845
3846/// Set the the channel to be shutdown (see [`ChannelListenerControlHandle::shutdown`])
3847/// if the responder is dropped without sending a response, so that the client
3848/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3849impl std::ops::Drop for ChannelListenerConnectedResponder {
3850    fn drop(&mut self) {
3851        self.control_handle.shutdown();
3852        // Safety: drops once, never accessed again
3853        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3854    }
3855}
3856
3857impl fidl::endpoints::Responder for ChannelListenerConnectedResponder {
3858    type ControlHandle = ChannelListenerControlHandle;
3859
3860    fn control_handle(&self) -> &ChannelListenerControlHandle {
3861        &self.control_handle
3862    }
3863
3864    fn drop_without_shutdown(mut self) {
3865        // Safety: drops once, never accessed again due to mem::forget
3866        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3867        // Prevent Drop from running (which would shut down the channel)
3868        std::mem::forget(self);
3869    }
3870}
3871
3872impl ChannelListenerConnectedResponder {
3873    /// Sends a response to the FIDL transaction.
3874    ///
3875    /// Sets the channel to shutdown if an error occurs.
3876    pub fn send(self) -> Result<(), fidl::Error> {
3877        let _result = self.send_raw();
3878        if _result.is_err() {
3879            self.control_handle.shutdown();
3880        }
3881        self.drop_without_shutdown();
3882        _result
3883    }
3884
3885    /// Similar to "send" but does not shutdown the channel if an error occurs.
3886    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3887        let _result = self.send_raw();
3888        self.drop_without_shutdown();
3889        _result
3890    }
3891
3892    fn send_raw(&self) -> Result<(), fidl::Error> {
3893        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
3894            fidl::encoding::Flexible::new(()),
3895            self.tx_id,
3896            0xf40756858f21866,
3897            fidl::encoding::DynamicFlags::FLEXIBLE,
3898        )
3899    }
3900}
3901
3902#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3903pub struct ChannelListenerRegistryMarker;
3904
3905impl fidl::endpoints::ProtocolMarker for ChannelListenerRegistryMarker {
3906    type Proxy = ChannelListenerRegistryProxy;
3907    type RequestStream = ChannelListenerRegistryRequestStream;
3908    #[cfg(target_os = "fuchsia")]
3909    type SynchronousProxy = ChannelListenerRegistrySynchronousProxy;
3910
3911    const DEBUG_NAME: &'static str = "(anonymous) ChannelListenerRegistry";
3912}
3913pub type ChannelListenerRegistryListenL2capResult =
3914    Result<ChannelListenerRegistryListenL2capResponse, i32>;
3915
3916pub trait ChannelListenerRegistryProxyInterface: Send + Sync {
3917    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
3918        + Send;
3919    fn r#listen_l2cap(
3920        &self,
3921        payload: ChannelListenerRegistryListenL2capRequest,
3922    ) -> Self::ListenL2capResponseFut;
3923}
3924#[derive(Debug)]
3925#[cfg(target_os = "fuchsia")]
3926pub struct ChannelListenerRegistrySynchronousProxy {
3927    client: fidl::client::sync::Client,
3928}
3929
3930#[cfg(target_os = "fuchsia")]
3931impl fidl::endpoints::SynchronousProxy for ChannelListenerRegistrySynchronousProxy {
3932    type Proxy = ChannelListenerRegistryProxy;
3933    type Protocol = ChannelListenerRegistryMarker;
3934
3935    fn from_channel(inner: fidl::Channel) -> Self {
3936        Self::new(inner)
3937    }
3938
3939    fn into_channel(self) -> fidl::Channel {
3940        self.client.into_channel()
3941    }
3942
3943    fn as_channel(&self) -> &fidl::Channel {
3944        self.client.as_channel()
3945    }
3946}
3947
3948#[cfg(target_os = "fuchsia")]
3949impl ChannelListenerRegistrySynchronousProxy {
3950    pub fn new(channel: fidl::Channel) -> Self {
3951        Self { client: fidl::client::sync::Client::new(channel) }
3952    }
3953
3954    pub fn into_channel(self) -> fidl::Channel {
3955        self.client.into_channel()
3956    }
3957
3958    /// Waits until an event arrives and returns it. It is safe for other
3959    /// threads to make concurrent requests while waiting for an event.
3960    pub fn wait_for_event(
3961        &self,
3962        deadline: zx::MonotonicInstant,
3963    ) -> Result<ChannelListenerRegistryEvent, fidl::Error> {
3964        ChannelListenerRegistryEvent::decode(
3965            self.client.wait_for_event::<ChannelListenerRegistryMarker>(deadline)?,
3966        )
3967    }
3968
3969    /// Register a listener for incoming channels. The registry will assign a
3970    /// PSM value that is unique for the local device, as well as open a
3971    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
3972    /// event that all PSMs have been assigned, this call will fail with
3973    /// `ZX_ERR_NO_RESOURCES`.
3974    ///
3975    /// Note that the method of service discovery or advertising is defined by
3976    /// the service or protocol, so it is the responsibility of the caller to
3977    /// communicate the assigned PSM to any clients.
3978    pub fn r#listen_l2cap(
3979        &self,
3980        mut payload: ChannelListenerRegistryListenL2capRequest,
3981        ___deadline: zx::MonotonicInstant,
3982    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
3983        let _response = self.client.send_query::<
3984            ChannelListenerRegistryListenL2capRequest,
3985            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
3986            ChannelListenerRegistryMarker,
3987        >(
3988            &mut payload,
3989            0x39c6e9001d102338,
3990            fidl::encoding::DynamicFlags::empty(),
3991            ___deadline,
3992        )?;
3993        Ok(_response.map(|x| x))
3994    }
3995}
3996
3997#[cfg(target_os = "fuchsia")]
3998impl From<ChannelListenerRegistrySynchronousProxy> for zx::NullableHandle {
3999    fn from(value: ChannelListenerRegistrySynchronousProxy) -> Self {
4000        value.into_channel().into()
4001    }
4002}
4003
4004#[cfg(target_os = "fuchsia")]
4005impl From<fidl::Channel> for ChannelListenerRegistrySynchronousProxy {
4006    fn from(value: fidl::Channel) -> Self {
4007        Self::new(value)
4008    }
4009}
4010
4011#[cfg(target_os = "fuchsia")]
4012impl fidl::endpoints::FromClient for ChannelListenerRegistrySynchronousProxy {
4013    type Protocol = ChannelListenerRegistryMarker;
4014
4015    fn from_client(value: fidl::endpoints::ClientEnd<ChannelListenerRegistryMarker>) -> Self {
4016        Self::new(value.into_channel())
4017    }
4018}
4019
4020#[derive(Debug, Clone)]
4021pub struct ChannelListenerRegistryProxy {
4022    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4023}
4024
4025impl fidl::endpoints::Proxy for ChannelListenerRegistryProxy {
4026    type Protocol = ChannelListenerRegistryMarker;
4027
4028    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4029        Self::new(inner)
4030    }
4031
4032    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4033        self.client.into_channel().map_err(|client| Self { client })
4034    }
4035
4036    fn as_channel(&self) -> &::fidl::AsyncChannel {
4037        self.client.as_channel()
4038    }
4039}
4040
4041impl ChannelListenerRegistryProxy {
4042    /// Create a new Proxy for fuchsia.bluetooth.le/ChannelListenerRegistry.
4043    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4044        let protocol_name =
4045            <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4046        Self { client: fidl::client::Client::new(channel, protocol_name) }
4047    }
4048
4049    /// Get a Stream of events from the remote end of the protocol.
4050    ///
4051    /// # Panics
4052    ///
4053    /// Panics if the event stream was already taken.
4054    pub fn take_event_stream(&self) -> ChannelListenerRegistryEventStream {
4055        ChannelListenerRegistryEventStream { event_receiver: self.client.take_event_receiver() }
4056    }
4057
4058    /// Register a listener for incoming channels. The registry will assign a
4059    /// PSM value that is unique for the local device, as well as open a
4060    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
4061    /// event that all PSMs have been assigned, this call will fail with
4062    /// `ZX_ERR_NO_RESOURCES`.
4063    ///
4064    /// Note that the method of service discovery or advertising is defined by
4065    /// the service or protocol, so it is the responsibility of the caller to
4066    /// communicate the assigned PSM to any clients.
4067    pub fn r#listen_l2cap(
4068        &self,
4069        mut payload: ChannelListenerRegistryListenL2capRequest,
4070    ) -> fidl::client::QueryResponseFut<
4071        ChannelListenerRegistryListenL2capResult,
4072        fidl::encoding::DefaultFuchsiaResourceDialect,
4073    > {
4074        ChannelListenerRegistryProxyInterface::r#listen_l2cap(self, payload)
4075    }
4076}
4077
4078impl ChannelListenerRegistryProxyInterface for ChannelListenerRegistryProxy {
4079    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
4080        ChannelListenerRegistryListenL2capResult,
4081        fidl::encoding::DefaultFuchsiaResourceDialect,
4082    >;
4083    fn r#listen_l2cap(
4084        &self,
4085        mut payload: ChannelListenerRegistryListenL2capRequest,
4086    ) -> Self::ListenL2capResponseFut {
4087        fn _decode(
4088            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4089        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
4090            let _response = fidl::client::decode_transaction_body::<
4091                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
4092                fidl::encoding::DefaultFuchsiaResourceDialect,
4093                0x39c6e9001d102338,
4094            >(_buf?)?;
4095            Ok(_response.map(|x| x))
4096        }
4097        self.client.send_query_and_decode::<
4098            ChannelListenerRegistryListenL2capRequest,
4099            ChannelListenerRegistryListenL2capResult,
4100        >(
4101            &mut payload,
4102            0x39c6e9001d102338,
4103            fidl::encoding::DynamicFlags::empty(),
4104            _decode,
4105        )
4106    }
4107}
4108
4109pub struct ChannelListenerRegistryEventStream {
4110    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4111}
4112
4113impl std::marker::Unpin for ChannelListenerRegistryEventStream {}
4114
4115impl futures::stream::FusedStream for ChannelListenerRegistryEventStream {
4116    fn is_terminated(&self) -> bool {
4117        self.event_receiver.is_terminated()
4118    }
4119}
4120
4121impl futures::Stream for ChannelListenerRegistryEventStream {
4122    type Item = Result<ChannelListenerRegistryEvent, fidl::Error>;
4123
4124    fn poll_next(
4125        mut self: std::pin::Pin<&mut Self>,
4126        cx: &mut std::task::Context<'_>,
4127    ) -> std::task::Poll<Option<Self::Item>> {
4128        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4129            &mut self.event_receiver,
4130            cx
4131        )?) {
4132            Some(buf) => std::task::Poll::Ready(Some(ChannelListenerRegistryEvent::decode(buf))),
4133            None => std::task::Poll::Ready(None),
4134        }
4135    }
4136}
4137
4138#[derive(Debug)]
4139pub enum ChannelListenerRegistryEvent {}
4140
4141impl ChannelListenerRegistryEvent {
4142    /// Decodes a message buffer as a [`ChannelListenerRegistryEvent`].
4143    fn decode(
4144        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4145    ) -> Result<ChannelListenerRegistryEvent, fidl::Error> {
4146        let (bytes, _handles) = buf.split_mut();
4147        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4148        debug_assert_eq!(tx_header.tx_id, 0);
4149        match tx_header.ordinal {
4150            _ => Err(fidl::Error::UnknownOrdinal {
4151                ordinal: tx_header.ordinal,
4152                protocol_name:
4153                    <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4154            }),
4155        }
4156    }
4157}
4158
4159/// A Stream of incoming requests for fuchsia.bluetooth.le/ChannelListenerRegistry.
4160pub struct ChannelListenerRegistryRequestStream {
4161    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4162    is_terminated: bool,
4163}
4164
4165impl std::marker::Unpin for ChannelListenerRegistryRequestStream {}
4166
4167impl futures::stream::FusedStream for ChannelListenerRegistryRequestStream {
4168    fn is_terminated(&self) -> bool {
4169        self.is_terminated
4170    }
4171}
4172
4173impl fidl::endpoints::RequestStream for ChannelListenerRegistryRequestStream {
4174    type Protocol = ChannelListenerRegistryMarker;
4175    type ControlHandle = ChannelListenerRegistryControlHandle;
4176
4177    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4178        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4179    }
4180
4181    fn control_handle(&self) -> Self::ControlHandle {
4182        ChannelListenerRegistryControlHandle { inner: self.inner.clone() }
4183    }
4184
4185    fn into_inner(
4186        self,
4187    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4188    {
4189        (self.inner, self.is_terminated)
4190    }
4191
4192    fn from_inner(
4193        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4194        is_terminated: bool,
4195    ) -> Self {
4196        Self { inner, is_terminated }
4197    }
4198}
4199
4200impl futures::Stream for ChannelListenerRegistryRequestStream {
4201    type Item = Result<ChannelListenerRegistryRequest, fidl::Error>;
4202
4203    fn poll_next(
4204        mut self: std::pin::Pin<&mut Self>,
4205        cx: &mut std::task::Context<'_>,
4206    ) -> std::task::Poll<Option<Self::Item>> {
4207        let this = &mut *self;
4208        if this.inner.check_shutdown(cx) {
4209            this.is_terminated = true;
4210            return std::task::Poll::Ready(None);
4211        }
4212        if this.is_terminated {
4213            panic!("polled ChannelListenerRegistryRequestStream after completion");
4214        }
4215        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4216            |bytes, handles| {
4217                match this.inner.channel().read_etc(cx, bytes, handles) {
4218                    std::task::Poll::Ready(Ok(())) => {}
4219                    std::task::Poll::Pending => return std::task::Poll::Pending,
4220                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4221                        this.is_terminated = true;
4222                        return std::task::Poll::Ready(None);
4223                    }
4224                    std::task::Poll::Ready(Err(e)) => {
4225                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4226                            e.into(),
4227                        ))));
4228                    }
4229                }
4230
4231                // A message has been received from the channel
4232                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4233
4234                std::task::Poll::Ready(Some(match header.ordinal {
4235                0x39c6e9001d102338 => {
4236                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4237                    let mut req = fidl::new_empty!(ChannelListenerRegistryListenL2capRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
4238                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
4239                    let control_handle = ChannelListenerRegistryControlHandle {
4240                        inner: this.inner.clone(),
4241                    };
4242                    Ok(ChannelListenerRegistryRequest::ListenL2cap {payload: req,
4243                        responder: ChannelListenerRegistryListenL2capResponder {
4244                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4245                            tx_id: header.tx_id,
4246                        },
4247                    })
4248                }
4249                _ => Err(fidl::Error::UnknownOrdinal {
4250                    ordinal: header.ordinal,
4251                    protocol_name: <ChannelListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4252                }),
4253            }))
4254            },
4255        )
4256    }
4257}
4258
4259/// Represents the ability to register and accept incoming connections on
4260/// connection oriented channels.
4261#[derive(Debug)]
4262pub enum ChannelListenerRegistryRequest {
4263    /// Register a listener for incoming channels. The registry will assign a
4264    /// PSM value that is unique for the local device, as well as open a
4265    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
4266    /// event that all PSMs have been assigned, this call will fail with
4267    /// `ZX_ERR_NO_RESOURCES`.
4268    ///
4269    /// Note that the method of service discovery or advertising is defined by
4270    /// the service or protocol, so it is the responsibility of the caller to
4271    /// communicate the assigned PSM to any clients.
4272    ListenL2cap {
4273        payload: ChannelListenerRegistryListenL2capRequest,
4274        responder: ChannelListenerRegistryListenL2capResponder,
4275    },
4276}
4277
4278impl ChannelListenerRegistryRequest {
4279    #[allow(irrefutable_let_patterns)]
4280    pub fn into_listen_l2cap(
4281        self,
4282    ) -> Option<(
4283        ChannelListenerRegistryListenL2capRequest,
4284        ChannelListenerRegistryListenL2capResponder,
4285    )> {
4286        if let ChannelListenerRegistryRequest::ListenL2cap { payload, responder } = self {
4287            Some((payload, responder))
4288        } else {
4289            None
4290        }
4291    }
4292
4293    /// Name of the method defined in FIDL
4294    pub fn method_name(&self) -> &'static str {
4295        match *self {
4296            ChannelListenerRegistryRequest::ListenL2cap { .. } => "listen_l2cap",
4297        }
4298    }
4299}
4300
4301#[derive(Debug, Clone)]
4302pub struct ChannelListenerRegistryControlHandle {
4303    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4304}
4305
4306impl fidl::endpoints::ControlHandle for ChannelListenerRegistryControlHandle {
4307    fn shutdown(&self) {
4308        self.inner.shutdown()
4309    }
4310
4311    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4312        self.inner.shutdown_with_epitaph(status)
4313    }
4314
4315    fn is_closed(&self) -> bool {
4316        self.inner.channel().is_closed()
4317    }
4318    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4319        self.inner.channel().on_closed()
4320    }
4321
4322    #[cfg(target_os = "fuchsia")]
4323    fn signal_peer(
4324        &self,
4325        clear_mask: zx::Signals,
4326        set_mask: zx::Signals,
4327    ) -> Result<(), zx_status::Status> {
4328        use fidl::Peered;
4329        self.inner.channel().signal_peer(clear_mask, set_mask)
4330    }
4331}
4332
4333impl ChannelListenerRegistryControlHandle {}
4334
4335#[must_use = "FIDL methods require a response to be sent"]
4336#[derive(Debug)]
4337pub struct ChannelListenerRegistryListenL2capResponder {
4338    control_handle: std::mem::ManuallyDrop<ChannelListenerRegistryControlHandle>,
4339    tx_id: u32,
4340}
4341
4342/// Set the the channel to be shutdown (see [`ChannelListenerRegistryControlHandle::shutdown`])
4343/// if the responder is dropped without sending a response, so that the client
4344/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4345impl std::ops::Drop for ChannelListenerRegistryListenL2capResponder {
4346    fn drop(&mut self) {
4347        self.control_handle.shutdown();
4348        // Safety: drops once, never accessed again
4349        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4350    }
4351}
4352
4353impl fidl::endpoints::Responder for ChannelListenerRegistryListenL2capResponder {
4354    type ControlHandle = ChannelListenerRegistryControlHandle;
4355
4356    fn control_handle(&self) -> &ChannelListenerRegistryControlHandle {
4357        &self.control_handle
4358    }
4359
4360    fn drop_without_shutdown(mut self) {
4361        // Safety: drops once, never accessed again due to mem::forget
4362        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4363        // Prevent Drop from running (which would shut down the channel)
4364        std::mem::forget(self);
4365    }
4366}
4367
4368impl ChannelListenerRegistryListenL2capResponder {
4369    /// Sends a response to the FIDL transaction.
4370    ///
4371    /// Sets the channel to shutdown if an error occurs.
4372    pub fn send(
4373        self,
4374        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
4375    ) -> Result<(), fidl::Error> {
4376        let _result = self.send_raw(result);
4377        if _result.is_err() {
4378            self.control_handle.shutdown();
4379        }
4380        self.drop_without_shutdown();
4381        _result
4382    }
4383
4384    /// Similar to "send" but does not shutdown the channel if an error occurs.
4385    pub fn send_no_shutdown_on_err(
4386        self,
4387        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
4388    ) -> Result<(), fidl::Error> {
4389        let _result = self.send_raw(result);
4390        self.drop_without_shutdown();
4391        _result
4392    }
4393
4394    fn send_raw(
4395        &self,
4396        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
4397    ) -> Result<(), fidl::Error> {
4398        self.control_handle.inner.send::<fidl::encoding::ResultType<
4399            ChannelListenerRegistryListenL2capResponse,
4400            i32,
4401        >>(
4402            result,
4403            self.tx_id,
4404            0x39c6e9001d102338,
4405            fidl::encoding::DynamicFlags::empty(),
4406        )
4407    }
4408}
4409
4410#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4411pub struct ChannelOffloadExtMarker;
4412
4413impl fidl::endpoints::ProtocolMarker for ChannelOffloadExtMarker {
4414    type Proxy = ChannelOffloadExtProxy;
4415    type RequestStream = ChannelOffloadExtRequestStream;
4416    #[cfg(target_os = "fuchsia")]
4417    type SynchronousProxy = ChannelOffloadExtSynchronousProxy;
4418
4419    const DEBUG_NAME: &'static str = "(anonymous) ChannelOffloadExt";
4420}
4421pub type ChannelOffloadExtStartOffloadResult = Result<ChannelOffloadExtStartOffloadResponse, i32>;
4422
4423pub trait ChannelOffloadExtProxyInterface: Send + Sync {
4424    type StartOffloadResponseFut: std::future::Future<Output = Result<ChannelOffloadExtStartOffloadResult, fidl::Error>>
4425        + Send;
4426    fn r#start_offload(
4427        &self,
4428        payload: &ChannelOffloadExtStartOffloadRequest,
4429    ) -> Self::StartOffloadResponseFut;
4430}
4431#[derive(Debug)]
4432#[cfg(target_os = "fuchsia")]
4433pub struct ChannelOffloadExtSynchronousProxy {
4434    client: fidl::client::sync::Client,
4435}
4436
4437#[cfg(target_os = "fuchsia")]
4438impl fidl::endpoints::SynchronousProxy for ChannelOffloadExtSynchronousProxy {
4439    type Proxy = ChannelOffloadExtProxy;
4440    type Protocol = ChannelOffloadExtMarker;
4441
4442    fn from_channel(inner: fidl::Channel) -> Self {
4443        Self::new(inner)
4444    }
4445
4446    fn into_channel(self) -> fidl::Channel {
4447        self.client.into_channel()
4448    }
4449
4450    fn as_channel(&self) -> &fidl::Channel {
4451        self.client.as_channel()
4452    }
4453}
4454
4455#[cfg(target_os = "fuchsia")]
4456impl ChannelOffloadExtSynchronousProxy {
4457    pub fn new(channel: fidl::Channel) -> Self {
4458        Self { client: fidl::client::sync::Client::new(channel) }
4459    }
4460
4461    pub fn into_channel(self) -> fidl::Channel {
4462        self.client.into_channel()
4463    }
4464
4465    /// Waits until an event arrives and returns it. It is safe for other
4466    /// threads to make concurrent requests while waiting for an event.
4467    pub fn wait_for_event(
4468        &self,
4469        deadline: zx::MonotonicInstant,
4470    ) -> Result<ChannelOffloadExtEvent, fidl::Error> {
4471        ChannelOffloadExtEvent::decode(
4472            self.client.wait_for_event::<ChannelOffloadExtMarker>(deadline)?,
4473        )
4474    }
4475
4476    /// StartOffload MUST be called before Channel.Receive(). The offloaded
4477    /// channel will have 0 RX credits given to the peer to prevent the peer
4478    /// from sending data until the offload processor is ready. This method may
4479    /// be called a maximum of one time.
4480    ///
4481    /// The following errors may be returned:
4482    /// * error `BAD_STATE` : Channel.Receive() has already been called or
4483    ///     StartOffload() has already been called.
4484    /// * error `INTERNAL`: An internal error occurred and the channel could not be offloaded.
4485    pub fn r#start_offload(
4486        &self,
4487        mut payload: &ChannelOffloadExtStartOffloadRequest,
4488        ___deadline: zx::MonotonicInstant,
4489    ) -> Result<ChannelOffloadExtStartOffloadResult, fidl::Error> {
4490        let _response = self.client.send_query::<
4491            ChannelOffloadExtStartOffloadRequest,
4492            fidl::encoding::FlexibleResultType<ChannelOffloadExtStartOffloadResponse, i32>,
4493            ChannelOffloadExtMarker,
4494        >(
4495            payload,
4496            0x2dd620feea793fe8,
4497            fidl::encoding::DynamicFlags::FLEXIBLE,
4498            ___deadline,
4499        )?
4500        .into_result::<ChannelOffloadExtMarker>("start_offload")?;
4501        Ok(_response.map(|x| x))
4502    }
4503}
4504
4505#[cfg(target_os = "fuchsia")]
4506impl From<ChannelOffloadExtSynchronousProxy> for zx::NullableHandle {
4507    fn from(value: ChannelOffloadExtSynchronousProxy) -> Self {
4508        value.into_channel().into()
4509    }
4510}
4511
4512#[cfg(target_os = "fuchsia")]
4513impl From<fidl::Channel> for ChannelOffloadExtSynchronousProxy {
4514    fn from(value: fidl::Channel) -> Self {
4515        Self::new(value)
4516    }
4517}
4518
4519#[cfg(target_os = "fuchsia")]
4520impl fidl::endpoints::FromClient for ChannelOffloadExtSynchronousProxy {
4521    type Protocol = ChannelOffloadExtMarker;
4522
4523    fn from_client(value: fidl::endpoints::ClientEnd<ChannelOffloadExtMarker>) -> Self {
4524        Self::new(value.into_channel())
4525    }
4526}
4527
4528#[derive(Debug, Clone)]
4529pub struct ChannelOffloadExtProxy {
4530    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4531}
4532
4533impl fidl::endpoints::Proxy for ChannelOffloadExtProxy {
4534    type Protocol = ChannelOffloadExtMarker;
4535
4536    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4537        Self::new(inner)
4538    }
4539
4540    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4541        self.client.into_channel().map_err(|client| Self { client })
4542    }
4543
4544    fn as_channel(&self) -> &::fidl::AsyncChannel {
4545        self.client.as_channel()
4546    }
4547}
4548
4549impl ChannelOffloadExtProxy {
4550    /// Create a new Proxy for fuchsia.bluetooth.le/ChannelOffloadExt.
4551    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4552        let protocol_name =
4553            <ChannelOffloadExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4554        Self { client: fidl::client::Client::new(channel, protocol_name) }
4555    }
4556
4557    /// Get a Stream of events from the remote end of the protocol.
4558    ///
4559    /// # Panics
4560    ///
4561    /// Panics if the event stream was already taken.
4562    pub fn take_event_stream(&self) -> ChannelOffloadExtEventStream {
4563        ChannelOffloadExtEventStream { event_receiver: self.client.take_event_receiver() }
4564    }
4565
4566    /// StartOffload MUST be called before Channel.Receive(). The offloaded
4567    /// channel will have 0 RX credits given to the peer to prevent the peer
4568    /// from sending data until the offload processor is ready. This method may
4569    /// be called a maximum of one time.
4570    ///
4571    /// The following errors may be returned:
4572    /// * error `BAD_STATE` : Channel.Receive() has already been called or
4573    ///     StartOffload() has already been called.
4574    /// * error `INTERNAL`: An internal error occurred and the channel could not be offloaded.
4575    pub fn r#start_offload(
4576        &self,
4577        mut payload: &ChannelOffloadExtStartOffloadRequest,
4578    ) -> fidl::client::QueryResponseFut<
4579        ChannelOffloadExtStartOffloadResult,
4580        fidl::encoding::DefaultFuchsiaResourceDialect,
4581    > {
4582        ChannelOffloadExtProxyInterface::r#start_offload(self, payload)
4583    }
4584}
4585
4586impl ChannelOffloadExtProxyInterface for ChannelOffloadExtProxy {
4587    type StartOffloadResponseFut = fidl::client::QueryResponseFut<
4588        ChannelOffloadExtStartOffloadResult,
4589        fidl::encoding::DefaultFuchsiaResourceDialect,
4590    >;
4591    fn r#start_offload(
4592        &self,
4593        mut payload: &ChannelOffloadExtStartOffloadRequest,
4594    ) -> Self::StartOffloadResponseFut {
4595        fn _decode(
4596            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4597        ) -> Result<ChannelOffloadExtStartOffloadResult, fidl::Error> {
4598            let _response = fidl::client::decode_transaction_body::<
4599                fidl::encoding::FlexibleResultType<ChannelOffloadExtStartOffloadResponse, i32>,
4600                fidl::encoding::DefaultFuchsiaResourceDialect,
4601                0x2dd620feea793fe8,
4602            >(_buf?)?
4603            .into_result::<ChannelOffloadExtMarker>("start_offload")?;
4604            Ok(_response.map(|x| x))
4605        }
4606        self.client.send_query_and_decode::<
4607            ChannelOffloadExtStartOffloadRequest,
4608            ChannelOffloadExtStartOffloadResult,
4609        >(
4610            payload,
4611            0x2dd620feea793fe8,
4612            fidl::encoding::DynamicFlags::FLEXIBLE,
4613            _decode,
4614        )
4615    }
4616}
4617
4618pub struct ChannelOffloadExtEventStream {
4619    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4620}
4621
4622impl std::marker::Unpin for ChannelOffloadExtEventStream {}
4623
4624impl futures::stream::FusedStream for ChannelOffloadExtEventStream {
4625    fn is_terminated(&self) -> bool {
4626        self.event_receiver.is_terminated()
4627    }
4628}
4629
4630impl futures::Stream for ChannelOffloadExtEventStream {
4631    type Item = Result<ChannelOffloadExtEvent, fidl::Error>;
4632
4633    fn poll_next(
4634        mut self: std::pin::Pin<&mut Self>,
4635        cx: &mut std::task::Context<'_>,
4636    ) -> std::task::Poll<Option<Self::Item>> {
4637        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4638            &mut self.event_receiver,
4639            cx
4640        )?) {
4641            Some(buf) => std::task::Poll::Ready(Some(ChannelOffloadExtEvent::decode(buf))),
4642            None => std::task::Poll::Ready(None),
4643        }
4644    }
4645}
4646
4647#[derive(Debug)]
4648pub enum ChannelOffloadExtEvent {
4649    #[non_exhaustive]
4650    _UnknownEvent {
4651        /// Ordinal of the event that was sent.
4652        ordinal: u64,
4653    },
4654}
4655
4656impl ChannelOffloadExtEvent {
4657    /// Decodes a message buffer as a [`ChannelOffloadExtEvent`].
4658    fn decode(
4659        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4660    ) -> Result<ChannelOffloadExtEvent, fidl::Error> {
4661        let (bytes, _handles) = buf.split_mut();
4662        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4663        debug_assert_eq!(tx_header.tx_id, 0);
4664        match tx_header.ordinal {
4665            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4666                Ok(ChannelOffloadExtEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4667            }
4668            _ => Err(fidl::Error::UnknownOrdinal {
4669                ordinal: tx_header.ordinal,
4670                protocol_name:
4671                    <ChannelOffloadExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4672            }),
4673        }
4674    }
4675}
4676
4677/// A Stream of incoming requests for fuchsia.bluetooth.le/ChannelOffloadExt.
4678pub struct ChannelOffloadExtRequestStream {
4679    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4680    is_terminated: bool,
4681}
4682
4683impl std::marker::Unpin for ChannelOffloadExtRequestStream {}
4684
4685impl futures::stream::FusedStream for ChannelOffloadExtRequestStream {
4686    fn is_terminated(&self) -> bool {
4687        self.is_terminated
4688    }
4689}
4690
4691impl fidl::endpoints::RequestStream for ChannelOffloadExtRequestStream {
4692    type Protocol = ChannelOffloadExtMarker;
4693    type ControlHandle = ChannelOffloadExtControlHandle;
4694
4695    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4696        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4697    }
4698
4699    fn control_handle(&self) -> Self::ControlHandle {
4700        ChannelOffloadExtControlHandle { inner: self.inner.clone() }
4701    }
4702
4703    fn into_inner(
4704        self,
4705    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4706    {
4707        (self.inner, self.is_terminated)
4708    }
4709
4710    fn from_inner(
4711        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4712        is_terminated: bool,
4713    ) -> Self {
4714        Self { inner, is_terminated }
4715    }
4716}
4717
4718impl futures::Stream for ChannelOffloadExtRequestStream {
4719    type Item = Result<ChannelOffloadExtRequest, fidl::Error>;
4720
4721    fn poll_next(
4722        mut self: std::pin::Pin<&mut Self>,
4723        cx: &mut std::task::Context<'_>,
4724    ) -> std::task::Poll<Option<Self::Item>> {
4725        let this = &mut *self;
4726        if this.inner.check_shutdown(cx) {
4727            this.is_terminated = true;
4728            return std::task::Poll::Ready(None);
4729        }
4730        if this.is_terminated {
4731            panic!("polled ChannelOffloadExtRequestStream after completion");
4732        }
4733        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4734            |bytes, handles| {
4735                match this.inner.channel().read_etc(cx, bytes, handles) {
4736                    std::task::Poll::Ready(Ok(())) => {}
4737                    std::task::Poll::Pending => return std::task::Poll::Pending,
4738                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4739                        this.is_terminated = true;
4740                        return std::task::Poll::Ready(None);
4741                    }
4742                    std::task::Poll::Ready(Err(e)) => {
4743                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4744                            e.into(),
4745                        ))));
4746                    }
4747                }
4748
4749                // A message has been received from the channel
4750                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4751
4752                std::task::Poll::Ready(Some(match header.ordinal {
4753                    0x2dd620feea793fe8 => {
4754                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4755                        let mut req = fidl::new_empty!(
4756                            ChannelOffloadExtStartOffloadRequest,
4757                            fidl::encoding::DefaultFuchsiaResourceDialect
4758                        );
4759                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelOffloadExtStartOffloadRequest>(&header, _body_bytes, handles, &mut req)?;
4760                        let control_handle =
4761                            ChannelOffloadExtControlHandle { inner: this.inner.clone() };
4762                        Ok(ChannelOffloadExtRequest::StartOffload {
4763                            payload: req,
4764                            responder: ChannelOffloadExtStartOffloadResponder {
4765                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4766                                tx_id: header.tx_id,
4767                            },
4768                        })
4769                    }
4770                    _ if header.tx_id == 0
4771                        && header
4772                            .dynamic_flags()
4773                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4774                    {
4775                        Ok(ChannelOffloadExtRequest::_UnknownMethod {
4776                            ordinal: header.ordinal,
4777                            control_handle: ChannelOffloadExtControlHandle {
4778                                inner: this.inner.clone(),
4779                            },
4780                            method_type: fidl::MethodType::OneWay,
4781                        })
4782                    }
4783                    _ if header
4784                        .dynamic_flags()
4785                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4786                    {
4787                        this.inner.send_framework_err(
4788                            fidl::encoding::FrameworkErr::UnknownMethod,
4789                            header.tx_id,
4790                            header.ordinal,
4791                            header.dynamic_flags(),
4792                            (bytes, handles),
4793                        )?;
4794                        Ok(ChannelOffloadExtRequest::_UnknownMethod {
4795                            ordinal: header.ordinal,
4796                            control_handle: ChannelOffloadExtControlHandle {
4797                                inner: this.inner.clone(),
4798                            },
4799                            method_type: fidl::MethodType::TwoWay,
4800                        })
4801                    }
4802                    _ => Err(fidl::Error::UnknownOrdinal {
4803                        ordinal: header.ordinal,
4804                        protocol_name:
4805                            <ChannelOffloadExtMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4806                    }),
4807                }))
4808            },
4809        )
4810    }
4811}
4812
4813/// Protocol extension for a `bt.Channel`. This is typically provided by or to
4814/// privileged clients alongside a `bt.Channel`. This protocol can be closed
4815/// before or after StartOffload has returned with no effect.
4816#[derive(Debug)]
4817pub enum ChannelOffloadExtRequest {
4818    /// StartOffload MUST be called before Channel.Receive(). The offloaded
4819    /// channel will have 0 RX credits given to the peer to prevent the peer
4820    /// from sending data until the offload processor is ready. This method may
4821    /// be called a maximum of one time.
4822    ///
4823    /// The following errors may be returned:
4824    /// * error `BAD_STATE` : Channel.Receive() has already been called or
4825    ///     StartOffload() has already been called.
4826    /// * error `INTERNAL`: An internal error occurred and the channel could not be offloaded.
4827    StartOffload {
4828        payload: ChannelOffloadExtStartOffloadRequest,
4829        responder: ChannelOffloadExtStartOffloadResponder,
4830    },
4831    /// An interaction was received which does not match any known method.
4832    #[non_exhaustive]
4833    _UnknownMethod {
4834        /// Ordinal of the method that was called.
4835        ordinal: u64,
4836        control_handle: ChannelOffloadExtControlHandle,
4837        method_type: fidl::MethodType,
4838    },
4839}
4840
4841impl ChannelOffloadExtRequest {
4842    #[allow(irrefutable_let_patterns)]
4843    pub fn into_start_offload(
4844        self,
4845    ) -> Option<(ChannelOffloadExtStartOffloadRequest, ChannelOffloadExtStartOffloadResponder)>
4846    {
4847        if let ChannelOffloadExtRequest::StartOffload { payload, responder } = self {
4848            Some((payload, responder))
4849        } else {
4850            None
4851        }
4852    }
4853
4854    /// Name of the method defined in FIDL
4855    pub fn method_name(&self) -> &'static str {
4856        match *self {
4857            ChannelOffloadExtRequest::StartOffload { .. } => "start_offload",
4858            ChannelOffloadExtRequest::_UnknownMethod {
4859                method_type: fidl::MethodType::OneWay,
4860                ..
4861            } => "unknown one-way method",
4862            ChannelOffloadExtRequest::_UnknownMethod {
4863                method_type: fidl::MethodType::TwoWay,
4864                ..
4865            } => "unknown two-way method",
4866        }
4867    }
4868}
4869
4870#[derive(Debug, Clone)]
4871pub struct ChannelOffloadExtControlHandle {
4872    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4873}
4874
4875impl fidl::endpoints::ControlHandle for ChannelOffloadExtControlHandle {
4876    fn shutdown(&self) {
4877        self.inner.shutdown()
4878    }
4879
4880    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4881        self.inner.shutdown_with_epitaph(status)
4882    }
4883
4884    fn is_closed(&self) -> bool {
4885        self.inner.channel().is_closed()
4886    }
4887    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4888        self.inner.channel().on_closed()
4889    }
4890
4891    #[cfg(target_os = "fuchsia")]
4892    fn signal_peer(
4893        &self,
4894        clear_mask: zx::Signals,
4895        set_mask: zx::Signals,
4896    ) -> Result<(), zx_status::Status> {
4897        use fidl::Peered;
4898        self.inner.channel().signal_peer(clear_mask, set_mask)
4899    }
4900}
4901
4902impl ChannelOffloadExtControlHandle {}
4903
4904#[must_use = "FIDL methods require a response to be sent"]
4905#[derive(Debug)]
4906pub struct ChannelOffloadExtStartOffloadResponder {
4907    control_handle: std::mem::ManuallyDrop<ChannelOffloadExtControlHandle>,
4908    tx_id: u32,
4909}
4910
4911/// Set the the channel to be shutdown (see [`ChannelOffloadExtControlHandle::shutdown`])
4912/// if the responder is dropped without sending a response, so that the client
4913/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4914impl std::ops::Drop for ChannelOffloadExtStartOffloadResponder {
4915    fn drop(&mut self) {
4916        self.control_handle.shutdown();
4917        // Safety: drops once, never accessed again
4918        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4919    }
4920}
4921
4922impl fidl::endpoints::Responder for ChannelOffloadExtStartOffloadResponder {
4923    type ControlHandle = ChannelOffloadExtControlHandle;
4924
4925    fn control_handle(&self) -> &ChannelOffloadExtControlHandle {
4926        &self.control_handle
4927    }
4928
4929    fn drop_without_shutdown(mut self) {
4930        // Safety: drops once, never accessed again due to mem::forget
4931        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4932        // Prevent Drop from running (which would shut down the channel)
4933        std::mem::forget(self);
4934    }
4935}
4936
4937impl ChannelOffloadExtStartOffloadResponder {
4938    /// Sends a response to the FIDL transaction.
4939    ///
4940    /// Sets the channel to shutdown if an error occurs.
4941    pub fn send(
4942        self,
4943        mut result: Result<&ChannelOffloadExtStartOffloadResponse, i32>,
4944    ) -> Result<(), fidl::Error> {
4945        let _result = self.send_raw(result);
4946        if _result.is_err() {
4947            self.control_handle.shutdown();
4948        }
4949        self.drop_without_shutdown();
4950        _result
4951    }
4952
4953    /// Similar to "send" but does not shutdown the channel if an error occurs.
4954    pub fn send_no_shutdown_on_err(
4955        self,
4956        mut result: Result<&ChannelOffloadExtStartOffloadResponse, i32>,
4957    ) -> Result<(), fidl::Error> {
4958        let _result = self.send_raw(result);
4959        self.drop_without_shutdown();
4960        _result
4961    }
4962
4963    fn send_raw(
4964        &self,
4965        mut result: Result<&ChannelOffloadExtStartOffloadResponse, i32>,
4966    ) -> Result<(), fidl::Error> {
4967        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4968            ChannelOffloadExtStartOffloadResponse,
4969            i32,
4970        >>(
4971            fidl::encoding::FlexibleResult::new(result),
4972            self.tx_id,
4973            0x2dd620feea793fe8,
4974            fidl::encoding::DynamicFlags::FLEXIBLE,
4975        )
4976    }
4977}
4978
4979#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4980pub struct CodecDelayMarker;
4981
4982impl fidl::endpoints::ProtocolMarker for CodecDelayMarker {
4983    type Proxy = CodecDelayProxy;
4984    type RequestStream = CodecDelayRequestStream;
4985    #[cfg(target_os = "fuchsia")]
4986    type SynchronousProxy = CodecDelaySynchronousProxy;
4987
4988    const DEBUG_NAME: &'static str = "(anonymous) CodecDelay";
4989}
4990pub type CodecDelayGetCodecLocalDelayRangeResult =
4991    Result<CodecDelayGetCodecLocalDelayRangeResponse, i32>;
4992
4993pub trait CodecDelayProxyInterface: Send + Sync {
4994    type GetCodecLocalDelayRangeResponseFut: std::future::Future<Output = Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error>>
4995        + Send;
4996    fn r#get_codec_local_delay_range(
4997        &self,
4998        payload: &CodecDelayGetCodecLocalDelayRangeRequest,
4999    ) -> Self::GetCodecLocalDelayRangeResponseFut;
5000}
5001#[derive(Debug)]
5002#[cfg(target_os = "fuchsia")]
5003pub struct CodecDelaySynchronousProxy {
5004    client: fidl::client::sync::Client,
5005}
5006
5007#[cfg(target_os = "fuchsia")]
5008impl fidl::endpoints::SynchronousProxy for CodecDelaySynchronousProxy {
5009    type Proxy = CodecDelayProxy;
5010    type Protocol = CodecDelayMarker;
5011
5012    fn from_channel(inner: fidl::Channel) -> Self {
5013        Self::new(inner)
5014    }
5015
5016    fn into_channel(self) -> fidl::Channel {
5017        self.client.into_channel()
5018    }
5019
5020    fn as_channel(&self) -> &fidl::Channel {
5021        self.client.as_channel()
5022    }
5023}
5024
5025#[cfg(target_os = "fuchsia")]
5026impl CodecDelaySynchronousProxy {
5027    pub fn new(channel: fidl::Channel) -> Self {
5028        Self { client: fidl::client::sync::Client::new(channel) }
5029    }
5030
5031    pub fn into_channel(self) -> fidl::Channel {
5032        self.client.into_channel()
5033    }
5034
5035    /// Waits until an event arrives and returns it. It is safe for other
5036    /// threads to make concurrent requests while waiting for an event.
5037    pub fn wait_for_event(
5038        &self,
5039        deadline: zx::MonotonicInstant,
5040    ) -> Result<CodecDelayEvent, fidl::Error> {
5041        CodecDelayEvent::decode(self.client.wait_for_event::<CodecDelayMarker>(deadline)?)
5042    }
5043
5044    /// Retrieve the range of controller delay for the codec specified with the provided stream
5045    /// attributes.
5046    ///
5047    /// On success, returns the minimum and maximum allowed delay.
5048    ///
5049    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
5050    /// Returns ZX_ERR_INTERNAL for all other failures.
5051    pub fn r#get_codec_local_delay_range(
5052        &self,
5053        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5054        ___deadline: zx::MonotonicInstant,
5055    ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
5056        let _response = self.client.send_query::<
5057            CodecDelayGetCodecLocalDelayRangeRequest,
5058            fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5059            CodecDelayMarker,
5060        >(
5061            payload,
5062            0x1cf34fdeed80b4d,
5063            fidl::encoding::DynamicFlags::empty(),
5064            ___deadline,
5065        )?;
5066        Ok(_response.map(|x| x))
5067    }
5068}
5069
5070#[cfg(target_os = "fuchsia")]
5071impl From<CodecDelaySynchronousProxy> for zx::NullableHandle {
5072    fn from(value: CodecDelaySynchronousProxy) -> Self {
5073        value.into_channel().into()
5074    }
5075}
5076
5077#[cfg(target_os = "fuchsia")]
5078impl From<fidl::Channel> for CodecDelaySynchronousProxy {
5079    fn from(value: fidl::Channel) -> Self {
5080        Self::new(value)
5081    }
5082}
5083
5084#[cfg(target_os = "fuchsia")]
5085impl fidl::endpoints::FromClient for CodecDelaySynchronousProxy {
5086    type Protocol = CodecDelayMarker;
5087
5088    fn from_client(value: fidl::endpoints::ClientEnd<CodecDelayMarker>) -> Self {
5089        Self::new(value.into_channel())
5090    }
5091}
5092
5093#[derive(Debug, Clone)]
5094pub struct CodecDelayProxy {
5095    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5096}
5097
5098impl fidl::endpoints::Proxy for CodecDelayProxy {
5099    type Protocol = CodecDelayMarker;
5100
5101    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5102        Self::new(inner)
5103    }
5104
5105    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5106        self.client.into_channel().map_err(|client| Self { client })
5107    }
5108
5109    fn as_channel(&self) -> &::fidl::AsyncChannel {
5110        self.client.as_channel()
5111    }
5112}
5113
5114impl CodecDelayProxy {
5115    /// Create a new Proxy for fuchsia.bluetooth.le/CodecDelay.
5116    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5117        let protocol_name = <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5118        Self { client: fidl::client::Client::new(channel, protocol_name) }
5119    }
5120
5121    /// Get a Stream of events from the remote end of the protocol.
5122    ///
5123    /// # Panics
5124    ///
5125    /// Panics if the event stream was already taken.
5126    pub fn take_event_stream(&self) -> CodecDelayEventStream {
5127        CodecDelayEventStream { event_receiver: self.client.take_event_receiver() }
5128    }
5129
5130    /// Retrieve the range of controller delay for the codec specified with the provided stream
5131    /// attributes.
5132    ///
5133    /// On success, returns the minimum and maximum allowed delay.
5134    ///
5135    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
5136    /// Returns ZX_ERR_INTERNAL for all other failures.
5137    pub fn r#get_codec_local_delay_range(
5138        &self,
5139        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5140    ) -> fidl::client::QueryResponseFut<
5141        CodecDelayGetCodecLocalDelayRangeResult,
5142        fidl::encoding::DefaultFuchsiaResourceDialect,
5143    > {
5144        CodecDelayProxyInterface::r#get_codec_local_delay_range(self, payload)
5145    }
5146}
5147
5148impl CodecDelayProxyInterface for CodecDelayProxy {
5149    type GetCodecLocalDelayRangeResponseFut = fidl::client::QueryResponseFut<
5150        CodecDelayGetCodecLocalDelayRangeResult,
5151        fidl::encoding::DefaultFuchsiaResourceDialect,
5152    >;
5153    fn r#get_codec_local_delay_range(
5154        &self,
5155        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
5156    ) -> Self::GetCodecLocalDelayRangeResponseFut {
5157        fn _decode(
5158            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5159        ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
5160            let _response = fidl::client::decode_transaction_body::<
5161                fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5162                fidl::encoding::DefaultFuchsiaResourceDialect,
5163                0x1cf34fdeed80b4d,
5164            >(_buf?)?;
5165            Ok(_response.map(|x| x))
5166        }
5167        self.client.send_query_and_decode::<
5168            CodecDelayGetCodecLocalDelayRangeRequest,
5169            CodecDelayGetCodecLocalDelayRangeResult,
5170        >(
5171            payload,
5172            0x1cf34fdeed80b4d,
5173            fidl::encoding::DynamicFlags::empty(),
5174            _decode,
5175        )
5176    }
5177}
5178
5179pub struct CodecDelayEventStream {
5180    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5181}
5182
5183impl std::marker::Unpin for CodecDelayEventStream {}
5184
5185impl futures::stream::FusedStream for CodecDelayEventStream {
5186    fn is_terminated(&self) -> bool {
5187        self.event_receiver.is_terminated()
5188    }
5189}
5190
5191impl futures::Stream for CodecDelayEventStream {
5192    type Item = Result<CodecDelayEvent, fidl::Error>;
5193
5194    fn poll_next(
5195        mut self: std::pin::Pin<&mut Self>,
5196        cx: &mut std::task::Context<'_>,
5197    ) -> std::task::Poll<Option<Self::Item>> {
5198        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5199            &mut self.event_receiver,
5200            cx
5201        )?) {
5202            Some(buf) => std::task::Poll::Ready(Some(CodecDelayEvent::decode(buf))),
5203            None => std::task::Poll::Ready(None),
5204        }
5205    }
5206}
5207
5208#[derive(Debug)]
5209pub enum CodecDelayEvent {}
5210
5211impl CodecDelayEvent {
5212    /// Decodes a message buffer as a [`CodecDelayEvent`].
5213    fn decode(
5214        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5215    ) -> Result<CodecDelayEvent, fidl::Error> {
5216        let (bytes, _handles) = buf.split_mut();
5217        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5218        debug_assert_eq!(tx_header.tx_id, 0);
5219        match tx_header.ordinal {
5220            _ => Err(fidl::Error::UnknownOrdinal {
5221                ordinal: tx_header.ordinal,
5222                protocol_name: <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5223            }),
5224        }
5225    }
5226}
5227
5228/// A Stream of incoming requests for fuchsia.bluetooth.le/CodecDelay.
5229pub struct CodecDelayRequestStream {
5230    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5231    is_terminated: bool,
5232}
5233
5234impl std::marker::Unpin for CodecDelayRequestStream {}
5235
5236impl futures::stream::FusedStream for CodecDelayRequestStream {
5237    fn is_terminated(&self) -> bool {
5238        self.is_terminated
5239    }
5240}
5241
5242impl fidl::endpoints::RequestStream for CodecDelayRequestStream {
5243    type Protocol = CodecDelayMarker;
5244    type ControlHandle = CodecDelayControlHandle;
5245
5246    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5247        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5248    }
5249
5250    fn control_handle(&self) -> Self::ControlHandle {
5251        CodecDelayControlHandle { inner: self.inner.clone() }
5252    }
5253
5254    fn into_inner(
5255        self,
5256    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5257    {
5258        (self.inner, self.is_terminated)
5259    }
5260
5261    fn from_inner(
5262        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5263        is_terminated: bool,
5264    ) -> Self {
5265        Self { inner, is_terminated }
5266    }
5267}
5268
5269impl futures::Stream for CodecDelayRequestStream {
5270    type Item = Result<CodecDelayRequest, fidl::Error>;
5271
5272    fn poll_next(
5273        mut self: std::pin::Pin<&mut Self>,
5274        cx: &mut std::task::Context<'_>,
5275    ) -> std::task::Poll<Option<Self::Item>> {
5276        let this = &mut *self;
5277        if this.inner.check_shutdown(cx) {
5278            this.is_terminated = true;
5279            return std::task::Poll::Ready(None);
5280        }
5281        if this.is_terminated {
5282            panic!("polled CodecDelayRequestStream after completion");
5283        }
5284        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5285            |bytes, handles| {
5286                match this.inner.channel().read_etc(cx, bytes, handles) {
5287                    std::task::Poll::Ready(Ok(())) => {}
5288                    std::task::Poll::Pending => return std::task::Poll::Pending,
5289                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5290                        this.is_terminated = true;
5291                        return std::task::Poll::Ready(None);
5292                    }
5293                    std::task::Poll::Ready(Err(e)) => {
5294                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5295                            e.into(),
5296                        ))));
5297                    }
5298                }
5299
5300                // A message has been received from the channel
5301                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5302
5303                std::task::Poll::Ready(Some(match header.ordinal {
5304                    0x1cf34fdeed80b4d => {
5305                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5306                        let mut req = fidl::new_empty!(
5307                            CodecDelayGetCodecLocalDelayRangeRequest,
5308                            fidl::encoding::DefaultFuchsiaResourceDialect
5309                        );
5310                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecDelayGetCodecLocalDelayRangeRequest>(&header, _body_bytes, handles, &mut req)?;
5311                        let control_handle = CodecDelayControlHandle { inner: this.inner.clone() };
5312                        Ok(CodecDelayRequest::GetCodecLocalDelayRange {
5313                            payload: req,
5314                            responder: CodecDelayGetCodecLocalDelayRangeResponder {
5315                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5316                                tx_id: header.tx_id,
5317                            },
5318                        })
5319                    }
5320                    _ => Err(fidl::Error::UnknownOrdinal {
5321                        ordinal: header.ordinal,
5322                        protocol_name:
5323                            <CodecDelayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5324                    }),
5325                }))
5326            },
5327        )
5328    }
5329}
5330
5331/// This protocol allows us to retrieve controller local delay values. It is not intended to be
5332/// used stand-alone, but to be composed into protocols that need access to this information.
5333#[derive(Debug)]
5334pub enum CodecDelayRequest {
5335    /// Retrieve the range of controller delay for the codec specified with the provided stream
5336    /// attributes.
5337    ///
5338    /// On success, returns the minimum and maximum allowed delay.
5339    ///
5340    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
5341    /// Returns ZX_ERR_INTERNAL for all other failures.
5342    GetCodecLocalDelayRange {
5343        payload: CodecDelayGetCodecLocalDelayRangeRequest,
5344        responder: CodecDelayGetCodecLocalDelayRangeResponder,
5345    },
5346}
5347
5348impl CodecDelayRequest {
5349    #[allow(irrefutable_let_patterns)]
5350    pub fn into_get_codec_local_delay_range(
5351        self,
5352    ) -> Option<(
5353        CodecDelayGetCodecLocalDelayRangeRequest,
5354        CodecDelayGetCodecLocalDelayRangeResponder,
5355    )> {
5356        if let CodecDelayRequest::GetCodecLocalDelayRange { payload, responder } = self {
5357            Some((payload, responder))
5358        } else {
5359            None
5360        }
5361    }
5362
5363    /// Name of the method defined in FIDL
5364    pub fn method_name(&self) -> &'static str {
5365        match *self {
5366            CodecDelayRequest::GetCodecLocalDelayRange { .. } => "get_codec_local_delay_range",
5367        }
5368    }
5369}
5370
5371#[derive(Debug, Clone)]
5372pub struct CodecDelayControlHandle {
5373    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5374}
5375
5376impl fidl::endpoints::ControlHandle for CodecDelayControlHandle {
5377    fn shutdown(&self) {
5378        self.inner.shutdown()
5379    }
5380
5381    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5382        self.inner.shutdown_with_epitaph(status)
5383    }
5384
5385    fn is_closed(&self) -> bool {
5386        self.inner.channel().is_closed()
5387    }
5388    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5389        self.inner.channel().on_closed()
5390    }
5391
5392    #[cfg(target_os = "fuchsia")]
5393    fn signal_peer(
5394        &self,
5395        clear_mask: zx::Signals,
5396        set_mask: zx::Signals,
5397    ) -> Result<(), zx_status::Status> {
5398        use fidl::Peered;
5399        self.inner.channel().signal_peer(clear_mask, set_mask)
5400    }
5401}
5402
5403impl CodecDelayControlHandle {}
5404
5405#[must_use = "FIDL methods require a response to be sent"]
5406#[derive(Debug)]
5407pub struct CodecDelayGetCodecLocalDelayRangeResponder {
5408    control_handle: std::mem::ManuallyDrop<CodecDelayControlHandle>,
5409    tx_id: u32,
5410}
5411
5412/// Set the the channel to be shutdown (see [`CodecDelayControlHandle::shutdown`])
5413/// if the responder is dropped without sending a response, so that the client
5414/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5415impl std::ops::Drop for CodecDelayGetCodecLocalDelayRangeResponder {
5416    fn drop(&mut self) {
5417        self.control_handle.shutdown();
5418        // Safety: drops once, never accessed again
5419        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5420    }
5421}
5422
5423impl fidl::endpoints::Responder for CodecDelayGetCodecLocalDelayRangeResponder {
5424    type ControlHandle = CodecDelayControlHandle;
5425
5426    fn control_handle(&self) -> &CodecDelayControlHandle {
5427        &self.control_handle
5428    }
5429
5430    fn drop_without_shutdown(mut self) {
5431        // Safety: drops once, never accessed again due to mem::forget
5432        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5433        // Prevent Drop from running (which would shut down the channel)
5434        std::mem::forget(self);
5435    }
5436}
5437
5438impl CodecDelayGetCodecLocalDelayRangeResponder {
5439    /// Sends a response to the FIDL transaction.
5440    ///
5441    /// Sets the channel to shutdown if an error occurs.
5442    pub fn send(
5443        self,
5444        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5445    ) -> Result<(), fidl::Error> {
5446        let _result = self.send_raw(result);
5447        if _result.is_err() {
5448            self.control_handle.shutdown();
5449        }
5450        self.drop_without_shutdown();
5451        _result
5452    }
5453
5454    /// Similar to "send" but does not shutdown the channel if an error occurs.
5455    pub fn send_no_shutdown_on_err(
5456        self,
5457        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5458    ) -> Result<(), fidl::Error> {
5459        let _result = self.send_raw(result);
5460        self.drop_without_shutdown();
5461        _result
5462    }
5463
5464    fn send_raw(
5465        &self,
5466        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
5467    ) -> Result<(), fidl::Error> {
5468        self.control_handle.inner.send::<fidl::encoding::ResultType<
5469            CodecDelayGetCodecLocalDelayRangeResponse,
5470            i32,
5471        >>(
5472            result,
5473            self.tx_id,
5474            0x1cf34fdeed80b4d,
5475            fidl::encoding::DynamicFlags::empty(),
5476        )
5477    }
5478}
5479
5480#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5481pub struct ConnectedIsochronousGroupMarker;
5482
5483impl fidl::endpoints::ProtocolMarker for ConnectedIsochronousGroupMarker {
5484    type Proxy = ConnectedIsochronousGroupProxy;
5485    type RequestStream = ConnectedIsochronousGroupRequestStream;
5486    #[cfg(target_os = "fuchsia")]
5487    type SynchronousProxy = ConnectedIsochronousGroupSynchronousProxy;
5488
5489    const DEBUG_NAME: &'static str = "(anonymous) ConnectedIsochronousGroup";
5490}
5491pub type ConnectedIsochronousGroupEstablishStreamsResult = Result<(), EstablishStreamsError>;
5492
5493pub trait ConnectedIsochronousGroupProxyInterface: Send + Sync {
5494    type EstablishStreamsResponseFut: std::future::Future<
5495            Output = Result<ConnectedIsochronousGroupEstablishStreamsResult, fidl::Error>,
5496        > + Send;
5497    fn r#establish_streams(
5498        &self,
5499        payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
5500    ) -> Self::EstablishStreamsResponseFut;
5501    fn r#remove(&self) -> Result<(), fidl::Error>;
5502}
5503#[derive(Debug)]
5504#[cfg(target_os = "fuchsia")]
5505pub struct ConnectedIsochronousGroupSynchronousProxy {
5506    client: fidl::client::sync::Client,
5507}
5508
5509#[cfg(target_os = "fuchsia")]
5510impl fidl::endpoints::SynchronousProxy for ConnectedIsochronousGroupSynchronousProxy {
5511    type Proxy = ConnectedIsochronousGroupProxy;
5512    type Protocol = ConnectedIsochronousGroupMarker;
5513
5514    fn from_channel(inner: fidl::Channel) -> Self {
5515        Self::new(inner)
5516    }
5517
5518    fn into_channel(self) -> fidl::Channel {
5519        self.client.into_channel()
5520    }
5521
5522    fn as_channel(&self) -> &fidl::Channel {
5523        self.client.as_channel()
5524    }
5525}
5526
5527#[cfg(target_os = "fuchsia")]
5528impl ConnectedIsochronousGroupSynchronousProxy {
5529    pub fn new(channel: fidl::Channel) -> Self {
5530        Self { client: fidl::client::sync::Client::new(channel) }
5531    }
5532
5533    pub fn into_channel(self) -> fidl::Channel {
5534        self.client.into_channel()
5535    }
5536
5537    /// Waits until an event arrives and returns it. It is safe for other
5538    /// threads to make concurrent requests while waiting for an event.
5539    pub fn wait_for_event(
5540        &self,
5541        deadline: zx::MonotonicInstant,
5542    ) -> Result<ConnectedIsochronousGroupEvent, fidl::Error> {
5543        ConnectedIsochronousGroupEvent::decode(
5544            self.client.wait_for_event::<ConnectedIsochronousGroupMarker>(deadline)?,
5545        )
5546    }
5547
5548    /// Connect one or more Isochronous streams. Each CIS is established with the peer specified
5549    /// in the parameters. On successful initiation of the operation, an OnEstablished() event will
5550    /// be sent on the IsochronousStream.
5551    ///
5552    /// Only one `EstablishStreams` call may be active at a time. Calling `EstablishStreams` while
5553    /// another is pending will result in the channel being closed with `ZX_ERR_BAD_STATE`.
5554    ///
5555    /// On error, no CISes are established and an appropriate `EstablishStreamsError` code will be
5556    /// returned.
5557    ///
5558    /// Otherwise, this call returns once each CIS specified has connected.
5559    pub fn r#establish_streams(
5560        &self,
5561        mut payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
5562        ___deadline: zx::MonotonicInstant,
5563    ) -> Result<ConnectedIsochronousGroupEstablishStreamsResult, fidl::Error> {
5564        let _response = self.client.send_query::<
5565            ConnectedIsochronousGroupEstablishStreamsRequest,
5566            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, EstablishStreamsError>,
5567            ConnectedIsochronousGroupMarker,
5568        >(
5569            payload,
5570            0xc7296c5edb4dacc,
5571            fidl::encoding::DynamicFlags::FLEXIBLE,
5572            ___deadline,
5573        )?
5574        .into_result::<ConnectedIsochronousGroupMarker>("establish_streams")?;
5575        Ok(_response.map(|x| x))
5576    }
5577
5578    /// Remove this CIG. Associated streams will be closed. This protocol will be closed after
5579    /// all of the associated streams have closed and the group has been removed.
5580    pub fn r#remove(&self) -> Result<(), fidl::Error> {
5581        self.client.send::<fidl::encoding::EmptyPayload>(
5582            (),
5583            0xbed433babd20503,
5584            fidl::encoding::DynamicFlags::FLEXIBLE,
5585        )
5586    }
5587}
5588
5589#[cfg(target_os = "fuchsia")]
5590impl From<ConnectedIsochronousGroupSynchronousProxy> for zx::NullableHandle {
5591    fn from(value: ConnectedIsochronousGroupSynchronousProxy) -> Self {
5592        value.into_channel().into()
5593    }
5594}
5595
5596#[cfg(target_os = "fuchsia")]
5597impl From<fidl::Channel> for ConnectedIsochronousGroupSynchronousProxy {
5598    fn from(value: fidl::Channel) -> Self {
5599        Self::new(value)
5600    }
5601}
5602
5603#[cfg(target_os = "fuchsia")]
5604impl fidl::endpoints::FromClient for ConnectedIsochronousGroupSynchronousProxy {
5605    type Protocol = ConnectedIsochronousGroupMarker;
5606
5607    fn from_client(value: fidl::endpoints::ClientEnd<ConnectedIsochronousGroupMarker>) -> Self {
5608        Self::new(value.into_channel())
5609    }
5610}
5611
5612#[derive(Debug, Clone)]
5613pub struct ConnectedIsochronousGroupProxy {
5614    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5615}
5616
5617impl fidl::endpoints::Proxy for ConnectedIsochronousGroupProxy {
5618    type Protocol = ConnectedIsochronousGroupMarker;
5619
5620    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5621        Self::new(inner)
5622    }
5623
5624    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5625        self.client.into_channel().map_err(|client| Self { client })
5626    }
5627
5628    fn as_channel(&self) -> &::fidl::AsyncChannel {
5629        self.client.as_channel()
5630    }
5631}
5632
5633impl ConnectedIsochronousGroupProxy {
5634    /// Create a new Proxy for fuchsia.bluetooth.le/ConnectedIsochronousGroup.
5635    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5636        let protocol_name =
5637            <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5638        Self { client: fidl::client::Client::new(channel, protocol_name) }
5639    }
5640
5641    /// Get a Stream of events from the remote end of the protocol.
5642    ///
5643    /// # Panics
5644    ///
5645    /// Panics if the event stream was already taken.
5646    pub fn take_event_stream(&self) -> ConnectedIsochronousGroupEventStream {
5647        ConnectedIsochronousGroupEventStream { event_receiver: self.client.take_event_receiver() }
5648    }
5649
5650    /// Connect one or more Isochronous streams. Each CIS is established with the peer specified
5651    /// in the parameters. On successful initiation of the operation, an OnEstablished() event will
5652    /// be sent on the IsochronousStream.
5653    ///
5654    /// Only one `EstablishStreams` call may be active at a time. Calling `EstablishStreams` while
5655    /// another is pending will result in the channel being closed with `ZX_ERR_BAD_STATE`.
5656    ///
5657    /// On error, no CISes are established and an appropriate `EstablishStreamsError` code will be
5658    /// returned.
5659    ///
5660    /// Otherwise, this call returns once each CIS specified has connected.
5661    pub fn r#establish_streams(
5662        &self,
5663        mut payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
5664    ) -> fidl::client::QueryResponseFut<
5665        ConnectedIsochronousGroupEstablishStreamsResult,
5666        fidl::encoding::DefaultFuchsiaResourceDialect,
5667    > {
5668        ConnectedIsochronousGroupProxyInterface::r#establish_streams(self, payload)
5669    }
5670
5671    /// Remove this CIG. Associated streams will be closed. This protocol will be closed after
5672    /// all of the associated streams have closed and the group has been removed.
5673    pub fn r#remove(&self) -> Result<(), fidl::Error> {
5674        ConnectedIsochronousGroupProxyInterface::r#remove(self)
5675    }
5676}
5677
5678impl ConnectedIsochronousGroupProxyInterface for ConnectedIsochronousGroupProxy {
5679    type EstablishStreamsResponseFut = fidl::client::QueryResponseFut<
5680        ConnectedIsochronousGroupEstablishStreamsResult,
5681        fidl::encoding::DefaultFuchsiaResourceDialect,
5682    >;
5683    fn r#establish_streams(
5684        &self,
5685        mut payload: &ConnectedIsochronousGroupEstablishStreamsRequest,
5686    ) -> Self::EstablishStreamsResponseFut {
5687        fn _decode(
5688            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5689        ) -> Result<ConnectedIsochronousGroupEstablishStreamsResult, fidl::Error> {
5690            let _response = fidl::client::decode_transaction_body::<
5691                fidl::encoding::FlexibleResultType<
5692                    fidl::encoding::EmptyStruct,
5693                    EstablishStreamsError,
5694                >,
5695                fidl::encoding::DefaultFuchsiaResourceDialect,
5696                0xc7296c5edb4dacc,
5697            >(_buf?)?
5698            .into_result::<ConnectedIsochronousGroupMarker>("establish_streams")?;
5699            Ok(_response.map(|x| x))
5700        }
5701        self.client.send_query_and_decode::<
5702            ConnectedIsochronousGroupEstablishStreamsRequest,
5703            ConnectedIsochronousGroupEstablishStreamsResult,
5704        >(
5705            payload,
5706            0xc7296c5edb4dacc,
5707            fidl::encoding::DynamicFlags::FLEXIBLE,
5708            _decode,
5709        )
5710    }
5711
5712    fn r#remove(&self) -> Result<(), fidl::Error> {
5713        self.client.send::<fidl::encoding::EmptyPayload>(
5714            (),
5715            0xbed433babd20503,
5716            fidl::encoding::DynamicFlags::FLEXIBLE,
5717        )
5718    }
5719}
5720
5721pub struct ConnectedIsochronousGroupEventStream {
5722    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5723}
5724
5725impl std::marker::Unpin for ConnectedIsochronousGroupEventStream {}
5726
5727impl futures::stream::FusedStream for ConnectedIsochronousGroupEventStream {
5728    fn is_terminated(&self) -> bool {
5729        self.event_receiver.is_terminated()
5730    }
5731}
5732
5733impl futures::Stream for ConnectedIsochronousGroupEventStream {
5734    type Item = Result<ConnectedIsochronousGroupEvent, fidl::Error>;
5735
5736    fn poll_next(
5737        mut self: std::pin::Pin<&mut Self>,
5738        cx: &mut std::task::Context<'_>,
5739    ) -> std::task::Poll<Option<Self::Item>> {
5740        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5741            &mut self.event_receiver,
5742            cx
5743        )?) {
5744            Some(buf) => std::task::Poll::Ready(Some(ConnectedIsochronousGroupEvent::decode(buf))),
5745            None => std::task::Poll::Ready(None),
5746        }
5747    }
5748}
5749
5750#[derive(Debug)]
5751pub enum ConnectedIsochronousGroupEvent {
5752    #[non_exhaustive]
5753    _UnknownEvent {
5754        /// Ordinal of the event that was sent.
5755        ordinal: u64,
5756    },
5757}
5758
5759impl ConnectedIsochronousGroupEvent {
5760    /// Decodes a message buffer as a [`ConnectedIsochronousGroupEvent`].
5761    fn decode(
5762        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5763    ) -> Result<ConnectedIsochronousGroupEvent, fidl::Error> {
5764        let (bytes, _handles) = buf.split_mut();
5765        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5766        debug_assert_eq!(tx_header.tx_id, 0);
5767        match tx_header.ordinal {
5768            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5769                Ok(ConnectedIsochronousGroupEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5770            }
5771            _ => Err(fidl::Error::UnknownOrdinal {
5772                ordinal: tx_header.ordinal,
5773                protocol_name:
5774                    <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5775            }),
5776        }
5777    }
5778}
5779
5780/// A Stream of incoming requests for fuchsia.bluetooth.le/ConnectedIsochronousGroup.
5781pub struct ConnectedIsochronousGroupRequestStream {
5782    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5783    is_terminated: bool,
5784}
5785
5786impl std::marker::Unpin for ConnectedIsochronousGroupRequestStream {}
5787
5788impl futures::stream::FusedStream for ConnectedIsochronousGroupRequestStream {
5789    fn is_terminated(&self) -> bool {
5790        self.is_terminated
5791    }
5792}
5793
5794impl fidl::endpoints::RequestStream for ConnectedIsochronousGroupRequestStream {
5795    type Protocol = ConnectedIsochronousGroupMarker;
5796    type ControlHandle = ConnectedIsochronousGroupControlHandle;
5797
5798    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5799        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5800    }
5801
5802    fn control_handle(&self) -> Self::ControlHandle {
5803        ConnectedIsochronousGroupControlHandle { inner: self.inner.clone() }
5804    }
5805
5806    fn into_inner(
5807        self,
5808    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5809    {
5810        (self.inner, self.is_terminated)
5811    }
5812
5813    fn from_inner(
5814        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5815        is_terminated: bool,
5816    ) -> Self {
5817        Self { inner, is_terminated }
5818    }
5819}
5820
5821impl futures::Stream for ConnectedIsochronousGroupRequestStream {
5822    type Item = Result<ConnectedIsochronousGroupRequest, fidl::Error>;
5823
5824    fn poll_next(
5825        mut self: std::pin::Pin<&mut Self>,
5826        cx: &mut std::task::Context<'_>,
5827    ) -> std::task::Poll<Option<Self::Item>> {
5828        let this = &mut *self;
5829        if this.inner.check_shutdown(cx) {
5830            this.is_terminated = true;
5831            return std::task::Poll::Ready(None);
5832        }
5833        if this.is_terminated {
5834            panic!("polled ConnectedIsochronousGroupRequestStream after completion");
5835        }
5836        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5837            |bytes, handles| {
5838                match this.inner.channel().read_etc(cx, bytes, handles) {
5839                    std::task::Poll::Ready(Ok(())) => {}
5840                    std::task::Poll::Pending => return std::task::Poll::Pending,
5841                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5842                        this.is_terminated = true;
5843                        return std::task::Poll::Ready(None);
5844                    }
5845                    std::task::Poll::Ready(Err(e)) => {
5846                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5847                            e.into(),
5848                        ))));
5849                    }
5850                }
5851
5852                // A message has been received from the channel
5853                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5854
5855                std::task::Poll::Ready(Some(match header.ordinal {
5856                0xc7296c5edb4dacc => {
5857                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5858                    let mut req = fidl::new_empty!(ConnectedIsochronousGroupEstablishStreamsRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5859                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectedIsochronousGroupEstablishStreamsRequest>(&header, _body_bytes, handles, &mut req)?;
5860                    let control_handle = ConnectedIsochronousGroupControlHandle {
5861                        inner: this.inner.clone(),
5862                    };
5863                    Ok(ConnectedIsochronousGroupRequest::EstablishStreams {payload: req,
5864                        responder: ConnectedIsochronousGroupEstablishStreamsResponder {
5865                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5866                            tx_id: header.tx_id,
5867                        },
5868                    })
5869                }
5870                0xbed433babd20503 => {
5871                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5872                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
5873                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5874                    let control_handle = ConnectedIsochronousGroupControlHandle {
5875                        inner: this.inner.clone(),
5876                    };
5877                    Ok(ConnectedIsochronousGroupRequest::Remove {
5878                        control_handle,
5879                    })
5880                }
5881                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5882                    Ok(ConnectedIsochronousGroupRequest::_UnknownMethod {
5883                        ordinal: header.ordinal,
5884                        control_handle: ConnectedIsochronousGroupControlHandle { inner: this.inner.clone() },
5885                        method_type: fidl::MethodType::OneWay,
5886                    })
5887                }
5888                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5889                    this.inner.send_framework_err(
5890                        fidl::encoding::FrameworkErr::UnknownMethod,
5891                        header.tx_id,
5892                        header.ordinal,
5893                        header.dynamic_flags(),
5894                        (bytes, handles),
5895                    )?;
5896                    Ok(ConnectedIsochronousGroupRequest::_UnknownMethod {
5897                        ordinal: header.ordinal,
5898                        control_handle: ConnectedIsochronousGroupControlHandle { inner: this.inner.clone() },
5899                        method_type: fidl::MethodType::TwoWay,
5900                    })
5901                }
5902                _ => Err(fidl::Error::UnknownOrdinal {
5903                    ordinal: header.ordinal,
5904                    protocol_name: <ConnectedIsochronousGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5905                }),
5906            }))
5907            },
5908        )
5909    }
5910}
5911
5912#[derive(Debug)]
5913pub enum ConnectedIsochronousGroupRequest {
5914    /// Connect one or more Isochronous streams. Each CIS is established with the peer specified
5915    /// in the parameters. On successful initiation of the operation, an OnEstablished() event will
5916    /// be sent on the IsochronousStream.
5917    ///
5918    /// Only one `EstablishStreams` call may be active at a time. Calling `EstablishStreams` while
5919    /// another is pending will result in the channel being closed with `ZX_ERR_BAD_STATE`.
5920    ///
5921    /// On error, no CISes are established and an appropriate `EstablishStreamsError` code will be
5922    /// returned.
5923    ///
5924    /// Otherwise, this call returns once each CIS specified has connected.
5925    EstablishStreams {
5926        payload: ConnectedIsochronousGroupEstablishStreamsRequest,
5927        responder: ConnectedIsochronousGroupEstablishStreamsResponder,
5928    },
5929    /// Remove this CIG. Associated streams will be closed. This protocol will be closed after
5930    /// all of the associated streams have closed and the group has been removed.
5931    Remove { control_handle: ConnectedIsochronousGroupControlHandle },
5932    /// An interaction was received which does not match any known method.
5933    #[non_exhaustive]
5934    _UnknownMethod {
5935        /// Ordinal of the method that was called.
5936        ordinal: u64,
5937        control_handle: ConnectedIsochronousGroupControlHandle,
5938        method_type: fidl::MethodType,
5939    },
5940}
5941
5942impl ConnectedIsochronousGroupRequest {
5943    #[allow(irrefutable_let_patterns)]
5944    pub fn into_establish_streams(
5945        self,
5946    ) -> Option<(
5947        ConnectedIsochronousGroupEstablishStreamsRequest,
5948        ConnectedIsochronousGroupEstablishStreamsResponder,
5949    )> {
5950        if let ConnectedIsochronousGroupRequest::EstablishStreams { payload, responder } = self {
5951            Some((payload, responder))
5952        } else {
5953            None
5954        }
5955    }
5956
5957    #[allow(irrefutable_let_patterns)]
5958    pub fn into_remove(self) -> Option<(ConnectedIsochronousGroupControlHandle)> {
5959        if let ConnectedIsochronousGroupRequest::Remove { control_handle } = self {
5960            Some((control_handle))
5961        } else {
5962            None
5963        }
5964    }
5965
5966    /// Name of the method defined in FIDL
5967    pub fn method_name(&self) -> &'static str {
5968        match *self {
5969            ConnectedIsochronousGroupRequest::EstablishStreams { .. } => "establish_streams",
5970            ConnectedIsochronousGroupRequest::Remove { .. } => "remove",
5971            ConnectedIsochronousGroupRequest::_UnknownMethod {
5972                method_type: fidl::MethodType::OneWay,
5973                ..
5974            } => "unknown one-way method",
5975            ConnectedIsochronousGroupRequest::_UnknownMethod {
5976                method_type: fidl::MethodType::TwoWay,
5977                ..
5978            } => "unknown two-way method",
5979        }
5980    }
5981}
5982
5983#[derive(Debug, Clone)]
5984pub struct ConnectedIsochronousGroupControlHandle {
5985    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5986}
5987
5988impl fidl::endpoints::ControlHandle for ConnectedIsochronousGroupControlHandle {
5989    fn shutdown(&self) {
5990        self.inner.shutdown()
5991    }
5992
5993    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5994        self.inner.shutdown_with_epitaph(status)
5995    }
5996
5997    fn is_closed(&self) -> bool {
5998        self.inner.channel().is_closed()
5999    }
6000    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6001        self.inner.channel().on_closed()
6002    }
6003
6004    #[cfg(target_os = "fuchsia")]
6005    fn signal_peer(
6006        &self,
6007        clear_mask: zx::Signals,
6008        set_mask: zx::Signals,
6009    ) -> Result<(), zx_status::Status> {
6010        use fidl::Peered;
6011        self.inner.channel().signal_peer(clear_mask, set_mask)
6012    }
6013}
6014
6015impl ConnectedIsochronousGroupControlHandle {}
6016
6017#[must_use = "FIDL methods require a response to be sent"]
6018#[derive(Debug)]
6019pub struct ConnectedIsochronousGroupEstablishStreamsResponder {
6020    control_handle: std::mem::ManuallyDrop<ConnectedIsochronousGroupControlHandle>,
6021    tx_id: u32,
6022}
6023
6024/// Set the the channel to be shutdown (see [`ConnectedIsochronousGroupControlHandle::shutdown`])
6025/// if the responder is dropped without sending a response, so that the client
6026/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6027impl std::ops::Drop for ConnectedIsochronousGroupEstablishStreamsResponder {
6028    fn drop(&mut self) {
6029        self.control_handle.shutdown();
6030        // Safety: drops once, never accessed again
6031        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6032    }
6033}
6034
6035impl fidl::endpoints::Responder for ConnectedIsochronousGroupEstablishStreamsResponder {
6036    type ControlHandle = ConnectedIsochronousGroupControlHandle;
6037
6038    fn control_handle(&self) -> &ConnectedIsochronousGroupControlHandle {
6039        &self.control_handle
6040    }
6041
6042    fn drop_without_shutdown(mut self) {
6043        // Safety: drops once, never accessed again due to mem::forget
6044        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6045        // Prevent Drop from running (which would shut down the channel)
6046        std::mem::forget(self);
6047    }
6048}
6049
6050impl ConnectedIsochronousGroupEstablishStreamsResponder {
6051    /// Sends a response to the FIDL transaction.
6052    ///
6053    /// Sets the channel to shutdown if an error occurs.
6054    pub fn send(self, mut result: Result<(), EstablishStreamsError>) -> Result<(), fidl::Error> {
6055        let _result = self.send_raw(result);
6056        if _result.is_err() {
6057            self.control_handle.shutdown();
6058        }
6059        self.drop_without_shutdown();
6060        _result
6061    }
6062
6063    /// Similar to "send" but does not shutdown the channel if an error occurs.
6064    pub fn send_no_shutdown_on_err(
6065        self,
6066        mut result: Result<(), EstablishStreamsError>,
6067    ) -> Result<(), fidl::Error> {
6068        let _result = self.send_raw(result);
6069        self.drop_without_shutdown();
6070        _result
6071    }
6072
6073    fn send_raw(&self, mut result: Result<(), EstablishStreamsError>) -> Result<(), fidl::Error> {
6074        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6075            fidl::encoding::EmptyStruct,
6076            EstablishStreamsError,
6077        >>(
6078            fidl::encoding::FlexibleResult::new(result),
6079            self.tx_id,
6080            0xc7296c5edb4dacc,
6081            fidl::encoding::DynamicFlags::FLEXIBLE,
6082        )
6083    }
6084}
6085
6086#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6087pub struct ConnectionMarker;
6088
6089impl fidl::endpoints::ProtocolMarker for ConnectionMarker {
6090    type Proxy = ConnectionProxy;
6091    type RequestStream = ConnectionRequestStream;
6092    #[cfg(target_os = "fuchsia")]
6093    type SynchronousProxy = ConnectionSynchronousProxy;
6094
6095    const DEBUG_NAME: &'static str = "(anonymous) Connection";
6096}
6097pub type ConnectionTransferPeriodicAdvertisingSyncResult =
6098    Result<(), PeriodicAdvertisingSyncTransferError>;
6099pub type ConnectionAcceptPeriodicAdvertisingSyncTransferResult =
6100    Result<(), PeriodicAdvertisingSyncTransferError>;
6101
6102pub trait ConnectionProxyInterface: Send + Sync {
6103    type GetCodecLocalDelayRangeResponseFut: std::future::Future<Output = Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error>>
6104        + Send;
6105    fn r#get_codec_local_delay_range(
6106        &self,
6107        payload: &CodecDelayGetCodecLocalDelayRangeRequest,
6108    ) -> Self::GetCodecLocalDelayRangeResponseFut;
6109    fn r#request_gatt_client(
6110        &self,
6111        client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
6112    ) -> Result<(), fidl::Error>;
6113    fn r#accept_cis(&self, payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error>;
6114    fn r#connect_l2cap(&self, payload: ConnectionConnectL2capRequest) -> Result<(), fidl::Error>;
6115    type TransferPeriodicAdvertisingSyncResponseFut: std::future::Future<
6116            Output = Result<ConnectionTransferPeriodicAdvertisingSyncResult, fidl::Error>,
6117        > + Send;
6118    fn r#transfer_periodic_advertising_sync(
6119        &self,
6120        payload: &ConnectionTransferPeriodicAdvertisingSyncRequest,
6121    ) -> Self::TransferPeriodicAdvertisingSyncResponseFut;
6122    type AcceptPeriodicAdvertisingSyncTransferResponseFut: std::future::Future<
6123            Output = Result<ConnectionAcceptPeriodicAdvertisingSyncTransferResult, fidl::Error>,
6124        > + Send;
6125    fn r#accept_periodic_advertising_sync_transfer(
6126        &self,
6127        payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6128    ) -> Self::AcceptPeriodicAdvertisingSyncTransferResponseFut;
6129}
6130#[derive(Debug)]
6131#[cfg(target_os = "fuchsia")]
6132pub struct ConnectionSynchronousProxy {
6133    client: fidl::client::sync::Client,
6134}
6135
6136#[cfg(target_os = "fuchsia")]
6137impl fidl::endpoints::SynchronousProxy for ConnectionSynchronousProxy {
6138    type Proxy = ConnectionProxy;
6139    type Protocol = ConnectionMarker;
6140
6141    fn from_channel(inner: fidl::Channel) -> Self {
6142        Self::new(inner)
6143    }
6144
6145    fn into_channel(self) -> fidl::Channel {
6146        self.client.into_channel()
6147    }
6148
6149    fn as_channel(&self) -> &fidl::Channel {
6150        self.client.as_channel()
6151    }
6152}
6153
6154#[cfg(target_os = "fuchsia")]
6155impl ConnectionSynchronousProxy {
6156    pub fn new(channel: fidl::Channel) -> Self {
6157        Self { client: fidl::client::sync::Client::new(channel) }
6158    }
6159
6160    pub fn into_channel(self) -> fidl::Channel {
6161        self.client.into_channel()
6162    }
6163
6164    /// Waits until an event arrives and returns it. It is safe for other
6165    /// threads to make concurrent requests while waiting for an event.
6166    pub fn wait_for_event(
6167        &self,
6168        deadline: zx::MonotonicInstant,
6169    ) -> Result<ConnectionEvent, fidl::Error> {
6170        ConnectionEvent::decode(self.client.wait_for_event::<ConnectionMarker>(deadline)?)
6171    }
6172
6173    /// Retrieve the range of controller delay for the codec specified with the provided stream
6174    /// attributes.
6175    ///
6176    /// On success, returns the minimum and maximum allowed delay.
6177    ///
6178    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
6179    /// Returns ZX_ERR_INTERNAL for all other failures.
6180    pub fn r#get_codec_local_delay_range(
6181        &self,
6182        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
6183        ___deadline: zx::MonotonicInstant,
6184    ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
6185        let _response = self.client.send_query::<
6186            CodecDelayGetCodecLocalDelayRangeRequest,
6187            fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
6188            ConnectionMarker,
6189        >(
6190            payload,
6191            0x1cf34fdeed80b4d,
6192            fidl::encoding::DynamicFlags::empty(),
6193            ___deadline,
6194        )?;
6195        Ok(_response.map(|x| x))
6196    }
6197
6198    /// The following epitaphs may be sent by the server on error:
6199    /// + `ZX_ERR_ALREADY_BOUND`: A Client server has already been bound in this Connection
6200    ///                           protocol. The existing Client should be used.
6201    pub fn r#request_gatt_client(
6202        &self,
6203        mut client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
6204    ) -> Result<(), fidl::Error> {
6205        self.client.send::<ConnectionRequestGattClientRequest>(
6206            (client,),
6207            0x2a670e0fec6ccc6b,
6208            fidl::encoding::DynamicFlags::empty(),
6209        )
6210    }
6211
6212    /// Accept a future CIS request from the peer with the specified CIG/CIS values. All
6213    /// CIS requests that have not explicitly been allowed will be rejected.
6214    ///
6215    /// The provided IsochronousStream will be used for future notification of established
6216    /// connections.
6217    ///
6218    /// The host may wait for multiple incoming connections simultaneously, although each
6219    /// must have a combination of CIG/CIS values that is unique to this connection.
6220    ///
6221    /// If we are not operating in the peripheral role in this connection, connection_stream
6222    /// will be closed with a ZX_ERR_NOT_SUPPORTED epitaph.
6223    ///
6224    /// If we are already waiting for another connection with the same combination of CIG/CIS
6225    /// values, connection_stream will be closed with a ZX_ERR_INVALID_ARGS epitaph.
6226    pub fn r#accept_cis(&self, mut payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error> {
6227        self.client.send::<ConnectionAcceptCisRequest>(
6228            &mut payload,
6229            0x7e6338c237088144,
6230            fidl::encoding::DynamicFlags::empty(),
6231        )
6232    }
6233
6234    /// Connect to an L2CAP LE connection-oriented channel.
6235    pub fn r#connect_l2cap(
6236        &self,
6237        mut payload: ConnectionConnectL2capRequest,
6238    ) -> Result<(), fidl::Error> {
6239        self.client.send::<ConnectionConnectL2capRequest>(
6240            &mut payload,
6241            0x12351316feaebce9,
6242            fidl::encoding::DynamicFlags::empty(),
6243        )
6244    }
6245
6246    /// Send synchronization information for a periodic advertising train identified by `sync_id` to
6247    /// the connected peer.
6248    pub fn r#transfer_periodic_advertising_sync(
6249        &self,
6250        mut payload: &ConnectionTransferPeriodicAdvertisingSyncRequest,
6251        ___deadline: zx::MonotonicInstant,
6252    ) -> Result<ConnectionTransferPeriodicAdvertisingSyncResult, fidl::Error> {
6253        let _response = self.client.send_query::<
6254            ConnectionTransferPeriodicAdvertisingSyncRequest,
6255            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeriodicAdvertisingSyncTransferError>,
6256            ConnectionMarker,
6257        >(
6258            payload,
6259            0x1117a10b5ba1e219,
6260            fidl::encoding::DynamicFlags::empty(),
6261            ___deadline,
6262        )?;
6263        Ok(_response.map(|x| x))
6264    }
6265
6266    /// Accept the next Periodic Advertising Sync Transfer from the peer. A response will be sent
6267    /// when the host is ready to accept the transfer. Only one request can be pending at a time.
6268    pub fn r#accept_periodic_advertising_sync_transfer(
6269        &self,
6270        mut payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6271        ___deadline: zx::MonotonicInstant,
6272    ) -> Result<ConnectionAcceptPeriodicAdvertisingSyncTransferResult, fidl::Error> {
6273        let _response = self.client.send_query::<
6274            ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6275            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeriodicAdvertisingSyncTransferError>,
6276            ConnectionMarker,
6277        >(
6278            &mut payload,
6279            0x441a31a7effa7e2b,
6280            fidl::encoding::DynamicFlags::empty(),
6281            ___deadline,
6282        )?;
6283        Ok(_response.map(|x| x))
6284    }
6285}
6286
6287#[cfg(target_os = "fuchsia")]
6288impl From<ConnectionSynchronousProxy> for zx::NullableHandle {
6289    fn from(value: ConnectionSynchronousProxy) -> Self {
6290        value.into_channel().into()
6291    }
6292}
6293
6294#[cfg(target_os = "fuchsia")]
6295impl From<fidl::Channel> for ConnectionSynchronousProxy {
6296    fn from(value: fidl::Channel) -> Self {
6297        Self::new(value)
6298    }
6299}
6300
6301#[cfg(target_os = "fuchsia")]
6302impl fidl::endpoints::FromClient for ConnectionSynchronousProxy {
6303    type Protocol = ConnectionMarker;
6304
6305    fn from_client(value: fidl::endpoints::ClientEnd<ConnectionMarker>) -> Self {
6306        Self::new(value.into_channel())
6307    }
6308}
6309
6310#[derive(Debug, Clone)]
6311pub struct ConnectionProxy {
6312    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6313}
6314
6315impl fidl::endpoints::Proxy for ConnectionProxy {
6316    type Protocol = ConnectionMarker;
6317
6318    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6319        Self::new(inner)
6320    }
6321
6322    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6323        self.client.into_channel().map_err(|client| Self { client })
6324    }
6325
6326    fn as_channel(&self) -> &::fidl::AsyncChannel {
6327        self.client.as_channel()
6328    }
6329}
6330
6331impl ConnectionProxy {
6332    /// Create a new Proxy for fuchsia.bluetooth.le/Connection.
6333    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6334        let protocol_name = <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6335        Self { client: fidl::client::Client::new(channel, protocol_name) }
6336    }
6337
6338    /// Get a Stream of events from the remote end of the protocol.
6339    ///
6340    /// # Panics
6341    ///
6342    /// Panics if the event stream was already taken.
6343    pub fn take_event_stream(&self) -> ConnectionEventStream {
6344        ConnectionEventStream { event_receiver: self.client.take_event_receiver() }
6345    }
6346
6347    /// Retrieve the range of controller delay for the codec specified with the provided stream
6348    /// attributes.
6349    ///
6350    /// On success, returns the minimum and maximum allowed delay.
6351    ///
6352    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
6353    /// Returns ZX_ERR_INTERNAL for all other failures.
6354    pub fn r#get_codec_local_delay_range(
6355        &self,
6356        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
6357    ) -> fidl::client::QueryResponseFut<
6358        CodecDelayGetCodecLocalDelayRangeResult,
6359        fidl::encoding::DefaultFuchsiaResourceDialect,
6360    > {
6361        ConnectionProxyInterface::r#get_codec_local_delay_range(self, payload)
6362    }
6363
6364    /// The following epitaphs may be sent by the server on error:
6365    /// + `ZX_ERR_ALREADY_BOUND`: A Client server has already been bound in this Connection
6366    ///                           protocol. The existing Client should be used.
6367    pub fn r#request_gatt_client(
6368        &self,
6369        mut client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
6370    ) -> Result<(), fidl::Error> {
6371        ConnectionProxyInterface::r#request_gatt_client(self, client)
6372    }
6373
6374    /// Accept a future CIS request from the peer with the specified CIG/CIS values. All
6375    /// CIS requests that have not explicitly been allowed will be rejected.
6376    ///
6377    /// The provided IsochronousStream will be used for future notification of established
6378    /// connections.
6379    ///
6380    /// The host may wait for multiple incoming connections simultaneously, although each
6381    /// must have a combination of CIG/CIS values that is unique to this connection.
6382    ///
6383    /// If we are not operating in the peripheral role in this connection, connection_stream
6384    /// will be closed with a ZX_ERR_NOT_SUPPORTED epitaph.
6385    ///
6386    /// If we are already waiting for another connection with the same combination of CIG/CIS
6387    /// values, connection_stream will be closed with a ZX_ERR_INVALID_ARGS epitaph.
6388    pub fn r#accept_cis(&self, mut payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error> {
6389        ConnectionProxyInterface::r#accept_cis(self, payload)
6390    }
6391
6392    /// Connect to an L2CAP LE connection-oriented channel.
6393    pub fn r#connect_l2cap(
6394        &self,
6395        mut payload: ConnectionConnectL2capRequest,
6396    ) -> Result<(), fidl::Error> {
6397        ConnectionProxyInterface::r#connect_l2cap(self, payload)
6398    }
6399
6400    /// Send synchronization information for a periodic advertising train identified by `sync_id` to
6401    /// the connected peer.
6402    pub fn r#transfer_periodic_advertising_sync(
6403        &self,
6404        mut payload: &ConnectionTransferPeriodicAdvertisingSyncRequest,
6405    ) -> fidl::client::QueryResponseFut<
6406        ConnectionTransferPeriodicAdvertisingSyncResult,
6407        fidl::encoding::DefaultFuchsiaResourceDialect,
6408    > {
6409        ConnectionProxyInterface::r#transfer_periodic_advertising_sync(self, payload)
6410    }
6411
6412    /// Accept the next Periodic Advertising Sync Transfer from the peer. A response will be sent
6413    /// when the host is ready to accept the transfer. Only one request can be pending at a time.
6414    pub fn r#accept_periodic_advertising_sync_transfer(
6415        &self,
6416        mut payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6417    ) -> fidl::client::QueryResponseFut<
6418        ConnectionAcceptPeriodicAdvertisingSyncTransferResult,
6419        fidl::encoding::DefaultFuchsiaResourceDialect,
6420    > {
6421        ConnectionProxyInterface::r#accept_periodic_advertising_sync_transfer(self, payload)
6422    }
6423}
6424
6425impl ConnectionProxyInterface for ConnectionProxy {
6426    type GetCodecLocalDelayRangeResponseFut = fidl::client::QueryResponseFut<
6427        CodecDelayGetCodecLocalDelayRangeResult,
6428        fidl::encoding::DefaultFuchsiaResourceDialect,
6429    >;
6430    fn r#get_codec_local_delay_range(
6431        &self,
6432        mut payload: &CodecDelayGetCodecLocalDelayRangeRequest,
6433    ) -> Self::GetCodecLocalDelayRangeResponseFut {
6434        fn _decode(
6435            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6436        ) -> Result<CodecDelayGetCodecLocalDelayRangeResult, fidl::Error> {
6437            let _response = fidl::client::decode_transaction_body::<
6438                fidl::encoding::ResultType<CodecDelayGetCodecLocalDelayRangeResponse, i32>,
6439                fidl::encoding::DefaultFuchsiaResourceDialect,
6440                0x1cf34fdeed80b4d,
6441            >(_buf?)?;
6442            Ok(_response.map(|x| x))
6443        }
6444        self.client.send_query_and_decode::<
6445            CodecDelayGetCodecLocalDelayRangeRequest,
6446            CodecDelayGetCodecLocalDelayRangeResult,
6447        >(
6448            payload,
6449            0x1cf34fdeed80b4d,
6450            fidl::encoding::DynamicFlags::empty(),
6451            _decode,
6452        )
6453    }
6454
6455    fn r#request_gatt_client(
6456        &self,
6457        mut client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
6458    ) -> Result<(), fidl::Error> {
6459        self.client.send::<ConnectionRequestGattClientRequest>(
6460            (client,),
6461            0x2a670e0fec6ccc6b,
6462            fidl::encoding::DynamicFlags::empty(),
6463        )
6464    }
6465
6466    fn r#accept_cis(&self, mut payload: ConnectionAcceptCisRequest) -> Result<(), fidl::Error> {
6467        self.client.send::<ConnectionAcceptCisRequest>(
6468            &mut payload,
6469            0x7e6338c237088144,
6470            fidl::encoding::DynamicFlags::empty(),
6471        )
6472    }
6473
6474    fn r#connect_l2cap(
6475        &self,
6476        mut payload: ConnectionConnectL2capRequest,
6477    ) -> Result<(), fidl::Error> {
6478        self.client.send::<ConnectionConnectL2capRequest>(
6479            &mut payload,
6480            0x12351316feaebce9,
6481            fidl::encoding::DynamicFlags::empty(),
6482        )
6483    }
6484
6485    type TransferPeriodicAdvertisingSyncResponseFut = fidl::client::QueryResponseFut<
6486        ConnectionTransferPeriodicAdvertisingSyncResult,
6487        fidl::encoding::DefaultFuchsiaResourceDialect,
6488    >;
6489    fn r#transfer_periodic_advertising_sync(
6490        &self,
6491        mut payload: &ConnectionTransferPeriodicAdvertisingSyncRequest,
6492    ) -> Self::TransferPeriodicAdvertisingSyncResponseFut {
6493        fn _decode(
6494            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6495        ) -> Result<ConnectionTransferPeriodicAdvertisingSyncResult, fidl::Error> {
6496            let _response = fidl::client::decode_transaction_body::<
6497                fidl::encoding::ResultType<
6498                    fidl::encoding::EmptyStruct,
6499                    PeriodicAdvertisingSyncTransferError,
6500                >,
6501                fidl::encoding::DefaultFuchsiaResourceDialect,
6502                0x1117a10b5ba1e219,
6503            >(_buf?)?;
6504            Ok(_response.map(|x| x))
6505        }
6506        self.client.send_query_and_decode::<
6507            ConnectionTransferPeriodicAdvertisingSyncRequest,
6508            ConnectionTransferPeriodicAdvertisingSyncResult,
6509        >(
6510            payload,
6511            0x1117a10b5ba1e219,
6512            fidl::encoding::DynamicFlags::empty(),
6513            _decode,
6514        )
6515    }
6516
6517    type AcceptPeriodicAdvertisingSyncTransferResponseFut = fidl::client::QueryResponseFut<
6518        ConnectionAcceptPeriodicAdvertisingSyncTransferResult,
6519        fidl::encoding::DefaultFuchsiaResourceDialect,
6520    >;
6521    fn r#accept_periodic_advertising_sync_transfer(
6522        &self,
6523        mut payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6524    ) -> Self::AcceptPeriodicAdvertisingSyncTransferResponseFut {
6525        fn _decode(
6526            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6527        ) -> Result<ConnectionAcceptPeriodicAdvertisingSyncTransferResult, fidl::Error> {
6528            let _response = fidl::client::decode_transaction_body::<
6529                fidl::encoding::ResultType<
6530                    fidl::encoding::EmptyStruct,
6531                    PeriodicAdvertisingSyncTransferError,
6532                >,
6533                fidl::encoding::DefaultFuchsiaResourceDialect,
6534                0x441a31a7effa7e2b,
6535            >(_buf?)?;
6536            Ok(_response.map(|x| x))
6537        }
6538        self.client.send_query_and_decode::<
6539            ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6540            ConnectionAcceptPeriodicAdvertisingSyncTransferResult,
6541        >(
6542            &mut payload,
6543            0x441a31a7effa7e2b,
6544            fidl::encoding::DynamicFlags::empty(),
6545            _decode,
6546        )
6547    }
6548}
6549
6550pub struct ConnectionEventStream {
6551    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6552}
6553
6554impl std::marker::Unpin for ConnectionEventStream {}
6555
6556impl futures::stream::FusedStream for ConnectionEventStream {
6557    fn is_terminated(&self) -> bool {
6558        self.event_receiver.is_terminated()
6559    }
6560}
6561
6562impl futures::Stream for ConnectionEventStream {
6563    type Item = Result<ConnectionEvent, fidl::Error>;
6564
6565    fn poll_next(
6566        mut self: std::pin::Pin<&mut Self>,
6567        cx: &mut std::task::Context<'_>,
6568    ) -> std::task::Poll<Option<Self::Item>> {
6569        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6570            &mut self.event_receiver,
6571            cx
6572        )?) {
6573            Some(buf) => std::task::Poll::Ready(Some(ConnectionEvent::decode(buf))),
6574            None => std::task::Poll::Ready(None),
6575        }
6576    }
6577}
6578
6579#[derive(Debug)]
6580pub enum ConnectionEvent {}
6581
6582impl ConnectionEvent {
6583    /// Decodes a message buffer as a [`ConnectionEvent`].
6584    fn decode(
6585        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6586    ) -> Result<ConnectionEvent, fidl::Error> {
6587        let (bytes, _handles) = buf.split_mut();
6588        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6589        debug_assert_eq!(tx_header.tx_id, 0);
6590        match tx_header.ordinal {
6591            _ => Err(fidl::Error::UnknownOrdinal {
6592                ordinal: tx_header.ordinal,
6593                protocol_name: <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6594            }),
6595        }
6596    }
6597}
6598
6599/// A Stream of incoming requests for fuchsia.bluetooth.le/Connection.
6600pub struct ConnectionRequestStream {
6601    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6602    is_terminated: bool,
6603}
6604
6605impl std::marker::Unpin for ConnectionRequestStream {}
6606
6607impl futures::stream::FusedStream for ConnectionRequestStream {
6608    fn is_terminated(&self) -> bool {
6609        self.is_terminated
6610    }
6611}
6612
6613impl fidl::endpoints::RequestStream for ConnectionRequestStream {
6614    type Protocol = ConnectionMarker;
6615    type ControlHandle = ConnectionControlHandle;
6616
6617    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6618        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6619    }
6620
6621    fn control_handle(&self) -> Self::ControlHandle {
6622        ConnectionControlHandle { inner: self.inner.clone() }
6623    }
6624
6625    fn into_inner(
6626        self,
6627    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6628    {
6629        (self.inner, self.is_terminated)
6630    }
6631
6632    fn from_inner(
6633        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6634        is_terminated: bool,
6635    ) -> Self {
6636        Self { inner, is_terminated }
6637    }
6638}
6639
6640impl futures::Stream for ConnectionRequestStream {
6641    type Item = Result<ConnectionRequest, fidl::Error>;
6642
6643    fn poll_next(
6644        mut self: std::pin::Pin<&mut Self>,
6645        cx: &mut std::task::Context<'_>,
6646    ) -> std::task::Poll<Option<Self::Item>> {
6647        let this = &mut *self;
6648        if this.inner.check_shutdown(cx) {
6649            this.is_terminated = true;
6650            return std::task::Poll::Ready(None);
6651        }
6652        if this.is_terminated {
6653            panic!("polled ConnectionRequestStream after completion");
6654        }
6655        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6656            |bytes, handles| {
6657                match this.inner.channel().read_etc(cx, bytes, handles) {
6658                    std::task::Poll::Ready(Ok(())) => {}
6659                    std::task::Poll::Pending => return std::task::Poll::Pending,
6660                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6661                        this.is_terminated = true;
6662                        return std::task::Poll::Ready(None);
6663                    }
6664                    std::task::Poll::Ready(Err(e)) => {
6665                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6666                            e.into(),
6667                        ))));
6668                    }
6669                }
6670
6671                // A message has been received from the channel
6672                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6673
6674                std::task::Poll::Ready(Some(match header.ordinal {
6675                    0x1cf34fdeed80b4d => {
6676                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6677                        let mut req = fidl::new_empty!(
6678                            CodecDelayGetCodecLocalDelayRangeRequest,
6679                            fidl::encoding::DefaultFuchsiaResourceDialect
6680                        );
6681                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CodecDelayGetCodecLocalDelayRangeRequest>(&header, _body_bytes, handles, &mut req)?;
6682                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
6683                        Ok(ConnectionRequest::GetCodecLocalDelayRange {
6684                            payload: req,
6685                            responder: ConnectionGetCodecLocalDelayRangeResponder {
6686                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6687                                tx_id: header.tx_id,
6688                            },
6689                        })
6690                    }
6691                    0x2a670e0fec6ccc6b => {
6692                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6693                        let mut req = fidl::new_empty!(
6694                            ConnectionRequestGattClientRequest,
6695                            fidl::encoding::DefaultFuchsiaResourceDialect
6696                        );
6697                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionRequestGattClientRequest>(&header, _body_bytes, handles, &mut req)?;
6698                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
6699                        Ok(ConnectionRequest::RequestGattClient {
6700                            client: req.client,
6701
6702                            control_handle,
6703                        })
6704                    }
6705                    0x7e6338c237088144 => {
6706                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6707                        let mut req = fidl::new_empty!(
6708                            ConnectionAcceptCisRequest,
6709                            fidl::encoding::DefaultFuchsiaResourceDialect
6710                        );
6711                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionAcceptCisRequest>(&header, _body_bytes, handles, &mut req)?;
6712                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
6713                        Ok(ConnectionRequest::AcceptCis { payload: req, control_handle })
6714                    }
6715                    0x12351316feaebce9 => {
6716                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6717                        let mut req = fidl::new_empty!(
6718                            ConnectionConnectL2capRequest,
6719                            fidl::encoding::DefaultFuchsiaResourceDialect
6720                        );
6721                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionConnectL2capRequest>(&header, _body_bytes, handles, &mut req)?;
6722                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
6723                        Ok(ConnectionRequest::ConnectL2cap { payload: req, control_handle })
6724                    }
6725                    0x1117a10b5ba1e219 => {
6726                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6727                        let mut req = fidl::new_empty!(
6728                            ConnectionTransferPeriodicAdvertisingSyncRequest,
6729                            fidl::encoding::DefaultFuchsiaResourceDialect
6730                        );
6731                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionTransferPeriodicAdvertisingSyncRequest>(&header, _body_bytes, handles, &mut req)?;
6732                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
6733                        Ok(ConnectionRequest::TransferPeriodicAdvertisingSync {
6734                            payload: req,
6735                            responder: ConnectionTransferPeriodicAdvertisingSyncResponder {
6736                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6737                                tx_id: header.tx_id,
6738                            },
6739                        })
6740                    }
6741                    0x441a31a7effa7e2b => {
6742                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6743                        let mut req = fidl::new_empty!(
6744                            ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6745                            fidl::encoding::DefaultFuchsiaResourceDialect
6746                        );
6747                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectionAcceptPeriodicAdvertisingSyncTransferRequest>(&header, _body_bytes, handles, &mut req)?;
6748                        let control_handle = ConnectionControlHandle { inner: this.inner.clone() };
6749                        Ok(ConnectionRequest::AcceptPeriodicAdvertisingSyncTransfer {
6750                            payload: req,
6751                            responder: ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
6752                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6753                                tx_id: header.tx_id,
6754                            },
6755                        })
6756                    }
6757                    _ => Err(fidl::Error::UnknownOrdinal {
6758                        ordinal: header.ordinal,
6759                        protocol_name:
6760                            <ConnectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6761                    }),
6762                }))
6763            },
6764        )
6765    }
6766}
6767
6768/// Protocol that represents the connection to a peer. This can be used to interact with GATT
6769/// services and establish L2CAP channels.
6770///
6771/// This lifetime of this capability is tied to that of the LE connection it represents. Closing the
6772/// channel results in a disconnection if no other clients hold a Connection to the same peer.
6773#[derive(Debug)]
6774pub enum ConnectionRequest {
6775    /// Retrieve the range of controller delay for the codec specified with the provided stream
6776    /// attributes.
6777    ///
6778    /// On success, returns the minimum and maximum allowed delay.
6779    ///
6780    /// Returns ZX_ERR_NOT_SUPPORTED if reading the delay is not supported.
6781    /// Returns ZX_ERR_INTERNAL for all other failures.
6782    GetCodecLocalDelayRange {
6783        payload: CodecDelayGetCodecLocalDelayRangeRequest,
6784        responder: ConnectionGetCodecLocalDelayRangeResponder,
6785    },
6786    /// The following epitaphs may be sent by the server on error:
6787    /// + `ZX_ERR_ALREADY_BOUND`: A Client server has already been bound in this Connection
6788    ///                           protocol. The existing Client should be used.
6789    RequestGattClient {
6790        client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
6791        control_handle: ConnectionControlHandle,
6792    },
6793    /// Accept a future CIS request from the peer with the specified CIG/CIS values. All
6794    /// CIS requests that have not explicitly been allowed will be rejected.
6795    ///
6796    /// The provided IsochronousStream will be used for future notification of established
6797    /// connections.
6798    ///
6799    /// The host may wait for multiple incoming connections simultaneously, although each
6800    /// must have a combination of CIG/CIS values that is unique to this connection.
6801    ///
6802    /// If we are not operating in the peripheral role in this connection, connection_stream
6803    /// will be closed with a ZX_ERR_NOT_SUPPORTED epitaph.
6804    ///
6805    /// If we are already waiting for another connection with the same combination of CIG/CIS
6806    /// values, connection_stream will be closed with a ZX_ERR_INVALID_ARGS epitaph.
6807    AcceptCis { payload: ConnectionAcceptCisRequest, control_handle: ConnectionControlHandle },
6808    /// Connect to an L2CAP LE connection-oriented channel.
6809    ConnectL2cap { payload: ConnectionConnectL2capRequest, control_handle: ConnectionControlHandle },
6810    /// Send synchronization information for a periodic advertising train identified by `sync_id` to
6811    /// the connected peer.
6812    TransferPeriodicAdvertisingSync {
6813        payload: ConnectionTransferPeriodicAdvertisingSyncRequest,
6814        responder: ConnectionTransferPeriodicAdvertisingSyncResponder,
6815    },
6816    /// Accept the next Periodic Advertising Sync Transfer from the peer. A response will be sent
6817    /// when the host is ready to accept the transfer. Only one request can be pending at a time.
6818    AcceptPeriodicAdvertisingSyncTransfer {
6819        payload: ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6820        responder: ConnectionAcceptPeriodicAdvertisingSyncTransferResponder,
6821    },
6822}
6823
6824impl ConnectionRequest {
6825    #[allow(irrefutable_let_patterns)]
6826    pub fn into_get_codec_local_delay_range(
6827        self,
6828    ) -> Option<(
6829        CodecDelayGetCodecLocalDelayRangeRequest,
6830        ConnectionGetCodecLocalDelayRangeResponder,
6831    )> {
6832        if let ConnectionRequest::GetCodecLocalDelayRange { payload, responder } = self {
6833            Some((payload, responder))
6834        } else {
6835            None
6836        }
6837    }
6838
6839    #[allow(irrefutable_let_patterns)]
6840    pub fn into_request_gatt_client(
6841        self,
6842    ) -> Option<(
6843        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
6844        ConnectionControlHandle,
6845    )> {
6846        if let ConnectionRequest::RequestGattClient { client, control_handle } = self {
6847            Some((client, control_handle))
6848        } else {
6849            None
6850        }
6851    }
6852
6853    #[allow(irrefutable_let_patterns)]
6854    pub fn into_accept_cis(self) -> Option<(ConnectionAcceptCisRequest, ConnectionControlHandle)> {
6855        if let ConnectionRequest::AcceptCis { payload, control_handle } = self {
6856            Some((payload, control_handle))
6857        } else {
6858            None
6859        }
6860    }
6861
6862    #[allow(irrefutable_let_patterns)]
6863    pub fn into_connect_l2cap(
6864        self,
6865    ) -> Option<(ConnectionConnectL2capRequest, ConnectionControlHandle)> {
6866        if let ConnectionRequest::ConnectL2cap { payload, control_handle } = self {
6867            Some((payload, control_handle))
6868        } else {
6869            None
6870        }
6871    }
6872
6873    #[allow(irrefutable_let_patterns)]
6874    pub fn into_transfer_periodic_advertising_sync(
6875        self,
6876    ) -> Option<(
6877        ConnectionTransferPeriodicAdvertisingSyncRequest,
6878        ConnectionTransferPeriodicAdvertisingSyncResponder,
6879    )> {
6880        if let ConnectionRequest::TransferPeriodicAdvertisingSync { payload, responder } = self {
6881            Some((payload, responder))
6882        } else {
6883            None
6884        }
6885    }
6886
6887    #[allow(irrefutable_let_patterns)]
6888    pub fn into_accept_periodic_advertising_sync_transfer(
6889        self,
6890    ) -> Option<(
6891        ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
6892        ConnectionAcceptPeriodicAdvertisingSyncTransferResponder,
6893    )> {
6894        if let ConnectionRequest::AcceptPeriodicAdvertisingSyncTransfer { payload, responder } =
6895            self
6896        {
6897            Some((payload, responder))
6898        } else {
6899            None
6900        }
6901    }
6902
6903    /// Name of the method defined in FIDL
6904    pub fn method_name(&self) -> &'static str {
6905        match *self {
6906            ConnectionRequest::GetCodecLocalDelayRange { .. } => "get_codec_local_delay_range",
6907            ConnectionRequest::RequestGattClient { .. } => "request_gatt_client",
6908            ConnectionRequest::AcceptCis { .. } => "accept_cis",
6909            ConnectionRequest::ConnectL2cap { .. } => "connect_l2cap",
6910            ConnectionRequest::TransferPeriodicAdvertisingSync { .. } => {
6911                "transfer_periodic_advertising_sync"
6912            }
6913            ConnectionRequest::AcceptPeriodicAdvertisingSyncTransfer { .. } => {
6914                "accept_periodic_advertising_sync_transfer"
6915            }
6916        }
6917    }
6918}
6919
6920#[derive(Debug, Clone)]
6921pub struct ConnectionControlHandle {
6922    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6923}
6924
6925impl fidl::endpoints::ControlHandle for ConnectionControlHandle {
6926    fn shutdown(&self) {
6927        self.inner.shutdown()
6928    }
6929
6930    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6931        self.inner.shutdown_with_epitaph(status)
6932    }
6933
6934    fn is_closed(&self) -> bool {
6935        self.inner.channel().is_closed()
6936    }
6937    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6938        self.inner.channel().on_closed()
6939    }
6940
6941    #[cfg(target_os = "fuchsia")]
6942    fn signal_peer(
6943        &self,
6944        clear_mask: zx::Signals,
6945        set_mask: zx::Signals,
6946    ) -> Result<(), zx_status::Status> {
6947        use fidl::Peered;
6948        self.inner.channel().signal_peer(clear_mask, set_mask)
6949    }
6950}
6951
6952impl ConnectionControlHandle {}
6953
6954#[must_use = "FIDL methods require a response to be sent"]
6955#[derive(Debug)]
6956pub struct ConnectionGetCodecLocalDelayRangeResponder {
6957    control_handle: std::mem::ManuallyDrop<ConnectionControlHandle>,
6958    tx_id: u32,
6959}
6960
6961/// Set the the channel to be shutdown (see [`ConnectionControlHandle::shutdown`])
6962/// if the responder is dropped without sending a response, so that the client
6963/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6964impl std::ops::Drop for ConnectionGetCodecLocalDelayRangeResponder {
6965    fn drop(&mut self) {
6966        self.control_handle.shutdown();
6967        // Safety: drops once, never accessed again
6968        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6969    }
6970}
6971
6972impl fidl::endpoints::Responder for ConnectionGetCodecLocalDelayRangeResponder {
6973    type ControlHandle = ConnectionControlHandle;
6974
6975    fn control_handle(&self) -> &ConnectionControlHandle {
6976        &self.control_handle
6977    }
6978
6979    fn drop_without_shutdown(mut self) {
6980        // Safety: drops once, never accessed again due to mem::forget
6981        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6982        // Prevent Drop from running (which would shut down the channel)
6983        std::mem::forget(self);
6984    }
6985}
6986
6987impl ConnectionGetCodecLocalDelayRangeResponder {
6988    /// Sends a response to the FIDL transaction.
6989    ///
6990    /// Sets the channel to shutdown if an error occurs.
6991    pub fn send(
6992        self,
6993        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
6994    ) -> Result<(), fidl::Error> {
6995        let _result = self.send_raw(result);
6996        if _result.is_err() {
6997            self.control_handle.shutdown();
6998        }
6999        self.drop_without_shutdown();
7000        _result
7001    }
7002
7003    /// Similar to "send" but does not shutdown the channel if an error occurs.
7004    pub fn send_no_shutdown_on_err(
7005        self,
7006        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
7007    ) -> Result<(), fidl::Error> {
7008        let _result = self.send_raw(result);
7009        self.drop_without_shutdown();
7010        _result
7011    }
7012
7013    fn send_raw(
7014        &self,
7015        mut result: Result<&CodecDelayGetCodecLocalDelayRangeResponse, i32>,
7016    ) -> Result<(), fidl::Error> {
7017        self.control_handle.inner.send::<fidl::encoding::ResultType<
7018            CodecDelayGetCodecLocalDelayRangeResponse,
7019            i32,
7020        >>(
7021            result,
7022            self.tx_id,
7023            0x1cf34fdeed80b4d,
7024            fidl::encoding::DynamicFlags::empty(),
7025        )
7026    }
7027}
7028
7029#[must_use = "FIDL methods require a response to be sent"]
7030#[derive(Debug)]
7031pub struct ConnectionTransferPeriodicAdvertisingSyncResponder {
7032    control_handle: std::mem::ManuallyDrop<ConnectionControlHandle>,
7033    tx_id: u32,
7034}
7035
7036/// Set the the channel to be shutdown (see [`ConnectionControlHandle::shutdown`])
7037/// if the responder is dropped without sending a response, so that the client
7038/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7039impl std::ops::Drop for ConnectionTransferPeriodicAdvertisingSyncResponder {
7040    fn drop(&mut self) {
7041        self.control_handle.shutdown();
7042        // Safety: drops once, never accessed again
7043        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7044    }
7045}
7046
7047impl fidl::endpoints::Responder for ConnectionTransferPeriodicAdvertisingSyncResponder {
7048    type ControlHandle = ConnectionControlHandle;
7049
7050    fn control_handle(&self) -> &ConnectionControlHandle {
7051        &self.control_handle
7052    }
7053
7054    fn drop_without_shutdown(mut self) {
7055        // Safety: drops once, never accessed again due to mem::forget
7056        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7057        // Prevent Drop from running (which would shut down the channel)
7058        std::mem::forget(self);
7059    }
7060}
7061
7062impl ConnectionTransferPeriodicAdvertisingSyncResponder {
7063    /// Sends a response to the FIDL transaction.
7064    ///
7065    /// Sets the channel to shutdown if an error occurs.
7066    pub fn send(
7067        self,
7068        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
7069    ) -> Result<(), fidl::Error> {
7070        let _result = self.send_raw(result);
7071        if _result.is_err() {
7072            self.control_handle.shutdown();
7073        }
7074        self.drop_without_shutdown();
7075        _result
7076    }
7077
7078    /// Similar to "send" but does not shutdown the channel if an error occurs.
7079    pub fn send_no_shutdown_on_err(
7080        self,
7081        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
7082    ) -> Result<(), fidl::Error> {
7083        let _result = self.send_raw(result);
7084        self.drop_without_shutdown();
7085        _result
7086    }
7087
7088    fn send_raw(
7089        &self,
7090        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
7091    ) -> Result<(), fidl::Error> {
7092        self.control_handle.inner.send::<fidl::encoding::ResultType<
7093            fidl::encoding::EmptyStruct,
7094            PeriodicAdvertisingSyncTransferError,
7095        >>(
7096            result,
7097            self.tx_id,
7098            0x1117a10b5ba1e219,
7099            fidl::encoding::DynamicFlags::empty(),
7100        )
7101    }
7102}
7103
7104#[must_use = "FIDL methods require a response to be sent"]
7105#[derive(Debug)]
7106pub struct ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
7107    control_handle: std::mem::ManuallyDrop<ConnectionControlHandle>,
7108    tx_id: u32,
7109}
7110
7111/// Set the the channel to be shutdown (see [`ConnectionControlHandle::shutdown`])
7112/// if the responder is dropped without sending a response, so that the client
7113/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7114impl std::ops::Drop for ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
7115    fn drop(&mut self) {
7116        self.control_handle.shutdown();
7117        // Safety: drops once, never accessed again
7118        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7119    }
7120}
7121
7122impl fidl::endpoints::Responder for ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
7123    type ControlHandle = ConnectionControlHandle;
7124
7125    fn control_handle(&self) -> &ConnectionControlHandle {
7126        &self.control_handle
7127    }
7128
7129    fn drop_without_shutdown(mut self) {
7130        // Safety: drops once, never accessed again due to mem::forget
7131        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7132        // Prevent Drop from running (which would shut down the channel)
7133        std::mem::forget(self);
7134    }
7135}
7136
7137impl ConnectionAcceptPeriodicAdvertisingSyncTransferResponder {
7138    /// Sends a response to the FIDL transaction.
7139    ///
7140    /// Sets the channel to shutdown if an error occurs.
7141    pub fn send(
7142        self,
7143        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
7144    ) -> Result<(), fidl::Error> {
7145        let _result = self.send_raw(result);
7146        if _result.is_err() {
7147            self.control_handle.shutdown();
7148        }
7149        self.drop_without_shutdown();
7150        _result
7151    }
7152
7153    /// Similar to "send" but does not shutdown the channel if an error occurs.
7154    pub fn send_no_shutdown_on_err(
7155        self,
7156        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
7157    ) -> Result<(), fidl::Error> {
7158        let _result = self.send_raw(result);
7159        self.drop_without_shutdown();
7160        _result
7161    }
7162
7163    fn send_raw(
7164        &self,
7165        mut result: Result<(), PeriodicAdvertisingSyncTransferError>,
7166    ) -> Result<(), fidl::Error> {
7167        self.control_handle.inner.send::<fidl::encoding::ResultType<
7168            fidl::encoding::EmptyStruct,
7169            PeriodicAdvertisingSyncTransferError,
7170        >>(
7171            result,
7172            self.tx_id,
7173            0x441a31a7effa7e2b,
7174            fidl::encoding::DynamicFlags::empty(),
7175        )
7176    }
7177}
7178
7179#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7180pub struct IsochronousStreamMarker;
7181
7182impl fidl::endpoints::ProtocolMarker for IsochronousStreamMarker {
7183    type Proxy = IsochronousStreamProxy;
7184    type RequestStream = IsochronousStreamRequestStream;
7185    #[cfg(target_os = "fuchsia")]
7186    type SynchronousProxy = IsochronousStreamSynchronousProxy;
7187
7188    const DEBUG_NAME: &'static str = "(anonymous) IsochronousStream";
7189}
7190pub type IsochronousStreamSetupDataPathResult = Result<(), i32>;
7191pub type IsochronousStreamWriteResult = Result<(), i32>;
7192
7193pub trait IsochronousStreamProxyInterface: Send + Sync {
7194    type SetupDataPathResponseFut: std::future::Future<Output = Result<IsochronousStreamSetupDataPathResult, fidl::Error>>
7195        + Send;
7196    fn r#setup_data_path(
7197        &self,
7198        payload: &IsochronousStreamSetupDataPathRequest,
7199    ) -> Self::SetupDataPathResponseFut;
7200    type ReadResponseFut: std::future::Future<Output = Result<IsochronousStreamReadResponse, fidl::Error>>
7201        + Send;
7202    fn r#read(&self) -> Self::ReadResponseFut;
7203    type WriteResponseFut: std::future::Future<Output = Result<IsochronousStreamWriteResult, fidl::Error>>
7204        + Send;
7205    fn r#write(&self, payload: &IsochronousStreamWriteRequest) -> Self::WriteResponseFut;
7206}
7207#[derive(Debug)]
7208#[cfg(target_os = "fuchsia")]
7209pub struct IsochronousStreamSynchronousProxy {
7210    client: fidl::client::sync::Client,
7211}
7212
7213#[cfg(target_os = "fuchsia")]
7214impl fidl::endpoints::SynchronousProxy for IsochronousStreamSynchronousProxy {
7215    type Proxy = IsochronousStreamProxy;
7216    type Protocol = IsochronousStreamMarker;
7217
7218    fn from_channel(inner: fidl::Channel) -> Self {
7219        Self::new(inner)
7220    }
7221
7222    fn into_channel(self) -> fidl::Channel {
7223        self.client.into_channel()
7224    }
7225
7226    fn as_channel(&self) -> &fidl::Channel {
7227        self.client.as_channel()
7228    }
7229}
7230
7231#[cfg(target_os = "fuchsia")]
7232impl IsochronousStreamSynchronousProxy {
7233    pub fn new(channel: fidl::Channel) -> Self {
7234        Self { client: fidl::client::sync::Client::new(channel) }
7235    }
7236
7237    pub fn into_channel(self) -> fidl::Channel {
7238        self.client.into_channel()
7239    }
7240
7241    /// Waits until an event arrives and returns it. It is safe for other
7242    /// threads to make concurrent requests while waiting for an event.
7243    pub fn wait_for_event(
7244        &self,
7245        deadline: zx::MonotonicInstant,
7246    ) -> Result<IsochronousStreamEvent, fidl::Error> {
7247        IsochronousStreamEvent::decode(
7248            self.client.wait_for_event::<IsochronousStreamMarker>(deadline)?,
7249        )
7250    }
7251
7252    /// Create an isochronous data path with the specified parameters. Only in-band (HCI) ISO
7253    /// transport is currently supported.
7254    ///
7255    /// Returns ZX_ERR_ALREADY_EXISTS if a ISO stream has already been created for this
7256    /// direction.
7257    ///
7258    /// Returns ZX_ERR_BAD_STATE if issued on a peripheral before a CIS request has been
7259    /// accepted.
7260    ///
7261    /// Returns ZX_ERR_INVALID_ARGS if the codec arguments are invalid or outside of the
7262    /// controller's supported range.
7263    pub fn r#setup_data_path(
7264        &self,
7265        mut payload: &IsochronousStreamSetupDataPathRequest,
7266        ___deadline: zx::MonotonicInstant,
7267    ) -> Result<IsochronousStreamSetupDataPathResult, fidl::Error> {
7268        let _response = self.client.send_query::<
7269            IsochronousStreamSetupDataPathRequest,
7270            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
7271            IsochronousStreamMarker,
7272        >(
7273            payload,
7274            0x7ec1e2b9cc6d2fbe,
7275            fidl::encoding::DynamicFlags::FLEXIBLE,
7276            ___deadline,
7277        )?
7278        .into_result::<IsochronousStreamMarker>("setup_data_path")?;
7279        Ok(_response.map(|x| x))
7280    }
7281
7282    /// Receive data from an output (controller => host) ISO stream that has been established and
7283    /// set up. Designed to be used with a hanging get pattern.
7284    ///
7285    /// Can be invoked before the ISO data stream has been established and set up, but will not
7286    /// return until after it has been set up and data has been received.
7287    pub fn r#read(
7288        &self,
7289        ___deadline: zx::MonotonicInstant,
7290    ) -> Result<IsochronousStreamReadResponse, fidl::Error> {
7291        let _response = self.client.send_query::<
7292            fidl::encoding::EmptyPayload,
7293            fidl::encoding::FlexibleType<IsochronousStreamReadResponse>,
7294            IsochronousStreamMarker,
7295        >(
7296            (),
7297            0x6d7d8b4950ed3a32,
7298            fidl::encoding::DynamicFlags::FLEXIBLE,
7299            ___deadline,
7300        )?
7301        .into_result::<IsochronousStreamMarker>("read")?;
7302        Ok(_response)
7303    }
7304
7305    /// Send data to an established ISO stream (host => controller).
7306    ///
7307    /// Returns ZX_ERR_INTERNAL for any errors encountered.
7308    pub fn r#write(
7309        &self,
7310        mut payload: &IsochronousStreamWriteRequest,
7311        ___deadline: zx::MonotonicInstant,
7312    ) -> Result<IsochronousStreamWriteResult, fidl::Error> {
7313        let _response = self.client.send_query::<
7314            IsochronousStreamWriteRequest,
7315            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
7316            IsochronousStreamMarker,
7317        >(
7318            payload,
7319            0x5282e90b667d0d43,
7320            fidl::encoding::DynamicFlags::FLEXIBLE,
7321            ___deadline,
7322        )?
7323        .into_result::<IsochronousStreamMarker>("write")?;
7324        Ok(_response.map(|x| x))
7325    }
7326}
7327
7328#[cfg(target_os = "fuchsia")]
7329impl From<IsochronousStreamSynchronousProxy> for zx::NullableHandle {
7330    fn from(value: IsochronousStreamSynchronousProxy) -> Self {
7331        value.into_channel().into()
7332    }
7333}
7334
7335#[cfg(target_os = "fuchsia")]
7336impl From<fidl::Channel> for IsochronousStreamSynchronousProxy {
7337    fn from(value: fidl::Channel) -> Self {
7338        Self::new(value)
7339    }
7340}
7341
7342#[cfg(target_os = "fuchsia")]
7343impl fidl::endpoints::FromClient for IsochronousStreamSynchronousProxy {
7344    type Protocol = IsochronousStreamMarker;
7345
7346    fn from_client(value: fidl::endpoints::ClientEnd<IsochronousStreamMarker>) -> Self {
7347        Self::new(value.into_channel())
7348    }
7349}
7350
7351#[derive(Debug, Clone)]
7352pub struct IsochronousStreamProxy {
7353    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7354}
7355
7356impl fidl::endpoints::Proxy for IsochronousStreamProxy {
7357    type Protocol = IsochronousStreamMarker;
7358
7359    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7360        Self::new(inner)
7361    }
7362
7363    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7364        self.client.into_channel().map_err(|client| Self { client })
7365    }
7366
7367    fn as_channel(&self) -> &::fidl::AsyncChannel {
7368        self.client.as_channel()
7369    }
7370}
7371
7372impl IsochronousStreamProxy {
7373    /// Create a new Proxy for fuchsia.bluetooth.le/IsochronousStream.
7374    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7375        let protocol_name =
7376            <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7377        Self { client: fidl::client::Client::new(channel, protocol_name) }
7378    }
7379
7380    /// Get a Stream of events from the remote end of the protocol.
7381    ///
7382    /// # Panics
7383    ///
7384    /// Panics if the event stream was already taken.
7385    pub fn take_event_stream(&self) -> IsochronousStreamEventStream {
7386        IsochronousStreamEventStream { event_receiver: self.client.take_event_receiver() }
7387    }
7388
7389    /// Create an isochronous data path with the specified parameters. Only in-band (HCI) ISO
7390    /// transport is currently supported.
7391    ///
7392    /// Returns ZX_ERR_ALREADY_EXISTS if a ISO stream has already been created for this
7393    /// direction.
7394    ///
7395    /// Returns ZX_ERR_BAD_STATE if issued on a peripheral before a CIS request has been
7396    /// accepted.
7397    ///
7398    /// Returns ZX_ERR_INVALID_ARGS if the codec arguments are invalid or outside of the
7399    /// controller's supported range.
7400    pub fn r#setup_data_path(
7401        &self,
7402        mut payload: &IsochronousStreamSetupDataPathRequest,
7403    ) -> fidl::client::QueryResponseFut<
7404        IsochronousStreamSetupDataPathResult,
7405        fidl::encoding::DefaultFuchsiaResourceDialect,
7406    > {
7407        IsochronousStreamProxyInterface::r#setup_data_path(self, payload)
7408    }
7409
7410    /// Receive data from an output (controller => host) ISO stream that has been established and
7411    /// set up. Designed to be used with a hanging get pattern.
7412    ///
7413    /// Can be invoked before the ISO data stream has been established and set up, but will not
7414    /// return until after it has been set up and data has been received.
7415    pub fn r#read(
7416        &self,
7417    ) -> fidl::client::QueryResponseFut<
7418        IsochronousStreamReadResponse,
7419        fidl::encoding::DefaultFuchsiaResourceDialect,
7420    > {
7421        IsochronousStreamProxyInterface::r#read(self)
7422    }
7423
7424    /// Send data to an established ISO stream (host => controller).
7425    ///
7426    /// Returns ZX_ERR_INTERNAL for any errors encountered.
7427    pub fn r#write(
7428        &self,
7429        mut payload: &IsochronousStreamWriteRequest,
7430    ) -> fidl::client::QueryResponseFut<
7431        IsochronousStreamWriteResult,
7432        fidl::encoding::DefaultFuchsiaResourceDialect,
7433    > {
7434        IsochronousStreamProxyInterface::r#write(self, payload)
7435    }
7436}
7437
7438impl IsochronousStreamProxyInterface for IsochronousStreamProxy {
7439    type SetupDataPathResponseFut = fidl::client::QueryResponseFut<
7440        IsochronousStreamSetupDataPathResult,
7441        fidl::encoding::DefaultFuchsiaResourceDialect,
7442    >;
7443    fn r#setup_data_path(
7444        &self,
7445        mut payload: &IsochronousStreamSetupDataPathRequest,
7446    ) -> Self::SetupDataPathResponseFut {
7447        fn _decode(
7448            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7449        ) -> Result<IsochronousStreamSetupDataPathResult, fidl::Error> {
7450            let _response = fidl::client::decode_transaction_body::<
7451                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
7452                fidl::encoding::DefaultFuchsiaResourceDialect,
7453                0x7ec1e2b9cc6d2fbe,
7454            >(_buf?)?
7455            .into_result::<IsochronousStreamMarker>("setup_data_path")?;
7456            Ok(_response.map(|x| x))
7457        }
7458        self.client.send_query_and_decode::<
7459            IsochronousStreamSetupDataPathRequest,
7460            IsochronousStreamSetupDataPathResult,
7461        >(
7462            payload,
7463            0x7ec1e2b9cc6d2fbe,
7464            fidl::encoding::DynamicFlags::FLEXIBLE,
7465            _decode,
7466        )
7467    }
7468
7469    type ReadResponseFut = fidl::client::QueryResponseFut<
7470        IsochronousStreamReadResponse,
7471        fidl::encoding::DefaultFuchsiaResourceDialect,
7472    >;
7473    fn r#read(&self) -> Self::ReadResponseFut {
7474        fn _decode(
7475            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7476        ) -> Result<IsochronousStreamReadResponse, fidl::Error> {
7477            let _response = fidl::client::decode_transaction_body::<
7478                fidl::encoding::FlexibleType<IsochronousStreamReadResponse>,
7479                fidl::encoding::DefaultFuchsiaResourceDialect,
7480                0x6d7d8b4950ed3a32,
7481            >(_buf?)?
7482            .into_result::<IsochronousStreamMarker>("read")?;
7483            Ok(_response)
7484        }
7485        self.client
7486            .send_query_and_decode::<fidl::encoding::EmptyPayload, IsochronousStreamReadResponse>(
7487                (),
7488                0x6d7d8b4950ed3a32,
7489                fidl::encoding::DynamicFlags::FLEXIBLE,
7490                _decode,
7491            )
7492    }
7493
7494    type WriteResponseFut = fidl::client::QueryResponseFut<
7495        IsochronousStreamWriteResult,
7496        fidl::encoding::DefaultFuchsiaResourceDialect,
7497    >;
7498    fn r#write(&self, mut payload: &IsochronousStreamWriteRequest) -> Self::WriteResponseFut {
7499        fn _decode(
7500            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7501        ) -> Result<IsochronousStreamWriteResult, fidl::Error> {
7502            let _response = fidl::client::decode_transaction_body::<
7503                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
7504                fidl::encoding::DefaultFuchsiaResourceDialect,
7505                0x5282e90b667d0d43,
7506            >(_buf?)?
7507            .into_result::<IsochronousStreamMarker>("write")?;
7508            Ok(_response.map(|x| x))
7509        }
7510        self.client
7511            .send_query_and_decode::<IsochronousStreamWriteRequest, IsochronousStreamWriteResult>(
7512                payload,
7513                0x5282e90b667d0d43,
7514                fidl::encoding::DynamicFlags::FLEXIBLE,
7515                _decode,
7516            )
7517    }
7518}
7519
7520pub struct IsochronousStreamEventStream {
7521    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7522}
7523
7524impl std::marker::Unpin for IsochronousStreamEventStream {}
7525
7526impl futures::stream::FusedStream for IsochronousStreamEventStream {
7527    fn is_terminated(&self) -> bool {
7528        self.event_receiver.is_terminated()
7529    }
7530}
7531
7532impl futures::Stream for IsochronousStreamEventStream {
7533    type Item = Result<IsochronousStreamEvent, fidl::Error>;
7534
7535    fn poll_next(
7536        mut self: std::pin::Pin<&mut Self>,
7537        cx: &mut std::task::Context<'_>,
7538    ) -> std::task::Poll<Option<Self::Item>> {
7539        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7540            &mut self.event_receiver,
7541            cx
7542        )?) {
7543            Some(buf) => std::task::Poll::Ready(Some(IsochronousStreamEvent::decode(buf))),
7544            None => std::task::Poll::Ready(None),
7545        }
7546    }
7547}
7548
7549#[derive(Debug)]
7550pub enum IsochronousStreamEvent {
7551    OnEstablished {
7552        payload: IsochronousStreamOnEstablishedRequest,
7553    },
7554    #[non_exhaustive]
7555    _UnknownEvent {
7556        /// Ordinal of the event that was sent.
7557        ordinal: u64,
7558    },
7559}
7560
7561impl IsochronousStreamEvent {
7562    #[allow(irrefutable_let_patterns)]
7563    pub fn into_on_established(self) -> Option<IsochronousStreamOnEstablishedRequest> {
7564        if let IsochronousStreamEvent::OnEstablished { payload } = self {
7565            Some((payload))
7566        } else {
7567            None
7568        }
7569    }
7570
7571    /// Decodes a message buffer as a [`IsochronousStreamEvent`].
7572    fn decode(
7573        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7574    ) -> Result<IsochronousStreamEvent, fidl::Error> {
7575        let (bytes, _handles) = buf.split_mut();
7576        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7577        debug_assert_eq!(tx_header.tx_id, 0);
7578        match tx_header.ordinal {
7579            0x341c50e9d10f3421 => {
7580                let mut out = fidl::new_empty!(
7581                    IsochronousStreamOnEstablishedRequest,
7582                    fidl::encoding::DefaultFuchsiaResourceDialect
7583                );
7584                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IsochronousStreamOnEstablishedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7585                Ok((IsochronousStreamEvent::OnEstablished { payload: out }))
7586            }
7587            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7588                Ok(IsochronousStreamEvent::_UnknownEvent { ordinal: tx_header.ordinal })
7589            }
7590            _ => Err(fidl::Error::UnknownOrdinal {
7591                ordinal: tx_header.ordinal,
7592                protocol_name:
7593                    <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7594            }),
7595        }
7596    }
7597}
7598
7599/// A Stream of incoming requests for fuchsia.bluetooth.le/IsochronousStream.
7600pub struct IsochronousStreamRequestStream {
7601    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7602    is_terminated: bool,
7603}
7604
7605impl std::marker::Unpin for IsochronousStreamRequestStream {}
7606
7607impl futures::stream::FusedStream for IsochronousStreamRequestStream {
7608    fn is_terminated(&self) -> bool {
7609        self.is_terminated
7610    }
7611}
7612
7613impl fidl::endpoints::RequestStream for IsochronousStreamRequestStream {
7614    type Protocol = IsochronousStreamMarker;
7615    type ControlHandle = IsochronousStreamControlHandle;
7616
7617    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7618        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7619    }
7620
7621    fn control_handle(&self) -> Self::ControlHandle {
7622        IsochronousStreamControlHandle { inner: self.inner.clone() }
7623    }
7624
7625    fn into_inner(
7626        self,
7627    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7628    {
7629        (self.inner, self.is_terminated)
7630    }
7631
7632    fn from_inner(
7633        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7634        is_terminated: bool,
7635    ) -> Self {
7636        Self { inner, is_terminated }
7637    }
7638}
7639
7640impl futures::Stream for IsochronousStreamRequestStream {
7641    type Item = Result<IsochronousStreamRequest, fidl::Error>;
7642
7643    fn poll_next(
7644        mut self: std::pin::Pin<&mut Self>,
7645        cx: &mut std::task::Context<'_>,
7646    ) -> std::task::Poll<Option<Self::Item>> {
7647        let this = &mut *self;
7648        if this.inner.check_shutdown(cx) {
7649            this.is_terminated = true;
7650            return std::task::Poll::Ready(None);
7651        }
7652        if this.is_terminated {
7653            panic!("polled IsochronousStreamRequestStream after completion");
7654        }
7655        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7656            |bytes, handles| {
7657                match this.inner.channel().read_etc(cx, bytes, handles) {
7658                    std::task::Poll::Ready(Ok(())) => {}
7659                    std::task::Poll::Pending => return std::task::Poll::Pending,
7660                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7661                        this.is_terminated = true;
7662                        return std::task::Poll::Ready(None);
7663                    }
7664                    std::task::Poll::Ready(Err(e)) => {
7665                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7666                            e.into(),
7667                        ))));
7668                    }
7669                }
7670
7671                // A message has been received from the channel
7672                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7673
7674                std::task::Poll::Ready(Some(match header.ordinal {
7675                    0x7ec1e2b9cc6d2fbe => {
7676                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7677                        let mut req = fidl::new_empty!(
7678                            IsochronousStreamSetupDataPathRequest,
7679                            fidl::encoding::DefaultFuchsiaResourceDialect
7680                        );
7681                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IsochronousStreamSetupDataPathRequest>(&header, _body_bytes, handles, &mut req)?;
7682                        let control_handle =
7683                            IsochronousStreamControlHandle { inner: this.inner.clone() };
7684                        Ok(IsochronousStreamRequest::SetupDataPath {
7685                            payload: req,
7686                            responder: IsochronousStreamSetupDataPathResponder {
7687                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7688                                tx_id: header.tx_id,
7689                            },
7690                        })
7691                    }
7692                    0x6d7d8b4950ed3a32 => {
7693                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7694                        let mut req = fidl::new_empty!(
7695                            fidl::encoding::EmptyPayload,
7696                            fidl::encoding::DefaultFuchsiaResourceDialect
7697                        );
7698                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7699                        let control_handle =
7700                            IsochronousStreamControlHandle { inner: this.inner.clone() };
7701                        Ok(IsochronousStreamRequest::Read {
7702                            responder: IsochronousStreamReadResponder {
7703                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7704                                tx_id: header.tx_id,
7705                            },
7706                        })
7707                    }
7708                    0x5282e90b667d0d43 => {
7709                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7710                        let mut req = fidl::new_empty!(
7711                            IsochronousStreamWriteRequest,
7712                            fidl::encoding::DefaultFuchsiaResourceDialect
7713                        );
7714                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IsochronousStreamWriteRequest>(&header, _body_bytes, handles, &mut req)?;
7715                        let control_handle =
7716                            IsochronousStreamControlHandle { inner: this.inner.clone() };
7717                        Ok(IsochronousStreamRequest::Write {
7718                            payload: req,
7719                            responder: IsochronousStreamWriteResponder {
7720                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7721                                tx_id: header.tx_id,
7722                            },
7723                        })
7724                    }
7725                    _ if header.tx_id == 0
7726                        && header
7727                            .dynamic_flags()
7728                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
7729                    {
7730                        Ok(IsochronousStreamRequest::_UnknownMethod {
7731                            ordinal: header.ordinal,
7732                            control_handle: IsochronousStreamControlHandle {
7733                                inner: this.inner.clone(),
7734                            },
7735                            method_type: fidl::MethodType::OneWay,
7736                        })
7737                    }
7738                    _ if header
7739                        .dynamic_flags()
7740                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
7741                    {
7742                        this.inner.send_framework_err(
7743                            fidl::encoding::FrameworkErr::UnknownMethod,
7744                            header.tx_id,
7745                            header.ordinal,
7746                            header.dynamic_flags(),
7747                            (bytes, handles),
7748                        )?;
7749                        Ok(IsochronousStreamRequest::_UnknownMethod {
7750                            ordinal: header.ordinal,
7751                            control_handle: IsochronousStreamControlHandle {
7752                                inner: this.inner.clone(),
7753                            },
7754                            method_type: fidl::MethodType::TwoWay,
7755                        })
7756                    }
7757                    _ => Err(fidl::Error::UnknownOrdinal {
7758                        ordinal: header.ordinal,
7759                        protocol_name:
7760                            <IsochronousStreamMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7761                    }),
7762                }))
7763            },
7764        )
7765    }
7766}
7767
7768#[derive(Debug)]
7769pub enum IsochronousStreamRequest {
7770    /// Create an isochronous data path with the specified parameters. Only in-band (HCI) ISO
7771    /// transport is currently supported.
7772    ///
7773    /// Returns ZX_ERR_ALREADY_EXISTS if a ISO stream has already been created for this
7774    /// direction.
7775    ///
7776    /// Returns ZX_ERR_BAD_STATE if issued on a peripheral before a CIS request has been
7777    /// accepted.
7778    ///
7779    /// Returns ZX_ERR_INVALID_ARGS if the codec arguments are invalid or outside of the
7780    /// controller's supported range.
7781    SetupDataPath {
7782        payload: IsochronousStreamSetupDataPathRequest,
7783        responder: IsochronousStreamSetupDataPathResponder,
7784    },
7785    /// Receive data from an output (controller => host) ISO stream that has been established and
7786    /// set up. Designed to be used with a hanging get pattern.
7787    ///
7788    /// Can be invoked before the ISO data stream has been established and set up, but will not
7789    /// return until after it has been set up and data has been received.
7790    Read { responder: IsochronousStreamReadResponder },
7791    /// Send data to an established ISO stream (host => controller).
7792    ///
7793    /// Returns ZX_ERR_INTERNAL for any errors encountered.
7794    Write { payload: IsochronousStreamWriteRequest, responder: IsochronousStreamWriteResponder },
7795    /// An interaction was received which does not match any known method.
7796    #[non_exhaustive]
7797    _UnknownMethod {
7798        /// Ordinal of the method that was called.
7799        ordinal: u64,
7800        control_handle: IsochronousStreamControlHandle,
7801        method_type: fidl::MethodType,
7802    },
7803}
7804
7805impl IsochronousStreamRequest {
7806    #[allow(irrefutable_let_patterns)]
7807    pub fn into_setup_data_path(
7808        self,
7809    ) -> Option<(IsochronousStreamSetupDataPathRequest, IsochronousStreamSetupDataPathResponder)>
7810    {
7811        if let IsochronousStreamRequest::SetupDataPath { payload, responder } = self {
7812            Some((payload, responder))
7813        } else {
7814            None
7815        }
7816    }
7817
7818    #[allow(irrefutable_let_patterns)]
7819    pub fn into_read(self) -> Option<(IsochronousStreamReadResponder)> {
7820        if let IsochronousStreamRequest::Read { responder } = self {
7821            Some((responder))
7822        } else {
7823            None
7824        }
7825    }
7826
7827    #[allow(irrefutable_let_patterns)]
7828    pub fn into_write(
7829        self,
7830    ) -> Option<(IsochronousStreamWriteRequest, IsochronousStreamWriteResponder)> {
7831        if let IsochronousStreamRequest::Write { payload, responder } = self {
7832            Some((payload, responder))
7833        } else {
7834            None
7835        }
7836    }
7837
7838    /// Name of the method defined in FIDL
7839    pub fn method_name(&self) -> &'static str {
7840        match *self {
7841            IsochronousStreamRequest::SetupDataPath { .. } => "setup_data_path",
7842            IsochronousStreamRequest::Read { .. } => "read",
7843            IsochronousStreamRequest::Write { .. } => "write",
7844            IsochronousStreamRequest::_UnknownMethod {
7845                method_type: fidl::MethodType::OneWay,
7846                ..
7847            } => "unknown one-way method",
7848            IsochronousStreamRequest::_UnknownMethod {
7849                method_type: fidl::MethodType::TwoWay,
7850                ..
7851            } => "unknown two-way method",
7852        }
7853    }
7854}
7855
7856#[derive(Debug, Clone)]
7857pub struct IsochronousStreamControlHandle {
7858    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7859}
7860
7861impl fidl::endpoints::ControlHandle for IsochronousStreamControlHandle {
7862    fn shutdown(&self) {
7863        self.inner.shutdown()
7864    }
7865
7866    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7867        self.inner.shutdown_with_epitaph(status)
7868    }
7869
7870    fn is_closed(&self) -> bool {
7871        self.inner.channel().is_closed()
7872    }
7873    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7874        self.inner.channel().on_closed()
7875    }
7876
7877    #[cfg(target_os = "fuchsia")]
7878    fn signal_peer(
7879        &self,
7880        clear_mask: zx::Signals,
7881        set_mask: zx::Signals,
7882    ) -> Result<(), zx_status::Status> {
7883        use fidl::Peered;
7884        self.inner.channel().signal_peer(clear_mask, set_mask)
7885    }
7886}
7887
7888impl IsochronousStreamControlHandle {
7889    pub fn send_on_established(
7890        &self,
7891        mut payload: &IsochronousStreamOnEstablishedRequest,
7892    ) -> Result<(), fidl::Error> {
7893        self.inner.send::<IsochronousStreamOnEstablishedRequest>(
7894            payload,
7895            0,
7896            0x341c50e9d10f3421,
7897            fidl::encoding::DynamicFlags::FLEXIBLE,
7898        )
7899    }
7900}
7901
7902#[must_use = "FIDL methods require a response to be sent"]
7903#[derive(Debug)]
7904pub struct IsochronousStreamSetupDataPathResponder {
7905    control_handle: std::mem::ManuallyDrop<IsochronousStreamControlHandle>,
7906    tx_id: u32,
7907}
7908
7909/// Set the the channel to be shutdown (see [`IsochronousStreamControlHandle::shutdown`])
7910/// if the responder is dropped without sending a response, so that the client
7911/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7912impl std::ops::Drop for IsochronousStreamSetupDataPathResponder {
7913    fn drop(&mut self) {
7914        self.control_handle.shutdown();
7915        // Safety: drops once, never accessed again
7916        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7917    }
7918}
7919
7920impl fidl::endpoints::Responder for IsochronousStreamSetupDataPathResponder {
7921    type ControlHandle = IsochronousStreamControlHandle;
7922
7923    fn control_handle(&self) -> &IsochronousStreamControlHandle {
7924        &self.control_handle
7925    }
7926
7927    fn drop_without_shutdown(mut self) {
7928        // Safety: drops once, never accessed again due to mem::forget
7929        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7930        // Prevent Drop from running (which would shut down the channel)
7931        std::mem::forget(self);
7932    }
7933}
7934
7935impl IsochronousStreamSetupDataPathResponder {
7936    /// Sends a response to the FIDL transaction.
7937    ///
7938    /// Sets the channel to shutdown if an error occurs.
7939    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7940        let _result = self.send_raw(result);
7941        if _result.is_err() {
7942            self.control_handle.shutdown();
7943        }
7944        self.drop_without_shutdown();
7945        _result
7946    }
7947
7948    /// Similar to "send" but does not shutdown the channel if an error occurs.
7949    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7950        let _result = self.send_raw(result);
7951        self.drop_without_shutdown();
7952        _result
7953    }
7954
7955    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7956        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7957            fidl::encoding::EmptyStruct,
7958            i32,
7959        >>(
7960            fidl::encoding::FlexibleResult::new(result),
7961            self.tx_id,
7962            0x7ec1e2b9cc6d2fbe,
7963            fidl::encoding::DynamicFlags::FLEXIBLE,
7964        )
7965    }
7966}
7967
7968#[must_use = "FIDL methods require a response to be sent"]
7969#[derive(Debug)]
7970pub struct IsochronousStreamReadResponder {
7971    control_handle: std::mem::ManuallyDrop<IsochronousStreamControlHandle>,
7972    tx_id: u32,
7973}
7974
7975/// Set the the channel to be shutdown (see [`IsochronousStreamControlHandle::shutdown`])
7976/// if the responder is dropped without sending a response, so that the client
7977/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7978impl std::ops::Drop for IsochronousStreamReadResponder {
7979    fn drop(&mut self) {
7980        self.control_handle.shutdown();
7981        // Safety: drops once, never accessed again
7982        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7983    }
7984}
7985
7986impl fidl::endpoints::Responder for IsochronousStreamReadResponder {
7987    type ControlHandle = IsochronousStreamControlHandle;
7988
7989    fn control_handle(&self) -> &IsochronousStreamControlHandle {
7990        &self.control_handle
7991    }
7992
7993    fn drop_without_shutdown(mut self) {
7994        // Safety: drops once, never accessed again due to mem::forget
7995        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7996        // Prevent Drop from running (which would shut down the channel)
7997        std::mem::forget(self);
7998    }
7999}
8000
8001impl IsochronousStreamReadResponder {
8002    /// Sends a response to the FIDL transaction.
8003    ///
8004    /// Sets the channel to shutdown if an error occurs.
8005    pub fn send(self, mut payload: &IsochronousStreamReadResponse) -> Result<(), fidl::Error> {
8006        let _result = self.send_raw(payload);
8007        if _result.is_err() {
8008            self.control_handle.shutdown();
8009        }
8010        self.drop_without_shutdown();
8011        _result
8012    }
8013
8014    /// Similar to "send" but does not shutdown the channel if an error occurs.
8015    pub fn send_no_shutdown_on_err(
8016        self,
8017        mut payload: &IsochronousStreamReadResponse,
8018    ) -> Result<(), fidl::Error> {
8019        let _result = self.send_raw(payload);
8020        self.drop_without_shutdown();
8021        _result
8022    }
8023
8024    fn send_raw(&self, mut payload: &IsochronousStreamReadResponse) -> Result<(), fidl::Error> {
8025        self.control_handle
8026            .inner
8027            .send::<fidl::encoding::FlexibleType<IsochronousStreamReadResponse>>(
8028                fidl::encoding::Flexible::new(payload),
8029                self.tx_id,
8030                0x6d7d8b4950ed3a32,
8031                fidl::encoding::DynamicFlags::FLEXIBLE,
8032            )
8033    }
8034}
8035
8036#[must_use = "FIDL methods require a response to be sent"]
8037#[derive(Debug)]
8038pub struct IsochronousStreamWriteResponder {
8039    control_handle: std::mem::ManuallyDrop<IsochronousStreamControlHandle>,
8040    tx_id: u32,
8041}
8042
8043/// Set the the channel to be shutdown (see [`IsochronousStreamControlHandle::shutdown`])
8044/// if the responder is dropped without sending a response, so that the client
8045/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8046impl std::ops::Drop for IsochronousStreamWriteResponder {
8047    fn drop(&mut self) {
8048        self.control_handle.shutdown();
8049        // Safety: drops once, never accessed again
8050        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8051    }
8052}
8053
8054impl fidl::endpoints::Responder for IsochronousStreamWriteResponder {
8055    type ControlHandle = IsochronousStreamControlHandle;
8056
8057    fn control_handle(&self) -> &IsochronousStreamControlHandle {
8058        &self.control_handle
8059    }
8060
8061    fn drop_without_shutdown(mut self) {
8062        // Safety: drops once, never accessed again due to mem::forget
8063        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8064        // Prevent Drop from running (which would shut down the channel)
8065        std::mem::forget(self);
8066    }
8067}
8068
8069impl IsochronousStreamWriteResponder {
8070    /// Sends a response to the FIDL transaction.
8071    ///
8072    /// Sets the channel to shutdown if an error occurs.
8073    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8074        let _result = self.send_raw(result);
8075        if _result.is_err() {
8076            self.control_handle.shutdown();
8077        }
8078        self.drop_without_shutdown();
8079        _result
8080    }
8081
8082    /// Similar to "send" but does not shutdown the channel if an error occurs.
8083    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8084        let _result = self.send_raw(result);
8085        self.drop_without_shutdown();
8086        _result
8087    }
8088
8089    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8090        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
8091            fidl::encoding::EmptyStruct,
8092            i32,
8093        >>(
8094            fidl::encoding::FlexibleResult::new(result),
8095            self.tx_id,
8096            0x5282e90b667d0d43,
8097            fidl::encoding::DynamicFlags::FLEXIBLE,
8098        )
8099    }
8100}
8101
8102#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8103pub struct PeriodicAdvertisingSyncMarker;
8104
8105impl fidl::endpoints::ProtocolMarker for PeriodicAdvertisingSyncMarker {
8106    type Proxy = PeriodicAdvertisingSyncProxy;
8107    type RequestStream = PeriodicAdvertisingSyncRequestStream;
8108    #[cfg(target_os = "fuchsia")]
8109    type SynchronousProxy = PeriodicAdvertisingSyncSynchronousProxy;
8110
8111    const DEBUG_NAME: &'static str = "(anonymous) PeriodicAdvertisingSync";
8112}
8113pub type PeriodicAdvertisingSyncSyncToSubeventsResult = Result<(), i32>;
8114
8115pub trait PeriodicAdvertisingSyncProxyInterface: Send + Sync {
8116    type WatchAdvertisingReportResponseFut: std::future::Future<
8117            Output = Result<PeriodicAdvertisingSyncWatchAdvertisingReportResponse, fidl::Error>,
8118        > + Send;
8119    fn r#watch_advertising_report(&self) -> Self::WatchAdvertisingReportResponseFut;
8120    type SyncToSubeventsResponseFut: std::future::Future<
8121            Output = Result<PeriodicAdvertisingSyncSyncToSubeventsResult, fidl::Error>,
8122        > + Send;
8123    fn r#sync_to_subevents(
8124        &self,
8125        payload: &PeriodicAdvertisingSyncSyncToSubeventsRequest,
8126    ) -> Self::SyncToSubeventsResponseFut;
8127    fn r#cancel(&self) -> Result<(), fidl::Error>;
8128}
8129#[derive(Debug)]
8130#[cfg(target_os = "fuchsia")]
8131pub struct PeriodicAdvertisingSyncSynchronousProxy {
8132    client: fidl::client::sync::Client,
8133}
8134
8135#[cfg(target_os = "fuchsia")]
8136impl fidl::endpoints::SynchronousProxy for PeriodicAdvertisingSyncSynchronousProxy {
8137    type Proxy = PeriodicAdvertisingSyncProxy;
8138    type Protocol = PeriodicAdvertisingSyncMarker;
8139
8140    fn from_channel(inner: fidl::Channel) -> Self {
8141        Self::new(inner)
8142    }
8143
8144    fn into_channel(self) -> fidl::Channel {
8145        self.client.into_channel()
8146    }
8147
8148    fn as_channel(&self) -> &fidl::Channel {
8149        self.client.as_channel()
8150    }
8151}
8152
8153#[cfg(target_os = "fuchsia")]
8154impl PeriodicAdvertisingSyncSynchronousProxy {
8155    pub fn new(channel: fidl::Channel) -> Self {
8156        Self { client: fidl::client::sync::Client::new(channel) }
8157    }
8158
8159    pub fn into_channel(self) -> fidl::Channel {
8160        self.client.into_channel()
8161    }
8162
8163    /// Waits until an event arrives and returns it. It is safe for other
8164    /// threads to make concurrent requests while waiting for an event.
8165    pub fn wait_for_event(
8166        &self,
8167        deadline: zx::MonotonicInstant,
8168    ) -> Result<PeriodicAdvertisingSyncEvent, fidl::Error> {
8169        PeriodicAdvertisingSyncEvent::decode(
8170            self.client.wait_for_event::<PeriodicAdvertisingSyncMarker>(deadline)?,
8171        )
8172    }
8173
8174    /// Returns the next advertising report(s). Hangs until the next advertisement is received.
8175    /// Only one call may be pending at a time.
8176    pub fn r#watch_advertising_report(
8177        &self,
8178        ___deadline: zx::MonotonicInstant,
8179    ) -> Result<PeriodicAdvertisingSyncWatchAdvertisingReportResponse, fidl::Error> {
8180        let _response = self.client.send_query::<
8181            fidl::encoding::EmptyPayload,
8182            fidl::encoding::FlexibleType<PeriodicAdvertisingSyncWatchAdvertisingReportResponse>,
8183            PeriodicAdvertisingSyncMarker,
8184        >(
8185            (),
8186            0x2ea610fea0e7d337,
8187            fidl::encoding::DynamicFlags::FLEXIBLE,
8188            ___deadline,
8189        )?
8190        .into_result::<PeriodicAdvertisingSyncMarker>("watch_advertising_report")?;
8191        Ok(_response)
8192    }
8193
8194    /// Synchronize to subevents of this periodic advertisement.
8195    /// * error FAILED: The synchronization failed.
8196    pub fn r#sync_to_subevents(
8197        &self,
8198        mut payload: &PeriodicAdvertisingSyncSyncToSubeventsRequest,
8199        ___deadline: zx::MonotonicInstant,
8200    ) -> Result<PeriodicAdvertisingSyncSyncToSubeventsResult, fidl::Error> {
8201        let _response = self.client.send_query::<
8202            PeriodicAdvertisingSyncSyncToSubeventsRequest,
8203            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
8204            PeriodicAdvertisingSyncMarker,
8205        >(
8206            payload,
8207            0x653c5dab1f1d80ed,
8208            fidl::encoding::DynamicFlags::FLEXIBLE,
8209            ___deadline,
8210        )?
8211        .into_result::<PeriodicAdvertisingSyncMarker>("sync_to_subevents")?;
8212        Ok(_response.map(|x| x))
8213    }
8214
8215    /// The server will end the synchronization and then close the protocol.
8216    /// Synchronization will not be cancelled if other clients are synchronized to the same Periodic
8217    /// Advertisement.
8218    /// Synchronization can also be cancelled by closing the protocol on the client end.
8219    pub fn r#cancel(&self) -> Result<(), fidl::Error> {
8220        self.client.send::<fidl::encoding::EmptyPayload>(
8221            (),
8222            0xd617c037eaf5d92,
8223            fidl::encoding::DynamicFlags::FLEXIBLE,
8224        )
8225    }
8226}
8227
8228#[cfg(target_os = "fuchsia")]
8229impl From<PeriodicAdvertisingSyncSynchronousProxy> for zx::NullableHandle {
8230    fn from(value: PeriodicAdvertisingSyncSynchronousProxy) -> Self {
8231        value.into_channel().into()
8232    }
8233}
8234
8235#[cfg(target_os = "fuchsia")]
8236impl From<fidl::Channel> for PeriodicAdvertisingSyncSynchronousProxy {
8237    fn from(value: fidl::Channel) -> Self {
8238        Self::new(value)
8239    }
8240}
8241
8242#[cfg(target_os = "fuchsia")]
8243impl fidl::endpoints::FromClient for PeriodicAdvertisingSyncSynchronousProxy {
8244    type Protocol = PeriodicAdvertisingSyncMarker;
8245
8246    fn from_client(value: fidl::endpoints::ClientEnd<PeriodicAdvertisingSyncMarker>) -> Self {
8247        Self::new(value.into_channel())
8248    }
8249}
8250
8251#[derive(Debug, Clone)]
8252pub struct PeriodicAdvertisingSyncProxy {
8253    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8254}
8255
8256impl fidl::endpoints::Proxy for PeriodicAdvertisingSyncProxy {
8257    type Protocol = PeriodicAdvertisingSyncMarker;
8258
8259    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8260        Self::new(inner)
8261    }
8262
8263    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8264        self.client.into_channel().map_err(|client| Self { client })
8265    }
8266
8267    fn as_channel(&self) -> &::fidl::AsyncChannel {
8268        self.client.as_channel()
8269    }
8270}
8271
8272impl PeriodicAdvertisingSyncProxy {
8273    /// Create a new Proxy for fuchsia.bluetooth.le/PeriodicAdvertisingSync.
8274    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8275        let protocol_name =
8276            <PeriodicAdvertisingSyncMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8277        Self { client: fidl::client::Client::new(channel, protocol_name) }
8278    }
8279
8280    /// Get a Stream of events from the remote end of the protocol.
8281    ///
8282    /// # Panics
8283    ///
8284    /// Panics if the event stream was already taken.
8285    pub fn take_event_stream(&self) -> PeriodicAdvertisingSyncEventStream {
8286        PeriodicAdvertisingSyncEventStream { event_receiver: self.client.take_event_receiver() }
8287    }
8288
8289    /// Returns the next advertising report(s). Hangs until the next advertisement is received.
8290    /// Only one call may be pending at a time.
8291    pub fn r#watch_advertising_report(
8292        &self,
8293    ) -> fidl::client::QueryResponseFut<
8294        PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8295        fidl::encoding::DefaultFuchsiaResourceDialect,
8296    > {
8297        PeriodicAdvertisingSyncProxyInterface::r#watch_advertising_report(self)
8298    }
8299
8300    /// Synchronize to subevents of this periodic advertisement.
8301    /// * error FAILED: The synchronization failed.
8302    pub fn r#sync_to_subevents(
8303        &self,
8304        mut payload: &PeriodicAdvertisingSyncSyncToSubeventsRequest,
8305    ) -> fidl::client::QueryResponseFut<
8306        PeriodicAdvertisingSyncSyncToSubeventsResult,
8307        fidl::encoding::DefaultFuchsiaResourceDialect,
8308    > {
8309        PeriodicAdvertisingSyncProxyInterface::r#sync_to_subevents(self, payload)
8310    }
8311
8312    /// The server will end the synchronization and then close the protocol.
8313    /// Synchronization will not be cancelled if other clients are synchronized to the same Periodic
8314    /// Advertisement.
8315    /// Synchronization can also be cancelled by closing the protocol on the client end.
8316    pub fn r#cancel(&self) -> Result<(), fidl::Error> {
8317        PeriodicAdvertisingSyncProxyInterface::r#cancel(self)
8318    }
8319}
8320
8321impl PeriodicAdvertisingSyncProxyInterface for PeriodicAdvertisingSyncProxy {
8322    type WatchAdvertisingReportResponseFut = fidl::client::QueryResponseFut<
8323        PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8324        fidl::encoding::DefaultFuchsiaResourceDialect,
8325    >;
8326    fn r#watch_advertising_report(&self) -> Self::WatchAdvertisingReportResponseFut {
8327        fn _decode(
8328            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8329        ) -> Result<PeriodicAdvertisingSyncWatchAdvertisingReportResponse, fidl::Error> {
8330            let _response = fidl::client::decode_transaction_body::<
8331                fidl::encoding::FlexibleType<PeriodicAdvertisingSyncWatchAdvertisingReportResponse>,
8332                fidl::encoding::DefaultFuchsiaResourceDialect,
8333                0x2ea610fea0e7d337,
8334            >(_buf?)?
8335            .into_result::<PeriodicAdvertisingSyncMarker>("watch_advertising_report")?;
8336            Ok(_response)
8337        }
8338        self.client.send_query_and_decode::<
8339            fidl::encoding::EmptyPayload,
8340            PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8341        >(
8342            (),
8343            0x2ea610fea0e7d337,
8344            fidl::encoding::DynamicFlags::FLEXIBLE,
8345            _decode,
8346        )
8347    }
8348
8349    type SyncToSubeventsResponseFut = fidl::client::QueryResponseFut<
8350        PeriodicAdvertisingSyncSyncToSubeventsResult,
8351        fidl::encoding::DefaultFuchsiaResourceDialect,
8352    >;
8353    fn r#sync_to_subevents(
8354        &self,
8355        mut payload: &PeriodicAdvertisingSyncSyncToSubeventsRequest,
8356    ) -> Self::SyncToSubeventsResponseFut {
8357        fn _decode(
8358            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8359        ) -> Result<PeriodicAdvertisingSyncSyncToSubeventsResult, fidl::Error> {
8360            let _response = fidl::client::decode_transaction_body::<
8361                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
8362                fidl::encoding::DefaultFuchsiaResourceDialect,
8363                0x653c5dab1f1d80ed,
8364            >(_buf?)?
8365            .into_result::<PeriodicAdvertisingSyncMarker>("sync_to_subevents")?;
8366            Ok(_response.map(|x| x))
8367        }
8368        self.client.send_query_and_decode::<
8369            PeriodicAdvertisingSyncSyncToSubeventsRequest,
8370            PeriodicAdvertisingSyncSyncToSubeventsResult,
8371        >(
8372            payload,
8373            0x653c5dab1f1d80ed,
8374            fidl::encoding::DynamicFlags::FLEXIBLE,
8375            _decode,
8376        )
8377    }
8378
8379    fn r#cancel(&self) -> Result<(), fidl::Error> {
8380        self.client.send::<fidl::encoding::EmptyPayload>(
8381            (),
8382            0xd617c037eaf5d92,
8383            fidl::encoding::DynamicFlags::FLEXIBLE,
8384        )
8385    }
8386}
8387
8388pub struct PeriodicAdvertisingSyncEventStream {
8389    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8390}
8391
8392impl std::marker::Unpin for PeriodicAdvertisingSyncEventStream {}
8393
8394impl futures::stream::FusedStream for PeriodicAdvertisingSyncEventStream {
8395    fn is_terminated(&self) -> bool {
8396        self.event_receiver.is_terminated()
8397    }
8398}
8399
8400impl futures::Stream for PeriodicAdvertisingSyncEventStream {
8401    type Item = Result<PeriodicAdvertisingSyncEvent, fidl::Error>;
8402
8403    fn poll_next(
8404        mut self: std::pin::Pin<&mut Self>,
8405        cx: &mut std::task::Context<'_>,
8406    ) -> std::task::Poll<Option<Self::Item>> {
8407        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8408            &mut self.event_receiver,
8409            cx
8410        )?) {
8411            Some(buf) => std::task::Poll::Ready(Some(PeriodicAdvertisingSyncEvent::decode(buf))),
8412            None => std::task::Poll::Ready(None),
8413        }
8414    }
8415}
8416
8417#[derive(Debug)]
8418pub enum PeriodicAdvertisingSyncEvent {
8419    OnEstablished {
8420        payload: PeriodicAdvertisingSyncOnEstablishedRequest,
8421    },
8422    OnError {
8423        error: PeriodicAdvertisingSyncError,
8424    },
8425    #[non_exhaustive]
8426    _UnknownEvent {
8427        /// Ordinal of the event that was sent.
8428        ordinal: u64,
8429    },
8430}
8431
8432impl PeriodicAdvertisingSyncEvent {
8433    #[allow(irrefutable_let_patterns)]
8434    pub fn into_on_established(self) -> Option<PeriodicAdvertisingSyncOnEstablishedRequest> {
8435        if let PeriodicAdvertisingSyncEvent::OnEstablished { payload } = self {
8436            Some((payload))
8437        } else {
8438            None
8439        }
8440    }
8441    #[allow(irrefutable_let_patterns)]
8442    pub fn into_on_error(self) -> Option<PeriodicAdvertisingSyncError> {
8443        if let PeriodicAdvertisingSyncEvent::OnError { error } = self {
8444            Some((error))
8445        } else {
8446            None
8447        }
8448    }
8449
8450    /// Decodes a message buffer as a [`PeriodicAdvertisingSyncEvent`].
8451    fn decode(
8452        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8453    ) -> Result<PeriodicAdvertisingSyncEvent, fidl::Error> {
8454        let (bytes, _handles) = buf.split_mut();
8455        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8456        debug_assert_eq!(tx_header.tx_id, 0);
8457        match tx_header.ordinal {
8458            0x4a5c307761c40fdc => {
8459                let mut out = fidl::new_empty!(
8460                    PeriodicAdvertisingSyncOnEstablishedRequest,
8461                    fidl::encoding::DefaultFuchsiaResourceDialect
8462                );
8463                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeriodicAdvertisingSyncOnEstablishedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
8464                Ok((PeriodicAdvertisingSyncEvent::OnEstablished { payload: out }))
8465            }
8466            0x1c051673126ce4a => {
8467                let mut out = fidl::new_empty!(
8468                    PeriodicAdvertisingSyncOnErrorRequest,
8469                    fidl::encoding::DefaultFuchsiaResourceDialect
8470                );
8471                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeriodicAdvertisingSyncOnErrorRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
8472                Ok((PeriodicAdvertisingSyncEvent::OnError { error: out.error }))
8473            }
8474            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
8475                Ok(PeriodicAdvertisingSyncEvent::_UnknownEvent { ordinal: tx_header.ordinal })
8476            }
8477            _ => Err(fidl::Error::UnknownOrdinal {
8478                ordinal: tx_header.ordinal,
8479                protocol_name:
8480                    <PeriodicAdvertisingSyncMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8481            }),
8482        }
8483    }
8484}
8485
8486/// A Stream of incoming requests for fuchsia.bluetooth.le/PeriodicAdvertisingSync.
8487pub struct PeriodicAdvertisingSyncRequestStream {
8488    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8489    is_terminated: bool,
8490}
8491
8492impl std::marker::Unpin for PeriodicAdvertisingSyncRequestStream {}
8493
8494impl futures::stream::FusedStream for PeriodicAdvertisingSyncRequestStream {
8495    fn is_terminated(&self) -> bool {
8496        self.is_terminated
8497    }
8498}
8499
8500impl fidl::endpoints::RequestStream for PeriodicAdvertisingSyncRequestStream {
8501    type Protocol = PeriodicAdvertisingSyncMarker;
8502    type ControlHandle = PeriodicAdvertisingSyncControlHandle;
8503
8504    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8505        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8506    }
8507
8508    fn control_handle(&self) -> Self::ControlHandle {
8509        PeriodicAdvertisingSyncControlHandle { inner: self.inner.clone() }
8510    }
8511
8512    fn into_inner(
8513        self,
8514    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8515    {
8516        (self.inner, self.is_terminated)
8517    }
8518
8519    fn from_inner(
8520        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8521        is_terminated: bool,
8522    ) -> Self {
8523        Self { inner, is_terminated }
8524    }
8525}
8526
8527impl futures::Stream for PeriodicAdvertisingSyncRequestStream {
8528    type Item = Result<PeriodicAdvertisingSyncRequest, fidl::Error>;
8529
8530    fn poll_next(
8531        mut self: std::pin::Pin<&mut Self>,
8532        cx: &mut std::task::Context<'_>,
8533    ) -> std::task::Poll<Option<Self::Item>> {
8534        let this = &mut *self;
8535        if this.inner.check_shutdown(cx) {
8536            this.is_terminated = true;
8537            return std::task::Poll::Ready(None);
8538        }
8539        if this.is_terminated {
8540            panic!("polled PeriodicAdvertisingSyncRequestStream after completion");
8541        }
8542        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8543            |bytes, handles| {
8544                match this.inner.channel().read_etc(cx, bytes, handles) {
8545                    std::task::Poll::Ready(Ok(())) => {}
8546                    std::task::Poll::Pending => return std::task::Poll::Pending,
8547                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8548                        this.is_terminated = true;
8549                        return std::task::Poll::Ready(None);
8550                    }
8551                    std::task::Poll::Ready(Err(e)) => {
8552                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8553                            e.into(),
8554                        ))));
8555                    }
8556                }
8557
8558                // A message has been received from the channel
8559                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8560
8561                std::task::Poll::Ready(Some(match header.ordinal {
8562                0x2ea610fea0e7d337 => {
8563                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8564                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
8565                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8566                    let control_handle = PeriodicAdvertisingSyncControlHandle {
8567                        inner: this.inner.clone(),
8568                    };
8569                    Ok(PeriodicAdvertisingSyncRequest::WatchAdvertisingReport {
8570                        responder: PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8571                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8572                            tx_id: header.tx_id,
8573                        },
8574                    })
8575                }
8576                0x653c5dab1f1d80ed => {
8577                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8578                    let mut req = fidl::new_empty!(PeriodicAdvertisingSyncSyncToSubeventsRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
8579                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeriodicAdvertisingSyncSyncToSubeventsRequest>(&header, _body_bytes, handles, &mut req)?;
8580                    let control_handle = PeriodicAdvertisingSyncControlHandle {
8581                        inner: this.inner.clone(),
8582                    };
8583                    Ok(PeriodicAdvertisingSyncRequest::SyncToSubevents {payload: req,
8584                        responder: PeriodicAdvertisingSyncSyncToSubeventsResponder {
8585                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8586                            tx_id: header.tx_id,
8587                        },
8588                    })
8589                }
8590                0xd617c037eaf5d92 => {
8591                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8592                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
8593                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8594                    let control_handle = PeriodicAdvertisingSyncControlHandle {
8595                        inner: this.inner.clone(),
8596                    };
8597                    Ok(PeriodicAdvertisingSyncRequest::Cancel {
8598                        control_handle,
8599                    })
8600                }
8601                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
8602                    Ok(PeriodicAdvertisingSyncRequest::_UnknownMethod {
8603                        ordinal: header.ordinal,
8604                        control_handle: PeriodicAdvertisingSyncControlHandle { inner: this.inner.clone() },
8605                        method_type: fidl::MethodType::OneWay,
8606                    })
8607                }
8608                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
8609                    this.inner.send_framework_err(
8610                        fidl::encoding::FrameworkErr::UnknownMethod,
8611                        header.tx_id,
8612                        header.ordinal,
8613                        header.dynamic_flags(),
8614                        (bytes, handles),
8615                    )?;
8616                    Ok(PeriodicAdvertisingSyncRequest::_UnknownMethod {
8617                        ordinal: header.ordinal,
8618                        control_handle: PeriodicAdvertisingSyncControlHandle { inner: this.inner.clone() },
8619                        method_type: fidl::MethodType::TwoWay,
8620                    })
8621                }
8622                _ => Err(fidl::Error::UnknownOrdinal {
8623                    ordinal: header.ordinal,
8624                    protocol_name: <PeriodicAdvertisingSyncMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8625                }),
8626            }))
8627            },
8628        )
8629    }
8630}
8631
8632/// Closed by the server when the sync fails to be established or is lost.
8633#[derive(Debug)]
8634pub enum PeriodicAdvertisingSyncRequest {
8635    /// Returns the next advertising report(s). Hangs until the next advertisement is received.
8636    /// Only one call may be pending at a time.
8637    WatchAdvertisingReport { responder: PeriodicAdvertisingSyncWatchAdvertisingReportResponder },
8638    /// Synchronize to subevents of this periodic advertisement.
8639    /// * error FAILED: The synchronization failed.
8640    SyncToSubevents {
8641        payload: PeriodicAdvertisingSyncSyncToSubeventsRequest,
8642        responder: PeriodicAdvertisingSyncSyncToSubeventsResponder,
8643    },
8644    /// The server will end the synchronization and then close the protocol.
8645    /// Synchronization will not be cancelled if other clients are synchronized to the same Periodic
8646    /// Advertisement.
8647    /// Synchronization can also be cancelled by closing the protocol on the client end.
8648    Cancel { control_handle: PeriodicAdvertisingSyncControlHandle },
8649    /// An interaction was received which does not match any known method.
8650    #[non_exhaustive]
8651    _UnknownMethod {
8652        /// Ordinal of the method that was called.
8653        ordinal: u64,
8654        control_handle: PeriodicAdvertisingSyncControlHandle,
8655        method_type: fidl::MethodType,
8656    },
8657}
8658
8659impl PeriodicAdvertisingSyncRequest {
8660    #[allow(irrefutable_let_patterns)]
8661    pub fn into_watch_advertising_report(
8662        self,
8663    ) -> Option<(PeriodicAdvertisingSyncWatchAdvertisingReportResponder)> {
8664        if let PeriodicAdvertisingSyncRequest::WatchAdvertisingReport { responder } = self {
8665            Some((responder))
8666        } else {
8667            None
8668        }
8669    }
8670
8671    #[allow(irrefutable_let_patterns)]
8672    pub fn into_sync_to_subevents(
8673        self,
8674    ) -> Option<(
8675        PeriodicAdvertisingSyncSyncToSubeventsRequest,
8676        PeriodicAdvertisingSyncSyncToSubeventsResponder,
8677    )> {
8678        if let PeriodicAdvertisingSyncRequest::SyncToSubevents { payload, responder } = self {
8679            Some((payload, responder))
8680        } else {
8681            None
8682        }
8683    }
8684
8685    #[allow(irrefutable_let_patterns)]
8686    pub fn into_cancel(self) -> Option<(PeriodicAdvertisingSyncControlHandle)> {
8687        if let PeriodicAdvertisingSyncRequest::Cancel { control_handle } = self {
8688            Some((control_handle))
8689        } else {
8690            None
8691        }
8692    }
8693
8694    /// Name of the method defined in FIDL
8695    pub fn method_name(&self) -> &'static str {
8696        match *self {
8697            PeriodicAdvertisingSyncRequest::WatchAdvertisingReport { .. } => {
8698                "watch_advertising_report"
8699            }
8700            PeriodicAdvertisingSyncRequest::SyncToSubevents { .. } => "sync_to_subevents",
8701            PeriodicAdvertisingSyncRequest::Cancel { .. } => "cancel",
8702            PeriodicAdvertisingSyncRequest::_UnknownMethod {
8703                method_type: fidl::MethodType::OneWay,
8704                ..
8705            } => "unknown one-way method",
8706            PeriodicAdvertisingSyncRequest::_UnknownMethod {
8707                method_type: fidl::MethodType::TwoWay,
8708                ..
8709            } => "unknown two-way method",
8710        }
8711    }
8712}
8713
8714#[derive(Debug, Clone)]
8715pub struct PeriodicAdvertisingSyncControlHandle {
8716    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8717}
8718
8719impl fidl::endpoints::ControlHandle for PeriodicAdvertisingSyncControlHandle {
8720    fn shutdown(&self) {
8721        self.inner.shutdown()
8722    }
8723
8724    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8725        self.inner.shutdown_with_epitaph(status)
8726    }
8727
8728    fn is_closed(&self) -> bool {
8729        self.inner.channel().is_closed()
8730    }
8731    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8732        self.inner.channel().on_closed()
8733    }
8734
8735    #[cfg(target_os = "fuchsia")]
8736    fn signal_peer(
8737        &self,
8738        clear_mask: zx::Signals,
8739        set_mask: zx::Signals,
8740    ) -> Result<(), zx_status::Status> {
8741        use fidl::Peered;
8742        self.inner.channel().signal_peer(clear_mask, set_mask)
8743    }
8744}
8745
8746impl PeriodicAdvertisingSyncControlHandle {
8747    pub fn send_on_established(
8748        &self,
8749        mut payload: &PeriodicAdvertisingSyncOnEstablishedRequest,
8750    ) -> Result<(), fidl::Error> {
8751        self.inner.send::<PeriodicAdvertisingSyncOnEstablishedRequest>(
8752            payload,
8753            0,
8754            0x4a5c307761c40fdc,
8755            fidl::encoding::DynamicFlags::FLEXIBLE,
8756        )
8757    }
8758
8759    pub fn send_on_error(
8760        &self,
8761        mut error: PeriodicAdvertisingSyncError,
8762    ) -> Result<(), fidl::Error> {
8763        self.inner.send::<PeriodicAdvertisingSyncOnErrorRequest>(
8764            (error,),
8765            0,
8766            0x1c051673126ce4a,
8767            fidl::encoding::DynamicFlags::FLEXIBLE,
8768        )
8769    }
8770}
8771
8772#[must_use = "FIDL methods require a response to be sent"]
8773#[derive(Debug)]
8774pub struct PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8775    control_handle: std::mem::ManuallyDrop<PeriodicAdvertisingSyncControlHandle>,
8776    tx_id: u32,
8777}
8778
8779/// Set the the channel to be shutdown (see [`PeriodicAdvertisingSyncControlHandle::shutdown`])
8780/// if the responder is dropped without sending a response, so that the client
8781/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8782impl std::ops::Drop for PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8783    fn drop(&mut self) {
8784        self.control_handle.shutdown();
8785        // Safety: drops once, never accessed again
8786        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8787    }
8788}
8789
8790impl fidl::endpoints::Responder for PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8791    type ControlHandle = PeriodicAdvertisingSyncControlHandle;
8792
8793    fn control_handle(&self) -> &PeriodicAdvertisingSyncControlHandle {
8794        &self.control_handle
8795    }
8796
8797    fn drop_without_shutdown(mut self) {
8798        // Safety: drops once, never accessed again due to mem::forget
8799        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8800        // Prevent Drop from running (which would shut down the channel)
8801        std::mem::forget(self);
8802    }
8803}
8804
8805impl PeriodicAdvertisingSyncWatchAdvertisingReportResponder {
8806    /// Sends a response to the FIDL transaction.
8807    ///
8808    /// Sets the channel to shutdown if an error occurs.
8809    pub fn send(
8810        self,
8811        mut payload: &PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8812    ) -> Result<(), fidl::Error> {
8813        let _result = self.send_raw(payload);
8814        if _result.is_err() {
8815            self.control_handle.shutdown();
8816        }
8817        self.drop_without_shutdown();
8818        _result
8819    }
8820
8821    /// Similar to "send" but does not shutdown the channel if an error occurs.
8822    pub fn send_no_shutdown_on_err(
8823        self,
8824        mut payload: &PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8825    ) -> Result<(), fidl::Error> {
8826        let _result = self.send_raw(payload);
8827        self.drop_without_shutdown();
8828        _result
8829    }
8830
8831    fn send_raw(
8832        &self,
8833        mut payload: &PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8834    ) -> Result<(), fidl::Error> {
8835        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
8836            PeriodicAdvertisingSyncWatchAdvertisingReportResponse,
8837        >>(
8838            fidl::encoding::Flexible::new(payload),
8839            self.tx_id,
8840            0x2ea610fea0e7d337,
8841            fidl::encoding::DynamicFlags::FLEXIBLE,
8842        )
8843    }
8844}
8845
8846#[must_use = "FIDL methods require a response to be sent"]
8847#[derive(Debug)]
8848pub struct PeriodicAdvertisingSyncSyncToSubeventsResponder {
8849    control_handle: std::mem::ManuallyDrop<PeriodicAdvertisingSyncControlHandle>,
8850    tx_id: u32,
8851}
8852
8853/// Set the the channel to be shutdown (see [`PeriodicAdvertisingSyncControlHandle::shutdown`])
8854/// if the responder is dropped without sending a response, so that the client
8855/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8856impl std::ops::Drop for PeriodicAdvertisingSyncSyncToSubeventsResponder {
8857    fn drop(&mut self) {
8858        self.control_handle.shutdown();
8859        // Safety: drops once, never accessed again
8860        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8861    }
8862}
8863
8864impl fidl::endpoints::Responder for PeriodicAdvertisingSyncSyncToSubeventsResponder {
8865    type ControlHandle = PeriodicAdvertisingSyncControlHandle;
8866
8867    fn control_handle(&self) -> &PeriodicAdvertisingSyncControlHandle {
8868        &self.control_handle
8869    }
8870
8871    fn drop_without_shutdown(mut self) {
8872        // Safety: drops once, never accessed again due to mem::forget
8873        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8874        // Prevent Drop from running (which would shut down the channel)
8875        std::mem::forget(self);
8876    }
8877}
8878
8879impl PeriodicAdvertisingSyncSyncToSubeventsResponder {
8880    /// Sends a response to the FIDL transaction.
8881    ///
8882    /// Sets the channel to shutdown if an error occurs.
8883    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8884        let _result = self.send_raw(result);
8885        if _result.is_err() {
8886            self.control_handle.shutdown();
8887        }
8888        self.drop_without_shutdown();
8889        _result
8890    }
8891
8892    /// Similar to "send" but does not shutdown the channel if an error occurs.
8893    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8894        let _result = self.send_raw(result);
8895        self.drop_without_shutdown();
8896        _result
8897    }
8898
8899    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
8900        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
8901            fidl::encoding::EmptyStruct,
8902            i32,
8903        >>(
8904            fidl::encoding::FlexibleResult::new(result),
8905            self.tx_id,
8906            0x653c5dab1f1d80ed,
8907            fidl::encoding::DynamicFlags::FLEXIBLE,
8908        )
8909    }
8910}
8911
8912#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8913pub struct PeripheralMarker;
8914
8915impl fidl::endpoints::ProtocolMarker for PeripheralMarker {
8916    type Proxy = PeripheralProxy;
8917    type RequestStream = PeripheralRequestStream;
8918    #[cfg(target_os = "fuchsia")]
8919    type SynchronousProxy = PeripheralSynchronousProxy;
8920
8921    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.Peripheral";
8922}
8923impl fidl::endpoints::DiscoverableProtocolMarker for PeripheralMarker {}
8924pub type PeripheralAdvertiseResult = Result<(), PeripheralError>;
8925pub type PeripheralStartAdvertisingResult = Result<(), PeripheralError>;
8926
8927pub trait PeripheralProxyInterface: Send + Sync {
8928    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
8929        + Send;
8930    fn r#listen_l2cap(
8931        &self,
8932        payload: ChannelListenerRegistryListenL2capRequest,
8933    ) -> Self::ListenL2capResponseFut;
8934    type AdvertiseResponseFut: std::future::Future<Output = Result<PeripheralAdvertiseResult, fidl::Error>>
8935        + Send;
8936    fn r#advertise(
8937        &self,
8938        parameters: &AdvertisingParameters,
8939        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
8940    ) -> Self::AdvertiseResponseFut;
8941    type StartAdvertisingResponseFut: std::future::Future<Output = Result<PeripheralStartAdvertisingResult, fidl::Error>>
8942        + Send;
8943    fn r#start_advertising(
8944        &self,
8945        parameters: &AdvertisingParameters,
8946        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
8947    ) -> Self::StartAdvertisingResponseFut;
8948}
8949#[derive(Debug)]
8950#[cfg(target_os = "fuchsia")]
8951pub struct PeripheralSynchronousProxy {
8952    client: fidl::client::sync::Client,
8953}
8954
8955#[cfg(target_os = "fuchsia")]
8956impl fidl::endpoints::SynchronousProxy for PeripheralSynchronousProxy {
8957    type Proxy = PeripheralProxy;
8958    type Protocol = PeripheralMarker;
8959
8960    fn from_channel(inner: fidl::Channel) -> Self {
8961        Self::new(inner)
8962    }
8963
8964    fn into_channel(self) -> fidl::Channel {
8965        self.client.into_channel()
8966    }
8967
8968    fn as_channel(&self) -> &fidl::Channel {
8969        self.client.as_channel()
8970    }
8971}
8972
8973#[cfg(target_os = "fuchsia")]
8974impl PeripheralSynchronousProxy {
8975    pub fn new(channel: fidl::Channel) -> Self {
8976        Self { client: fidl::client::sync::Client::new(channel) }
8977    }
8978
8979    pub fn into_channel(self) -> fidl::Channel {
8980        self.client.into_channel()
8981    }
8982
8983    /// Waits until an event arrives and returns it. It is safe for other
8984    /// threads to make concurrent requests while waiting for an event.
8985    pub fn wait_for_event(
8986        &self,
8987        deadline: zx::MonotonicInstant,
8988    ) -> Result<PeripheralEvent, fidl::Error> {
8989        PeripheralEvent::decode(self.client.wait_for_event::<PeripheralMarker>(deadline)?)
8990    }
8991
8992    /// Register a listener for incoming channels. The registry will assign a
8993    /// PSM value that is unique for the local device, as well as open a
8994    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
8995    /// event that all PSMs have been assigned, this call will fail with
8996    /// `ZX_ERR_NO_RESOURCES`.
8997    ///
8998    /// Note that the method of service discovery or advertising is defined by
8999    /// the service or protocol, so it is the responsibility of the caller to
9000    /// communicate the assigned PSM to any clients.
9001    pub fn r#listen_l2cap(
9002        &self,
9003        mut payload: ChannelListenerRegistryListenL2capRequest,
9004        ___deadline: zx::MonotonicInstant,
9005    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
9006        let _response = self.client.send_query::<
9007            ChannelListenerRegistryListenL2capRequest,
9008            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
9009            PeripheralMarker,
9010        >(
9011            &mut payload,
9012            0x39c6e9001d102338,
9013            fidl::encoding::DynamicFlags::empty(),
9014            ___deadline,
9015        )?;
9016        Ok(_response.map(|x| x))
9017    }
9018
9019    /// Start advertising continuously as a LE peripheral. If advertising cannot
9020    /// be initiated then `advertised_peripheral` will be closed and an error
9021    /// will be returned.
9022    ///
9023    /// This method may be called any number of times. To reconfigure an
9024    /// advertisement, first close the original advertisement and then initiate
9025    /// a new advertisement after an empty response is returned.
9026    ///
9027    /// If the client closes its end of the
9028    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
9029    /// advertising will be stopped. If the handle is closed before the request
9030    /// is fulfilled, advertising may be briefly enabled before it is
9031    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
9032    /// the Peripheral protocol, but this may be changed in the future
9033    /// (https://fxbug.dev/42157682).
9034    ///
9035    /// + request `parameters` Parameters used while configuring the advertising
9036    ///   instance.
9037    /// + request `advertised_peripheral` Protocol that remains valid for the
9038    ///   duration of this advertising session.
9039    /// - response An empty response will be sent when the advertisement is
9040    ///   successfully stopped (due to release of the `advertised_peripheral`
9041    ///   protocol). To prevent overlapping similar advertisements and transient
9042    ///   errors with limited advertising resources, waiting for a response is
9043    ///   recommended before calling `Advertise` again.
9044    /// * error If an error occurs, `advertised_peripheral` will be closed and a
9045    ///   `PeripheralError` will be returned.
9046    pub fn r#advertise(
9047        &self,
9048        mut parameters: &AdvertisingParameters,
9049        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9050        ___deadline: zx::MonotonicInstant,
9051    ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
9052        let _response = self.client.send_query::<
9053            PeripheralAdvertiseRequest,
9054            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
9055            PeripheralMarker,
9056        >(
9057            (parameters, advertised_peripheral,),
9058            0x2d9ec9260c32c17f,
9059            fidl::encoding::DynamicFlags::empty(),
9060            ___deadline,
9061        )?;
9062        Ok(_response.map(|x| x))
9063    }
9064
9065    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
9066    /// has successfully initiated. If advertising cannot be initiated, then the response will
9067    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
9068    ///
9069    /// This method can get called any number of times and successive calls can be made to
9070    /// reconfigure the advertising parameters. However only the most recent
9071    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
9072    ///
9073    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
9074    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
9075    /// advertisements.
9076    ///
9077    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
9078    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
9079    /// advertising will be briefly enabled before it is terminated.
9080    ///
9081    /// + request `parameters` Parameters used while configuring the advertising instance.
9082    /// + request `handle` Handle that remains valid for the duration of this advertising session.
9083    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
9084    ///         initiated. In this case the `handle` will be closed.
9085    pub fn r#start_advertising(
9086        &self,
9087        mut parameters: &AdvertisingParameters,
9088        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9089        ___deadline: zx::MonotonicInstant,
9090    ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
9091        let _response = self.client.send_query::<
9092            PeripheralStartAdvertisingRequest,
9093            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
9094            PeripheralMarker,
9095        >(
9096            (parameters, handle,),
9097            0x5875c1c575f00f7d,
9098            fidl::encoding::DynamicFlags::empty(),
9099            ___deadline,
9100        )?;
9101        Ok(_response.map(|x| x))
9102    }
9103}
9104
9105#[cfg(target_os = "fuchsia")]
9106impl From<PeripheralSynchronousProxy> for zx::NullableHandle {
9107    fn from(value: PeripheralSynchronousProxy) -> Self {
9108        value.into_channel().into()
9109    }
9110}
9111
9112#[cfg(target_os = "fuchsia")]
9113impl From<fidl::Channel> for PeripheralSynchronousProxy {
9114    fn from(value: fidl::Channel) -> Self {
9115        Self::new(value)
9116    }
9117}
9118
9119#[cfg(target_os = "fuchsia")]
9120impl fidl::endpoints::FromClient for PeripheralSynchronousProxy {
9121    type Protocol = PeripheralMarker;
9122
9123    fn from_client(value: fidl::endpoints::ClientEnd<PeripheralMarker>) -> Self {
9124        Self::new(value.into_channel())
9125    }
9126}
9127
9128#[derive(Debug, Clone)]
9129pub struct PeripheralProxy {
9130    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
9131}
9132
9133impl fidl::endpoints::Proxy for PeripheralProxy {
9134    type Protocol = PeripheralMarker;
9135
9136    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
9137        Self::new(inner)
9138    }
9139
9140    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
9141        self.client.into_channel().map_err(|client| Self { client })
9142    }
9143
9144    fn as_channel(&self) -> &::fidl::AsyncChannel {
9145        self.client.as_channel()
9146    }
9147}
9148
9149impl PeripheralProxy {
9150    /// Create a new Proxy for fuchsia.bluetooth.le/Peripheral.
9151    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
9152        let protocol_name = <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
9153        Self { client: fidl::client::Client::new(channel, protocol_name) }
9154    }
9155
9156    /// Get a Stream of events from the remote end of the protocol.
9157    ///
9158    /// # Panics
9159    ///
9160    /// Panics if the event stream was already taken.
9161    pub fn take_event_stream(&self) -> PeripheralEventStream {
9162        PeripheralEventStream { event_receiver: self.client.take_event_receiver() }
9163    }
9164
9165    /// Register a listener for incoming channels. The registry will assign a
9166    /// PSM value that is unique for the local device, as well as open a
9167    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
9168    /// event that all PSMs have been assigned, this call will fail with
9169    /// `ZX_ERR_NO_RESOURCES`.
9170    ///
9171    /// Note that the method of service discovery or advertising is defined by
9172    /// the service or protocol, so it is the responsibility of the caller to
9173    /// communicate the assigned PSM to any clients.
9174    pub fn r#listen_l2cap(
9175        &self,
9176        mut payload: ChannelListenerRegistryListenL2capRequest,
9177    ) -> fidl::client::QueryResponseFut<
9178        ChannelListenerRegistryListenL2capResult,
9179        fidl::encoding::DefaultFuchsiaResourceDialect,
9180    > {
9181        PeripheralProxyInterface::r#listen_l2cap(self, payload)
9182    }
9183
9184    /// Start advertising continuously as a LE peripheral. If advertising cannot
9185    /// be initiated then `advertised_peripheral` will be closed and an error
9186    /// will be returned.
9187    ///
9188    /// This method may be called any number of times. To reconfigure an
9189    /// advertisement, first close the original advertisement and then initiate
9190    /// a new advertisement after an empty response is returned.
9191    ///
9192    /// If the client closes its end of the
9193    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
9194    /// advertising will be stopped. If the handle is closed before the request
9195    /// is fulfilled, advertising may be briefly enabled before it is
9196    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
9197    /// the Peripheral protocol, but this may be changed in the future
9198    /// (https://fxbug.dev/42157682).
9199    ///
9200    /// + request `parameters` Parameters used while configuring the advertising
9201    ///   instance.
9202    /// + request `advertised_peripheral` Protocol that remains valid for the
9203    ///   duration of this advertising session.
9204    /// - response An empty response will be sent when the advertisement is
9205    ///   successfully stopped (due to release of the `advertised_peripheral`
9206    ///   protocol). To prevent overlapping similar advertisements and transient
9207    ///   errors with limited advertising resources, waiting for a response is
9208    ///   recommended before calling `Advertise` again.
9209    /// * error If an error occurs, `advertised_peripheral` will be closed and a
9210    ///   `PeripheralError` will be returned.
9211    pub fn r#advertise(
9212        &self,
9213        mut parameters: &AdvertisingParameters,
9214        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9215    ) -> fidl::client::QueryResponseFut<
9216        PeripheralAdvertiseResult,
9217        fidl::encoding::DefaultFuchsiaResourceDialect,
9218    > {
9219        PeripheralProxyInterface::r#advertise(self, parameters, advertised_peripheral)
9220    }
9221
9222    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
9223    /// has successfully initiated. If advertising cannot be initiated, then the response will
9224    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
9225    ///
9226    /// This method can get called any number of times and successive calls can be made to
9227    /// reconfigure the advertising parameters. However only the most recent
9228    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
9229    ///
9230    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
9231    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
9232    /// advertisements.
9233    ///
9234    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
9235    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
9236    /// advertising will be briefly enabled before it is terminated.
9237    ///
9238    /// + request `parameters` Parameters used while configuring the advertising instance.
9239    /// + request `handle` Handle that remains valid for the duration of this advertising session.
9240    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
9241    ///         initiated. In this case the `handle` will be closed.
9242    pub fn r#start_advertising(
9243        &self,
9244        mut parameters: &AdvertisingParameters,
9245        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9246    ) -> fidl::client::QueryResponseFut<
9247        PeripheralStartAdvertisingResult,
9248        fidl::encoding::DefaultFuchsiaResourceDialect,
9249    > {
9250        PeripheralProxyInterface::r#start_advertising(self, parameters, handle)
9251    }
9252}
9253
9254impl PeripheralProxyInterface for PeripheralProxy {
9255    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
9256        ChannelListenerRegistryListenL2capResult,
9257        fidl::encoding::DefaultFuchsiaResourceDialect,
9258    >;
9259    fn r#listen_l2cap(
9260        &self,
9261        mut payload: ChannelListenerRegistryListenL2capRequest,
9262    ) -> Self::ListenL2capResponseFut {
9263        fn _decode(
9264            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9265        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
9266            let _response = fidl::client::decode_transaction_body::<
9267                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
9268                fidl::encoding::DefaultFuchsiaResourceDialect,
9269                0x39c6e9001d102338,
9270            >(_buf?)?;
9271            Ok(_response.map(|x| x))
9272        }
9273        self.client.send_query_and_decode::<
9274            ChannelListenerRegistryListenL2capRequest,
9275            ChannelListenerRegistryListenL2capResult,
9276        >(
9277            &mut payload,
9278            0x39c6e9001d102338,
9279            fidl::encoding::DynamicFlags::empty(),
9280            _decode,
9281        )
9282    }
9283
9284    type AdvertiseResponseFut = fidl::client::QueryResponseFut<
9285        PeripheralAdvertiseResult,
9286        fidl::encoding::DefaultFuchsiaResourceDialect,
9287    >;
9288    fn r#advertise(
9289        &self,
9290        mut parameters: &AdvertisingParameters,
9291        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9292    ) -> Self::AdvertiseResponseFut {
9293        fn _decode(
9294            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9295        ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
9296            let _response = fidl::client::decode_transaction_body::<
9297                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
9298                fidl::encoding::DefaultFuchsiaResourceDialect,
9299                0x2d9ec9260c32c17f,
9300            >(_buf?)?;
9301            Ok(_response.map(|x| x))
9302        }
9303        self.client.send_query_and_decode::<PeripheralAdvertiseRequest, PeripheralAdvertiseResult>(
9304            (parameters, advertised_peripheral),
9305            0x2d9ec9260c32c17f,
9306            fidl::encoding::DynamicFlags::empty(),
9307            _decode,
9308        )
9309    }
9310
9311    type StartAdvertisingResponseFut = fidl::client::QueryResponseFut<
9312        PeripheralStartAdvertisingResult,
9313        fidl::encoding::DefaultFuchsiaResourceDialect,
9314    >;
9315    fn r#start_advertising(
9316        &self,
9317        mut parameters: &AdvertisingParameters,
9318        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9319    ) -> Self::StartAdvertisingResponseFut {
9320        fn _decode(
9321            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9322        ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
9323            let _response = fidl::client::decode_transaction_body::<
9324                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
9325                fidl::encoding::DefaultFuchsiaResourceDialect,
9326                0x5875c1c575f00f7d,
9327            >(_buf?)?;
9328            Ok(_response.map(|x| x))
9329        }
9330        self.client.send_query_and_decode::<
9331            PeripheralStartAdvertisingRequest,
9332            PeripheralStartAdvertisingResult,
9333        >(
9334            (parameters, handle,),
9335            0x5875c1c575f00f7d,
9336            fidl::encoding::DynamicFlags::empty(),
9337            _decode,
9338        )
9339    }
9340}
9341
9342pub struct PeripheralEventStream {
9343    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
9344}
9345
9346impl std::marker::Unpin for PeripheralEventStream {}
9347
9348impl futures::stream::FusedStream for PeripheralEventStream {
9349    fn is_terminated(&self) -> bool {
9350        self.event_receiver.is_terminated()
9351    }
9352}
9353
9354impl futures::Stream for PeripheralEventStream {
9355    type Item = Result<PeripheralEvent, fidl::Error>;
9356
9357    fn poll_next(
9358        mut self: std::pin::Pin<&mut Self>,
9359        cx: &mut std::task::Context<'_>,
9360    ) -> std::task::Poll<Option<Self::Item>> {
9361        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9362            &mut self.event_receiver,
9363            cx
9364        )?) {
9365            Some(buf) => std::task::Poll::Ready(Some(PeripheralEvent::decode(buf))),
9366            None => std::task::Poll::Ready(None),
9367        }
9368    }
9369}
9370
9371#[derive(Debug)]
9372pub enum PeripheralEvent {
9373    OnPeerConnected { peer: Peer, connection: fidl::endpoints::ClientEnd<ConnectionMarker> },
9374}
9375
9376impl PeripheralEvent {
9377    #[allow(irrefutable_let_patterns)]
9378    pub fn into_on_peer_connected(
9379        self,
9380    ) -> Option<(Peer, fidl::endpoints::ClientEnd<ConnectionMarker>)> {
9381        if let PeripheralEvent::OnPeerConnected { peer, connection } = self {
9382            Some((peer, connection))
9383        } else {
9384            None
9385        }
9386    }
9387
9388    /// Decodes a message buffer as a [`PeripheralEvent`].
9389    fn decode(
9390        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9391    ) -> Result<PeripheralEvent, fidl::Error> {
9392        let (bytes, _handles) = buf.split_mut();
9393        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9394        debug_assert_eq!(tx_header.tx_id, 0);
9395        match tx_header.ordinal {
9396            0x16135d464299e356 => {
9397                let mut out = fidl::new_empty!(
9398                    PeripheralOnPeerConnectedRequest,
9399                    fidl::encoding::DefaultFuchsiaResourceDialect
9400                );
9401                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralOnPeerConnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
9402                Ok((PeripheralEvent::OnPeerConnected {
9403                    peer: out.peer,
9404                    connection: out.connection,
9405                }))
9406            }
9407            _ => Err(fidl::Error::UnknownOrdinal {
9408                ordinal: tx_header.ordinal,
9409                protocol_name: <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9410            }),
9411        }
9412    }
9413}
9414
9415/// A Stream of incoming requests for fuchsia.bluetooth.le/Peripheral.
9416pub struct PeripheralRequestStream {
9417    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9418    is_terminated: bool,
9419}
9420
9421impl std::marker::Unpin for PeripheralRequestStream {}
9422
9423impl futures::stream::FusedStream for PeripheralRequestStream {
9424    fn is_terminated(&self) -> bool {
9425        self.is_terminated
9426    }
9427}
9428
9429impl fidl::endpoints::RequestStream for PeripheralRequestStream {
9430    type Protocol = PeripheralMarker;
9431    type ControlHandle = PeripheralControlHandle;
9432
9433    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9434        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9435    }
9436
9437    fn control_handle(&self) -> Self::ControlHandle {
9438        PeripheralControlHandle { inner: self.inner.clone() }
9439    }
9440
9441    fn into_inner(
9442        self,
9443    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9444    {
9445        (self.inner, self.is_terminated)
9446    }
9447
9448    fn from_inner(
9449        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9450        is_terminated: bool,
9451    ) -> Self {
9452        Self { inner, is_terminated }
9453    }
9454}
9455
9456impl futures::Stream for PeripheralRequestStream {
9457    type Item = Result<PeripheralRequest, fidl::Error>;
9458
9459    fn poll_next(
9460        mut self: std::pin::Pin<&mut Self>,
9461        cx: &mut std::task::Context<'_>,
9462    ) -> std::task::Poll<Option<Self::Item>> {
9463        let this = &mut *self;
9464        if this.inner.check_shutdown(cx) {
9465            this.is_terminated = true;
9466            return std::task::Poll::Ready(None);
9467        }
9468        if this.is_terminated {
9469            panic!("polled PeripheralRequestStream after completion");
9470        }
9471        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9472            |bytes, handles| {
9473                match this.inner.channel().read_etc(cx, bytes, handles) {
9474                    std::task::Poll::Ready(Ok(())) => {}
9475                    std::task::Poll::Pending => return std::task::Poll::Pending,
9476                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9477                        this.is_terminated = true;
9478                        return std::task::Poll::Ready(None);
9479                    }
9480                    std::task::Poll::Ready(Err(e)) => {
9481                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9482                            e.into(),
9483                        ))));
9484                    }
9485                }
9486
9487                // A message has been received from the channel
9488                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9489
9490                std::task::Poll::Ready(Some(match header.ordinal {
9491                    0x39c6e9001d102338 => {
9492                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9493                        let mut req = fidl::new_empty!(
9494                            ChannelListenerRegistryListenL2capRequest,
9495                            fidl::encoding::DefaultFuchsiaResourceDialect
9496                        );
9497                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
9498                        let control_handle = PeripheralControlHandle { inner: this.inner.clone() };
9499                        Ok(PeripheralRequest::ListenL2cap {
9500                            payload: req,
9501                            responder: PeripheralListenL2capResponder {
9502                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9503                                tx_id: header.tx_id,
9504                            },
9505                        })
9506                    }
9507                    0x2d9ec9260c32c17f => {
9508                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9509                        let mut req = fidl::new_empty!(
9510                            PeripheralAdvertiseRequest,
9511                            fidl::encoding::DefaultFuchsiaResourceDialect
9512                        );
9513                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralAdvertiseRequest>(&header, _body_bytes, handles, &mut req)?;
9514                        let control_handle = PeripheralControlHandle { inner: this.inner.clone() };
9515                        Ok(PeripheralRequest::Advertise {
9516                            parameters: req.parameters,
9517                            advertised_peripheral: req.advertised_peripheral,
9518
9519                            responder: PeripheralAdvertiseResponder {
9520                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9521                                tx_id: header.tx_id,
9522                            },
9523                        })
9524                    }
9525                    0x5875c1c575f00f7d => {
9526                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9527                        let mut req = fidl::new_empty!(
9528                            PeripheralStartAdvertisingRequest,
9529                            fidl::encoding::DefaultFuchsiaResourceDialect
9530                        );
9531                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralStartAdvertisingRequest>(&header, _body_bytes, handles, &mut req)?;
9532                        let control_handle = PeripheralControlHandle { inner: this.inner.clone() };
9533                        Ok(PeripheralRequest::StartAdvertising {
9534                            parameters: req.parameters,
9535                            handle: req.handle,
9536
9537                            responder: PeripheralStartAdvertisingResponder {
9538                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9539                                tx_id: header.tx_id,
9540                            },
9541                        })
9542                    }
9543                    _ => Err(fidl::Error::UnknownOrdinal {
9544                        ordinal: header.ordinal,
9545                        protocol_name:
9546                            <PeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9547                    }),
9548                }))
9549            },
9550        )
9551    }
9552}
9553
9554#[derive(Debug)]
9555pub enum PeripheralRequest {
9556    /// Register a listener for incoming channels. The registry will assign a
9557    /// PSM value that is unique for the local device, as well as open a
9558    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
9559    /// event that all PSMs have been assigned, this call will fail with
9560    /// `ZX_ERR_NO_RESOURCES`.
9561    ///
9562    /// Note that the method of service discovery or advertising is defined by
9563    /// the service or protocol, so it is the responsibility of the caller to
9564    /// communicate the assigned PSM to any clients.
9565    ListenL2cap {
9566        payload: ChannelListenerRegistryListenL2capRequest,
9567        responder: PeripheralListenL2capResponder,
9568    },
9569    /// Start advertising continuously as a LE peripheral. If advertising cannot
9570    /// be initiated then `advertised_peripheral` will be closed and an error
9571    /// will be returned.
9572    ///
9573    /// This method may be called any number of times. To reconfigure an
9574    /// advertisement, first close the original advertisement and then initiate
9575    /// a new advertisement after an empty response is returned.
9576    ///
9577    /// If the client closes its end of the
9578    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
9579    /// advertising will be stopped. If the handle is closed before the request
9580    /// is fulfilled, advertising may be briefly enabled before it is
9581    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
9582    /// the Peripheral protocol, but this may be changed in the future
9583    /// (https://fxbug.dev/42157682).
9584    ///
9585    /// + request `parameters` Parameters used while configuring the advertising
9586    ///   instance.
9587    /// + request `advertised_peripheral` Protocol that remains valid for the
9588    ///   duration of this advertising session.
9589    /// - response An empty response will be sent when the advertisement is
9590    ///   successfully stopped (due to release of the `advertised_peripheral`
9591    ///   protocol). To prevent overlapping similar advertisements and transient
9592    ///   errors with limited advertising resources, waiting for a response is
9593    ///   recommended before calling `Advertise` again.
9594    /// * error If an error occurs, `advertised_peripheral` will be closed and a
9595    ///   `PeripheralError` will be returned.
9596    Advertise {
9597        parameters: AdvertisingParameters,
9598        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9599        responder: PeripheralAdvertiseResponder,
9600    },
9601    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
9602    /// has successfully initiated. If advertising cannot be initiated, then the response will
9603    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
9604    ///
9605    /// This method can get called any number of times and successive calls can be made to
9606    /// reconfigure the advertising parameters. However only the most recent
9607    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
9608    ///
9609    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
9610    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
9611    /// advertisements.
9612    ///
9613    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
9614    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
9615    /// advertising will be briefly enabled before it is terminated.
9616    ///
9617    /// + request `parameters` Parameters used while configuring the advertising instance.
9618    /// + request `handle` Handle that remains valid for the duration of this advertising session.
9619    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
9620    ///         initiated. In this case the `handle` will be closed.
9621    StartAdvertising {
9622        parameters: AdvertisingParameters,
9623        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9624        responder: PeripheralStartAdvertisingResponder,
9625    },
9626}
9627
9628impl PeripheralRequest {
9629    #[allow(irrefutable_let_patterns)]
9630    pub fn into_listen_l2cap(
9631        self,
9632    ) -> Option<(ChannelListenerRegistryListenL2capRequest, PeripheralListenL2capResponder)> {
9633        if let PeripheralRequest::ListenL2cap { payload, responder } = self {
9634            Some((payload, responder))
9635        } else {
9636            None
9637        }
9638    }
9639
9640    #[allow(irrefutable_let_patterns)]
9641    pub fn into_advertise(
9642        self,
9643    ) -> Option<(
9644        AdvertisingParameters,
9645        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
9646        PeripheralAdvertiseResponder,
9647    )> {
9648        if let PeripheralRequest::Advertise { parameters, advertised_peripheral, responder } = self
9649        {
9650            Some((parameters, advertised_peripheral, responder))
9651        } else {
9652            None
9653        }
9654    }
9655
9656    #[allow(irrefutable_let_patterns)]
9657    pub fn into_start_advertising(
9658        self,
9659    ) -> Option<(
9660        AdvertisingParameters,
9661        fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
9662        PeripheralStartAdvertisingResponder,
9663    )> {
9664        if let PeripheralRequest::StartAdvertising { parameters, handle, responder } = self {
9665            Some((parameters, handle, responder))
9666        } else {
9667            None
9668        }
9669    }
9670
9671    /// Name of the method defined in FIDL
9672    pub fn method_name(&self) -> &'static str {
9673        match *self {
9674            PeripheralRequest::ListenL2cap { .. } => "listen_l2cap",
9675            PeripheralRequest::Advertise { .. } => "advertise",
9676            PeripheralRequest::StartAdvertising { .. } => "start_advertising",
9677        }
9678    }
9679}
9680
9681#[derive(Debug, Clone)]
9682pub struct PeripheralControlHandle {
9683    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9684}
9685
9686impl fidl::endpoints::ControlHandle for PeripheralControlHandle {
9687    fn shutdown(&self) {
9688        self.inner.shutdown()
9689    }
9690
9691    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
9692        self.inner.shutdown_with_epitaph(status)
9693    }
9694
9695    fn is_closed(&self) -> bool {
9696        self.inner.channel().is_closed()
9697    }
9698    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
9699        self.inner.channel().on_closed()
9700    }
9701
9702    #[cfg(target_os = "fuchsia")]
9703    fn signal_peer(
9704        &self,
9705        clear_mask: zx::Signals,
9706        set_mask: zx::Signals,
9707    ) -> Result<(), zx_status::Status> {
9708        use fidl::Peered;
9709        self.inner.channel().signal_peer(clear_mask, set_mask)
9710    }
9711}
9712
9713impl PeripheralControlHandle {
9714    pub fn send_on_peer_connected(
9715        &self,
9716        mut peer: &Peer,
9717        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
9718    ) -> Result<(), fidl::Error> {
9719        self.inner.send::<PeripheralOnPeerConnectedRequest>(
9720            (peer, connection),
9721            0,
9722            0x16135d464299e356,
9723            fidl::encoding::DynamicFlags::empty(),
9724        )
9725    }
9726}
9727
9728#[must_use = "FIDL methods require a response to be sent"]
9729#[derive(Debug)]
9730pub struct PeripheralListenL2capResponder {
9731    control_handle: std::mem::ManuallyDrop<PeripheralControlHandle>,
9732    tx_id: u32,
9733}
9734
9735/// Set the the channel to be shutdown (see [`PeripheralControlHandle::shutdown`])
9736/// if the responder is dropped without sending a response, so that the client
9737/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9738impl std::ops::Drop for PeripheralListenL2capResponder {
9739    fn drop(&mut self) {
9740        self.control_handle.shutdown();
9741        // Safety: drops once, never accessed again
9742        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9743    }
9744}
9745
9746impl fidl::endpoints::Responder for PeripheralListenL2capResponder {
9747    type ControlHandle = PeripheralControlHandle;
9748
9749    fn control_handle(&self) -> &PeripheralControlHandle {
9750        &self.control_handle
9751    }
9752
9753    fn drop_without_shutdown(mut self) {
9754        // Safety: drops once, never accessed again due to mem::forget
9755        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9756        // Prevent Drop from running (which would shut down the channel)
9757        std::mem::forget(self);
9758    }
9759}
9760
9761impl PeripheralListenL2capResponder {
9762    /// Sends a response to the FIDL transaction.
9763    ///
9764    /// Sets the channel to shutdown if an error occurs.
9765    pub fn send(
9766        self,
9767        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
9768    ) -> Result<(), fidl::Error> {
9769        let _result = self.send_raw(result);
9770        if _result.is_err() {
9771            self.control_handle.shutdown();
9772        }
9773        self.drop_without_shutdown();
9774        _result
9775    }
9776
9777    /// Similar to "send" but does not shutdown the channel if an error occurs.
9778    pub fn send_no_shutdown_on_err(
9779        self,
9780        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
9781    ) -> Result<(), fidl::Error> {
9782        let _result = self.send_raw(result);
9783        self.drop_without_shutdown();
9784        _result
9785    }
9786
9787    fn send_raw(
9788        &self,
9789        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
9790    ) -> Result<(), fidl::Error> {
9791        self.control_handle.inner.send::<fidl::encoding::ResultType<
9792            ChannelListenerRegistryListenL2capResponse,
9793            i32,
9794        >>(
9795            result,
9796            self.tx_id,
9797            0x39c6e9001d102338,
9798            fidl::encoding::DynamicFlags::empty(),
9799        )
9800    }
9801}
9802
9803#[must_use = "FIDL methods require a response to be sent"]
9804#[derive(Debug)]
9805pub struct PeripheralAdvertiseResponder {
9806    control_handle: std::mem::ManuallyDrop<PeripheralControlHandle>,
9807    tx_id: u32,
9808}
9809
9810/// Set the the channel to be shutdown (see [`PeripheralControlHandle::shutdown`])
9811/// if the responder is dropped without sending a response, so that the client
9812/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9813impl std::ops::Drop for PeripheralAdvertiseResponder {
9814    fn drop(&mut self) {
9815        self.control_handle.shutdown();
9816        // Safety: drops once, never accessed again
9817        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9818    }
9819}
9820
9821impl fidl::endpoints::Responder for PeripheralAdvertiseResponder {
9822    type ControlHandle = PeripheralControlHandle;
9823
9824    fn control_handle(&self) -> &PeripheralControlHandle {
9825        &self.control_handle
9826    }
9827
9828    fn drop_without_shutdown(mut self) {
9829        // Safety: drops once, never accessed again due to mem::forget
9830        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9831        // Prevent Drop from running (which would shut down the channel)
9832        std::mem::forget(self);
9833    }
9834}
9835
9836impl PeripheralAdvertiseResponder {
9837    /// Sends a response to the FIDL transaction.
9838    ///
9839    /// Sets the channel to shutdown if an error occurs.
9840    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
9841        let _result = self.send_raw(result);
9842        if _result.is_err() {
9843            self.control_handle.shutdown();
9844        }
9845        self.drop_without_shutdown();
9846        _result
9847    }
9848
9849    /// Similar to "send" but does not shutdown the channel if an error occurs.
9850    pub fn send_no_shutdown_on_err(
9851        self,
9852        mut result: Result<(), PeripheralError>,
9853    ) -> Result<(), fidl::Error> {
9854        let _result = self.send_raw(result);
9855        self.drop_without_shutdown();
9856        _result
9857    }
9858
9859    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
9860        self.control_handle.inner.send::<fidl::encoding::ResultType<
9861            fidl::encoding::EmptyStruct,
9862            PeripheralError,
9863        >>(
9864            result,
9865            self.tx_id,
9866            0x2d9ec9260c32c17f,
9867            fidl::encoding::DynamicFlags::empty(),
9868        )
9869    }
9870}
9871
9872#[must_use = "FIDL methods require a response to be sent"]
9873#[derive(Debug)]
9874pub struct PeripheralStartAdvertisingResponder {
9875    control_handle: std::mem::ManuallyDrop<PeripheralControlHandle>,
9876    tx_id: u32,
9877}
9878
9879/// Set the the channel to be shutdown (see [`PeripheralControlHandle::shutdown`])
9880/// if the responder is dropped without sending a response, so that the client
9881/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9882impl std::ops::Drop for PeripheralStartAdvertisingResponder {
9883    fn drop(&mut self) {
9884        self.control_handle.shutdown();
9885        // Safety: drops once, never accessed again
9886        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9887    }
9888}
9889
9890impl fidl::endpoints::Responder for PeripheralStartAdvertisingResponder {
9891    type ControlHandle = PeripheralControlHandle;
9892
9893    fn control_handle(&self) -> &PeripheralControlHandle {
9894        &self.control_handle
9895    }
9896
9897    fn drop_without_shutdown(mut self) {
9898        // Safety: drops once, never accessed again due to mem::forget
9899        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9900        // Prevent Drop from running (which would shut down the channel)
9901        std::mem::forget(self);
9902    }
9903}
9904
9905impl PeripheralStartAdvertisingResponder {
9906    /// Sends a response to the FIDL transaction.
9907    ///
9908    /// Sets the channel to shutdown if an error occurs.
9909    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
9910        let _result = self.send_raw(result);
9911        if _result.is_err() {
9912            self.control_handle.shutdown();
9913        }
9914        self.drop_without_shutdown();
9915        _result
9916    }
9917
9918    /// Similar to "send" but does not shutdown the channel if an error occurs.
9919    pub fn send_no_shutdown_on_err(
9920        self,
9921        mut result: Result<(), PeripheralError>,
9922    ) -> Result<(), fidl::Error> {
9923        let _result = self.send_raw(result);
9924        self.drop_without_shutdown();
9925        _result
9926    }
9927
9928    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
9929        self.control_handle.inner.send::<fidl::encoding::ResultType<
9930            fidl::encoding::EmptyStruct,
9931            PeripheralError,
9932        >>(
9933            result,
9934            self.tx_id,
9935            0x5875c1c575f00f7d,
9936            fidl::encoding::DynamicFlags::empty(),
9937        )
9938    }
9939}
9940
9941#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
9942pub struct PrivilegedCentralMarker;
9943
9944impl fidl::endpoints::ProtocolMarker for PrivilegedCentralMarker {
9945    type Proxy = PrivilegedCentralProxy;
9946    type RequestStream = PrivilegedCentralRequestStream;
9947    #[cfg(target_os = "fuchsia")]
9948    type SynchronousProxy = PrivilegedCentralSynchronousProxy;
9949
9950    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.PrivilegedCentral";
9951}
9952impl fidl::endpoints::DiscoverableProtocolMarker for PrivilegedCentralMarker {}
9953
9954pub trait PrivilegedCentralProxyInterface: Send + Sync {
9955    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
9956        + Send;
9957    fn r#listen_l2cap(
9958        &self,
9959        payload: ChannelListenerRegistryListenL2capRequest,
9960    ) -> Self::ListenL2capResponseFut;
9961    type ScanResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
9962    fn r#scan(
9963        &self,
9964        options: &ScanOptions,
9965        result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
9966    ) -> Self::ScanResponseFut;
9967    fn r#connect(
9968        &self,
9969        id: &fidl_fuchsia_bluetooth::PeerId,
9970        options: &ConnectionOptions,
9971        handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
9972    ) -> Result<(), fidl::Error>;
9973    fn r#sync_to_periodic_advertising(
9974        &self,
9975        payload: CentralSyncToPeriodicAdvertisingRequest,
9976    ) -> Result<(), fidl::Error>;
9977    type CreateConnectedIsochronousGroupResponseFut: std::future::Future<
9978            Output = Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error>,
9979        > + Send;
9980    fn r#create_connected_isochronous_group(
9981        &self,
9982        payload: CentralCreateConnectedIsochronousGroupRequest,
9983    ) -> Self::CreateConnectedIsochronousGroupResponseFut;
9984    type GetPeripheralsResponseFut: std::future::Future<Output = Result<Vec<RemoteDevice>, fidl::Error>>
9985        + Send;
9986    fn r#get_peripherals(
9987        &self,
9988        service_uuids: Option<&[String]>,
9989    ) -> Self::GetPeripheralsResponseFut;
9990    type GetPeripheralResponseFut: std::future::Future<Output = Result<Option<Box<RemoteDevice>>, fidl::Error>>
9991        + Send;
9992    fn r#get_peripheral(&self, identifier: &str) -> Self::GetPeripheralResponseFut;
9993    type StartScanResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
9994        + Send;
9995    fn r#start_scan(&self, filter: Option<&ScanFilter>) -> Self::StartScanResponseFut;
9996    fn r#stop_scan(&self) -> Result<(), fidl::Error>;
9997    type ConnectPeripheralResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
9998        + Send;
9999    fn r#connect_peripheral(
10000        &self,
10001        identifier: &str,
10002        options: &ConnectionOptions,
10003        gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
10004    ) -> Self::ConnectPeripheralResponseFut;
10005    type DisconnectPeripheralResponseFut: std::future::Future<Output = Result<fidl_fuchsia_bluetooth::Status, fidl::Error>>
10006        + Send;
10007    fn r#disconnect_peripheral(&self, identifier: &str) -> Self::DisconnectPeripheralResponseFut;
10008}
10009#[derive(Debug)]
10010#[cfg(target_os = "fuchsia")]
10011pub struct PrivilegedCentralSynchronousProxy {
10012    client: fidl::client::sync::Client,
10013}
10014
10015#[cfg(target_os = "fuchsia")]
10016impl fidl::endpoints::SynchronousProxy for PrivilegedCentralSynchronousProxy {
10017    type Proxy = PrivilegedCentralProxy;
10018    type Protocol = PrivilegedCentralMarker;
10019
10020    fn from_channel(inner: fidl::Channel) -> Self {
10021        Self::new(inner)
10022    }
10023
10024    fn into_channel(self) -> fidl::Channel {
10025        self.client.into_channel()
10026    }
10027
10028    fn as_channel(&self) -> &fidl::Channel {
10029        self.client.as_channel()
10030    }
10031}
10032
10033#[cfg(target_os = "fuchsia")]
10034impl PrivilegedCentralSynchronousProxy {
10035    pub fn new(channel: fidl::Channel) -> Self {
10036        Self { client: fidl::client::sync::Client::new(channel) }
10037    }
10038
10039    pub fn into_channel(self) -> fidl::Channel {
10040        self.client.into_channel()
10041    }
10042
10043    /// Waits until an event arrives and returns it. It is safe for other
10044    /// threads to make concurrent requests while waiting for an event.
10045    pub fn wait_for_event(
10046        &self,
10047        deadline: zx::MonotonicInstant,
10048    ) -> Result<PrivilegedCentralEvent, fidl::Error> {
10049        PrivilegedCentralEvent::decode(
10050            self.client.wait_for_event::<PrivilegedCentralMarker>(deadline)?,
10051        )
10052    }
10053
10054    /// Register a listener for incoming channels. The registry will assign a
10055    /// PSM value that is unique for the local device, as well as open a
10056    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
10057    /// event that all PSMs have been assigned, this call will fail with
10058    /// `ZX_ERR_NO_RESOURCES`.
10059    ///
10060    /// Note that the method of service discovery or advertising is defined by
10061    /// the service or protocol, so it is the responsibility of the caller to
10062    /// communicate the assigned PSM to any clients.
10063    pub fn r#listen_l2cap(
10064        &self,
10065        mut payload: ChannelListenerRegistryListenL2capRequest,
10066        ___deadline: zx::MonotonicInstant,
10067    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
10068        let _response = self.client.send_query::<
10069            ChannelListenerRegistryListenL2capRequest,
10070            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
10071            PrivilegedCentralMarker,
10072        >(
10073            &mut payload,
10074            0x39c6e9001d102338,
10075            fidl::encoding::DynamicFlags::empty(),
10076            ___deadline,
10077        )?;
10078        Ok(_response.map(|x| x))
10079    }
10080
10081    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
10082    /// initiated, then `result_watcher` will be closed with an epitaph.
10083    ///
10084    /// A Central client is allowed to have only one active scan at a time.
10085    /// Accordingly, only one Scan request can be outstanding at a time.
10086    /// Additional calls to Scan will fail.
10087    ///
10088    /// The lifetime of the scan session is tied to the `result_watcher`
10089    /// protocol provided. The scan will be stopped if the channel is closed.
10090    ///
10091    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
10092    /// can be used to watch for scan results.
10093    ///
10094    /// + request `options` Options used to configure the scan session.
10095    /// + request `result_watcher` Protocol that remains valid for the duration
10096    ///   of this scan session.
10097    /// - response An empty response will be sent to acknowledge the scan has
10098    ///   stopped.
10099    ///
10100    /// The following epitaphs may be sent by the server on error:
10101    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
10102    ///   protocol is only allowed 1 active scan.
10103    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
10104    ///   `ScanOptions` documentation.
10105    /// * error `INTERNAL`: An internal error occurred and a scan could not be
10106    ///   started.
10107    pub fn r#scan(
10108        &self,
10109        mut options: &ScanOptions,
10110        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
10111        ___deadline: zx::MonotonicInstant,
10112    ) -> Result<(), fidl::Error> {
10113        let _response = self.client.send_query::<
10114            CentralScanRequest,
10115            fidl::encoding::EmptyPayload,
10116            PrivilegedCentralMarker,
10117        >(
10118            (options, result_watcher,),
10119            0x41f7121798dfe15f,
10120            fidl::encoding::DynamicFlags::empty(),
10121            ___deadline,
10122        )?;
10123        Ok(_response)
10124    }
10125
10126    /// Connect to the peer with the given identifier.
10127    ///
10128    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
10129    /// client's interest on the LE connection to the peer. Closing the channel
10130    /// removes interest, but may not result in disconnection if another client
10131    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
10132    ///
10133    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
10134    /// system if the connection to the peer is lost or an error occurs.
10135    ///
10136    /// The following epitaphs may be sent by the server on error:
10137    /// + `INVALID_ARGS`: Some of the parameters are invalid.
10138    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
10139    ///                    Connection should be used.
10140    /// + `NOT_CONNECTED`: A connection could not be established.
10141    /// + `CONNECTION_RESET`: The peer disconnected.
10142    ///
10143    /// + request `id` Identifier of the peer to initiate a connection to.
10144    /// + request `options` Options used to configure the connection.
10145    /// + request `handle` Handle that remains valid for the duration of this
10146    ///   connection.
10147    pub fn r#connect(
10148        &self,
10149        mut id: &fidl_fuchsia_bluetooth::PeerId,
10150        mut options: &ConnectionOptions,
10151        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
10152    ) -> Result<(), fidl::Error> {
10153        self.client.send::<CentralConnectRequest>(
10154            (id, options, handle),
10155            0x31a3065f2a6913c4,
10156            fidl::encoding::DynamicFlags::empty(),
10157        )
10158    }
10159
10160    /// Synchronize to a periodic advertising train. Reports will be delivered via the
10161    /// `PeriodicAdvertisingSync` protocol.
10162    pub fn r#sync_to_periodic_advertising(
10163        &self,
10164        mut payload: CentralSyncToPeriodicAdvertisingRequest,
10165    ) -> Result<(), fidl::Error> {
10166        self.client.send::<CentralSyncToPeriodicAdvertisingRequest>(
10167            &mut payload,
10168            0x1db6df126a00c5b9,
10169            fidl::encoding::DynamicFlags::empty(),
10170        )
10171    }
10172
10173    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
10174    /// operation is only valid when operating in the Central role for a connection.
10175    ///
10176    /// If the Central channel is closed before the CIG is explicitly removed, the group will
10177    /// be removed and disconnected.
10178    ///
10179    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
10180    /// id allocated by the host.
10181    pub fn r#create_connected_isochronous_group(
10182        &self,
10183        mut payload: CentralCreateConnectedIsochronousGroupRequest,
10184        ___deadline: zx::MonotonicInstant,
10185    ) -> Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error> {
10186        let _response = self
10187            .client
10188            .send_query::<CentralCreateConnectedIsochronousGroupRequest, fidl::encoding::ResultType<
10189                CentralCreateConnectedIsochronousGroupResponse,
10190                CreateCigError,
10191            >, PrivilegedCentralMarker>(
10192                &mut payload,
10193                0x60323e70ae22e13,
10194                fidl::encoding::DynamicFlags::empty(),
10195                ___deadline,
10196            )?;
10197        Ok(_response.map(|x| x))
10198    }
10199
10200    /// Returns the list of peripherals that are known to the system from previous scan, connection,
10201    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
10202    /// be present on the peripheral.
10203    ///
10204    /// This method only returns peripherals (i.e. connectable devices).
10205    pub fn r#get_peripherals(
10206        &self,
10207        mut service_uuids: Option<&[String]>,
10208        ___deadline: zx::MonotonicInstant,
10209    ) -> Result<Vec<RemoteDevice>, fidl::Error> {
10210        let _response = self.client.send_query::<
10211            CentralGetPeripheralsRequest,
10212            CentralGetPeripheralsResponse,
10213            PrivilegedCentralMarker,
10214        >(
10215            (service_uuids,),
10216            0x37ba777499c683a8,
10217            fidl::encoding::DynamicFlags::empty(),
10218            ___deadline,
10219        )?;
10220        Ok(_response.peripherals)
10221    }
10222
10223    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
10224    ///
10225    /// Returns information about a single peripheral that is known to the system from previous scan,
10226    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
10227    /// `identifier` is not recognized.
10228    pub fn r#get_peripheral(
10229        &self,
10230        mut identifier: &str,
10231        ___deadline: zx::MonotonicInstant,
10232    ) -> Result<Option<Box<RemoteDevice>>, fidl::Error> {
10233        let _response = self.client.send_query::<
10234            CentralGetPeripheralRequest,
10235            CentralGetPeripheralResponse,
10236            PrivilegedCentralMarker,
10237        >(
10238            (identifier,),
10239            0x97f5a2f2d9c13da,
10240            fidl::encoding::DynamicFlags::empty(),
10241            ___deadline,
10242        )?;
10243        Ok(_response.peripheral)
10244    }
10245
10246    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
10247    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
10248    /// `filter` will replace the existing session's filter.
10249    ///
10250    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
10251    /// will be notified for all discoverable devices that are found. This is not recommended; clients
10252    /// should generally filter results by at least one of `filter.service_uuids`,
10253    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
10254    pub fn r#start_scan(
10255        &self,
10256        mut filter: Option<&ScanFilter>,
10257        ___deadline: zx::MonotonicInstant,
10258    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
10259        let _response = self.client.send_query::<
10260            CentralStartScanRequest,
10261            CentralStartScanResponse,
10262            PrivilegedCentralMarker,
10263        >(
10264            (filter,),
10265            0xeb4cf0cd0e1132b,
10266            fidl::encoding::DynamicFlags::empty(),
10267            ___deadline,
10268        )?;
10269        Ok(_response.status)
10270    }
10271
10272    /// Terminate a previously started scan session.
10273    pub fn r#stop_scan(&self) -> Result<(), fidl::Error> {
10274        self.client.send::<fidl::encoding::EmptyPayload>(
10275            (),
10276            0x5f79ee6a0bb037a0,
10277            fidl::encoding::DynamicFlags::empty(),
10278        )
10279    }
10280
10281    /// Creates a connection to the peripheral device with the given identifier.
10282    /// Returns the status of the operation in `status`.
10283    ///
10284    /// On success, `gatt_client` will be bound and can be used for GATT client
10285    /// role procedures. On failure, `gatt_client` will be closed and `status` will
10286    /// indicate an error.
10287    pub fn r#connect_peripheral(
10288        &self,
10289        mut identifier: &str,
10290        mut options: &ConnectionOptions,
10291        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
10292        ___deadline: zx::MonotonicInstant,
10293    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
10294        let _response = self.client.send_query::<
10295            CentralConnectPeripheralRequest,
10296            CentralConnectPeripheralResponse,
10297            PrivilegedCentralMarker,
10298        >(
10299            (identifier, options, gatt_client,),
10300            0x714d6c32d066d75a,
10301            fidl::encoding::DynamicFlags::empty(),
10302            ___deadline,
10303        )?;
10304        Ok(_response.status)
10305    }
10306
10307    /// Disconnects this Central's connection to the peripheral with the given identifier.
10308    pub fn r#disconnect_peripheral(
10309        &self,
10310        mut identifier: &str,
10311        ___deadline: zx::MonotonicInstant,
10312    ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
10313        let _response = self.client.send_query::<
10314            CentralDisconnectPeripheralRequest,
10315            CentralDisconnectPeripheralResponse,
10316            PrivilegedCentralMarker,
10317        >(
10318            (identifier,),
10319            0xa9430da197362fd,
10320            fidl::encoding::DynamicFlags::empty(),
10321            ___deadline,
10322        )?;
10323        Ok(_response.status)
10324    }
10325}
10326
10327#[cfg(target_os = "fuchsia")]
10328impl From<PrivilegedCentralSynchronousProxy> for zx::NullableHandle {
10329    fn from(value: PrivilegedCentralSynchronousProxy) -> Self {
10330        value.into_channel().into()
10331    }
10332}
10333
10334#[cfg(target_os = "fuchsia")]
10335impl From<fidl::Channel> for PrivilegedCentralSynchronousProxy {
10336    fn from(value: fidl::Channel) -> Self {
10337        Self::new(value)
10338    }
10339}
10340
10341#[cfg(target_os = "fuchsia")]
10342impl fidl::endpoints::FromClient for PrivilegedCentralSynchronousProxy {
10343    type Protocol = PrivilegedCentralMarker;
10344
10345    fn from_client(value: fidl::endpoints::ClientEnd<PrivilegedCentralMarker>) -> Self {
10346        Self::new(value.into_channel())
10347    }
10348}
10349
10350#[derive(Debug, Clone)]
10351pub struct PrivilegedCentralProxy {
10352    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
10353}
10354
10355impl fidl::endpoints::Proxy for PrivilegedCentralProxy {
10356    type Protocol = PrivilegedCentralMarker;
10357
10358    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
10359        Self::new(inner)
10360    }
10361
10362    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
10363        self.client.into_channel().map_err(|client| Self { client })
10364    }
10365
10366    fn as_channel(&self) -> &::fidl::AsyncChannel {
10367        self.client.as_channel()
10368    }
10369}
10370
10371impl PrivilegedCentralProxy {
10372    /// Create a new Proxy for fuchsia.bluetooth.le/PrivilegedCentral.
10373    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
10374        let protocol_name =
10375            <PrivilegedCentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10376        Self { client: fidl::client::Client::new(channel, protocol_name) }
10377    }
10378
10379    /// Get a Stream of events from the remote end of the protocol.
10380    ///
10381    /// # Panics
10382    ///
10383    /// Panics if the event stream was already taken.
10384    pub fn take_event_stream(&self) -> PrivilegedCentralEventStream {
10385        PrivilegedCentralEventStream { event_receiver: self.client.take_event_receiver() }
10386    }
10387
10388    /// Register a listener for incoming channels. The registry will assign a
10389    /// PSM value that is unique for the local device, as well as open a
10390    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
10391    /// event that all PSMs have been assigned, this call will fail with
10392    /// `ZX_ERR_NO_RESOURCES`.
10393    ///
10394    /// Note that the method of service discovery or advertising is defined by
10395    /// the service or protocol, so it is the responsibility of the caller to
10396    /// communicate the assigned PSM to any clients.
10397    pub fn r#listen_l2cap(
10398        &self,
10399        mut payload: ChannelListenerRegistryListenL2capRequest,
10400    ) -> fidl::client::QueryResponseFut<
10401        ChannelListenerRegistryListenL2capResult,
10402        fidl::encoding::DefaultFuchsiaResourceDialect,
10403    > {
10404        PrivilegedCentralProxyInterface::r#listen_l2cap(self, payload)
10405    }
10406
10407    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
10408    /// initiated, then `result_watcher` will be closed with an epitaph.
10409    ///
10410    /// A Central client is allowed to have only one active scan at a time.
10411    /// Accordingly, only one Scan request can be outstanding at a time.
10412    /// Additional calls to Scan will fail.
10413    ///
10414    /// The lifetime of the scan session is tied to the `result_watcher`
10415    /// protocol provided. The scan will be stopped if the channel is closed.
10416    ///
10417    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
10418    /// can be used to watch for scan results.
10419    ///
10420    /// + request `options` Options used to configure the scan session.
10421    /// + request `result_watcher` Protocol that remains valid for the duration
10422    ///   of this scan session.
10423    /// - response An empty response will be sent to acknowledge the scan has
10424    ///   stopped.
10425    ///
10426    /// The following epitaphs may be sent by the server on error:
10427    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
10428    ///   protocol is only allowed 1 active scan.
10429    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
10430    ///   `ScanOptions` documentation.
10431    /// * error `INTERNAL`: An internal error occurred and a scan could not be
10432    ///   started.
10433    pub fn r#scan(
10434        &self,
10435        mut options: &ScanOptions,
10436        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
10437    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
10438        PrivilegedCentralProxyInterface::r#scan(self, options, result_watcher)
10439    }
10440
10441    /// Connect to the peer with the given identifier.
10442    ///
10443    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
10444    /// client's interest on the LE connection to the peer. Closing the channel
10445    /// removes interest, but may not result in disconnection if another client
10446    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
10447    ///
10448    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
10449    /// system if the connection to the peer is lost or an error occurs.
10450    ///
10451    /// The following epitaphs may be sent by the server on error:
10452    /// + `INVALID_ARGS`: Some of the parameters are invalid.
10453    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
10454    ///                    Connection should be used.
10455    /// + `NOT_CONNECTED`: A connection could not be established.
10456    /// + `CONNECTION_RESET`: The peer disconnected.
10457    ///
10458    /// + request `id` Identifier of the peer to initiate a connection to.
10459    /// + request `options` Options used to configure the connection.
10460    /// + request `handle` Handle that remains valid for the duration of this
10461    ///   connection.
10462    pub fn r#connect(
10463        &self,
10464        mut id: &fidl_fuchsia_bluetooth::PeerId,
10465        mut options: &ConnectionOptions,
10466        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
10467    ) -> Result<(), fidl::Error> {
10468        PrivilegedCentralProxyInterface::r#connect(self, id, options, handle)
10469    }
10470
10471    /// Synchronize to a periodic advertising train. Reports will be delivered via the
10472    /// `PeriodicAdvertisingSync` protocol.
10473    pub fn r#sync_to_periodic_advertising(
10474        &self,
10475        mut payload: CentralSyncToPeriodicAdvertisingRequest,
10476    ) -> Result<(), fidl::Error> {
10477        PrivilegedCentralProxyInterface::r#sync_to_periodic_advertising(self, payload)
10478    }
10479
10480    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
10481    /// operation is only valid when operating in the Central role for a connection.
10482    ///
10483    /// If the Central channel is closed before the CIG is explicitly removed, the group will
10484    /// be removed and disconnected.
10485    ///
10486    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
10487    /// id allocated by the host.
10488    pub fn r#create_connected_isochronous_group(
10489        &self,
10490        mut payload: CentralCreateConnectedIsochronousGroupRequest,
10491    ) -> fidl::client::QueryResponseFut<
10492        CentralCreateConnectedIsochronousGroupResult,
10493        fidl::encoding::DefaultFuchsiaResourceDialect,
10494    > {
10495        PrivilegedCentralProxyInterface::r#create_connected_isochronous_group(self, payload)
10496    }
10497
10498    /// Returns the list of peripherals that are known to the system from previous scan, connection,
10499    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
10500    /// be present on the peripheral.
10501    ///
10502    /// This method only returns peripherals (i.e. connectable devices).
10503    pub fn r#get_peripherals(
10504        &self,
10505        mut service_uuids: Option<&[String]>,
10506    ) -> fidl::client::QueryResponseFut<
10507        Vec<RemoteDevice>,
10508        fidl::encoding::DefaultFuchsiaResourceDialect,
10509    > {
10510        PrivilegedCentralProxyInterface::r#get_peripherals(self, service_uuids)
10511    }
10512
10513    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
10514    ///
10515    /// Returns information about a single peripheral that is known to the system from previous scan,
10516    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
10517    /// `identifier` is not recognized.
10518    pub fn r#get_peripheral(
10519        &self,
10520        mut identifier: &str,
10521    ) -> fidl::client::QueryResponseFut<
10522        Option<Box<RemoteDevice>>,
10523        fidl::encoding::DefaultFuchsiaResourceDialect,
10524    > {
10525        PrivilegedCentralProxyInterface::r#get_peripheral(self, identifier)
10526    }
10527
10528    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
10529    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
10530    /// `filter` will replace the existing session's filter.
10531    ///
10532    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
10533    /// will be notified for all discoverable devices that are found. This is not recommended; clients
10534    /// should generally filter results by at least one of `filter.service_uuids`,
10535    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
10536    pub fn r#start_scan(
10537        &self,
10538        mut filter: Option<&ScanFilter>,
10539    ) -> fidl::client::QueryResponseFut<
10540        fidl_fuchsia_bluetooth::Status,
10541        fidl::encoding::DefaultFuchsiaResourceDialect,
10542    > {
10543        PrivilegedCentralProxyInterface::r#start_scan(self, filter)
10544    }
10545
10546    /// Terminate a previously started scan session.
10547    pub fn r#stop_scan(&self) -> Result<(), fidl::Error> {
10548        PrivilegedCentralProxyInterface::r#stop_scan(self)
10549    }
10550
10551    /// Creates a connection to the peripheral device with the given identifier.
10552    /// Returns the status of the operation in `status`.
10553    ///
10554    /// On success, `gatt_client` will be bound and can be used for GATT client
10555    /// role procedures. On failure, `gatt_client` will be closed and `status` will
10556    /// indicate an error.
10557    pub fn r#connect_peripheral(
10558        &self,
10559        mut identifier: &str,
10560        mut options: &ConnectionOptions,
10561        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
10562    ) -> fidl::client::QueryResponseFut<
10563        fidl_fuchsia_bluetooth::Status,
10564        fidl::encoding::DefaultFuchsiaResourceDialect,
10565    > {
10566        PrivilegedCentralProxyInterface::r#connect_peripheral(
10567            self,
10568            identifier,
10569            options,
10570            gatt_client,
10571        )
10572    }
10573
10574    /// Disconnects this Central's connection to the peripheral with the given identifier.
10575    pub fn r#disconnect_peripheral(
10576        &self,
10577        mut identifier: &str,
10578    ) -> fidl::client::QueryResponseFut<
10579        fidl_fuchsia_bluetooth::Status,
10580        fidl::encoding::DefaultFuchsiaResourceDialect,
10581    > {
10582        PrivilegedCentralProxyInterface::r#disconnect_peripheral(self, identifier)
10583    }
10584}
10585
10586impl PrivilegedCentralProxyInterface for PrivilegedCentralProxy {
10587    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
10588        ChannelListenerRegistryListenL2capResult,
10589        fidl::encoding::DefaultFuchsiaResourceDialect,
10590    >;
10591    fn r#listen_l2cap(
10592        &self,
10593        mut payload: ChannelListenerRegistryListenL2capRequest,
10594    ) -> Self::ListenL2capResponseFut {
10595        fn _decode(
10596            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10597        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
10598            let _response = fidl::client::decode_transaction_body::<
10599                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
10600                fidl::encoding::DefaultFuchsiaResourceDialect,
10601                0x39c6e9001d102338,
10602            >(_buf?)?;
10603            Ok(_response.map(|x| x))
10604        }
10605        self.client.send_query_and_decode::<
10606            ChannelListenerRegistryListenL2capRequest,
10607            ChannelListenerRegistryListenL2capResult,
10608        >(
10609            &mut payload,
10610            0x39c6e9001d102338,
10611            fidl::encoding::DynamicFlags::empty(),
10612            _decode,
10613        )
10614    }
10615
10616    type ScanResponseFut =
10617        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
10618    fn r#scan(
10619        &self,
10620        mut options: &ScanOptions,
10621        mut result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
10622    ) -> Self::ScanResponseFut {
10623        fn _decode(
10624            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10625        ) -> Result<(), fidl::Error> {
10626            let _response = fidl::client::decode_transaction_body::<
10627                fidl::encoding::EmptyPayload,
10628                fidl::encoding::DefaultFuchsiaResourceDialect,
10629                0x41f7121798dfe15f,
10630            >(_buf?)?;
10631            Ok(_response)
10632        }
10633        self.client.send_query_and_decode::<CentralScanRequest, ()>(
10634            (options, result_watcher),
10635            0x41f7121798dfe15f,
10636            fidl::encoding::DynamicFlags::empty(),
10637            _decode,
10638        )
10639    }
10640
10641    fn r#connect(
10642        &self,
10643        mut id: &fidl_fuchsia_bluetooth::PeerId,
10644        mut options: &ConnectionOptions,
10645        mut handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
10646    ) -> Result<(), fidl::Error> {
10647        self.client.send::<CentralConnectRequest>(
10648            (id, options, handle),
10649            0x31a3065f2a6913c4,
10650            fidl::encoding::DynamicFlags::empty(),
10651        )
10652    }
10653
10654    fn r#sync_to_periodic_advertising(
10655        &self,
10656        mut payload: CentralSyncToPeriodicAdvertisingRequest,
10657    ) -> Result<(), fidl::Error> {
10658        self.client.send::<CentralSyncToPeriodicAdvertisingRequest>(
10659            &mut payload,
10660            0x1db6df126a00c5b9,
10661            fidl::encoding::DynamicFlags::empty(),
10662        )
10663    }
10664
10665    type CreateConnectedIsochronousGroupResponseFut = fidl::client::QueryResponseFut<
10666        CentralCreateConnectedIsochronousGroupResult,
10667        fidl::encoding::DefaultFuchsiaResourceDialect,
10668    >;
10669    fn r#create_connected_isochronous_group(
10670        &self,
10671        mut payload: CentralCreateConnectedIsochronousGroupRequest,
10672    ) -> Self::CreateConnectedIsochronousGroupResponseFut {
10673        fn _decode(
10674            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10675        ) -> Result<CentralCreateConnectedIsochronousGroupResult, fidl::Error> {
10676            let _response = fidl::client::decode_transaction_body::<
10677                fidl::encoding::ResultType<
10678                    CentralCreateConnectedIsochronousGroupResponse,
10679                    CreateCigError,
10680                >,
10681                fidl::encoding::DefaultFuchsiaResourceDialect,
10682                0x60323e70ae22e13,
10683            >(_buf?)?;
10684            Ok(_response.map(|x| x))
10685        }
10686        self.client.send_query_and_decode::<
10687            CentralCreateConnectedIsochronousGroupRequest,
10688            CentralCreateConnectedIsochronousGroupResult,
10689        >(
10690            &mut payload,
10691            0x60323e70ae22e13,
10692            fidl::encoding::DynamicFlags::empty(),
10693            _decode,
10694        )
10695    }
10696
10697    type GetPeripheralsResponseFut = fidl::client::QueryResponseFut<
10698        Vec<RemoteDevice>,
10699        fidl::encoding::DefaultFuchsiaResourceDialect,
10700    >;
10701    fn r#get_peripherals(
10702        &self,
10703        mut service_uuids: Option<&[String]>,
10704    ) -> Self::GetPeripheralsResponseFut {
10705        fn _decode(
10706            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10707        ) -> Result<Vec<RemoteDevice>, fidl::Error> {
10708            let _response = fidl::client::decode_transaction_body::<
10709                CentralGetPeripheralsResponse,
10710                fidl::encoding::DefaultFuchsiaResourceDialect,
10711                0x37ba777499c683a8,
10712            >(_buf?)?;
10713            Ok(_response.peripherals)
10714        }
10715        self.client.send_query_and_decode::<CentralGetPeripheralsRequest, Vec<RemoteDevice>>(
10716            (service_uuids,),
10717            0x37ba777499c683a8,
10718            fidl::encoding::DynamicFlags::empty(),
10719            _decode,
10720        )
10721    }
10722
10723    type GetPeripheralResponseFut = fidl::client::QueryResponseFut<
10724        Option<Box<RemoteDevice>>,
10725        fidl::encoding::DefaultFuchsiaResourceDialect,
10726    >;
10727    fn r#get_peripheral(&self, mut identifier: &str) -> Self::GetPeripheralResponseFut {
10728        fn _decode(
10729            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10730        ) -> Result<Option<Box<RemoteDevice>>, fidl::Error> {
10731            let _response = fidl::client::decode_transaction_body::<
10732                CentralGetPeripheralResponse,
10733                fidl::encoding::DefaultFuchsiaResourceDialect,
10734                0x97f5a2f2d9c13da,
10735            >(_buf?)?;
10736            Ok(_response.peripheral)
10737        }
10738        self.client.send_query_and_decode::<CentralGetPeripheralRequest, Option<Box<RemoteDevice>>>(
10739            (identifier,),
10740            0x97f5a2f2d9c13da,
10741            fidl::encoding::DynamicFlags::empty(),
10742            _decode,
10743        )
10744    }
10745
10746    type StartScanResponseFut = fidl::client::QueryResponseFut<
10747        fidl_fuchsia_bluetooth::Status,
10748        fidl::encoding::DefaultFuchsiaResourceDialect,
10749    >;
10750    fn r#start_scan(&self, mut filter: Option<&ScanFilter>) -> Self::StartScanResponseFut {
10751        fn _decode(
10752            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10753        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
10754            let _response = fidl::client::decode_transaction_body::<
10755                CentralStartScanResponse,
10756                fidl::encoding::DefaultFuchsiaResourceDialect,
10757                0xeb4cf0cd0e1132b,
10758            >(_buf?)?;
10759            Ok(_response.status)
10760        }
10761        self.client
10762            .send_query_and_decode::<CentralStartScanRequest, fidl_fuchsia_bluetooth::Status>(
10763                (filter,),
10764                0xeb4cf0cd0e1132b,
10765                fidl::encoding::DynamicFlags::empty(),
10766                _decode,
10767            )
10768    }
10769
10770    fn r#stop_scan(&self) -> Result<(), fidl::Error> {
10771        self.client.send::<fidl::encoding::EmptyPayload>(
10772            (),
10773            0x5f79ee6a0bb037a0,
10774            fidl::encoding::DynamicFlags::empty(),
10775        )
10776    }
10777
10778    type ConnectPeripheralResponseFut = fidl::client::QueryResponseFut<
10779        fidl_fuchsia_bluetooth::Status,
10780        fidl::encoding::DefaultFuchsiaResourceDialect,
10781    >;
10782    fn r#connect_peripheral(
10783        &self,
10784        mut identifier: &str,
10785        mut options: &ConnectionOptions,
10786        mut gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
10787    ) -> Self::ConnectPeripheralResponseFut {
10788        fn _decode(
10789            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10790        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
10791            let _response = fidl::client::decode_transaction_body::<
10792                CentralConnectPeripheralResponse,
10793                fidl::encoding::DefaultFuchsiaResourceDialect,
10794                0x714d6c32d066d75a,
10795            >(_buf?)?;
10796            Ok(_response.status)
10797        }
10798        self.client.send_query_and_decode::<
10799            CentralConnectPeripheralRequest,
10800            fidl_fuchsia_bluetooth::Status,
10801        >(
10802            (identifier, options, gatt_client,),
10803            0x714d6c32d066d75a,
10804            fidl::encoding::DynamicFlags::empty(),
10805            _decode,
10806        )
10807    }
10808
10809    type DisconnectPeripheralResponseFut = fidl::client::QueryResponseFut<
10810        fidl_fuchsia_bluetooth::Status,
10811        fidl::encoding::DefaultFuchsiaResourceDialect,
10812    >;
10813    fn r#disconnect_peripheral(
10814        &self,
10815        mut identifier: &str,
10816    ) -> Self::DisconnectPeripheralResponseFut {
10817        fn _decode(
10818            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10819        ) -> Result<fidl_fuchsia_bluetooth::Status, fidl::Error> {
10820            let _response = fidl::client::decode_transaction_body::<
10821                CentralDisconnectPeripheralResponse,
10822                fidl::encoding::DefaultFuchsiaResourceDialect,
10823                0xa9430da197362fd,
10824            >(_buf?)?;
10825            Ok(_response.status)
10826        }
10827        self.client.send_query_and_decode::<
10828            CentralDisconnectPeripheralRequest,
10829            fidl_fuchsia_bluetooth::Status,
10830        >(
10831            (identifier,),
10832            0xa9430da197362fd,
10833            fidl::encoding::DynamicFlags::empty(),
10834            _decode,
10835        )
10836    }
10837}
10838
10839pub struct PrivilegedCentralEventStream {
10840    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
10841}
10842
10843impl std::marker::Unpin for PrivilegedCentralEventStream {}
10844
10845impl futures::stream::FusedStream for PrivilegedCentralEventStream {
10846    fn is_terminated(&self) -> bool {
10847        self.event_receiver.is_terminated()
10848    }
10849}
10850
10851impl futures::Stream for PrivilegedCentralEventStream {
10852    type Item = Result<PrivilegedCentralEvent, fidl::Error>;
10853
10854    fn poll_next(
10855        mut self: std::pin::Pin<&mut Self>,
10856        cx: &mut std::task::Context<'_>,
10857    ) -> std::task::Poll<Option<Self::Item>> {
10858        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
10859            &mut self.event_receiver,
10860            cx
10861        )?) {
10862            Some(buf) => std::task::Poll::Ready(Some(PrivilegedCentralEvent::decode(buf))),
10863            None => std::task::Poll::Ready(None),
10864        }
10865    }
10866}
10867
10868#[derive(Debug)]
10869pub enum PrivilegedCentralEvent {
10870    OnScanStateChanged { scanning: bool },
10871    OnDeviceDiscovered { device: RemoteDevice },
10872    OnPeripheralDisconnected { identifier: String },
10873}
10874
10875impl PrivilegedCentralEvent {
10876    #[allow(irrefutable_let_patterns)]
10877    pub fn into_on_scan_state_changed(self) -> Option<bool> {
10878        if let PrivilegedCentralEvent::OnScanStateChanged { scanning } = self {
10879            Some((scanning))
10880        } else {
10881            None
10882        }
10883    }
10884    #[allow(irrefutable_let_patterns)]
10885    pub fn into_on_device_discovered(self) -> Option<RemoteDevice> {
10886        if let PrivilegedCentralEvent::OnDeviceDiscovered { device } = self {
10887            Some((device))
10888        } else {
10889            None
10890        }
10891    }
10892    #[allow(irrefutable_let_patterns)]
10893    pub fn into_on_peripheral_disconnected(self) -> Option<String> {
10894        if let PrivilegedCentralEvent::OnPeripheralDisconnected { identifier } = self {
10895            Some((identifier))
10896        } else {
10897            None
10898        }
10899    }
10900
10901    /// Decodes a message buffer as a [`PrivilegedCentralEvent`].
10902    fn decode(
10903        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
10904    ) -> Result<PrivilegedCentralEvent, fidl::Error> {
10905        let (bytes, _handles) = buf.split_mut();
10906        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10907        debug_assert_eq!(tx_header.tx_id, 0);
10908        match tx_header.ordinal {
10909            0x5f8edc23cad04d3f => {
10910                let mut out = fidl::new_empty!(
10911                    CentralOnScanStateChangedRequest,
10912                    fidl::encoding::DefaultFuchsiaResourceDialect
10913                );
10914                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnScanStateChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
10915                Ok((PrivilegedCentralEvent::OnScanStateChanged { scanning: out.scanning }))
10916            }
10917            0x708dadf20d66db6 => {
10918                let mut out = fidl::new_empty!(
10919                    CentralOnDeviceDiscoveredRequest,
10920                    fidl::encoding::DefaultFuchsiaResourceDialect
10921                );
10922                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnDeviceDiscoveredRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
10923                Ok((PrivilegedCentralEvent::OnDeviceDiscovered { device: out.device }))
10924            }
10925            0x4e4c6b979b2126df => {
10926                let mut out = fidl::new_empty!(
10927                    CentralOnPeripheralDisconnectedRequest,
10928                    fidl::encoding::DefaultFuchsiaResourceDialect
10929                );
10930                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralOnPeripheralDisconnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
10931                Ok((PrivilegedCentralEvent::OnPeripheralDisconnected {
10932                    identifier: out.identifier,
10933                }))
10934            }
10935            _ => Err(fidl::Error::UnknownOrdinal {
10936                ordinal: tx_header.ordinal,
10937                protocol_name:
10938                    <PrivilegedCentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
10939            }),
10940        }
10941    }
10942}
10943
10944/// A Stream of incoming requests for fuchsia.bluetooth.le/PrivilegedCentral.
10945pub struct PrivilegedCentralRequestStream {
10946    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10947    is_terminated: bool,
10948}
10949
10950impl std::marker::Unpin for PrivilegedCentralRequestStream {}
10951
10952impl futures::stream::FusedStream for PrivilegedCentralRequestStream {
10953    fn is_terminated(&self) -> bool {
10954        self.is_terminated
10955    }
10956}
10957
10958impl fidl::endpoints::RequestStream for PrivilegedCentralRequestStream {
10959    type Protocol = PrivilegedCentralMarker;
10960    type ControlHandle = PrivilegedCentralControlHandle;
10961
10962    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
10963        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
10964    }
10965
10966    fn control_handle(&self) -> Self::ControlHandle {
10967        PrivilegedCentralControlHandle { inner: self.inner.clone() }
10968    }
10969
10970    fn into_inner(
10971        self,
10972    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
10973    {
10974        (self.inner, self.is_terminated)
10975    }
10976
10977    fn from_inner(
10978        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10979        is_terminated: bool,
10980    ) -> Self {
10981        Self { inner, is_terminated }
10982    }
10983}
10984
10985impl futures::Stream for PrivilegedCentralRequestStream {
10986    type Item = Result<PrivilegedCentralRequest, fidl::Error>;
10987
10988    fn poll_next(
10989        mut self: std::pin::Pin<&mut Self>,
10990        cx: &mut std::task::Context<'_>,
10991    ) -> std::task::Poll<Option<Self::Item>> {
10992        let this = &mut *self;
10993        if this.inner.check_shutdown(cx) {
10994            this.is_terminated = true;
10995            return std::task::Poll::Ready(None);
10996        }
10997        if this.is_terminated {
10998            panic!("polled PrivilegedCentralRequestStream after completion");
10999        }
11000        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
11001            |bytes, handles| {
11002                match this.inner.channel().read_etc(cx, bytes, handles) {
11003                    std::task::Poll::Ready(Ok(())) => {}
11004                    std::task::Poll::Pending => return std::task::Poll::Pending,
11005                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
11006                        this.is_terminated = true;
11007                        return std::task::Poll::Ready(None);
11008                    }
11009                    std::task::Poll::Ready(Err(e)) => {
11010                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11011                            e.into(),
11012                        ))));
11013                    }
11014                }
11015
11016                // A message has been received from the channel
11017                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11018
11019                std::task::Poll::Ready(Some(match header.ordinal {
11020                    0x39c6e9001d102338 => {
11021                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11022                        let mut req = fidl::new_empty!(
11023                            ChannelListenerRegistryListenL2capRequest,
11024                            fidl::encoding::DefaultFuchsiaResourceDialect
11025                        );
11026                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
11027                        let control_handle =
11028                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11029                        Ok(PrivilegedCentralRequest::ListenL2cap {
11030                            payload: req,
11031                            responder: PrivilegedCentralListenL2capResponder {
11032                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11033                                tx_id: header.tx_id,
11034                            },
11035                        })
11036                    }
11037                    0x41f7121798dfe15f => {
11038                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11039                        let mut req = fidl::new_empty!(
11040                            CentralScanRequest,
11041                            fidl::encoding::DefaultFuchsiaResourceDialect
11042                        );
11043                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralScanRequest>(&header, _body_bytes, handles, &mut req)?;
11044                        let control_handle =
11045                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11046                        Ok(PrivilegedCentralRequest::Scan {
11047                            options: req.options,
11048                            result_watcher: req.result_watcher,
11049
11050                            responder: PrivilegedCentralScanResponder {
11051                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11052                                tx_id: header.tx_id,
11053                            },
11054                        })
11055                    }
11056                    0x31a3065f2a6913c4 => {
11057                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11058                        let mut req = fidl::new_empty!(
11059                            CentralConnectRequest,
11060                            fidl::encoding::DefaultFuchsiaResourceDialect
11061                        );
11062                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralConnectRequest>(&header, _body_bytes, handles, &mut req)?;
11063                        let control_handle =
11064                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11065                        Ok(PrivilegedCentralRequest::Connect {
11066                            id: req.id,
11067                            options: req.options,
11068                            handle: req.handle,
11069
11070                            control_handle,
11071                        })
11072                    }
11073                    0x1db6df126a00c5b9 => {
11074                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11075                        let mut req = fidl::new_empty!(
11076                            CentralSyncToPeriodicAdvertisingRequest,
11077                            fidl::encoding::DefaultFuchsiaResourceDialect
11078                        );
11079                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralSyncToPeriodicAdvertisingRequest>(&header, _body_bytes, handles, &mut req)?;
11080                        let control_handle =
11081                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11082                        Ok(PrivilegedCentralRequest::SyncToPeriodicAdvertising {
11083                            payload: req,
11084                            control_handle,
11085                        })
11086                    }
11087                    0x60323e70ae22e13 => {
11088                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11089                        let mut req = fidl::new_empty!(
11090                            CentralCreateConnectedIsochronousGroupRequest,
11091                            fidl::encoding::DefaultFuchsiaResourceDialect
11092                        );
11093                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralCreateConnectedIsochronousGroupRequest>(&header, _body_bytes, handles, &mut req)?;
11094                        let control_handle =
11095                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11096                        Ok(PrivilegedCentralRequest::CreateConnectedIsochronousGroup {
11097                            payload: req,
11098                            responder: PrivilegedCentralCreateConnectedIsochronousGroupResponder {
11099                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11100                                tx_id: header.tx_id,
11101                            },
11102                        })
11103                    }
11104                    0x37ba777499c683a8 => {
11105                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11106                        let mut req = fidl::new_empty!(
11107                            CentralGetPeripheralsRequest,
11108                            fidl::encoding::DefaultFuchsiaResourceDialect
11109                        );
11110                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralGetPeripheralsRequest>(&header, _body_bytes, handles, &mut req)?;
11111                        let control_handle =
11112                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11113                        Ok(PrivilegedCentralRequest::GetPeripherals {
11114                            service_uuids: req.service_uuids,
11115
11116                            responder: PrivilegedCentralGetPeripheralsResponder {
11117                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11118                                tx_id: header.tx_id,
11119                            },
11120                        })
11121                    }
11122                    0x97f5a2f2d9c13da => {
11123                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11124                        let mut req = fidl::new_empty!(
11125                            CentralGetPeripheralRequest,
11126                            fidl::encoding::DefaultFuchsiaResourceDialect
11127                        );
11128                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralGetPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
11129                        let control_handle =
11130                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11131                        Ok(PrivilegedCentralRequest::GetPeripheral {
11132                            identifier: req.identifier,
11133
11134                            responder: PrivilegedCentralGetPeripheralResponder {
11135                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11136                                tx_id: header.tx_id,
11137                            },
11138                        })
11139                    }
11140                    0xeb4cf0cd0e1132b => {
11141                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11142                        let mut req = fidl::new_empty!(
11143                            CentralStartScanRequest,
11144                            fidl::encoding::DefaultFuchsiaResourceDialect
11145                        );
11146                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralStartScanRequest>(&header, _body_bytes, handles, &mut req)?;
11147                        let control_handle =
11148                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11149                        Ok(PrivilegedCentralRequest::StartScan {
11150                            filter: req.filter,
11151
11152                            responder: PrivilegedCentralStartScanResponder {
11153                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11154                                tx_id: header.tx_id,
11155                            },
11156                        })
11157                    }
11158                    0x5f79ee6a0bb037a0 => {
11159                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11160                        let mut req = fidl::new_empty!(
11161                            fidl::encoding::EmptyPayload,
11162                            fidl::encoding::DefaultFuchsiaResourceDialect
11163                        );
11164                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
11165                        let control_handle =
11166                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11167                        Ok(PrivilegedCentralRequest::StopScan { control_handle })
11168                    }
11169                    0x714d6c32d066d75a => {
11170                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11171                        let mut req = fidl::new_empty!(
11172                            CentralConnectPeripheralRequest,
11173                            fidl::encoding::DefaultFuchsiaResourceDialect
11174                        );
11175                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralConnectPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
11176                        let control_handle =
11177                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11178                        Ok(PrivilegedCentralRequest::ConnectPeripheral {
11179                            identifier: req.identifier,
11180                            options: req.options,
11181                            gatt_client: req.gatt_client,
11182
11183                            responder: PrivilegedCentralConnectPeripheralResponder {
11184                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11185                                tx_id: header.tx_id,
11186                            },
11187                        })
11188                    }
11189                    0xa9430da197362fd => {
11190                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11191                        let mut req = fidl::new_empty!(
11192                            CentralDisconnectPeripheralRequest,
11193                            fidl::encoding::DefaultFuchsiaResourceDialect
11194                        );
11195                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CentralDisconnectPeripheralRequest>(&header, _body_bytes, handles, &mut req)?;
11196                        let control_handle =
11197                            PrivilegedCentralControlHandle { inner: this.inner.clone() };
11198                        Ok(PrivilegedCentralRequest::DisconnectPeripheral {
11199                            identifier: req.identifier,
11200
11201                            responder: PrivilegedCentralDisconnectPeripheralResponder {
11202                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11203                                tx_id: header.tx_id,
11204                            },
11205                        })
11206                    }
11207                    _ => Err(fidl::Error::UnknownOrdinal {
11208                        ordinal: header.ordinal,
11209                        protocol_name:
11210                            <PrivilegedCentralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11211                    }),
11212                }))
11213            },
11214        )
11215    }
11216}
11217
11218/// Privileged version of the Central protocol, providing advanced features
11219/// like socket offload. This protocol should only be routed to trusted and
11220/// system components due to sensitive information and capabilities it composes.
11221#[derive(Debug)]
11222pub enum PrivilegedCentralRequest {
11223    /// Register a listener for incoming channels. The registry will assign a
11224    /// PSM value that is unique for the local device, as well as open a
11225    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
11226    /// event that all PSMs have been assigned, this call will fail with
11227    /// `ZX_ERR_NO_RESOURCES`.
11228    ///
11229    /// Note that the method of service discovery or advertising is defined by
11230    /// the service or protocol, so it is the responsibility of the caller to
11231    /// communicate the assigned PSM to any clients.
11232    ListenL2cap {
11233        payload: ChannelListenerRegistryListenL2capRequest,
11234        responder: PrivilegedCentralListenL2capResponder,
11235    },
11236    /// Scans for nearby LE peripherals and broadcasters. If the scan cannot be
11237    /// initiated, then `result_watcher` will be closed with an epitaph.
11238    ///
11239    /// A Central client is allowed to have only one active scan at a time.
11240    /// Accordingly, only one Scan request can be outstanding at a time.
11241    /// Additional calls to Scan will fail.
11242    ///
11243    /// The lifetime of the scan session is tied to the `result_watcher`
11244    /// protocol provided. The scan will be stopped if the channel is closed.
11245    ///
11246    /// Once a scan is started, the [`fuchsia.bluetooth.le/ScanResultWatcher`]
11247    /// can be used to watch for scan results.
11248    ///
11249    /// + request `options` Options used to configure the scan session.
11250    /// + request `result_watcher` Protocol that remains valid for the duration
11251    ///   of this scan session.
11252    /// - response An empty response will be sent to acknowledge the scan has
11253    ///   stopped.
11254    ///
11255    /// The following epitaphs may be sent by the server on error:
11256    /// * error `ALREADY_EXISTS`: A scan is already in progress. Each `Central`
11257    ///   protocol is only allowed 1 active scan.
11258    /// * error `INVALID_ARGS`: Some of the scan `options` are invalid. See the
11259    ///   `ScanOptions` documentation.
11260    /// * error `INTERNAL`: An internal error occurred and a scan could not be
11261    ///   started.
11262    Scan {
11263        options: ScanOptions,
11264        result_watcher: fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
11265        responder: PrivilegedCentralScanResponder,
11266    },
11267    /// Connect to the peer with the given identifier.
11268    ///
11269    /// The requested [`fuchsia.bluetooth.le/Connection`] represents the
11270    /// client's interest on the LE connection to the peer. Closing the channel
11271    /// removes interest, but may not result in disconnection if another client
11272    /// holds a valid [`fuchsia.bluetooth.le/Connection`] to the same peer.
11273    ///
11274    /// The [`fuchsia.bluetooth.le/Connection`] `handle` will be closed by the
11275    /// system if the connection to the peer is lost or an error occurs.
11276    ///
11277    /// The following epitaphs may be sent by the server on error:
11278    /// + `INVALID_ARGS`: Some of the parameters are invalid.
11279    /// + `ALREADY_BOUND`: A Connection to the peer already exists for this Central. The existing
11280    ///                    Connection should be used.
11281    /// + `NOT_CONNECTED`: A connection could not be established.
11282    /// + `CONNECTION_RESET`: The peer disconnected.
11283    ///
11284    /// + request `id` Identifier of the peer to initiate a connection to.
11285    /// + request `options` Options used to configure the connection.
11286    /// + request `handle` Handle that remains valid for the duration of this
11287    ///   connection.
11288    Connect {
11289        id: fidl_fuchsia_bluetooth::PeerId,
11290        options: ConnectionOptions,
11291        handle: fidl::endpoints::ServerEnd<ConnectionMarker>,
11292        control_handle: PrivilegedCentralControlHandle,
11293    },
11294    /// Synchronize to a periodic advertising train. Reports will be delivered via the
11295    /// `PeriodicAdvertisingSync` protocol.
11296    SyncToPeriodicAdvertising {
11297        payload: CentralSyncToPeriodicAdvertisingRequest,
11298        control_handle: PrivilegedCentralControlHandle,
11299    },
11300    /// Create a new Connected Iosochronous Group (CIG) with the specified parameters. This
11301    /// operation is only valid when operating in the Central role for a connection.
11302    ///
11303    /// If the Central channel is closed before the CIG is explicitly removed, the group will
11304    /// be removed and disconnected.
11305    ///
11306    /// On failure, returns an error code, see `CreateCigError`. On success, returns a unique
11307    /// id allocated by the host.
11308    CreateConnectedIsochronousGroup {
11309        payload: CentralCreateConnectedIsochronousGroupRequest,
11310        responder: PrivilegedCentralCreateConnectedIsochronousGroupResponder,
11311    },
11312    /// Returns the list of peripherals that are known to the system from previous scan, connection,
11313    /// and/or bonding procedures. The results can be filtered based on service UUIDs that are known to
11314    /// be present on the peripheral.
11315    ///
11316    /// This method only returns peripherals (i.e. connectable devices).
11317    GetPeripherals {
11318        service_uuids: Option<Vec<String>>,
11319        responder: PrivilegedCentralGetPeripheralsResponder,
11320    },
11321    /// **This method is not implemented by the Fuchsia core stack- TODO(https://fxbug.dev/42087303)**
11322    ///
11323    /// Returns information about a single peripheral that is known to the system from previous scan,
11324    /// connection, and/or bonding procedures based on its unique identifier. Returns null if
11325    /// `identifier` is not recognized.
11326    GetPeripheral { identifier: String, responder: PrivilegedCentralGetPeripheralResponder },
11327    /// Initiates a scan session for nearby peripherals and broadcasters. Discovered devices will be
11328    /// reported via CentralDelegate.OnDeviceDiscovered(). If a scan session is already in progress,
11329    /// `filter` will replace the existing session's filter.
11330    ///
11331    /// If `filter` is null or empty (i.e. none of its fields has been populated) then the delegate
11332    /// will be notified for all discoverable devices that are found. This is not recommended; clients
11333    /// should generally filter results by at least one of `filter.service_uuids`,
11334    /// `filter.service_data`, and/or `filter.manufacturer_identifier`.
11335    StartScan { filter: Option<Box<ScanFilter>>, responder: PrivilegedCentralStartScanResponder },
11336    /// Terminate a previously started scan session.
11337    StopScan { control_handle: PrivilegedCentralControlHandle },
11338    /// Creates a connection to the peripheral device with the given identifier.
11339    /// Returns the status of the operation in `status`.
11340    ///
11341    /// On success, `gatt_client` will be bound and can be used for GATT client
11342    /// role procedures. On failure, `gatt_client` will be closed and `status` will
11343    /// indicate an error.
11344    ConnectPeripheral {
11345        identifier: String,
11346        options: ConnectionOptions,
11347        gatt_client: fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
11348        responder: PrivilegedCentralConnectPeripheralResponder,
11349    },
11350    /// Disconnects this Central's connection to the peripheral with the given identifier.
11351    DisconnectPeripheral {
11352        identifier: String,
11353        responder: PrivilegedCentralDisconnectPeripheralResponder,
11354    },
11355}
11356
11357impl PrivilegedCentralRequest {
11358    #[allow(irrefutable_let_patterns)]
11359    pub fn into_listen_l2cap(
11360        self,
11361    ) -> Option<(ChannelListenerRegistryListenL2capRequest, PrivilegedCentralListenL2capResponder)>
11362    {
11363        if let PrivilegedCentralRequest::ListenL2cap { payload, responder } = self {
11364            Some((payload, responder))
11365        } else {
11366            None
11367        }
11368    }
11369
11370    #[allow(irrefutable_let_patterns)]
11371    pub fn into_scan(
11372        self,
11373    ) -> Option<(
11374        ScanOptions,
11375        fidl::endpoints::ServerEnd<ScanResultWatcherMarker>,
11376        PrivilegedCentralScanResponder,
11377    )> {
11378        if let PrivilegedCentralRequest::Scan { options, result_watcher, responder } = self {
11379            Some((options, result_watcher, responder))
11380        } else {
11381            None
11382        }
11383    }
11384
11385    #[allow(irrefutable_let_patterns)]
11386    pub fn into_connect(
11387        self,
11388    ) -> Option<(
11389        fidl_fuchsia_bluetooth::PeerId,
11390        ConnectionOptions,
11391        fidl::endpoints::ServerEnd<ConnectionMarker>,
11392        PrivilegedCentralControlHandle,
11393    )> {
11394        if let PrivilegedCentralRequest::Connect { id, options, handle, control_handle } = self {
11395            Some((id, options, handle, control_handle))
11396        } else {
11397            None
11398        }
11399    }
11400
11401    #[allow(irrefutable_let_patterns)]
11402    pub fn into_sync_to_periodic_advertising(
11403        self,
11404    ) -> Option<(CentralSyncToPeriodicAdvertisingRequest, PrivilegedCentralControlHandle)> {
11405        if let PrivilegedCentralRequest::SyncToPeriodicAdvertising { payload, control_handle } =
11406            self
11407        {
11408            Some((payload, control_handle))
11409        } else {
11410            None
11411        }
11412    }
11413
11414    #[allow(irrefutable_let_patterns)]
11415    pub fn into_create_connected_isochronous_group(
11416        self,
11417    ) -> Option<(
11418        CentralCreateConnectedIsochronousGroupRequest,
11419        PrivilegedCentralCreateConnectedIsochronousGroupResponder,
11420    )> {
11421        if let PrivilegedCentralRequest::CreateConnectedIsochronousGroup { payload, responder } =
11422            self
11423        {
11424            Some((payload, responder))
11425        } else {
11426            None
11427        }
11428    }
11429
11430    #[allow(irrefutable_let_patterns)]
11431    pub fn into_get_peripherals(
11432        self,
11433    ) -> Option<(Option<Vec<String>>, PrivilegedCentralGetPeripheralsResponder)> {
11434        if let PrivilegedCentralRequest::GetPeripherals { service_uuids, responder } = self {
11435            Some((service_uuids, responder))
11436        } else {
11437            None
11438        }
11439    }
11440
11441    #[allow(irrefutable_let_patterns)]
11442    pub fn into_get_peripheral(self) -> Option<(String, PrivilegedCentralGetPeripheralResponder)> {
11443        if let PrivilegedCentralRequest::GetPeripheral { identifier, responder } = self {
11444            Some((identifier, responder))
11445        } else {
11446            None
11447        }
11448    }
11449
11450    #[allow(irrefutable_let_patterns)]
11451    pub fn into_start_scan(
11452        self,
11453    ) -> Option<(Option<Box<ScanFilter>>, PrivilegedCentralStartScanResponder)> {
11454        if let PrivilegedCentralRequest::StartScan { filter, responder } = self {
11455            Some((filter, responder))
11456        } else {
11457            None
11458        }
11459    }
11460
11461    #[allow(irrefutable_let_patterns)]
11462    pub fn into_stop_scan(self) -> Option<(PrivilegedCentralControlHandle)> {
11463        if let PrivilegedCentralRequest::StopScan { control_handle } = self {
11464            Some((control_handle))
11465        } else {
11466            None
11467        }
11468    }
11469
11470    #[allow(irrefutable_let_patterns)]
11471    pub fn into_connect_peripheral(
11472        self,
11473    ) -> Option<(
11474        String,
11475        ConnectionOptions,
11476        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
11477        PrivilegedCentralConnectPeripheralResponder,
11478    )> {
11479        if let PrivilegedCentralRequest::ConnectPeripheral {
11480            identifier,
11481            options,
11482            gatt_client,
11483            responder,
11484        } = self
11485        {
11486            Some((identifier, options, gatt_client, responder))
11487        } else {
11488            None
11489        }
11490    }
11491
11492    #[allow(irrefutable_let_patterns)]
11493    pub fn into_disconnect_peripheral(
11494        self,
11495    ) -> Option<(String, PrivilegedCentralDisconnectPeripheralResponder)> {
11496        if let PrivilegedCentralRequest::DisconnectPeripheral { identifier, responder } = self {
11497            Some((identifier, responder))
11498        } else {
11499            None
11500        }
11501    }
11502
11503    /// Name of the method defined in FIDL
11504    pub fn method_name(&self) -> &'static str {
11505        match *self {
11506            PrivilegedCentralRequest::ListenL2cap { .. } => "listen_l2cap",
11507            PrivilegedCentralRequest::Scan { .. } => "scan",
11508            PrivilegedCentralRequest::Connect { .. } => "connect",
11509            PrivilegedCentralRequest::SyncToPeriodicAdvertising { .. } => {
11510                "sync_to_periodic_advertising"
11511            }
11512            PrivilegedCentralRequest::CreateConnectedIsochronousGroup { .. } => {
11513                "create_connected_isochronous_group"
11514            }
11515            PrivilegedCentralRequest::GetPeripherals { .. } => "get_peripherals",
11516            PrivilegedCentralRequest::GetPeripheral { .. } => "get_peripheral",
11517            PrivilegedCentralRequest::StartScan { .. } => "start_scan",
11518            PrivilegedCentralRequest::StopScan { .. } => "stop_scan",
11519            PrivilegedCentralRequest::ConnectPeripheral { .. } => "connect_peripheral",
11520            PrivilegedCentralRequest::DisconnectPeripheral { .. } => "disconnect_peripheral",
11521        }
11522    }
11523}
11524
11525#[derive(Debug, Clone)]
11526pub struct PrivilegedCentralControlHandle {
11527    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11528}
11529
11530impl fidl::endpoints::ControlHandle for PrivilegedCentralControlHandle {
11531    fn shutdown(&self) {
11532        self.inner.shutdown()
11533    }
11534
11535    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
11536        self.inner.shutdown_with_epitaph(status)
11537    }
11538
11539    fn is_closed(&self) -> bool {
11540        self.inner.channel().is_closed()
11541    }
11542    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
11543        self.inner.channel().on_closed()
11544    }
11545
11546    #[cfg(target_os = "fuchsia")]
11547    fn signal_peer(
11548        &self,
11549        clear_mask: zx::Signals,
11550        set_mask: zx::Signals,
11551    ) -> Result<(), zx_status::Status> {
11552        use fidl::Peered;
11553        self.inner.channel().signal_peer(clear_mask, set_mask)
11554    }
11555}
11556
11557impl PrivilegedCentralControlHandle {
11558    pub fn send_on_scan_state_changed(&self, mut scanning: bool) -> Result<(), fidl::Error> {
11559        self.inner.send::<CentralOnScanStateChangedRequest>(
11560            (scanning,),
11561            0,
11562            0x5f8edc23cad04d3f,
11563            fidl::encoding::DynamicFlags::empty(),
11564        )
11565    }
11566
11567    pub fn send_on_device_discovered(&self, mut device: &RemoteDevice) -> Result<(), fidl::Error> {
11568        self.inner.send::<CentralOnDeviceDiscoveredRequest>(
11569            (device,),
11570            0,
11571            0x708dadf20d66db6,
11572            fidl::encoding::DynamicFlags::empty(),
11573        )
11574    }
11575
11576    pub fn send_on_peripheral_disconnected(&self, mut identifier: &str) -> Result<(), fidl::Error> {
11577        self.inner.send::<CentralOnPeripheralDisconnectedRequest>(
11578            (identifier,),
11579            0,
11580            0x4e4c6b979b2126df,
11581            fidl::encoding::DynamicFlags::empty(),
11582        )
11583    }
11584}
11585
11586#[must_use = "FIDL methods require a response to be sent"]
11587#[derive(Debug)]
11588pub struct PrivilegedCentralListenL2capResponder {
11589    control_handle: std::mem::ManuallyDrop<PrivilegedCentralControlHandle>,
11590    tx_id: u32,
11591}
11592
11593/// Set the the channel to be shutdown (see [`PrivilegedCentralControlHandle::shutdown`])
11594/// if the responder is dropped without sending a response, so that the client
11595/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11596impl std::ops::Drop for PrivilegedCentralListenL2capResponder {
11597    fn drop(&mut self) {
11598        self.control_handle.shutdown();
11599        // Safety: drops once, never accessed again
11600        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11601    }
11602}
11603
11604impl fidl::endpoints::Responder for PrivilegedCentralListenL2capResponder {
11605    type ControlHandle = PrivilegedCentralControlHandle;
11606
11607    fn control_handle(&self) -> &PrivilegedCentralControlHandle {
11608        &self.control_handle
11609    }
11610
11611    fn drop_without_shutdown(mut self) {
11612        // Safety: drops once, never accessed again due to mem::forget
11613        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11614        // Prevent Drop from running (which would shut down the channel)
11615        std::mem::forget(self);
11616    }
11617}
11618
11619impl PrivilegedCentralListenL2capResponder {
11620    /// Sends a response to the FIDL transaction.
11621    ///
11622    /// Sets the channel to shutdown if an error occurs.
11623    pub fn send(
11624        self,
11625        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
11626    ) -> Result<(), fidl::Error> {
11627        let _result = self.send_raw(result);
11628        if _result.is_err() {
11629            self.control_handle.shutdown();
11630        }
11631        self.drop_without_shutdown();
11632        _result
11633    }
11634
11635    /// Similar to "send" but does not shutdown the channel if an error occurs.
11636    pub fn send_no_shutdown_on_err(
11637        self,
11638        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
11639    ) -> Result<(), fidl::Error> {
11640        let _result = self.send_raw(result);
11641        self.drop_without_shutdown();
11642        _result
11643    }
11644
11645    fn send_raw(
11646        &self,
11647        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
11648    ) -> Result<(), fidl::Error> {
11649        self.control_handle.inner.send::<fidl::encoding::ResultType<
11650            ChannelListenerRegistryListenL2capResponse,
11651            i32,
11652        >>(
11653            result,
11654            self.tx_id,
11655            0x39c6e9001d102338,
11656            fidl::encoding::DynamicFlags::empty(),
11657        )
11658    }
11659}
11660
11661#[must_use = "FIDL methods require a response to be sent"]
11662#[derive(Debug)]
11663pub struct PrivilegedCentralScanResponder {
11664    control_handle: std::mem::ManuallyDrop<PrivilegedCentralControlHandle>,
11665    tx_id: u32,
11666}
11667
11668/// Set the the channel to be shutdown (see [`PrivilegedCentralControlHandle::shutdown`])
11669/// if the responder is dropped without sending a response, so that the client
11670/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11671impl std::ops::Drop for PrivilegedCentralScanResponder {
11672    fn drop(&mut self) {
11673        self.control_handle.shutdown();
11674        // Safety: drops once, never accessed again
11675        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11676    }
11677}
11678
11679impl fidl::endpoints::Responder for PrivilegedCentralScanResponder {
11680    type ControlHandle = PrivilegedCentralControlHandle;
11681
11682    fn control_handle(&self) -> &PrivilegedCentralControlHandle {
11683        &self.control_handle
11684    }
11685
11686    fn drop_without_shutdown(mut self) {
11687        // Safety: drops once, never accessed again due to mem::forget
11688        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11689        // Prevent Drop from running (which would shut down the channel)
11690        std::mem::forget(self);
11691    }
11692}
11693
11694impl PrivilegedCentralScanResponder {
11695    /// Sends a response to the FIDL transaction.
11696    ///
11697    /// Sets the channel to shutdown if an error occurs.
11698    pub fn send(self) -> Result<(), fidl::Error> {
11699        let _result = self.send_raw();
11700        if _result.is_err() {
11701            self.control_handle.shutdown();
11702        }
11703        self.drop_without_shutdown();
11704        _result
11705    }
11706
11707    /// Similar to "send" but does not shutdown the channel if an error occurs.
11708    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11709        let _result = self.send_raw();
11710        self.drop_without_shutdown();
11711        _result
11712    }
11713
11714    fn send_raw(&self) -> Result<(), fidl::Error> {
11715        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11716            (),
11717            self.tx_id,
11718            0x41f7121798dfe15f,
11719            fidl::encoding::DynamicFlags::empty(),
11720        )
11721    }
11722}
11723
11724#[must_use = "FIDL methods require a response to be sent"]
11725#[derive(Debug)]
11726pub struct PrivilegedCentralCreateConnectedIsochronousGroupResponder {
11727    control_handle: std::mem::ManuallyDrop<PrivilegedCentralControlHandle>,
11728    tx_id: u32,
11729}
11730
11731/// Set the the channel to be shutdown (see [`PrivilegedCentralControlHandle::shutdown`])
11732/// if the responder is dropped without sending a response, so that the client
11733/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11734impl std::ops::Drop for PrivilegedCentralCreateConnectedIsochronousGroupResponder {
11735    fn drop(&mut self) {
11736        self.control_handle.shutdown();
11737        // Safety: drops once, never accessed again
11738        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11739    }
11740}
11741
11742impl fidl::endpoints::Responder for PrivilegedCentralCreateConnectedIsochronousGroupResponder {
11743    type ControlHandle = PrivilegedCentralControlHandle;
11744
11745    fn control_handle(&self) -> &PrivilegedCentralControlHandle {
11746        &self.control_handle
11747    }
11748
11749    fn drop_without_shutdown(mut self) {
11750        // Safety: drops once, never accessed again due to mem::forget
11751        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11752        // Prevent Drop from running (which would shut down the channel)
11753        std::mem::forget(self);
11754    }
11755}
11756
11757impl PrivilegedCentralCreateConnectedIsochronousGroupResponder {
11758    /// Sends a response to the FIDL transaction.
11759    ///
11760    /// Sets the channel to shutdown if an error occurs.
11761    pub fn send(
11762        self,
11763        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
11764    ) -> Result<(), fidl::Error> {
11765        let _result = self.send_raw(result);
11766        if _result.is_err() {
11767            self.control_handle.shutdown();
11768        }
11769        self.drop_without_shutdown();
11770        _result
11771    }
11772
11773    /// Similar to "send" but does not shutdown the channel if an error occurs.
11774    pub fn send_no_shutdown_on_err(
11775        self,
11776        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
11777    ) -> Result<(), fidl::Error> {
11778        let _result = self.send_raw(result);
11779        self.drop_without_shutdown();
11780        _result
11781    }
11782
11783    fn send_raw(
11784        &self,
11785        mut result: Result<&CentralCreateConnectedIsochronousGroupResponse, CreateCigError>,
11786    ) -> Result<(), fidl::Error> {
11787        self.control_handle.inner.send::<fidl::encoding::ResultType<
11788            CentralCreateConnectedIsochronousGroupResponse,
11789            CreateCigError,
11790        >>(
11791            result,
11792            self.tx_id,
11793            0x60323e70ae22e13,
11794            fidl::encoding::DynamicFlags::empty(),
11795        )
11796    }
11797}
11798
11799#[must_use = "FIDL methods require a response to be sent"]
11800#[derive(Debug)]
11801pub struct PrivilegedCentralGetPeripheralsResponder {
11802    control_handle: std::mem::ManuallyDrop<PrivilegedCentralControlHandle>,
11803    tx_id: u32,
11804}
11805
11806/// Set the the channel to be shutdown (see [`PrivilegedCentralControlHandle::shutdown`])
11807/// if the responder is dropped without sending a response, so that the client
11808/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11809impl std::ops::Drop for PrivilegedCentralGetPeripheralsResponder {
11810    fn drop(&mut self) {
11811        self.control_handle.shutdown();
11812        // Safety: drops once, never accessed again
11813        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11814    }
11815}
11816
11817impl fidl::endpoints::Responder for PrivilegedCentralGetPeripheralsResponder {
11818    type ControlHandle = PrivilegedCentralControlHandle;
11819
11820    fn control_handle(&self) -> &PrivilegedCentralControlHandle {
11821        &self.control_handle
11822    }
11823
11824    fn drop_without_shutdown(mut self) {
11825        // Safety: drops once, never accessed again due to mem::forget
11826        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11827        // Prevent Drop from running (which would shut down the channel)
11828        std::mem::forget(self);
11829    }
11830}
11831
11832impl PrivilegedCentralGetPeripheralsResponder {
11833    /// Sends a response to the FIDL transaction.
11834    ///
11835    /// Sets the channel to shutdown if an error occurs.
11836    pub fn send(self, mut peripherals: &[RemoteDevice]) -> Result<(), fidl::Error> {
11837        let _result = self.send_raw(peripherals);
11838        if _result.is_err() {
11839            self.control_handle.shutdown();
11840        }
11841        self.drop_without_shutdown();
11842        _result
11843    }
11844
11845    /// Similar to "send" but does not shutdown the channel if an error occurs.
11846    pub fn send_no_shutdown_on_err(
11847        self,
11848        mut peripherals: &[RemoteDevice],
11849    ) -> Result<(), fidl::Error> {
11850        let _result = self.send_raw(peripherals);
11851        self.drop_without_shutdown();
11852        _result
11853    }
11854
11855    fn send_raw(&self, mut peripherals: &[RemoteDevice]) -> Result<(), fidl::Error> {
11856        self.control_handle.inner.send::<CentralGetPeripheralsResponse>(
11857            (peripherals,),
11858            self.tx_id,
11859            0x37ba777499c683a8,
11860            fidl::encoding::DynamicFlags::empty(),
11861        )
11862    }
11863}
11864
11865#[must_use = "FIDL methods require a response to be sent"]
11866#[derive(Debug)]
11867pub struct PrivilegedCentralGetPeripheralResponder {
11868    control_handle: std::mem::ManuallyDrop<PrivilegedCentralControlHandle>,
11869    tx_id: u32,
11870}
11871
11872/// Set the the channel to be shutdown (see [`PrivilegedCentralControlHandle::shutdown`])
11873/// if the responder is dropped without sending a response, so that the client
11874/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11875impl std::ops::Drop for PrivilegedCentralGetPeripheralResponder {
11876    fn drop(&mut self) {
11877        self.control_handle.shutdown();
11878        // Safety: drops once, never accessed again
11879        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11880    }
11881}
11882
11883impl fidl::endpoints::Responder for PrivilegedCentralGetPeripheralResponder {
11884    type ControlHandle = PrivilegedCentralControlHandle;
11885
11886    fn control_handle(&self) -> &PrivilegedCentralControlHandle {
11887        &self.control_handle
11888    }
11889
11890    fn drop_without_shutdown(mut self) {
11891        // Safety: drops once, never accessed again due to mem::forget
11892        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11893        // Prevent Drop from running (which would shut down the channel)
11894        std::mem::forget(self);
11895    }
11896}
11897
11898impl PrivilegedCentralGetPeripheralResponder {
11899    /// Sends a response to the FIDL transaction.
11900    ///
11901    /// Sets the channel to shutdown if an error occurs.
11902    pub fn send(self, mut peripheral: Option<&RemoteDevice>) -> Result<(), fidl::Error> {
11903        let _result = self.send_raw(peripheral);
11904        if _result.is_err() {
11905            self.control_handle.shutdown();
11906        }
11907        self.drop_without_shutdown();
11908        _result
11909    }
11910
11911    /// Similar to "send" but does not shutdown the channel if an error occurs.
11912    pub fn send_no_shutdown_on_err(
11913        self,
11914        mut peripheral: Option<&RemoteDevice>,
11915    ) -> Result<(), fidl::Error> {
11916        let _result = self.send_raw(peripheral);
11917        self.drop_without_shutdown();
11918        _result
11919    }
11920
11921    fn send_raw(&self, mut peripheral: Option<&RemoteDevice>) -> Result<(), fidl::Error> {
11922        self.control_handle.inner.send::<CentralGetPeripheralResponse>(
11923            (peripheral,),
11924            self.tx_id,
11925            0x97f5a2f2d9c13da,
11926            fidl::encoding::DynamicFlags::empty(),
11927        )
11928    }
11929}
11930
11931#[must_use = "FIDL methods require a response to be sent"]
11932#[derive(Debug)]
11933pub struct PrivilegedCentralStartScanResponder {
11934    control_handle: std::mem::ManuallyDrop<PrivilegedCentralControlHandle>,
11935    tx_id: u32,
11936}
11937
11938/// Set the the channel to be shutdown (see [`PrivilegedCentralControlHandle::shutdown`])
11939/// if the responder is dropped without sending a response, so that the client
11940/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11941impl std::ops::Drop for PrivilegedCentralStartScanResponder {
11942    fn drop(&mut self) {
11943        self.control_handle.shutdown();
11944        // Safety: drops once, never accessed again
11945        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11946    }
11947}
11948
11949impl fidl::endpoints::Responder for PrivilegedCentralStartScanResponder {
11950    type ControlHandle = PrivilegedCentralControlHandle;
11951
11952    fn control_handle(&self) -> &PrivilegedCentralControlHandle {
11953        &self.control_handle
11954    }
11955
11956    fn drop_without_shutdown(mut self) {
11957        // Safety: drops once, never accessed again due to mem::forget
11958        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11959        // Prevent Drop from running (which would shut down the channel)
11960        std::mem::forget(self);
11961    }
11962}
11963
11964impl PrivilegedCentralStartScanResponder {
11965    /// Sends a response to the FIDL transaction.
11966    ///
11967    /// Sets the channel to shutdown if an error occurs.
11968    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
11969        let _result = self.send_raw(status);
11970        if _result.is_err() {
11971            self.control_handle.shutdown();
11972        }
11973        self.drop_without_shutdown();
11974        _result
11975    }
11976
11977    /// Similar to "send" but does not shutdown the channel if an error occurs.
11978    pub fn send_no_shutdown_on_err(
11979        self,
11980        mut status: &fidl_fuchsia_bluetooth::Status,
11981    ) -> Result<(), fidl::Error> {
11982        let _result = self.send_raw(status);
11983        self.drop_without_shutdown();
11984        _result
11985    }
11986
11987    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
11988        self.control_handle.inner.send::<CentralStartScanResponse>(
11989            (status,),
11990            self.tx_id,
11991            0xeb4cf0cd0e1132b,
11992            fidl::encoding::DynamicFlags::empty(),
11993        )
11994    }
11995}
11996
11997#[must_use = "FIDL methods require a response to be sent"]
11998#[derive(Debug)]
11999pub struct PrivilegedCentralConnectPeripheralResponder {
12000    control_handle: std::mem::ManuallyDrop<PrivilegedCentralControlHandle>,
12001    tx_id: u32,
12002}
12003
12004/// Set the the channel to be shutdown (see [`PrivilegedCentralControlHandle::shutdown`])
12005/// if the responder is dropped without sending a response, so that the client
12006/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12007impl std::ops::Drop for PrivilegedCentralConnectPeripheralResponder {
12008    fn drop(&mut self) {
12009        self.control_handle.shutdown();
12010        // Safety: drops once, never accessed again
12011        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12012    }
12013}
12014
12015impl fidl::endpoints::Responder for PrivilegedCentralConnectPeripheralResponder {
12016    type ControlHandle = PrivilegedCentralControlHandle;
12017
12018    fn control_handle(&self) -> &PrivilegedCentralControlHandle {
12019        &self.control_handle
12020    }
12021
12022    fn drop_without_shutdown(mut self) {
12023        // Safety: drops once, never accessed again due to mem::forget
12024        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12025        // Prevent Drop from running (which would shut down the channel)
12026        std::mem::forget(self);
12027    }
12028}
12029
12030impl PrivilegedCentralConnectPeripheralResponder {
12031    /// Sends a response to the FIDL transaction.
12032    ///
12033    /// Sets the channel to shutdown if an error occurs.
12034    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
12035        let _result = self.send_raw(status);
12036        if _result.is_err() {
12037            self.control_handle.shutdown();
12038        }
12039        self.drop_without_shutdown();
12040        _result
12041    }
12042
12043    /// Similar to "send" but does not shutdown the channel if an error occurs.
12044    pub fn send_no_shutdown_on_err(
12045        self,
12046        mut status: &fidl_fuchsia_bluetooth::Status,
12047    ) -> Result<(), fidl::Error> {
12048        let _result = self.send_raw(status);
12049        self.drop_without_shutdown();
12050        _result
12051    }
12052
12053    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
12054        self.control_handle.inner.send::<CentralConnectPeripheralResponse>(
12055            (status,),
12056            self.tx_id,
12057            0x714d6c32d066d75a,
12058            fidl::encoding::DynamicFlags::empty(),
12059        )
12060    }
12061}
12062
12063#[must_use = "FIDL methods require a response to be sent"]
12064#[derive(Debug)]
12065pub struct PrivilegedCentralDisconnectPeripheralResponder {
12066    control_handle: std::mem::ManuallyDrop<PrivilegedCentralControlHandle>,
12067    tx_id: u32,
12068}
12069
12070/// Set the the channel to be shutdown (see [`PrivilegedCentralControlHandle::shutdown`])
12071/// if the responder is dropped without sending a response, so that the client
12072/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12073impl std::ops::Drop for PrivilegedCentralDisconnectPeripheralResponder {
12074    fn drop(&mut self) {
12075        self.control_handle.shutdown();
12076        // Safety: drops once, never accessed again
12077        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12078    }
12079}
12080
12081impl fidl::endpoints::Responder for PrivilegedCentralDisconnectPeripheralResponder {
12082    type ControlHandle = PrivilegedCentralControlHandle;
12083
12084    fn control_handle(&self) -> &PrivilegedCentralControlHandle {
12085        &self.control_handle
12086    }
12087
12088    fn drop_without_shutdown(mut self) {
12089        // Safety: drops once, never accessed again due to mem::forget
12090        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12091        // Prevent Drop from running (which would shut down the channel)
12092        std::mem::forget(self);
12093    }
12094}
12095
12096impl PrivilegedCentralDisconnectPeripheralResponder {
12097    /// Sends a response to the FIDL transaction.
12098    ///
12099    /// Sets the channel to shutdown if an error occurs.
12100    pub fn send(self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
12101        let _result = self.send_raw(status);
12102        if _result.is_err() {
12103            self.control_handle.shutdown();
12104        }
12105        self.drop_without_shutdown();
12106        _result
12107    }
12108
12109    /// Similar to "send" but does not shutdown the channel if an error occurs.
12110    pub fn send_no_shutdown_on_err(
12111        self,
12112        mut status: &fidl_fuchsia_bluetooth::Status,
12113    ) -> Result<(), fidl::Error> {
12114        let _result = self.send_raw(status);
12115        self.drop_without_shutdown();
12116        _result
12117    }
12118
12119    fn send_raw(&self, mut status: &fidl_fuchsia_bluetooth::Status) -> Result<(), fidl::Error> {
12120        self.control_handle.inner.send::<CentralDisconnectPeripheralResponse>(
12121            (status,),
12122            self.tx_id,
12123            0xa9430da197362fd,
12124            fidl::encoding::DynamicFlags::empty(),
12125        )
12126    }
12127}
12128
12129#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
12130pub struct PrivilegedPeripheralMarker;
12131
12132impl fidl::endpoints::ProtocolMarker for PrivilegedPeripheralMarker {
12133    type Proxy = PrivilegedPeripheralProxy;
12134    type RequestStream = PrivilegedPeripheralRequestStream;
12135    #[cfg(target_os = "fuchsia")]
12136    type SynchronousProxy = PrivilegedPeripheralSynchronousProxy;
12137
12138    const DEBUG_NAME: &'static str = "fuchsia.bluetooth.le.PrivilegedPeripheral";
12139}
12140impl fidl::endpoints::DiscoverableProtocolMarker for PrivilegedPeripheralMarker {}
12141
12142pub trait PrivilegedPeripheralProxyInterface: Send + Sync {
12143    type ListenL2capResponseFut: std::future::Future<Output = Result<ChannelListenerRegistryListenL2capResult, fidl::Error>>
12144        + Send;
12145    fn r#listen_l2cap(
12146        &self,
12147        payload: ChannelListenerRegistryListenL2capRequest,
12148    ) -> Self::ListenL2capResponseFut;
12149    type AdvertiseResponseFut: std::future::Future<Output = Result<PeripheralAdvertiseResult, fidl::Error>>
12150        + Send;
12151    fn r#advertise(
12152        &self,
12153        parameters: &AdvertisingParameters,
12154        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
12155    ) -> Self::AdvertiseResponseFut;
12156    type StartAdvertisingResponseFut: std::future::Future<Output = Result<PeripheralStartAdvertisingResult, fidl::Error>>
12157        + Send;
12158    fn r#start_advertising(
12159        &self,
12160        parameters: &AdvertisingParameters,
12161        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
12162    ) -> Self::StartAdvertisingResponseFut;
12163}
12164#[derive(Debug)]
12165#[cfg(target_os = "fuchsia")]
12166pub struct PrivilegedPeripheralSynchronousProxy {
12167    client: fidl::client::sync::Client,
12168}
12169
12170#[cfg(target_os = "fuchsia")]
12171impl fidl::endpoints::SynchronousProxy for PrivilegedPeripheralSynchronousProxy {
12172    type Proxy = PrivilegedPeripheralProxy;
12173    type Protocol = PrivilegedPeripheralMarker;
12174
12175    fn from_channel(inner: fidl::Channel) -> Self {
12176        Self::new(inner)
12177    }
12178
12179    fn into_channel(self) -> fidl::Channel {
12180        self.client.into_channel()
12181    }
12182
12183    fn as_channel(&self) -> &fidl::Channel {
12184        self.client.as_channel()
12185    }
12186}
12187
12188#[cfg(target_os = "fuchsia")]
12189impl PrivilegedPeripheralSynchronousProxy {
12190    pub fn new(channel: fidl::Channel) -> Self {
12191        Self { client: fidl::client::sync::Client::new(channel) }
12192    }
12193
12194    pub fn into_channel(self) -> fidl::Channel {
12195        self.client.into_channel()
12196    }
12197
12198    /// Waits until an event arrives and returns it. It is safe for other
12199    /// threads to make concurrent requests while waiting for an event.
12200    pub fn wait_for_event(
12201        &self,
12202        deadline: zx::MonotonicInstant,
12203    ) -> Result<PrivilegedPeripheralEvent, fidl::Error> {
12204        PrivilegedPeripheralEvent::decode(
12205            self.client.wait_for_event::<PrivilegedPeripheralMarker>(deadline)?,
12206        )
12207    }
12208
12209    /// Register a listener for incoming channels. The registry will assign a
12210    /// PSM value that is unique for the local device, as well as open a
12211    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
12212    /// event that all PSMs have been assigned, this call will fail with
12213    /// `ZX_ERR_NO_RESOURCES`.
12214    ///
12215    /// Note that the method of service discovery or advertising is defined by
12216    /// the service or protocol, so it is the responsibility of the caller to
12217    /// communicate the assigned PSM to any clients.
12218    pub fn r#listen_l2cap(
12219        &self,
12220        mut payload: ChannelListenerRegistryListenL2capRequest,
12221        ___deadline: zx::MonotonicInstant,
12222    ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
12223        let _response = self.client.send_query::<
12224            ChannelListenerRegistryListenL2capRequest,
12225            fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
12226            PrivilegedPeripheralMarker,
12227        >(
12228            &mut payload,
12229            0x39c6e9001d102338,
12230            fidl::encoding::DynamicFlags::empty(),
12231            ___deadline,
12232        )?;
12233        Ok(_response.map(|x| x))
12234    }
12235
12236    /// Start advertising continuously as a LE peripheral. If advertising cannot
12237    /// be initiated then `advertised_peripheral` will be closed and an error
12238    /// will be returned.
12239    ///
12240    /// This method may be called any number of times. To reconfigure an
12241    /// advertisement, first close the original advertisement and then initiate
12242    /// a new advertisement after an empty response is returned.
12243    ///
12244    /// If the client closes its end of the
12245    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
12246    /// advertising will be stopped. If the handle is closed before the request
12247    /// is fulfilled, advertising may be briefly enabled before it is
12248    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
12249    /// the Peripheral protocol, but this may be changed in the future
12250    /// (https://fxbug.dev/42157682).
12251    ///
12252    /// + request `parameters` Parameters used while configuring the advertising
12253    ///   instance.
12254    /// + request `advertised_peripheral` Protocol that remains valid for the
12255    ///   duration of this advertising session.
12256    /// - response An empty response will be sent when the advertisement is
12257    ///   successfully stopped (due to release of the `advertised_peripheral`
12258    ///   protocol). To prevent overlapping similar advertisements and transient
12259    ///   errors with limited advertising resources, waiting for a response is
12260    ///   recommended before calling `Advertise` again.
12261    /// * error If an error occurs, `advertised_peripheral` will be closed and a
12262    ///   `PeripheralError` will be returned.
12263    pub fn r#advertise(
12264        &self,
12265        mut parameters: &AdvertisingParameters,
12266        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
12267        ___deadline: zx::MonotonicInstant,
12268    ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
12269        let _response = self.client.send_query::<
12270            PeripheralAdvertiseRequest,
12271            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
12272            PrivilegedPeripheralMarker,
12273        >(
12274            (parameters, advertised_peripheral,),
12275            0x2d9ec9260c32c17f,
12276            fidl::encoding::DynamicFlags::empty(),
12277            ___deadline,
12278        )?;
12279        Ok(_response.map(|x| x))
12280    }
12281
12282    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
12283    /// has successfully initiated. If advertising cannot be initiated, then the response will
12284    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
12285    ///
12286    /// This method can get called any number of times and successive calls can be made to
12287    /// reconfigure the advertising parameters. However only the most recent
12288    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
12289    ///
12290    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
12291    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
12292    /// advertisements.
12293    ///
12294    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
12295    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
12296    /// advertising will be briefly enabled before it is terminated.
12297    ///
12298    /// + request `parameters` Parameters used while configuring the advertising instance.
12299    /// + request `handle` Handle that remains valid for the duration of this advertising session.
12300    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
12301    ///         initiated. In this case the `handle` will be closed.
12302    pub fn r#start_advertising(
12303        &self,
12304        mut parameters: &AdvertisingParameters,
12305        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
12306        ___deadline: zx::MonotonicInstant,
12307    ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
12308        let _response = self.client.send_query::<
12309            PeripheralStartAdvertisingRequest,
12310            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
12311            PrivilegedPeripheralMarker,
12312        >(
12313            (parameters, handle,),
12314            0x5875c1c575f00f7d,
12315            fidl::encoding::DynamicFlags::empty(),
12316            ___deadline,
12317        )?;
12318        Ok(_response.map(|x| x))
12319    }
12320}
12321
12322#[cfg(target_os = "fuchsia")]
12323impl From<PrivilegedPeripheralSynchronousProxy> for zx::NullableHandle {
12324    fn from(value: PrivilegedPeripheralSynchronousProxy) -> Self {
12325        value.into_channel().into()
12326    }
12327}
12328
12329#[cfg(target_os = "fuchsia")]
12330impl From<fidl::Channel> for PrivilegedPeripheralSynchronousProxy {
12331    fn from(value: fidl::Channel) -> Self {
12332        Self::new(value)
12333    }
12334}
12335
12336#[cfg(target_os = "fuchsia")]
12337impl fidl::endpoints::FromClient for PrivilegedPeripheralSynchronousProxy {
12338    type Protocol = PrivilegedPeripheralMarker;
12339
12340    fn from_client(value: fidl::endpoints::ClientEnd<PrivilegedPeripheralMarker>) -> Self {
12341        Self::new(value.into_channel())
12342    }
12343}
12344
12345#[derive(Debug, Clone)]
12346pub struct PrivilegedPeripheralProxy {
12347    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
12348}
12349
12350impl fidl::endpoints::Proxy for PrivilegedPeripheralProxy {
12351    type Protocol = PrivilegedPeripheralMarker;
12352
12353    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
12354        Self::new(inner)
12355    }
12356
12357    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
12358        self.client.into_channel().map_err(|client| Self { client })
12359    }
12360
12361    fn as_channel(&self) -> &::fidl::AsyncChannel {
12362        self.client.as_channel()
12363    }
12364}
12365
12366impl PrivilegedPeripheralProxy {
12367    /// Create a new Proxy for fuchsia.bluetooth.le/PrivilegedPeripheral.
12368    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
12369        let protocol_name =
12370            <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
12371        Self { client: fidl::client::Client::new(channel, protocol_name) }
12372    }
12373
12374    /// Get a Stream of events from the remote end of the protocol.
12375    ///
12376    /// # Panics
12377    ///
12378    /// Panics if the event stream was already taken.
12379    pub fn take_event_stream(&self) -> PrivilegedPeripheralEventStream {
12380        PrivilegedPeripheralEventStream { event_receiver: self.client.take_event_receiver() }
12381    }
12382
12383    /// Register a listener for incoming channels. The registry will assign a
12384    /// PSM value that is unique for the local device, as well as open a
12385    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
12386    /// event that all PSMs have been assigned, this call will fail with
12387    /// `ZX_ERR_NO_RESOURCES`.
12388    ///
12389    /// Note that the method of service discovery or advertising is defined by
12390    /// the service or protocol, so it is the responsibility of the caller to
12391    /// communicate the assigned PSM to any clients.
12392    pub fn r#listen_l2cap(
12393        &self,
12394        mut payload: ChannelListenerRegistryListenL2capRequest,
12395    ) -> fidl::client::QueryResponseFut<
12396        ChannelListenerRegistryListenL2capResult,
12397        fidl::encoding::DefaultFuchsiaResourceDialect,
12398    > {
12399        PrivilegedPeripheralProxyInterface::r#listen_l2cap(self, payload)
12400    }
12401
12402    /// Start advertising continuously as a LE peripheral. If advertising cannot
12403    /// be initiated then `advertised_peripheral` will be closed and an error
12404    /// will be returned.
12405    ///
12406    /// This method may be called any number of times. To reconfigure an
12407    /// advertisement, first close the original advertisement and then initiate
12408    /// a new advertisement after an empty response is returned.
12409    ///
12410    /// If the client closes its end of the
12411    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
12412    /// advertising will be stopped. If the handle is closed before the request
12413    /// is fulfilled, advertising may be briefly enabled before it is
12414    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
12415    /// the Peripheral protocol, but this may be changed in the future
12416    /// (https://fxbug.dev/42157682).
12417    ///
12418    /// + request `parameters` Parameters used while configuring the advertising
12419    ///   instance.
12420    /// + request `advertised_peripheral` Protocol that remains valid for the
12421    ///   duration of this advertising session.
12422    /// - response An empty response will be sent when the advertisement is
12423    ///   successfully stopped (due to release of the `advertised_peripheral`
12424    ///   protocol). To prevent overlapping similar advertisements and transient
12425    ///   errors with limited advertising resources, waiting for a response is
12426    ///   recommended before calling `Advertise` again.
12427    /// * error If an error occurs, `advertised_peripheral` will be closed and a
12428    ///   `PeripheralError` will be returned.
12429    pub fn r#advertise(
12430        &self,
12431        mut parameters: &AdvertisingParameters,
12432        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
12433    ) -> fidl::client::QueryResponseFut<
12434        PeripheralAdvertiseResult,
12435        fidl::encoding::DefaultFuchsiaResourceDialect,
12436    > {
12437        PrivilegedPeripheralProxyInterface::r#advertise(self, parameters, advertised_peripheral)
12438    }
12439
12440    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
12441    /// has successfully initiated. If advertising cannot be initiated, then the response will
12442    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
12443    ///
12444    /// This method can get called any number of times and successive calls can be made to
12445    /// reconfigure the advertising parameters. However only the most recent
12446    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
12447    ///
12448    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
12449    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
12450    /// advertisements.
12451    ///
12452    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
12453    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
12454    /// advertising will be briefly enabled before it is terminated.
12455    ///
12456    /// + request `parameters` Parameters used while configuring the advertising instance.
12457    /// + request `handle` Handle that remains valid for the duration of this advertising session.
12458    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
12459    ///         initiated. In this case the `handle` will be closed.
12460    pub fn r#start_advertising(
12461        &self,
12462        mut parameters: &AdvertisingParameters,
12463        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
12464    ) -> fidl::client::QueryResponseFut<
12465        PeripheralStartAdvertisingResult,
12466        fidl::encoding::DefaultFuchsiaResourceDialect,
12467    > {
12468        PrivilegedPeripheralProxyInterface::r#start_advertising(self, parameters, handle)
12469    }
12470}
12471
12472impl PrivilegedPeripheralProxyInterface for PrivilegedPeripheralProxy {
12473    type ListenL2capResponseFut = fidl::client::QueryResponseFut<
12474        ChannelListenerRegistryListenL2capResult,
12475        fidl::encoding::DefaultFuchsiaResourceDialect,
12476    >;
12477    fn r#listen_l2cap(
12478        &self,
12479        mut payload: ChannelListenerRegistryListenL2capRequest,
12480    ) -> Self::ListenL2capResponseFut {
12481        fn _decode(
12482            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12483        ) -> Result<ChannelListenerRegistryListenL2capResult, fidl::Error> {
12484            let _response = fidl::client::decode_transaction_body::<
12485                fidl::encoding::ResultType<ChannelListenerRegistryListenL2capResponse, i32>,
12486                fidl::encoding::DefaultFuchsiaResourceDialect,
12487                0x39c6e9001d102338,
12488            >(_buf?)?;
12489            Ok(_response.map(|x| x))
12490        }
12491        self.client.send_query_and_decode::<
12492            ChannelListenerRegistryListenL2capRequest,
12493            ChannelListenerRegistryListenL2capResult,
12494        >(
12495            &mut payload,
12496            0x39c6e9001d102338,
12497            fidl::encoding::DynamicFlags::empty(),
12498            _decode,
12499        )
12500    }
12501
12502    type AdvertiseResponseFut = fidl::client::QueryResponseFut<
12503        PeripheralAdvertiseResult,
12504        fidl::encoding::DefaultFuchsiaResourceDialect,
12505    >;
12506    fn r#advertise(
12507        &self,
12508        mut parameters: &AdvertisingParameters,
12509        mut advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
12510    ) -> Self::AdvertiseResponseFut {
12511        fn _decode(
12512            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12513        ) -> Result<PeripheralAdvertiseResult, fidl::Error> {
12514            let _response = fidl::client::decode_transaction_body::<
12515                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
12516                fidl::encoding::DefaultFuchsiaResourceDialect,
12517                0x2d9ec9260c32c17f,
12518            >(_buf?)?;
12519            Ok(_response.map(|x| x))
12520        }
12521        self.client.send_query_and_decode::<PeripheralAdvertiseRequest, PeripheralAdvertiseResult>(
12522            (parameters, advertised_peripheral),
12523            0x2d9ec9260c32c17f,
12524            fidl::encoding::DynamicFlags::empty(),
12525            _decode,
12526        )
12527    }
12528
12529    type StartAdvertisingResponseFut = fidl::client::QueryResponseFut<
12530        PeripheralStartAdvertisingResult,
12531        fidl::encoding::DefaultFuchsiaResourceDialect,
12532    >;
12533    fn r#start_advertising(
12534        &self,
12535        mut parameters: &AdvertisingParameters,
12536        mut handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
12537    ) -> Self::StartAdvertisingResponseFut {
12538        fn _decode(
12539            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12540        ) -> Result<PeripheralStartAdvertisingResult, fidl::Error> {
12541            let _response = fidl::client::decode_transaction_body::<
12542                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, PeripheralError>,
12543                fidl::encoding::DefaultFuchsiaResourceDialect,
12544                0x5875c1c575f00f7d,
12545            >(_buf?)?;
12546            Ok(_response.map(|x| x))
12547        }
12548        self.client.send_query_and_decode::<
12549            PeripheralStartAdvertisingRequest,
12550            PeripheralStartAdvertisingResult,
12551        >(
12552            (parameters, handle,),
12553            0x5875c1c575f00f7d,
12554            fidl::encoding::DynamicFlags::empty(),
12555            _decode,
12556        )
12557    }
12558}
12559
12560pub struct PrivilegedPeripheralEventStream {
12561    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
12562}
12563
12564impl std::marker::Unpin for PrivilegedPeripheralEventStream {}
12565
12566impl futures::stream::FusedStream for PrivilegedPeripheralEventStream {
12567    fn is_terminated(&self) -> bool {
12568        self.event_receiver.is_terminated()
12569    }
12570}
12571
12572impl futures::Stream for PrivilegedPeripheralEventStream {
12573    type Item = Result<PrivilegedPeripheralEvent, fidl::Error>;
12574
12575    fn poll_next(
12576        mut self: std::pin::Pin<&mut Self>,
12577        cx: &mut std::task::Context<'_>,
12578    ) -> std::task::Poll<Option<Self::Item>> {
12579        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
12580            &mut self.event_receiver,
12581            cx
12582        )?) {
12583            Some(buf) => std::task::Poll::Ready(Some(PrivilegedPeripheralEvent::decode(buf))),
12584            None => std::task::Poll::Ready(None),
12585        }
12586    }
12587}
12588
12589#[derive(Debug)]
12590pub enum PrivilegedPeripheralEvent {
12591    OnPeerConnected { peer: Peer, connection: fidl::endpoints::ClientEnd<ConnectionMarker> },
12592}
12593
12594impl PrivilegedPeripheralEvent {
12595    #[allow(irrefutable_let_patterns)]
12596    pub fn into_on_peer_connected(
12597        self,
12598    ) -> Option<(Peer, fidl::endpoints::ClientEnd<ConnectionMarker>)> {
12599        if let PrivilegedPeripheralEvent::OnPeerConnected { peer, connection } = self {
12600            Some((peer, connection))
12601        } else {
12602            None
12603        }
12604    }
12605
12606    /// Decodes a message buffer as a [`PrivilegedPeripheralEvent`].
12607    fn decode(
12608        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12609    ) -> Result<PrivilegedPeripheralEvent, fidl::Error> {
12610        let (bytes, _handles) = buf.split_mut();
12611        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12612        debug_assert_eq!(tx_header.tx_id, 0);
12613        match tx_header.ordinal {
12614            0x16135d464299e356 => {
12615                let mut out = fidl::new_empty!(
12616                    PeripheralOnPeerConnectedRequest,
12617                    fidl::encoding::DefaultFuchsiaResourceDialect
12618                );
12619                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralOnPeerConnectedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12620                Ok((PrivilegedPeripheralEvent::OnPeerConnected {
12621                    peer: out.peer,
12622                    connection: out.connection,
12623                }))
12624            }
12625            _ => Err(fidl::Error::UnknownOrdinal {
12626                ordinal: tx_header.ordinal,
12627                protocol_name:
12628                    <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12629            }),
12630        }
12631    }
12632}
12633
12634/// A Stream of incoming requests for fuchsia.bluetooth.le/PrivilegedPeripheral.
12635pub struct PrivilegedPeripheralRequestStream {
12636    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12637    is_terminated: bool,
12638}
12639
12640impl std::marker::Unpin for PrivilegedPeripheralRequestStream {}
12641
12642impl futures::stream::FusedStream for PrivilegedPeripheralRequestStream {
12643    fn is_terminated(&self) -> bool {
12644        self.is_terminated
12645    }
12646}
12647
12648impl fidl::endpoints::RequestStream for PrivilegedPeripheralRequestStream {
12649    type Protocol = PrivilegedPeripheralMarker;
12650    type ControlHandle = PrivilegedPeripheralControlHandle;
12651
12652    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
12653        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12654    }
12655
12656    fn control_handle(&self) -> Self::ControlHandle {
12657        PrivilegedPeripheralControlHandle { inner: self.inner.clone() }
12658    }
12659
12660    fn into_inner(
12661        self,
12662    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
12663    {
12664        (self.inner, self.is_terminated)
12665    }
12666
12667    fn from_inner(
12668        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12669        is_terminated: bool,
12670    ) -> Self {
12671        Self { inner, is_terminated }
12672    }
12673}
12674
12675impl futures::Stream for PrivilegedPeripheralRequestStream {
12676    type Item = Result<PrivilegedPeripheralRequest, fidl::Error>;
12677
12678    fn poll_next(
12679        mut self: std::pin::Pin<&mut Self>,
12680        cx: &mut std::task::Context<'_>,
12681    ) -> std::task::Poll<Option<Self::Item>> {
12682        let this = &mut *self;
12683        if this.inner.check_shutdown(cx) {
12684            this.is_terminated = true;
12685            return std::task::Poll::Ready(None);
12686        }
12687        if this.is_terminated {
12688            panic!("polled PrivilegedPeripheralRequestStream after completion");
12689        }
12690        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
12691            |bytes, handles| {
12692                match this.inner.channel().read_etc(cx, bytes, handles) {
12693                    std::task::Poll::Ready(Ok(())) => {}
12694                    std::task::Poll::Pending => return std::task::Poll::Pending,
12695                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
12696                        this.is_terminated = true;
12697                        return std::task::Poll::Ready(None);
12698                    }
12699                    std::task::Poll::Ready(Err(e)) => {
12700                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12701                            e.into(),
12702                        ))));
12703                    }
12704                }
12705
12706                // A message has been received from the channel
12707                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12708
12709                std::task::Poll::Ready(Some(match header.ordinal {
12710                0x39c6e9001d102338 => {
12711                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12712                    let mut req = fidl::new_empty!(ChannelListenerRegistryListenL2capRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
12713                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChannelListenerRegistryListenL2capRequest>(&header, _body_bytes, handles, &mut req)?;
12714                    let control_handle = PrivilegedPeripheralControlHandle {
12715                        inner: this.inner.clone(),
12716                    };
12717                    Ok(PrivilegedPeripheralRequest::ListenL2cap {payload: req,
12718                        responder: PrivilegedPeripheralListenL2capResponder {
12719                            control_handle: std::mem::ManuallyDrop::new(control_handle),
12720                            tx_id: header.tx_id,
12721                        },
12722                    })
12723                }
12724                0x2d9ec9260c32c17f => {
12725                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12726                    let mut req = fidl::new_empty!(PeripheralAdvertiseRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
12727                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralAdvertiseRequest>(&header, _body_bytes, handles, &mut req)?;
12728                    let control_handle = PrivilegedPeripheralControlHandle {
12729                        inner: this.inner.clone(),
12730                    };
12731                    Ok(PrivilegedPeripheralRequest::Advertise {parameters: req.parameters,
12732advertised_peripheral: req.advertised_peripheral,
12733
12734                        responder: PrivilegedPeripheralAdvertiseResponder {
12735                            control_handle: std::mem::ManuallyDrop::new(control_handle),
12736                            tx_id: header.tx_id,
12737                        },
12738                    })
12739                }
12740                0x5875c1c575f00f7d => {
12741                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12742                    let mut req = fidl::new_empty!(PeripheralStartAdvertisingRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
12743                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PeripheralStartAdvertisingRequest>(&header, _body_bytes, handles, &mut req)?;
12744                    let control_handle = PrivilegedPeripheralControlHandle {
12745                        inner: this.inner.clone(),
12746                    };
12747                    Ok(PrivilegedPeripheralRequest::StartAdvertising {parameters: req.parameters,
12748handle: req.handle,
12749
12750                        responder: PrivilegedPeripheralStartAdvertisingResponder {
12751                            control_handle: std::mem::ManuallyDrop::new(control_handle),
12752                            tx_id: header.tx_id,
12753                        },
12754                    })
12755                }
12756                _ => Err(fidl::Error::UnknownOrdinal {
12757                    ordinal: header.ordinal,
12758                    protocol_name: <PrivilegedPeripheralMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12759                }),
12760            }))
12761            },
12762        )
12763    }
12764}
12765
12766/// Privileged version of the Peripheral protocol.
12767/// This protocol should only be routed to trusted and system components. Using this protocol will
12768/// enable the client to break normal privacy restrictions which could leak information about the
12769/// location or owner of the device.
12770///
12771/// Use cases which reveal information are noted in documentation and marked as only available
12772/// through PrivilegedPeripheral, and are an error if used through Peripheral.
12773#[derive(Debug)]
12774pub enum PrivilegedPeripheralRequest {
12775    /// Register a listener for incoming channels. The registry will assign a
12776    /// PSM value that is unique for the local device, as well as open a
12777    /// [`ChannelListener`] for accepting incoming channels. In the unlikely
12778    /// event that all PSMs have been assigned, this call will fail with
12779    /// `ZX_ERR_NO_RESOURCES`.
12780    ///
12781    /// Note that the method of service discovery or advertising is defined by
12782    /// the service or protocol, so it is the responsibility of the caller to
12783    /// communicate the assigned PSM to any clients.
12784    ListenL2cap {
12785        payload: ChannelListenerRegistryListenL2capRequest,
12786        responder: PrivilegedPeripheralListenL2capResponder,
12787    },
12788    /// Start advertising continuously as a LE peripheral. If advertising cannot
12789    /// be initiated then `advertised_peripheral` will be closed and an error
12790    /// will be returned.
12791    ///
12792    /// This method may be called any number of times. To reconfigure an
12793    /// advertisement, first close the original advertisement and then initiate
12794    /// a new advertisement after an empty response is returned.
12795    ///
12796    /// If the client closes its end of the
12797    /// [`fuchsia.bluetooth.le/AdvertisedPeripheral`] channel,
12798    /// advertising will be stopped. If the handle is closed before the request
12799    /// is fulfilled, advertising may be briefly enabled before it is
12800    /// terminated. AdvertisedPeripheral lifetime is bounded by the lifetime of
12801    /// the Peripheral protocol, but this may be changed in the future
12802    /// (https://fxbug.dev/42157682).
12803    ///
12804    /// + request `parameters` Parameters used while configuring the advertising
12805    ///   instance.
12806    /// + request `advertised_peripheral` Protocol that remains valid for the
12807    ///   duration of this advertising session.
12808    /// - response An empty response will be sent when the advertisement is
12809    ///   successfully stopped (due to release of the `advertised_peripheral`
12810    ///   protocol). To prevent overlapping similar advertisements and transient
12811    ///   errors with limited advertising resources, waiting for a response is
12812    ///   recommended before calling `Advertise` again.
12813    /// * error If an error occurs, `advertised_peripheral` will be closed and a
12814    ///   `PeripheralError` will be returned.
12815    Advertise {
12816        parameters: AdvertisingParameters,
12817        advertised_peripheral: fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
12818        responder: PrivilegedPeripheralAdvertiseResponder,
12819    },
12820    /// Start advertising as a LE peripheral. An empty response is sent to indicate when advertising
12821    /// has successfully initiated. If advertising cannot be initiated, then the response will
12822    /// contain a [`fuchsia.bluetooth.le/PeripheralError`].
12823    ///
12824    /// This method can get called any number of times and successive calls can be made to
12825    /// reconfigure the advertising parameters. However only the most recent
12826    /// [`fuchsia.bluetooth.le/AdvertisingHandle`] will remain valid.
12827    ///
12828    /// An instance of [`fuchsia.bluetooth.le/Peripheral`] can only have one active advertisement at
12829    /// a time. Clients must obtain multiple Peripheral instances for multiple simultaneous
12830    /// advertisements.
12831    ///
12832    /// If the client closes its end of the [`fuchsia.bluetooth.le/AdvertisingHandle`] channel,
12833    /// advertising will be stopped. If the handle is closed before the request is fulfilled,
12834    /// advertising will be briefly enabled before it is terminated.
12835    ///
12836    /// + request `parameters` Parameters used while configuring the advertising instance.
12837    /// + request `handle` Handle that remains valid for the duration of this advertising session.
12838    /// * error Returns a [`fuchsia.bluetooth.le/PeripheralError`] if advertising cannot be
12839    ///         initiated. In this case the `handle` will be closed.
12840    StartAdvertising {
12841        parameters: AdvertisingParameters,
12842        handle: fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
12843        responder: PrivilegedPeripheralStartAdvertisingResponder,
12844    },
12845}
12846
12847impl PrivilegedPeripheralRequest {
12848    #[allow(irrefutable_let_patterns)]
12849    pub fn into_listen_l2cap(
12850        self,
12851    ) -> Option<(ChannelListenerRegistryListenL2capRequest, PrivilegedPeripheralListenL2capResponder)>
12852    {
12853        if let PrivilegedPeripheralRequest::ListenL2cap { payload, responder } = self {
12854            Some((payload, responder))
12855        } else {
12856            None
12857        }
12858    }
12859
12860    #[allow(irrefutable_let_patterns)]
12861    pub fn into_advertise(
12862        self,
12863    ) -> Option<(
12864        AdvertisingParameters,
12865        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
12866        PrivilegedPeripheralAdvertiseResponder,
12867    )> {
12868        if let PrivilegedPeripheralRequest::Advertise {
12869            parameters,
12870            advertised_peripheral,
12871            responder,
12872        } = self
12873        {
12874            Some((parameters, advertised_peripheral, responder))
12875        } else {
12876            None
12877        }
12878    }
12879
12880    #[allow(irrefutable_let_patterns)]
12881    pub fn into_start_advertising(
12882        self,
12883    ) -> Option<(
12884        AdvertisingParameters,
12885        fidl::endpoints::ServerEnd<AdvertisingHandleMarker>,
12886        PrivilegedPeripheralStartAdvertisingResponder,
12887    )> {
12888        if let PrivilegedPeripheralRequest::StartAdvertising { parameters, handle, responder } =
12889            self
12890        {
12891            Some((parameters, handle, responder))
12892        } else {
12893            None
12894        }
12895    }
12896
12897    /// Name of the method defined in FIDL
12898    pub fn method_name(&self) -> &'static str {
12899        match *self {
12900            PrivilegedPeripheralRequest::ListenL2cap { .. } => "listen_l2cap",
12901            PrivilegedPeripheralRequest::Advertise { .. } => "advertise",
12902            PrivilegedPeripheralRequest::StartAdvertising { .. } => "start_advertising",
12903        }
12904    }
12905}
12906
12907#[derive(Debug, Clone)]
12908pub struct PrivilegedPeripheralControlHandle {
12909    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12910}
12911
12912impl fidl::endpoints::ControlHandle for PrivilegedPeripheralControlHandle {
12913    fn shutdown(&self) {
12914        self.inner.shutdown()
12915    }
12916
12917    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
12918        self.inner.shutdown_with_epitaph(status)
12919    }
12920
12921    fn is_closed(&self) -> bool {
12922        self.inner.channel().is_closed()
12923    }
12924    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
12925        self.inner.channel().on_closed()
12926    }
12927
12928    #[cfg(target_os = "fuchsia")]
12929    fn signal_peer(
12930        &self,
12931        clear_mask: zx::Signals,
12932        set_mask: zx::Signals,
12933    ) -> Result<(), zx_status::Status> {
12934        use fidl::Peered;
12935        self.inner.channel().signal_peer(clear_mask, set_mask)
12936    }
12937}
12938
12939impl PrivilegedPeripheralControlHandle {
12940    pub fn send_on_peer_connected(
12941        &self,
12942        mut peer: &Peer,
12943        mut connection: fidl::endpoints::ClientEnd<ConnectionMarker>,
12944    ) -> Result<(), fidl::Error> {
12945        self.inner.send::<PeripheralOnPeerConnectedRequest>(
12946            (peer, connection),
12947            0,
12948            0x16135d464299e356,
12949            fidl::encoding::DynamicFlags::empty(),
12950        )
12951    }
12952}
12953
12954#[must_use = "FIDL methods require a response to be sent"]
12955#[derive(Debug)]
12956pub struct PrivilegedPeripheralListenL2capResponder {
12957    control_handle: std::mem::ManuallyDrop<PrivilegedPeripheralControlHandle>,
12958    tx_id: u32,
12959}
12960
12961/// Set the the channel to be shutdown (see [`PrivilegedPeripheralControlHandle::shutdown`])
12962/// if the responder is dropped without sending a response, so that the client
12963/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12964impl std::ops::Drop for PrivilegedPeripheralListenL2capResponder {
12965    fn drop(&mut self) {
12966        self.control_handle.shutdown();
12967        // Safety: drops once, never accessed again
12968        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12969    }
12970}
12971
12972impl fidl::endpoints::Responder for PrivilegedPeripheralListenL2capResponder {
12973    type ControlHandle = PrivilegedPeripheralControlHandle;
12974
12975    fn control_handle(&self) -> &PrivilegedPeripheralControlHandle {
12976        &self.control_handle
12977    }
12978
12979    fn drop_without_shutdown(mut self) {
12980        // Safety: drops once, never accessed again due to mem::forget
12981        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12982        // Prevent Drop from running (which would shut down the channel)
12983        std::mem::forget(self);
12984    }
12985}
12986
12987impl PrivilegedPeripheralListenL2capResponder {
12988    /// Sends a response to the FIDL transaction.
12989    ///
12990    /// Sets the channel to shutdown if an error occurs.
12991    pub fn send(
12992        self,
12993        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
12994    ) -> Result<(), fidl::Error> {
12995        let _result = self.send_raw(result);
12996        if _result.is_err() {
12997            self.control_handle.shutdown();
12998        }
12999        self.drop_without_shutdown();
13000        _result
13001    }
13002
13003    /// Similar to "send" but does not shutdown the channel if an error occurs.
13004    pub fn send_no_shutdown_on_err(
13005        self,
13006        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
13007    ) -> Result<(), fidl::Error> {
13008        let _result = self.send_raw(result);
13009        self.drop_without_shutdown();
13010        _result
13011    }
13012
13013    fn send_raw(
13014        &self,
13015        mut result: Result<&ChannelListenerRegistryListenL2capResponse, i32>,
13016    ) -> Result<(), fidl::Error> {
13017        self.control_handle.inner.send::<fidl::encoding::ResultType<
13018            ChannelListenerRegistryListenL2capResponse,
13019            i32,
13020        >>(
13021            result,
13022            self.tx_id,
13023            0x39c6e9001d102338,
13024            fidl::encoding::DynamicFlags::empty(),
13025        )
13026    }
13027}
13028
13029#[must_use = "FIDL methods require a response to be sent"]
13030#[derive(Debug)]
13031pub struct PrivilegedPeripheralAdvertiseResponder {
13032    control_handle: std::mem::ManuallyDrop<PrivilegedPeripheralControlHandle>,
13033    tx_id: u32,
13034}
13035
13036/// Set the the channel to be shutdown (see [`PrivilegedPeripheralControlHandle::shutdown`])
13037/// if the responder is dropped without sending a response, so that the client
13038/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13039impl std::ops::Drop for PrivilegedPeripheralAdvertiseResponder {
13040    fn drop(&mut self) {
13041        self.control_handle.shutdown();
13042        // Safety: drops once, never accessed again
13043        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13044    }
13045}
13046
13047impl fidl::endpoints::Responder for PrivilegedPeripheralAdvertiseResponder {
13048    type ControlHandle = PrivilegedPeripheralControlHandle;
13049
13050    fn control_handle(&self) -> &PrivilegedPeripheralControlHandle {
13051        &self.control_handle
13052    }
13053
13054    fn drop_without_shutdown(mut self) {
13055        // Safety: drops once, never accessed again due to mem::forget
13056        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13057        // Prevent Drop from running (which would shut down the channel)
13058        std::mem::forget(self);
13059    }
13060}
13061
13062impl PrivilegedPeripheralAdvertiseResponder {
13063    /// Sends a response to the FIDL transaction.
13064    ///
13065    /// Sets the channel to shutdown if an error occurs.
13066    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
13067        let _result = self.send_raw(result);
13068        if _result.is_err() {
13069            self.control_handle.shutdown();
13070        }
13071        self.drop_without_shutdown();
13072        _result
13073    }
13074
13075    /// Similar to "send" but does not shutdown the channel if an error occurs.
13076    pub fn send_no_shutdown_on_err(
13077        self,
13078        mut result: Result<(), PeripheralError>,
13079    ) -> Result<(), fidl::Error> {
13080        let _result = self.send_raw(result);
13081        self.drop_without_shutdown();
13082        _result
13083    }
13084
13085    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
13086        self.control_handle.inner.send::<fidl::encoding::ResultType<
13087            fidl::encoding::EmptyStruct,
13088            PeripheralError,
13089        >>(
13090            result,
13091            self.tx_id,
13092            0x2d9ec9260c32c17f,
13093            fidl::encoding::DynamicFlags::empty(),
13094        )
13095    }
13096}
13097
13098#[must_use = "FIDL methods require a response to be sent"]
13099#[derive(Debug)]
13100pub struct PrivilegedPeripheralStartAdvertisingResponder {
13101    control_handle: std::mem::ManuallyDrop<PrivilegedPeripheralControlHandle>,
13102    tx_id: u32,
13103}
13104
13105/// Set the the channel to be shutdown (see [`PrivilegedPeripheralControlHandle::shutdown`])
13106/// if the responder is dropped without sending a response, so that the client
13107/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13108impl std::ops::Drop for PrivilegedPeripheralStartAdvertisingResponder {
13109    fn drop(&mut self) {
13110        self.control_handle.shutdown();
13111        // Safety: drops once, never accessed again
13112        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13113    }
13114}
13115
13116impl fidl::endpoints::Responder for PrivilegedPeripheralStartAdvertisingResponder {
13117    type ControlHandle = PrivilegedPeripheralControlHandle;
13118
13119    fn control_handle(&self) -> &PrivilegedPeripheralControlHandle {
13120        &self.control_handle
13121    }
13122
13123    fn drop_without_shutdown(mut self) {
13124        // Safety: drops once, never accessed again due to mem::forget
13125        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13126        // Prevent Drop from running (which would shut down the channel)
13127        std::mem::forget(self);
13128    }
13129}
13130
13131impl PrivilegedPeripheralStartAdvertisingResponder {
13132    /// Sends a response to the FIDL transaction.
13133    ///
13134    /// Sets the channel to shutdown if an error occurs.
13135    pub fn send(self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
13136        let _result = self.send_raw(result);
13137        if _result.is_err() {
13138            self.control_handle.shutdown();
13139        }
13140        self.drop_without_shutdown();
13141        _result
13142    }
13143
13144    /// Similar to "send" but does not shutdown the channel if an error occurs.
13145    pub fn send_no_shutdown_on_err(
13146        self,
13147        mut result: Result<(), PeripheralError>,
13148    ) -> Result<(), fidl::Error> {
13149        let _result = self.send_raw(result);
13150        self.drop_without_shutdown();
13151        _result
13152    }
13153
13154    fn send_raw(&self, mut result: Result<(), PeripheralError>) -> Result<(), fidl::Error> {
13155        self.control_handle.inner.send::<fidl::encoding::ResultType<
13156            fidl::encoding::EmptyStruct,
13157            PeripheralError,
13158        >>(
13159            result,
13160            self.tx_id,
13161            0x5875c1c575f00f7d,
13162            fidl::encoding::DynamicFlags::empty(),
13163        )
13164    }
13165}
13166
13167#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
13168pub struct ScanResultWatcherMarker;
13169
13170impl fidl::endpoints::ProtocolMarker for ScanResultWatcherMarker {
13171    type Proxy = ScanResultWatcherProxy;
13172    type RequestStream = ScanResultWatcherRequestStream;
13173    #[cfg(target_os = "fuchsia")]
13174    type SynchronousProxy = ScanResultWatcherSynchronousProxy;
13175
13176    const DEBUG_NAME: &'static str = "(anonymous) ScanResultWatcher";
13177}
13178
13179pub trait ScanResultWatcherProxyInterface: Send + Sync {
13180    type WatchResponseFut: std::future::Future<Output = Result<Vec<Peer>, fidl::Error>> + Send;
13181    fn r#watch(&self) -> Self::WatchResponseFut;
13182}
13183#[derive(Debug)]
13184#[cfg(target_os = "fuchsia")]
13185pub struct ScanResultWatcherSynchronousProxy {
13186    client: fidl::client::sync::Client,
13187}
13188
13189#[cfg(target_os = "fuchsia")]
13190impl fidl::endpoints::SynchronousProxy for ScanResultWatcherSynchronousProxy {
13191    type Proxy = ScanResultWatcherProxy;
13192    type Protocol = ScanResultWatcherMarker;
13193
13194    fn from_channel(inner: fidl::Channel) -> Self {
13195        Self::new(inner)
13196    }
13197
13198    fn into_channel(self) -> fidl::Channel {
13199        self.client.into_channel()
13200    }
13201
13202    fn as_channel(&self) -> &fidl::Channel {
13203        self.client.as_channel()
13204    }
13205}
13206
13207#[cfg(target_os = "fuchsia")]
13208impl ScanResultWatcherSynchronousProxy {
13209    pub fn new(channel: fidl::Channel) -> Self {
13210        Self { client: fidl::client::sync::Client::new(channel) }
13211    }
13212
13213    pub fn into_channel(self) -> fidl::Channel {
13214        self.client.into_channel()
13215    }
13216
13217    /// Waits until an event arrives and returns it. It is safe for other
13218    /// threads to make concurrent requests while waiting for an event.
13219    pub fn wait_for_event(
13220        &self,
13221        deadline: zx::MonotonicInstant,
13222    ) -> Result<ScanResultWatcherEvent, fidl::Error> {
13223        ScanResultWatcherEvent::decode(
13224            self.client.wait_for_event::<ScanResultWatcherMarker>(deadline)?,
13225        )
13226    }
13227
13228    /// Returns a list of all LE peers that satisfy the filters indicated in
13229    /// `ScanOptions`. The first response(s) will return matching discovered
13230    /// peers immediately. Subsequent calls receive a response only when peers
13231    /// have been scanned or updated since the last call. If a second call to
13232    /// `Watch` is erronously sent while one call is already pending, the scan
13233    /// will be canceled and the protocol will be closed.
13234    ///
13235    /// - response `updated` Peers that were added or updated since the last
13236    ///   call to Watch().
13237    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<Peer>, fidl::Error> {
13238        let _response = self.client.send_query::<
13239            fidl::encoding::EmptyPayload,
13240            ScanResultWatcherWatchResponse,
13241            ScanResultWatcherMarker,
13242        >(
13243            (),
13244            0x713a122e949f301a,
13245            fidl::encoding::DynamicFlags::empty(),
13246            ___deadline,
13247        )?;
13248        Ok(_response.updated)
13249    }
13250}
13251
13252#[cfg(target_os = "fuchsia")]
13253impl From<ScanResultWatcherSynchronousProxy> for zx::NullableHandle {
13254    fn from(value: ScanResultWatcherSynchronousProxy) -> Self {
13255        value.into_channel().into()
13256    }
13257}
13258
13259#[cfg(target_os = "fuchsia")]
13260impl From<fidl::Channel> for ScanResultWatcherSynchronousProxy {
13261    fn from(value: fidl::Channel) -> Self {
13262        Self::new(value)
13263    }
13264}
13265
13266#[cfg(target_os = "fuchsia")]
13267impl fidl::endpoints::FromClient for ScanResultWatcherSynchronousProxy {
13268    type Protocol = ScanResultWatcherMarker;
13269
13270    fn from_client(value: fidl::endpoints::ClientEnd<ScanResultWatcherMarker>) -> Self {
13271        Self::new(value.into_channel())
13272    }
13273}
13274
13275#[derive(Debug, Clone)]
13276pub struct ScanResultWatcherProxy {
13277    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
13278}
13279
13280impl fidl::endpoints::Proxy for ScanResultWatcherProxy {
13281    type Protocol = ScanResultWatcherMarker;
13282
13283    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
13284        Self::new(inner)
13285    }
13286
13287    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
13288        self.client.into_channel().map_err(|client| Self { client })
13289    }
13290
13291    fn as_channel(&self) -> &::fidl::AsyncChannel {
13292        self.client.as_channel()
13293    }
13294}
13295
13296impl ScanResultWatcherProxy {
13297    /// Create a new Proxy for fuchsia.bluetooth.le/ScanResultWatcher.
13298    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
13299        let protocol_name =
13300            <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
13301        Self { client: fidl::client::Client::new(channel, protocol_name) }
13302    }
13303
13304    /// Get a Stream of events from the remote end of the protocol.
13305    ///
13306    /// # Panics
13307    ///
13308    /// Panics if the event stream was already taken.
13309    pub fn take_event_stream(&self) -> ScanResultWatcherEventStream {
13310        ScanResultWatcherEventStream { event_receiver: self.client.take_event_receiver() }
13311    }
13312
13313    /// Returns a list of all LE peers that satisfy the filters indicated in
13314    /// `ScanOptions`. The first response(s) will return matching discovered
13315    /// peers immediately. Subsequent calls receive a response only when peers
13316    /// have been scanned or updated since the last call. If a second call to
13317    /// `Watch` is erronously sent while one call is already pending, the scan
13318    /// will be canceled and the protocol will be closed.
13319    ///
13320    /// - response `updated` Peers that were added or updated since the last
13321    ///   call to Watch().
13322    pub fn r#watch(
13323        &self,
13324    ) -> fidl::client::QueryResponseFut<Vec<Peer>, fidl::encoding::DefaultFuchsiaResourceDialect>
13325    {
13326        ScanResultWatcherProxyInterface::r#watch(self)
13327    }
13328}
13329
13330impl ScanResultWatcherProxyInterface for ScanResultWatcherProxy {
13331    type WatchResponseFut =
13332        fidl::client::QueryResponseFut<Vec<Peer>, fidl::encoding::DefaultFuchsiaResourceDialect>;
13333    fn r#watch(&self) -> Self::WatchResponseFut {
13334        fn _decode(
13335            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
13336        ) -> Result<Vec<Peer>, fidl::Error> {
13337            let _response = fidl::client::decode_transaction_body::<
13338                ScanResultWatcherWatchResponse,
13339                fidl::encoding::DefaultFuchsiaResourceDialect,
13340                0x713a122e949f301a,
13341            >(_buf?)?;
13342            Ok(_response.updated)
13343        }
13344        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<Peer>>(
13345            (),
13346            0x713a122e949f301a,
13347            fidl::encoding::DynamicFlags::empty(),
13348            _decode,
13349        )
13350    }
13351}
13352
13353pub struct ScanResultWatcherEventStream {
13354    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
13355}
13356
13357impl std::marker::Unpin for ScanResultWatcherEventStream {}
13358
13359impl futures::stream::FusedStream for ScanResultWatcherEventStream {
13360    fn is_terminated(&self) -> bool {
13361        self.event_receiver.is_terminated()
13362    }
13363}
13364
13365impl futures::Stream for ScanResultWatcherEventStream {
13366    type Item = Result<ScanResultWatcherEvent, fidl::Error>;
13367
13368    fn poll_next(
13369        mut self: std::pin::Pin<&mut Self>,
13370        cx: &mut std::task::Context<'_>,
13371    ) -> std::task::Poll<Option<Self::Item>> {
13372        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
13373            &mut self.event_receiver,
13374            cx
13375        )?) {
13376            Some(buf) => std::task::Poll::Ready(Some(ScanResultWatcherEvent::decode(buf))),
13377            None => std::task::Poll::Ready(None),
13378        }
13379    }
13380}
13381
13382#[derive(Debug)]
13383pub enum ScanResultWatcherEvent {}
13384
13385impl ScanResultWatcherEvent {
13386    /// Decodes a message buffer as a [`ScanResultWatcherEvent`].
13387    fn decode(
13388        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
13389    ) -> Result<ScanResultWatcherEvent, fidl::Error> {
13390        let (bytes, _handles) = buf.split_mut();
13391        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13392        debug_assert_eq!(tx_header.tx_id, 0);
13393        match tx_header.ordinal {
13394            _ => Err(fidl::Error::UnknownOrdinal {
13395                ordinal: tx_header.ordinal,
13396                protocol_name:
13397                    <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13398            }),
13399        }
13400    }
13401}
13402
13403/// A Stream of incoming requests for fuchsia.bluetooth.le/ScanResultWatcher.
13404pub struct ScanResultWatcherRequestStream {
13405    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13406    is_terminated: bool,
13407}
13408
13409impl std::marker::Unpin for ScanResultWatcherRequestStream {}
13410
13411impl futures::stream::FusedStream for ScanResultWatcherRequestStream {
13412    fn is_terminated(&self) -> bool {
13413        self.is_terminated
13414    }
13415}
13416
13417impl fidl::endpoints::RequestStream for ScanResultWatcherRequestStream {
13418    type Protocol = ScanResultWatcherMarker;
13419    type ControlHandle = ScanResultWatcherControlHandle;
13420
13421    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
13422        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
13423    }
13424
13425    fn control_handle(&self) -> Self::ControlHandle {
13426        ScanResultWatcherControlHandle { inner: self.inner.clone() }
13427    }
13428
13429    fn into_inner(
13430        self,
13431    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
13432    {
13433        (self.inner, self.is_terminated)
13434    }
13435
13436    fn from_inner(
13437        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13438        is_terminated: bool,
13439    ) -> Self {
13440        Self { inner, is_terminated }
13441    }
13442}
13443
13444impl futures::Stream for ScanResultWatcherRequestStream {
13445    type Item = Result<ScanResultWatcherRequest, fidl::Error>;
13446
13447    fn poll_next(
13448        mut self: std::pin::Pin<&mut Self>,
13449        cx: &mut std::task::Context<'_>,
13450    ) -> std::task::Poll<Option<Self::Item>> {
13451        let this = &mut *self;
13452        if this.inner.check_shutdown(cx) {
13453            this.is_terminated = true;
13454            return std::task::Poll::Ready(None);
13455        }
13456        if this.is_terminated {
13457            panic!("polled ScanResultWatcherRequestStream after completion");
13458        }
13459        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
13460            |bytes, handles| {
13461                match this.inner.channel().read_etc(cx, bytes, handles) {
13462                    std::task::Poll::Ready(Ok(())) => {}
13463                    std::task::Poll::Pending => return std::task::Poll::Pending,
13464                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
13465                        this.is_terminated = true;
13466                        return std::task::Poll::Ready(None);
13467                    }
13468                    std::task::Poll::Ready(Err(e)) => {
13469                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
13470                            e.into(),
13471                        ))));
13472                    }
13473                }
13474
13475                // A message has been received from the channel
13476                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13477
13478                std::task::Poll::Ready(Some(match header.ordinal {
13479                    0x713a122e949f301a => {
13480                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
13481                        let mut req = fidl::new_empty!(
13482                            fidl::encoding::EmptyPayload,
13483                            fidl::encoding::DefaultFuchsiaResourceDialect
13484                        );
13485                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
13486                        let control_handle =
13487                            ScanResultWatcherControlHandle { inner: this.inner.clone() };
13488                        Ok(ScanResultWatcherRequest::Watch {
13489                            responder: ScanResultWatcherWatchResponder {
13490                                control_handle: std::mem::ManuallyDrop::new(control_handle),
13491                                tx_id: header.tx_id,
13492                            },
13493                        })
13494                    }
13495                    _ => Err(fidl::Error::UnknownOrdinal {
13496                        ordinal: header.ordinal,
13497                        protocol_name:
13498                            <ScanResultWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13499                    }),
13500                }))
13501            },
13502        )
13503    }
13504}
13505
13506/// Represents an active scan procedure. This protocol remains valid for the
13507/// duration of a scan and can be used to obtain scan results. The client can
13508/// close the protocol to stop scanning. If a scan is stopped by the system, the
13509/// protocol will be closed with the epitaph `CANCELED` to communicate this to
13510/// the client.
13511#[derive(Debug)]
13512pub enum ScanResultWatcherRequest {
13513    /// Returns a list of all LE peers that satisfy the filters indicated in
13514    /// `ScanOptions`. The first response(s) will return matching discovered
13515    /// peers immediately. Subsequent calls receive a response only when peers
13516    /// have been scanned or updated since the last call. If a second call to
13517    /// `Watch` is erronously sent while one call is already pending, the scan
13518    /// will be canceled and the protocol will be closed.
13519    ///
13520    /// - response `updated` Peers that were added or updated since the last
13521    ///   call to Watch().
13522    Watch { responder: ScanResultWatcherWatchResponder },
13523}
13524
13525impl ScanResultWatcherRequest {
13526    #[allow(irrefutable_let_patterns)]
13527    pub fn into_watch(self) -> Option<(ScanResultWatcherWatchResponder)> {
13528        if let ScanResultWatcherRequest::Watch { responder } = self {
13529            Some((responder))
13530        } else {
13531            None
13532        }
13533    }
13534
13535    /// Name of the method defined in FIDL
13536    pub fn method_name(&self) -> &'static str {
13537        match *self {
13538            ScanResultWatcherRequest::Watch { .. } => "watch",
13539        }
13540    }
13541}
13542
13543#[derive(Debug, Clone)]
13544pub struct ScanResultWatcherControlHandle {
13545    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13546}
13547
13548impl fidl::endpoints::ControlHandle for ScanResultWatcherControlHandle {
13549    fn shutdown(&self) {
13550        self.inner.shutdown()
13551    }
13552
13553    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
13554        self.inner.shutdown_with_epitaph(status)
13555    }
13556
13557    fn is_closed(&self) -> bool {
13558        self.inner.channel().is_closed()
13559    }
13560    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
13561        self.inner.channel().on_closed()
13562    }
13563
13564    #[cfg(target_os = "fuchsia")]
13565    fn signal_peer(
13566        &self,
13567        clear_mask: zx::Signals,
13568        set_mask: zx::Signals,
13569    ) -> Result<(), zx_status::Status> {
13570        use fidl::Peered;
13571        self.inner.channel().signal_peer(clear_mask, set_mask)
13572    }
13573}
13574
13575impl ScanResultWatcherControlHandle {}
13576
13577#[must_use = "FIDL methods require a response to be sent"]
13578#[derive(Debug)]
13579pub struct ScanResultWatcherWatchResponder {
13580    control_handle: std::mem::ManuallyDrop<ScanResultWatcherControlHandle>,
13581    tx_id: u32,
13582}
13583
13584/// Set the the channel to be shutdown (see [`ScanResultWatcherControlHandle::shutdown`])
13585/// if the responder is dropped without sending a response, so that the client
13586/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13587impl std::ops::Drop for ScanResultWatcherWatchResponder {
13588    fn drop(&mut self) {
13589        self.control_handle.shutdown();
13590        // Safety: drops once, never accessed again
13591        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13592    }
13593}
13594
13595impl fidl::endpoints::Responder for ScanResultWatcherWatchResponder {
13596    type ControlHandle = ScanResultWatcherControlHandle;
13597
13598    fn control_handle(&self) -> &ScanResultWatcherControlHandle {
13599        &self.control_handle
13600    }
13601
13602    fn drop_without_shutdown(mut self) {
13603        // Safety: drops once, never accessed again due to mem::forget
13604        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13605        // Prevent Drop from running (which would shut down the channel)
13606        std::mem::forget(self);
13607    }
13608}
13609
13610impl ScanResultWatcherWatchResponder {
13611    /// Sends a response to the FIDL transaction.
13612    ///
13613    /// Sets the channel to shutdown if an error occurs.
13614    pub fn send(self, mut updated: &[Peer]) -> Result<(), fidl::Error> {
13615        let _result = self.send_raw(updated);
13616        if _result.is_err() {
13617            self.control_handle.shutdown();
13618        }
13619        self.drop_without_shutdown();
13620        _result
13621    }
13622
13623    /// Similar to "send" but does not shutdown the channel if an error occurs.
13624    pub fn send_no_shutdown_on_err(self, mut updated: &[Peer]) -> Result<(), fidl::Error> {
13625        let _result = self.send_raw(updated);
13626        self.drop_without_shutdown();
13627        _result
13628    }
13629
13630    fn send_raw(&self, mut updated: &[Peer]) -> Result<(), fidl::Error> {
13631        self.control_handle.inner.send::<ScanResultWatcherWatchResponse>(
13632            (updated,),
13633            self.tx_id,
13634            0x713a122e949f301a,
13635            fidl::encoding::DynamicFlags::empty(),
13636        )
13637    }
13638}
13639
13640mod internal {
13641    use super::*;
13642
13643    impl fidl::encoding::ResourceTypeMarker for AdvertisedPeripheralOnConnectedRequest {
13644        type Borrowed<'a> = &'a mut Self;
13645        fn take_or_borrow<'a>(
13646            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13647        ) -> Self::Borrowed<'a> {
13648            value
13649        }
13650    }
13651
13652    unsafe impl fidl::encoding::TypeMarker for AdvertisedPeripheralOnConnectedRequest {
13653        type Owned = Self;
13654
13655        #[inline(always)]
13656        fn inline_align(_context: fidl::encoding::Context) -> usize {
13657            8
13658        }
13659
13660        #[inline(always)]
13661        fn inline_size(_context: fidl::encoding::Context) -> usize {
13662            24
13663        }
13664    }
13665
13666    unsafe impl
13667        fidl::encoding::Encode<
13668            AdvertisedPeripheralOnConnectedRequest,
13669            fidl::encoding::DefaultFuchsiaResourceDialect,
13670        > for &mut AdvertisedPeripheralOnConnectedRequest
13671    {
13672        #[inline]
13673        unsafe fn encode(
13674            self,
13675            encoder: &mut fidl::encoding::Encoder<
13676                '_,
13677                fidl::encoding::DefaultFuchsiaResourceDialect,
13678            >,
13679            offset: usize,
13680            _depth: fidl::encoding::Depth,
13681        ) -> fidl::Result<()> {
13682            encoder.debug_check_bounds::<AdvertisedPeripheralOnConnectedRequest>(offset);
13683            // Delegate to tuple encoding.
13684            fidl::encoding::Encode::<AdvertisedPeripheralOnConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
13685                (
13686                    <Peer as fidl::encoding::ValueTypeMarker>::borrow(&self.peer),
13687                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.connection),
13688                ),
13689                encoder, offset, _depth
13690            )
13691        }
13692    }
13693    unsafe impl<
13694        T0: fidl::encoding::Encode<Peer, fidl::encoding::DefaultFuchsiaResourceDialect>,
13695        T1: fidl::encoding::Encode<
13696                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
13697                fidl::encoding::DefaultFuchsiaResourceDialect,
13698            >,
13699    >
13700        fidl::encoding::Encode<
13701            AdvertisedPeripheralOnConnectedRequest,
13702            fidl::encoding::DefaultFuchsiaResourceDialect,
13703        > for (T0, T1)
13704    {
13705        #[inline]
13706        unsafe fn encode(
13707            self,
13708            encoder: &mut fidl::encoding::Encoder<
13709                '_,
13710                fidl::encoding::DefaultFuchsiaResourceDialect,
13711            >,
13712            offset: usize,
13713            depth: fidl::encoding::Depth,
13714        ) -> fidl::Result<()> {
13715            encoder.debug_check_bounds::<AdvertisedPeripheralOnConnectedRequest>(offset);
13716            // Zero out padding regions. There's no need to apply masks
13717            // because the unmasked parts will be overwritten by fields.
13718            unsafe {
13719                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
13720                (ptr as *mut u64).write_unaligned(0);
13721            }
13722            // Write the fields.
13723            self.0.encode(encoder, offset + 0, depth)?;
13724            self.1.encode(encoder, offset + 16, depth)?;
13725            Ok(())
13726        }
13727    }
13728
13729    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13730        for AdvertisedPeripheralOnConnectedRequest
13731    {
13732        #[inline(always)]
13733        fn new_empty() -> Self {
13734            Self {
13735                peer: fidl::new_empty!(Peer, fidl::encoding::DefaultFuchsiaResourceDialect),
13736                connection: fidl::new_empty!(
13737                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
13738                    fidl::encoding::DefaultFuchsiaResourceDialect
13739                ),
13740            }
13741        }
13742
13743        #[inline]
13744        unsafe fn decode(
13745            &mut self,
13746            decoder: &mut fidl::encoding::Decoder<
13747                '_,
13748                fidl::encoding::DefaultFuchsiaResourceDialect,
13749            >,
13750            offset: usize,
13751            _depth: fidl::encoding::Depth,
13752        ) -> fidl::Result<()> {
13753            decoder.debug_check_bounds::<Self>(offset);
13754            // Verify that padding bytes are zero.
13755            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
13756            let padval = unsafe { (ptr as *const u64).read_unaligned() };
13757            let mask = 0xffffffff00000000u64;
13758            let maskedval = padval & mask;
13759            if maskedval != 0 {
13760                return Err(fidl::Error::NonZeroPadding {
13761                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
13762                });
13763            }
13764            fidl::decode!(
13765                Peer,
13766                fidl::encoding::DefaultFuchsiaResourceDialect,
13767                &mut self.peer,
13768                decoder,
13769                offset + 0,
13770                _depth
13771            )?;
13772            fidl::decode!(
13773                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
13774                fidl::encoding::DefaultFuchsiaResourceDialect,
13775                &mut self.connection,
13776                decoder,
13777                offset + 16,
13778                _depth
13779            )?;
13780            Ok(())
13781        }
13782    }
13783
13784    impl fidl::encoding::ResourceTypeMarker for CentralConnectPeripheralRequest {
13785        type Borrowed<'a> = &'a mut Self;
13786        fn take_or_borrow<'a>(
13787            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13788        ) -> Self::Borrowed<'a> {
13789            value
13790        }
13791    }
13792
13793    unsafe impl fidl::encoding::TypeMarker for CentralConnectPeripheralRequest {
13794        type Owned = Self;
13795
13796        #[inline(always)]
13797        fn inline_align(_context: fidl::encoding::Context) -> usize {
13798            8
13799        }
13800
13801        #[inline(always)]
13802        fn inline_size(_context: fidl::encoding::Context) -> usize {
13803            40
13804        }
13805    }
13806
13807    unsafe impl
13808        fidl::encoding::Encode<
13809            CentralConnectPeripheralRequest,
13810            fidl::encoding::DefaultFuchsiaResourceDialect,
13811        > for &mut CentralConnectPeripheralRequest
13812    {
13813        #[inline]
13814        unsafe fn encode(
13815            self,
13816            encoder: &mut fidl::encoding::Encoder<
13817                '_,
13818                fidl::encoding::DefaultFuchsiaResourceDialect,
13819            >,
13820            offset: usize,
13821            _depth: fidl::encoding::Depth,
13822        ) -> fidl::Result<()> {
13823            encoder.debug_check_bounds::<CentralConnectPeripheralRequest>(offset);
13824            // Delegate to tuple encoding.
13825            fidl::encoding::Encode::<
13826                CentralConnectPeripheralRequest,
13827                fidl::encoding::DefaultFuchsiaResourceDialect,
13828            >::encode(
13829                (
13830                    <fidl::encoding::BoundedString<16> as fidl::encoding::ValueTypeMarker>::borrow(
13831                        &self.identifier,
13832                    ),
13833                    <ConnectionOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
13834                    <fidl::encoding::Endpoint<
13835                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
13836                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
13837                        &mut self.gatt_client
13838                    ),
13839                ),
13840                encoder,
13841                offset,
13842                _depth,
13843            )
13844        }
13845    }
13846    unsafe impl<
13847        T0: fidl::encoding::Encode<
13848                fidl::encoding::BoundedString<16>,
13849                fidl::encoding::DefaultFuchsiaResourceDialect,
13850            >,
13851        T1: fidl::encoding::Encode<ConnectionOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
13852        T2: fidl::encoding::Encode<
13853                fidl::encoding::Endpoint<
13854                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
13855                >,
13856                fidl::encoding::DefaultFuchsiaResourceDialect,
13857            >,
13858    >
13859        fidl::encoding::Encode<
13860            CentralConnectPeripheralRequest,
13861            fidl::encoding::DefaultFuchsiaResourceDialect,
13862        > for (T0, T1, T2)
13863    {
13864        #[inline]
13865        unsafe fn encode(
13866            self,
13867            encoder: &mut fidl::encoding::Encoder<
13868                '_,
13869                fidl::encoding::DefaultFuchsiaResourceDialect,
13870            >,
13871            offset: usize,
13872            depth: fidl::encoding::Depth,
13873        ) -> fidl::Result<()> {
13874            encoder.debug_check_bounds::<CentralConnectPeripheralRequest>(offset);
13875            // Zero out padding regions. There's no need to apply masks
13876            // because the unmasked parts will be overwritten by fields.
13877            unsafe {
13878                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
13879                (ptr as *mut u64).write_unaligned(0);
13880            }
13881            // Write the fields.
13882            self.0.encode(encoder, offset + 0, depth)?;
13883            self.1.encode(encoder, offset + 16, depth)?;
13884            self.2.encode(encoder, offset + 32, depth)?;
13885            Ok(())
13886        }
13887    }
13888
13889    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13890        for CentralConnectPeripheralRequest
13891    {
13892        #[inline(always)]
13893        fn new_empty() -> Self {
13894            Self {
13895                identifier: fidl::new_empty!(
13896                    fidl::encoding::BoundedString<16>,
13897                    fidl::encoding::DefaultFuchsiaResourceDialect
13898                ),
13899                options: fidl::new_empty!(
13900                    ConnectionOptions,
13901                    fidl::encoding::DefaultFuchsiaResourceDialect
13902                ),
13903                gatt_client: fidl::new_empty!(
13904                    fidl::encoding::Endpoint<
13905                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
13906                    >,
13907                    fidl::encoding::DefaultFuchsiaResourceDialect
13908                ),
13909            }
13910        }
13911
13912        #[inline]
13913        unsafe fn decode(
13914            &mut self,
13915            decoder: &mut fidl::encoding::Decoder<
13916                '_,
13917                fidl::encoding::DefaultFuchsiaResourceDialect,
13918            >,
13919            offset: usize,
13920            _depth: fidl::encoding::Depth,
13921        ) -> fidl::Result<()> {
13922            decoder.debug_check_bounds::<Self>(offset);
13923            // Verify that padding bytes are zero.
13924            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
13925            let padval = unsafe { (ptr as *const u64).read_unaligned() };
13926            let mask = 0xffffffff00000000u64;
13927            let maskedval = padval & mask;
13928            if maskedval != 0 {
13929                return Err(fidl::Error::NonZeroPadding {
13930                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
13931                });
13932            }
13933            fidl::decode!(
13934                fidl::encoding::BoundedString<16>,
13935                fidl::encoding::DefaultFuchsiaResourceDialect,
13936                &mut self.identifier,
13937                decoder,
13938                offset + 0,
13939                _depth
13940            )?;
13941            fidl::decode!(
13942                ConnectionOptions,
13943                fidl::encoding::DefaultFuchsiaResourceDialect,
13944                &mut self.options,
13945                decoder,
13946                offset + 16,
13947                _depth
13948            )?;
13949            fidl::decode!(
13950                fidl::encoding::Endpoint<
13951                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt::ClientMarker>,
13952                >,
13953                fidl::encoding::DefaultFuchsiaResourceDialect,
13954                &mut self.gatt_client,
13955                decoder,
13956                offset + 32,
13957                _depth
13958            )?;
13959            Ok(())
13960        }
13961    }
13962
13963    impl fidl::encoding::ResourceTypeMarker for CentralConnectRequest {
13964        type Borrowed<'a> = &'a mut Self;
13965        fn take_or_borrow<'a>(
13966            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13967        ) -> Self::Borrowed<'a> {
13968            value
13969        }
13970    }
13971
13972    unsafe impl fidl::encoding::TypeMarker for CentralConnectRequest {
13973        type Owned = Self;
13974
13975        #[inline(always)]
13976        fn inline_align(_context: fidl::encoding::Context) -> usize {
13977            8
13978        }
13979
13980        #[inline(always)]
13981        fn inline_size(_context: fidl::encoding::Context) -> usize {
13982            32
13983        }
13984    }
13985
13986    unsafe impl
13987        fidl::encoding::Encode<CentralConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
13988        for &mut CentralConnectRequest
13989    {
13990        #[inline]
13991        unsafe fn encode(
13992            self,
13993            encoder: &mut fidl::encoding::Encoder<
13994                '_,
13995                fidl::encoding::DefaultFuchsiaResourceDialect,
13996            >,
13997            offset: usize,
13998            _depth: fidl::encoding::Depth,
13999        ) -> fidl::Result<()> {
14000            encoder.debug_check_bounds::<CentralConnectRequest>(offset);
14001            // Delegate to tuple encoding.
14002            fidl::encoding::Encode::<CentralConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
14003                (
14004                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
14005                    <ConnectionOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
14006                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handle),
14007                ),
14008                encoder, offset, _depth
14009            )
14010        }
14011    }
14012    unsafe impl<
14013        T0: fidl::encoding::Encode<
14014                fidl_fuchsia_bluetooth::PeerId,
14015                fidl::encoding::DefaultFuchsiaResourceDialect,
14016            >,
14017        T1: fidl::encoding::Encode<ConnectionOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
14018        T2: fidl::encoding::Encode<
14019                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
14020                fidl::encoding::DefaultFuchsiaResourceDialect,
14021            >,
14022    >
14023        fidl::encoding::Encode<CentralConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
14024        for (T0, T1, T2)
14025    {
14026        #[inline]
14027        unsafe fn encode(
14028            self,
14029            encoder: &mut fidl::encoding::Encoder<
14030                '_,
14031                fidl::encoding::DefaultFuchsiaResourceDialect,
14032            >,
14033            offset: usize,
14034            depth: fidl::encoding::Depth,
14035        ) -> fidl::Result<()> {
14036            encoder.debug_check_bounds::<CentralConnectRequest>(offset);
14037            // Zero out padding regions. There's no need to apply masks
14038            // because the unmasked parts will be overwritten by fields.
14039            unsafe {
14040                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
14041                (ptr as *mut u64).write_unaligned(0);
14042            }
14043            // Write the fields.
14044            self.0.encode(encoder, offset + 0, depth)?;
14045            self.1.encode(encoder, offset + 8, depth)?;
14046            self.2.encode(encoder, offset + 24, depth)?;
14047            Ok(())
14048        }
14049    }
14050
14051    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14052        for CentralConnectRequest
14053    {
14054        #[inline(always)]
14055        fn new_empty() -> Self {
14056            Self {
14057                id: fidl::new_empty!(
14058                    fidl_fuchsia_bluetooth::PeerId,
14059                    fidl::encoding::DefaultFuchsiaResourceDialect
14060                ),
14061                options: fidl::new_empty!(
14062                    ConnectionOptions,
14063                    fidl::encoding::DefaultFuchsiaResourceDialect
14064                ),
14065                handle: fidl::new_empty!(
14066                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
14067                    fidl::encoding::DefaultFuchsiaResourceDialect
14068                ),
14069            }
14070        }
14071
14072        #[inline]
14073        unsafe fn decode(
14074            &mut self,
14075            decoder: &mut fidl::encoding::Decoder<
14076                '_,
14077                fidl::encoding::DefaultFuchsiaResourceDialect,
14078            >,
14079            offset: usize,
14080            _depth: fidl::encoding::Depth,
14081        ) -> fidl::Result<()> {
14082            decoder.debug_check_bounds::<Self>(offset);
14083            // Verify that padding bytes are zero.
14084            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
14085            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14086            let mask = 0xffffffff00000000u64;
14087            let maskedval = padval & mask;
14088            if maskedval != 0 {
14089                return Err(fidl::Error::NonZeroPadding {
14090                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
14091                });
14092            }
14093            fidl::decode!(
14094                fidl_fuchsia_bluetooth::PeerId,
14095                fidl::encoding::DefaultFuchsiaResourceDialect,
14096                &mut self.id,
14097                decoder,
14098                offset + 0,
14099                _depth
14100            )?;
14101            fidl::decode!(
14102                ConnectionOptions,
14103                fidl::encoding::DefaultFuchsiaResourceDialect,
14104                &mut self.options,
14105                decoder,
14106                offset + 8,
14107                _depth
14108            )?;
14109            fidl::decode!(
14110                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ConnectionMarker>>,
14111                fidl::encoding::DefaultFuchsiaResourceDialect,
14112                &mut self.handle,
14113                decoder,
14114                offset + 24,
14115                _depth
14116            )?;
14117            Ok(())
14118        }
14119    }
14120
14121    impl fidl::encoding::ResourceTypeMarker for CentralScanRequest {
14122        type Borrowed<'a> = &'a mut Self;
14123        fn take_or_borrow<'a>(
14124            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14125        ) -> Self::Borrowed<'a> {
14126            value
14127        }
14128    }
14129
14130    unsafe impl fidl::encoding::TypeMarker for CentralScanRequest {
14131        type Owned = Self;
14132
14133        #[inline(always)]
14134        fn inline_align(_context: fidl::encoding::Context) -> usize {
14135            8
14136        }
14137
14138        #[inline(always)]
14139        fn inline_size(_context: fidl::encoding::Context) -> usize {
14140            24
14141        }
14142    }
14143
14144    unsafe impl
14145        fidl::encoding::Encode<CentralScanRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
14146        for &mut CentralScanRequest
14147    {
14148        #[inline]
14149        unsafe fn encode(
14150            self,
14151            encoder: &mut fidl::encoding::Encoder<
14152                '_,
14153                fidl::encoding::DefaultFuchsiaResourceDialect,
14154            >,
14155            offset: usize,
14156            _depth: fidl::encoding::Depth,
14157        ) -> fidl::Result<()> {
14158            encoder.debug_check_bounds::<CentralScanRequest>(offset);
14159            // Delegate to tuple encoding.
14160            fidl::encoding::Encode::<CentralScanRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
14161                (
14162                    <ScanOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
14163                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.result_watcher),
14164                ),
14165                encoder, offset, _depth
14166            )
14167        }
14168    }
14169    unsafe impl<
14170        T0: fidl::encoding::Encode<ScanOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
14171        T1: fidl::encoding::Encode<
14172                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>>,
14173                fidl::encoding::DefaultFuchsiaResourceDialect,
14174            >,
14175    > fidl::encoding::Encode<CentralScanRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
14176        for (T0, T1)
14177    {
14178        #[inline]
14179        unsafe fn encode(
14180            self,
14181            encoder: &mut fidl::encoding::Encoder<
14182                '_,
14183                fidl::encoding::DefaultFuchsiaResourceDialect,
14184            >,
14185            offset: usize,
14186            depth: fidl::encoding::Depth,
14187        ) -> fidl::Result<()> {
14188            encoder.debug_check_bounds::<CentralScanRequest>(offset);
14189            // Zero out padding regions. There's no need to apply masks
14190            // because the unmasked parts will be overwritten by fields.
14191            unsafe {
14192                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
14193                (ptr as *mut u64).write_unaligned(0);
14194            }
14195            // Write the fields.
14196            self.0.encode(encoder, offset + 0, depth)?;
14197            self.1.encode(encoder, offset + 16, depth)?;
14198            Ok(())
14199        }
14200    }
14201
14202    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14203        for CentralScanRequest
14204    {
14205        #[inline(always)]
14206        fn new_empty() -> Self {
14207            Self {
14208                options: fidl::new_empty!(
14209                    ScanOptions,
14210                    fidl::encoding::DefaultFuchsiaResourceDialect
14211                ),
14212                result_watcher: fidl::new_empty!(
14213                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>>,
14214                    fidl::encoding::DefaultFuchsiaResourceDialect
14215                ),
14216            }
14217        }
14218
14219        #[inline]
14220        unsafe fn decode(
14221            &mut self,
14222            decoder: &mut fidl::encoding::Decoder<
14223                '_,
14224                fidl::encoding::DefaultFuchsiaResourceDialect,
14225            >,
14226            offset: usize,
14227            _depth: fidl::encoding::Depth,
14228        ) -> fidl::Result<()> {
14229            decoder.debug_check_bounds::<Self>(offset);
14230            // Verify that padding bytes are zero.
14231            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
14232            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14233            let mask = 0xffffffff00000000u64;
14234            let maskedval = padval & mask;
14235            if maskedval != 0 {
14236                return Err(fidl::Error::NonZeroPadding {
14237                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
14238                });
14239            }
14240            fidl::decode!(
14241                ScanOptions,
14242                fidl::encoding::DefaultFuchsiaResourceDialect,
14243                &mut self.options,
14244                decoder,
14245                offset + 0,
14246                _depth
14247            )?;
14248            fidl::decode!(
14249                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ScanResultWatcherMarker>>,
14250                fidl::encoding::DefaultFuchsiaResourceDialect,
14251                &mut self.result_watcher,
14252                decoder,
14253                offset + 16,
14254                _depth
14255            )?;
14256            Ok(())
14257        }
14258    }
14259
14260    impl fidl::encoding::ResourceTypeMarker for ChannelListenerAcceptRequest {
14261        type Borrowed<'a> = &'a mut Self;
14262        fn take_or_borrow<'a>(
14263            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14264        ) -> Self::Borrowed<'a> {
14265            value
14266        }
14267    }
14268
14269    unsafe impl fidl::encoding::TypeMarker for ChannelListenerAcceptRequest {
14270        type Owned = Self;
14271
14272        #[inline(always)]
14273        fn inline_align(_context: fidl::encoding::Context) -> usize {
14274            4
14275        }
14276
14277        #[inline(always)]
14278        fn inline_size(_context: fidl::encoding::Context) -> usize {
14279            4
14280        }
14281    }
14282
14283    unsafe impl
14284        fidl::encoding::Encode<
14285            ChannelListenerAcceptRequest,
14286            fidl::encoding::DefaultFuchsiaResourceDialect,
14287        > for &mut ChannelListenerAcceptRequest
14288    {
14289        #[inline]
14290        unsafe fn encode(
14291            self,
14292            encoder: &mut fidl::encoding::Encoder<
14293                '_,
14294                fidl::encoding::DefaultFuchsiaResourceDialect,
14295            >,
14296            offset: usize,
14297            _depth: fidl::encoding::Depth,
14298        ) -> fidl::Result<()> {
14299            encoder.debug_check_bounds::<ChannelListenerAcceptRequest>(offset);
14300            // Delegate to tuple encoding.
14301            fidl::encoding::Encode::<
14302                ChannelListenerAcceptRequest,
14303                fidl::encoding::DefaultFuchsiaResourceDialect,
14304            >::encode(
14305                (<fidl::encoding::Endpoint<
14306                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14307                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14308                    &mut self.channel
14309                ),),
14310                encoder,
14311                offset,
14312                _depth,
14313            )
14314        }
14315    }
14316    unsafe impl<
14317        T0: fidl::encoding::Encode<
14318                fidl::encoding::Endpoint<
14319                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14320                >,
14321                fidl::encoding::DefaultFuchsiaResourceDialect,
14322            >,
14323    >
14324        fidl::encoding::Encode<
14325            ChannelListenerAcceptRequest,
14326            fidl::encoding::DefaultFuchsiaResourceDialect,
14327        > for (T0,)
14328    {
14329        #[inline]
14330        unsafe fn encode(
14331            self,
14332            encoder: &mut fidl::encoding::Encoder<
14333                '_,
14334                fidl::encoding::DefaultFuchsiaResourceDialect,
14335            >,
14336            offset: usize,
14337            depth: fidl::encoding::Depth,
14338        ) -> fidl::Result<()> {
14339            encoder.debug_check_bounds::<ChannelListenerAcceptRequest>(offset);
14340            // Zero out padding regions. There's no need to apply masks
14341            // because the unmasked parts will be overwritten by fields.
14342            // Write the fields.
14343            self.0.encode(encoder, offset + 0, depth)?;
14344            Ok(())
14345        }
14346    }
14347
14348    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14349        for ChannelListenerAcceptRequest
14350    {
14351        #[inline(always)]
14352        fn new_empty() -> Self {
14353            Self {
14354                channel: fidl::new_empty!(
14355                    fidl::encoding::Endpoint<
14356                        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14357                    >,
14358                    fidl::encoding::DefaultFuchsiaResourceDialect
14359                ),
14360            }
14361        }
14362
14363        #[inline]
14364        unsafe fn decode(
14365            &mut self,
14366            decoder: &mut fidl::encoding::Decoder<
14367                '_,
14368                fidl::encoding::DefaultFuchsiaResourceDialect,
14369            >,
14370            offset: usize,
14371            _depth: fidl::encoding::Depth,
14372        ) -> fidl::Result<()> {
14373            decoder.debug_check_bounds::<Self>(offset);
14374            // Verify that padding bytes are zero.
14375            fidl::decode!(
14376                fidl::encoding::Endpoint<
14377                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
14378                >,
14379                fidl::encoding::DefaultFuchsiaResourceDialect,
14380                &mut self.channel,
14381                decoder,
14382                offset + 0,
14383                _depth
14384            )?;
14385            Ok(())
14386        }
14387    }
14388
14389    impl fidl::encoding::ResourceTypeMarker for ConnectionRequestGattClientRequest {
14390        type Borrowed<'a> = &'a mut Self;
14391        fn take_or_borrow<'a>(
14392            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14393        ) -> Self::Borrowed<'a> {
14394            value
14395        }
14396    }
14397
14398    unsafe impl fidl::encoding::TypeMarker for ConnectionRequestGattClientRequest {
14399        type Owned = Self;
14400
14401        #[inline(always)]
14402        fn inline_align(_context: fidl::encoding::Context) -> usize {
14403            4
14404        }
14405
14406        #[inline(always)]
14407        fn inline_size(_context: fidl::encoding::Context) -> usize {
14408            4
14409        }
14410    }
14411
14412    unsafe impl
14413        fidl::encoding::Encode<
14414            ConnectionRequestGattClientRequest,
14415            fidl::encoding::DefaultFuchsiaResourceDialect,
14416        > for &mut ConnectionRequestGattClientRequest
14417    {
14418        #[inline]
14419        unsafe fn encode(
14420            self,
14421            encoder: &mut fidl::encoding::Encoder<
14422                '_,
14423                fidl::encoding::DefaultFuchsiaResourceDialect,
14424            >,
14425            offset: usize,
14426            _depth: fidl::encoding::Depth,
14427        ) -> fidl::Result<()> {
14428            encoder.debug_check_bounds::<ConnectionRequestGattClientRequest>(offset);
14429            // Delegate to tuple encoding.
14430            fidl::encoding::Encode::<
14431                ConnectionRequestGattClientRequest,
14432                fidl::encoding::DefaultFuchsiaResourceDialect,
14433            >::encode(
14434                (<fidl::encoding::Endpoint<
14435                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
14436                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14437                    &mut self.client
14438                ),),
14439                encoder,
14440                offset,
14441                _depth,
14442            )
14443        }
14444    }
14445    unsafe impl<
14446        T0: fidl::encoding::Encode<
14447                fidl::encoding::Endpoint<
14448                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
14449                >,
14450                fidl::encoding::DefaultFuchsiaResourceDialect,
14451            >,
14452    >
14453        fidl::encoding::Encode<
14454            ConnectionRequestGattClientRequest,
14455            fidl::encoding::DefaultFuchsiaResourceDialect,
14456        > for (T0,)
14457    {
14458        #[inline]
14459        unsafe fn encode(
14460            self,
14461            encoder: &mut fidl::encoding::Encoder<
14462                '_,
14463                fidl::encoding::DefaultFuchsiaResourceDialect,
14464            >,
14465            offset: usize,
14466            depth: fidl::encoding::Depth,
14467        ) -> fidl::Result<()> {
14468            encoder.debug_check_bounds::<ConnectionRequestGattClientRequest>(offset);
14469            // Zero out padding regions. There's no need to apply masks
14470            // because the unmasked parts will be overwritten by fields.
14471            // Write the fields.
14472            self.0.encode(encoder, offset + 0, depth)?;
14473            Ok(())
14474        }
14475    }
14476
14477    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14478        for ConnectionRequestGattClientRequest
14479    {
14480        #[inline(always)]
14481        fn new_empty() -> Self {
14482            Self {
14483                client: fidl::new_empty!(
14484                    fidl::encoding::Endpoint<
14485                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
14486                    >,
14487                    fidl::encoding::DefaultFuchsiaResourceDialect
14488                ),
14489            }
14490        }
14491
14492        #[inline]
14493        unsafe fn decode(
14494            &mut self,
14495            decoder: &mut fidl::encoding::Decoder<
14496                '_,
14497                fidl::encoding::DefaultFuchsiaResourceDialect,
14498            >,
14499            offset: usize,
14500            _depth: fidl::encoding::Depth,
14501        ) -> fidl::Result<()> {
14502            decoder.debug_check_bounds::<Self>(offset);
14503            // Verify that padding bytes are zero.
14504            fidl::decode!(
14505                fidl::encoding::Endpoint<
14506                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth_gatt2::ClientMarker>,
14507                >,
14508                fidl::encoding::DefaultFuchsiaResourceDialect,
14509                &mut self.client,
14510                decoder,
14511                offset + 0,
14512                _depth
14513            )?;
14514            Ok(())
14515        }
14516    }
14517
14518    impl fidl::encoding::ResourceTypeMarker for PeripheralAdvertiseRequest {
14519        type Borrowed<'a> = &'a mut Self;
14520        fn take_or_borrow<'a>(
14521            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14522        ) -> Self::Borrowed<'a> {
14523            value
14524        }
14525    }
14526
14527    unsafe impl fidl::encoding::TypeMarker for PeripheralAdvertiseRequest {
14528        type Owned = Self;
14529
14530        #[inline(always)]
14531        fn inline_align(_context: fidl::encoding::Context) -> usize {
14532            8
14533        }
14534
14535        #[inline(always)]
14536        fn inline_size(_context: fidl::encoding::Context) -> usize {
14537            24
14538        }
14539    }
14540
14541    unsafe impl
14542        fidl::encoding::Encode<
14543            PeripheralAdvertiseRequest,
14544            fidl::encoding::DefaultFuchsiaResourceDialect,
14545        > for &mut PeripheralAdvertiseRequest
14546    {
14547        #[inline]
14548        unsafe fn encode(
14549            self,
14550            encoder: &mut fidl::encoding::Encoder<
14551                '_,
14552                fidl::encoding::DefaultFuchsiaResourceDialect,
14553            >,
14554            offset: usize,
14555            _depth: fidl::encoding::Depth,
14556        ) -> fidl::Result<()> {
14557            encoder.debug_check_bounds::<PeripheralAdvertiseRequest>(offset);
14558            // Delegate to tuple encoding.
14559            fidl::encoding::Encode::<
14560                PeripheralAdvertiseRequest,
14561                fidl::encoding::DefaultFuchsiaResourceDialect,
14562            >::encode(
14563                (
14564                    <AdvertisingParameters as fidl::encoding::ValueTypeMarker>::borrow(
14565                        &self.parameters,
14566                    ),
14567                    <fidl::encoding::Endpoint<
14568                        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
14569                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
14570                        &mut self.advertised_peripheral,
14571                    ),
14572                ),
14573                encoder,
14574                offset,
14575                _depth,
14576            )
14577        }
14578    }
14579    unsafe impl<
14580        T0: fidl::encoding::Encode<
14581                AdvertisingParameters,
14582                fidl::encoding::DefaultFuchsiaResourceDialect,
14583            >,
14584        T1: fidl::encoding::Encode<
14585                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>>,
14586                fidl::encoding::DefaultFuchsiaResourceDialect,
14587            >,
14588    >
14589        fidl::encoding::Encode<
14590            PeripheralAdvertiseRequest,
14591            fidl::encoding::DefaultFuchsiaResourceDialect,
14592        > for (T0, T1)
14593    {
14594        #[inline]
14595        unsafe fn encode(
14596            self,
14597            encoder: &mut fidl::encoding::Encoder<
14598                '_,
14599                fidl::encoding::DefaultFuchsiaResourceDialect,
14600            >,
14601            offset: usize,
14602            depth: fidl::encoding::Depth,
14603        ) -> fidl::Result<()> {
14604            encoder.debug_check_bounds::<PeripheralAdvertiseRequest>(offset);
14605            // Zero out padding regions. There's no need to apply masks
14606            // because the unmasked parts will be overwritten by fields.
14607            unsafe {
14608                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
14609                (ptr as *mut u64).write_unaligned(0);
14610            }
14611            // Write the fields.
14612            self.0.encode(encoder, offset + 0, depth)?;
14613            self.1.encode(encoder, offset + 16, depth)?;
14614            Ok(())
14615        }
14616    }
14617
14618    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14619        for PeripheralAdvertiseRequest
14620    {
14621        #[inline(always)]
14622        fn new_empty() -> Self {
14623            Self {
14624                parameters: fidl::new_empty!(
14625                    AdvertisingParameters,
14626                    fidl::encoding::DefaultFuchsiaResourceDialect
14627                ),
14628                advertised_peripheral: fidl::new_empty!(
14629                    fidl::encoding::Endpoint<
14630                        fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>,
14631                    >,
14632                    fidl::encoding::DefaultFuchsiaResourceDialect
14633                ),
14634            }
14635        }
14636
14637        #[inline]
14638        unsafe fn decode(
14639            &mut self,
14640            decoder: &mut fidl::encoding::Decoder<
14641                '_,
14642                fidl::encoding::DefaultFuchsiaResourceDialect,
14643            >,
14644            offset: usize,
14645            _depth: fidl::encoding::Depth,
14646        ) -> fidl::Result<()> {
14647            decoder.debug_check_bounds::<Self>(offset);
14648            // Verify that padding bytes are zero.
14649            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
14650            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14651            let mask = 0xffffffff00000000u64;
14652            let maskedval = padval & mask;
14653            if maskedval != 0 {
14654                return Err(fidl::Error::NonZeroPadding {
14655                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
14656                });
14657            }
14658            fidl::decode!(
14659                AdvertisingParameters,
14660                fidl::encoding::DefaultFuchsiaResourceDialect,
14661                &mut self.parameters,
14662                decoder,
14663                offset + 0,
14664                _depth
14665            )?;
14666            fidl::decode!(
14667                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AdvertisedPeripheralMarker>>,
14668                fidl::encoding::DefaultFuchsiaResourceDialect,
14669                &mut self.advertised_peripheral,
14670                decoder,
14671                offset + 16,
14672                _depth
14673            )?;
14674            Ok(())
14675        }
14676    }
14677
14678    impl fidl::encoding::ResourceTypeMarker for PeripheralOnPeerConnectedRequest {
14679        type Borrowed<'a> = &'a mut Self;
14680        fn take_or_borrow<'a>(
14681            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14682        ) -> Self::Borrowed<'a> {
14683            value
14684        }
14685    }
14686
14687    unsafe impl fidl::encoding::TypeMarker for PeripheralOnPeerConnectedRequest {
14688        type Owned = Self;
14689
14690        #[inline(always)]
14691        fn inline_align(_context: fidl::encoding::Context) -> usize {
14692            8
14693        }
14694
14695        #[inline(always)]
14696        fn inline_size(_context: fidl::encoding::Context) -> usize {
14697            24
14698        }
14699    }
14700
14701    unsafe impl
14702        fidl::encoding::Encode<
14703            PeripheralOnPeerConnectedRequest,
14704            fidl::encoding::DefaultFuchsiaResourceDialect,
14705        > for &mut PeripheralOnPeerConnectedRequest
14706    {
14707        #[inline]
14708        unsafe fn encode(
14709            self,
14710            encoder: &mut fidl::encoding::Encoder<
14711                '_,
14712                fidl::encoding::DefaultFuchsiaResourceDialect,
14713            >,
14714            offset: usize,
14715            _depth: fidl::encoding::Depth,
14716        ) -> fidl::Result<()> {
14717            encoder.debug_check_bounds::<PeripheralOnPeerConnectedRequest>(offset);
14718            // Delegate to tuple encoding.
14719            fidl::encoding::Encode::<PeripheralOnPeerConnectedRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
14720                (
14721                    <Peer as fidl::encoding::ValueTypeMarker>::borrow(&self.peer),
14722                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.connection),
14723                ),
14724                encoder, offset, _depth
14725            )
14726        }
14727    }
14728    unsafe impl<
14729        T0: fidl::encoding::Encode<Peer, fidl::encoding::DefaultFuchsiaResourceDialect>,
14730        T1: fidl::encoding::Encode<
14731                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
14732                fidl::encoding::DefaultFuchsiaResourceDialect,
14733            >,
14734    >
14735        fidl::encoding::Encode<
14736            PeripheralOnPeerConnectedRequest,
14737            fidl::encoding::DefaultFuchsiaResourceDialect,
14738        > for (T0, T1)
14739    {
14740        #[inline]
14741        unsafe fn encode(
14742            self,
14743            encoder: &mut fidl::encoding::Encoder<
14744                '_,
14745                fidl::encoding::DefaultFuchsiaResourceDialect,
14746            >,
14747            offset: usize,
14748            depth: fidl::encoding::Depth,
14749        ) -> fidl::Result<()> {
14750            encoder.debug_check_bounds::<PeripheralOnPeerConnectedRequest>(offset);
14751            // Zero out padding regions. There's no need to apply masks
14752            // because the unmasked parts will be overwritten by fields.
14753            unsafe {
14754                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
14755                (ptr as *mut u64).write_unaligned(0);
14756            }
14757            // Write the fields.
14758            self.0.encode(encoder, offset + 0, depth)?;
14759            self.1.encode(encoder, offset + 16, depth)?;
14760            Ok(())
14761        }
14762    }
14763
14764    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14765        for PeripheralOnPeerConnectedRequest
14766    {
14767        #[inline(always)]
14768        fn new_empty() -> Self {
14769            Self {
14770                peer: fidl::new_empty!(Peer, fidl::encoding::DefaultFuchsiaResourceDialect),
14771                connection: fidl::new_empty!(
14772                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
14773                    fidl::encoding::DefaultFuchsiaResourceDialect
14774                ),
14775            }
14776        }
14777
14778        #[inline]
14779        unsafe fn decode(
14780            &mut self,
14781            decoder: &mut fidl::encoding::Decoder<
14782                '_,
14783                fidl::encoding::DefaultFuchsiaResourceDialect,
14784            >,
14785            offset: usize,
14786            _depth: fidl::encoding::Depth,
14787        ) -> fidl::Result<()> {
14788            decoder.debug_check_bounds::<Self>(offset);
14789            // Verify that padding bytes are zero.
14790            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
14791            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14792            let mask = 0xffffffff00000000u64;
14793            let maskedval = padval & mask;
14794            if maskedval != 0 {
14795                return Err(fidl::Error::NonZeroPadding {
14796                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
14797                });
14798            }
14799            fidl::decode!(
14800                Peer,
14801                fidl::encoding::DefaultFuchsiaResourceDialect,
14802                &mut self.peer,
14803                decoder,
14804                offset + 0,
14805                _depth
14806            )?;
14807            fidl::decode!(
14808                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ConnectionMarker>>,
14809                fidl::encoding::DefaultFuchsiaResourceDialect,
14810                &mut self.connection,
14811                decoder,
14812                offset + 16,
14813                _depth
14814            )?;
14815            Ok(())
14816        }
14817    }
14818
14819    impl fidl::encoding::ResourceTypeMarker for PeripheralStartAdvertisingRequest {
14820        type Borrowed<'a> = &'a mut Self;
14821        fn take_or_borrow<'a>(
14822            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14823        ) -> Self::Borrowed<'a> {
14824            value
14825        }
14826    }
14827
14828    unsafe impl fidl::encoding::TypeMarker for PeripheralStartAdvertisingRequest {
14829        type Owned = Self;
14830
14831        #[inline(always)]
14832        fn inline_align(_context: fidl::encoding::Context) -> usize {
14833            8
14834        }
14835
14836        #[inline(always)]
14837        fn inline_size(_context: fidl::encoding::Context) -> usize {
14838            24
14839        }
14840    }
14841
14842    unsafe impl
14843        fidl::encoding::Encode<
14844            PeripheralStartAdvertisingRequest,
14845            fidl::encoding::DefaultFuchsiaResourceDialect,
14846        > for &mut PeripheralStartAdvertisingRequest
14847    {
14848        #[inline]
14849        unsafe fn encode(
14850            self,
14851            encoder: &mut fidl::encoding::Encoder<
14852                '_,
14853                fidl::encoding::DefaultFuchsiaResourceDialect,
14854            >,
14855            offset: usize,
14856            _depth: fidl::encoding::Depth,
14857        ) -> fidl::Result<()> {
14858            encoder.debug_check_bounds::<PeripheralStartAdvertisingRequest>(offset);
14859            // Delegate to tuple encoding.
14860            fidl::encoding::Encode::<PeripheralStartAdvertisingRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
14861                (
14862                    <AdvertisingParameters as fidl::encoding::ValueTypeMarker>::borrow(&self.parameters),
14863                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.handle),
14864                ),
14865                encoder, offset, _depth
14866            )
14867        }
14868    }
14869    unsafe impl<
14870        T0: fidl::encoding::Encode<
14871                AdvertisingParameters,
14872                fidl::encoding::DefaultFuchsiaResourceDialect,
14873            >,
14874        T1: fidl::encoding::Encode<
14875                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>>,
14876                fidl::encoding::DefaultFuchsiaResourceDialect,
14877            >,
14878    >
14879        fidl::encoding::Encode<
14880            PeripheralStartAdvertisingRequest,
14881            fidl::encoding::DefaultFuchsiaResourceDialect,
14882        > for (T0, T1)
14883    {
14884        #[inline]
14885        unsafe fn encode(
14886            self,
14887            encoder: &mut fidl::encoding::Encoder<
14888                '_,
14889                fidl::encoding::DefaultFuchsiaResourceDialect,
14890            >,
14891            offset: usize,
14892            depth: fidl::encoding::Depth,
14893        ) -> fidl::Result<()> {
14894            encoder.debug_check_bounds::<PeripheralStartAdvertisingRequest>(offset);
14895            // Zero out padding regions. There's no need to apply masks
14896            // because the unmasked parts will be overwritten by fields.
14897            unsafe {
14898                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
14899                (ptr as *mut u64).write_unaligned(0);
14900            }
14901            // Write the fields.
14902            self.0.encode(encoder, offset + 0, depth)?;
14903            self.1.encode(encoder, offset + 16, depth)?;
14904            Ok(())
14905        }
14906    }
14907
14908    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
14909        for PeripheralStartAdvertisingRequest
14910    {
14911        #[inline(always)]
14912        fn new_empty() -> Self {
14913            Self {
14914                parameters: fidl::new_empty!(
14915                    AdvertisingParameters,
14916                    fidl::encoding::DefaultFuchsiaResourceDialect
14917                ),
14918                handle: fidl::new_empty!(
14919                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>>,
14920                    fidl::encoding::DefaultFuchsiaResourceDialect
14921                ),
14922            }
14923        }
14924
14925        #[inline]
14926        unsafe fn decode(
14927            &mut self,
14928            decoder: &mut fidl::encoding::Decoder<
14929                '_,
14930                fidl::encoding::DefaultFuchsiaResourceDialect,
14931            >,
14932            offset: usize,
14933            _depth: fidl::encoding::Depth,
14934        ) -> fidl::Result<()> {
14935            decoder.debug_check_bounds::<Self>(offset);
14936            // Verify that padding bytes are zero.
14937            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
14938            let padval = unsafe { (ptr as *const u64).read_unaligned() };
14939            let mask = 0xffffffff00000000u64;
14940            let maskedval = padval & mask;
14941            if maskedval != 0 {
14942                return Err(fidl::Error::NonZeroPadding {
14943                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
14944                });
14945            }
14946            fidl::decode!(
14947                AdvertisingParameters,
14948                fidl::encoding::DefaultFuchsiaResourceDialect,
14949                &mut self.parameters,
14950                decoder,
14951                offset + 0,
14952                _depth
14953            )?;
14954            fidl::decode!(
14955                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AdvertisingHandleMarker>>,
14956                fidl::encoding::DefaultFuchsiaResourceDialect,
14957                &mut self.handle,
14958                decoder,
14959                offset + 16,
14960                _depth
14961            )?;
14962            Ok(())
14963        }
14964    }
14965
14966    impl CentralCreateConnectedIsochronousGroupRequest {
14967        #[inline(always)]
14968        fn max_ordinal_present(&self) -> u64 {
14969            if let Some(_) = self.cig {
14970                return 3;
14971            }
14972            if let Some(_) = self.cis_requested_parameters {
14973                return 2;
14974            }
14975            if let Some(_) = self.cig_parameters {
14976                return 1;
14977            }
14978            0
14979        }
14980    }
14981
14982    impl fidl::encoding::ResourceTypeMarker for CentralCreateConnectedIsochronousGroupRequest {
14983        type Borrowed<'a> = &'a mut Self;
14984        fn take_or_borrow<'a>(
14985            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14986        ) -> Self::Borrowed<'a> {
14987            value
14988        }
14989    }
14990
14991    unsafe impl fidl::encoding::TypeMarker for CentralCreateConnectedIsochronousGroupRequest {
14992        type Owned = Self;
14993
14994        #[inline(always)]
14995        fn inline_align(_context: fidl::encoding::Context) -> usize {
14996            8
14997        }
14998
14999        #[inline(always)]
15000        fn inline_size(_context: fidl::encoding::Context) -> usize {
15001            16
15002        }
15003    }
15004
15005    unsafe impl
15006        fidl::encoding::Encode<
15007            CentralCreateConnectedIsochronousGroupRequest,
15008            fidl::encoding::DefaultFuchsiaResourceDialect,
15009        > for &mut CentralCreateConnectedIsochronousGroupRequest
15010    {
15011        unsafe fn encode(
15012            self,
15013            encoder: &mut fidl::encoding::Encoder<
15014                '_,
15015                fidl::encoding::DefaultFuchsiaResourceDialect,
15016            >,
15017            offset: usize,
15018            mut depth: fidl::encoding::Depth,
15019        ) -> fidl::Result<()> {
15020            encoder.debug_check_bounds::<CentralCreateConnectedIsochronousGroupRequest>(offset);
15021            // Vector header
15022            let max_ordinal: u64 = self.max_ordinal_present();
15023            encoder.write_num(max_ordinal, offset);
15024            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
15025            // Calling encoder.out_of_line_offset(0) is not allowed.
15026            if max_ordinal == 0 {
15027                return Ok(());
15028            }
15029            depth.increment()?;
15030            let envelope_size = 8;
15031            let bytes_len = max_ordinal as usize * envelope_size;
15032            #[allow(unused_variables)]
15033            let offset = encoder.out_of_line_offset(bytes_len);
15034            let mut _prev_end_offset: usize = 0;
15035            if 1 > max_ordinal {
15036                return Ok(());
15037            }
15038
15039            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15040            // are envelope_size bytes.
15041            let cur_offset: usize = (1 - 1) * envelope_size;
15042
15043            // Zero reserved fields.
15044            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15045
15046            // Safety:
15047            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15048            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15049            //   envelope_size bytes, there is always sufficient room.
15050            fidl::encoding::encode_in_envelope_optional::<
15051                CigParameters,
15052                fidl::encoding::DefaultFuchsiaResourceDialect,
15053            >(
15054                self.cig_parameters
15055                    .as_ref()
15056                    .map(<CigParameters as fidl::encoding::ValueTypeMarker>::borrow),
15057                encoder,
15058                offset + cur_offset,
15059                depth,
15060            )?;
15061
15062            _prev_end_offset = cur_offset + envelope_size;
15063            if 2 > max_ordinal {
15064                return Ok(());
15065            }
15066
15067            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15068            // are envelope_size bytes.
15069            let cur_offset: usize = (2 - 1) * envelope_size;
15070
15071            // Zero reserved fields.
15072            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15073
15074            // Safety:
15075            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15076            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15077            //   envelope_size bytes, there is always sufficient room.
15078            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<CisRequestedParameters, 31>, fidl::encoding::DefaultFuchsiaResourceDialect>(
15079            self.cis_requested_parameters.as_mut().map(<fidl::encoding::Vector<CisRequestedParameters, 31> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
15080            encoder, offset + cur_offset, depth
15081        )?;
15082
15083            _prev_end_offset = cur_offset + envelope_size;
15084            if 3 > max_ordinal {
15085                return Ok(());
15086            }
15087
15088            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15089            // are envelope_size bytes.
15090            let cur_offset: usize = (3 - 1) * envelope_size;
15091
15092            // Zero reserved fields.
15093            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15094
15095            // Safety:
15096            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15097            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15098            //   envelope_size bytes, there is always sufficient room.
15099            fidl::encoding::encode_in_envelope_optional::<
15100                fidl::encoding::Endpoint<
15101                    fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
15102                >,
15103                fidl::encoding::DefaultFuchsiaResourceDialect,
15104            >(
15105                self.cig.as_mut().map(
15106                    <fidl::encoding::Endpoint<
15107                        fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
15108                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
15109                ),
15110                encoder,
15111                offset + cur_offset,
15112                depth,
15113            )?;
15114
15115            _prev_end_offset = cur_offset + envelope_size;
15116
15117            Ok(())
15118        }
15119    }
15120
15121    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
15122        for CentralCreateConnectedIsochronousGroupRequest
15123    {
15124        #[inline(always)]
15125        fn new_empty() -> Self {
15126            Self::default()
15127        }
15128
15129        unsafe fn decode(
15130            &mut self,
15131            decoder: &mut fidl::encoding::Decoder<
15132                '_,
15133                fidl::encoding::DefaultFuchsiaResourceDialect,
15134            >,
15135            offset: usize,
15136            mut depth: fidl::encoding::Depth,
15137        ) -> fidl::Result<()> {
15138            decoder.debug_check_bounds::<Self>(offset);
15139            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
15140                None => return Err(fidl::Error::NotNullable),
15141                Some(len) => len,
15142            };
15143            // Calling decoder.out_of_line_offset(0) is not allowed.
15144            if len == 0 {
15145                return Ok(());
15146            };
15147            depth.increment()?;
15148            let envelope_size = 8;
15149            let bytes_len = len * envelope_size;
15150            let offset = decoder.out_of_line_offset(bytes_len)?;
15151            // Decode the envelope for each type.
15152            let mut _next_ordinal_to_read = 0;
15153            let mut next_offset = offset;
15154            let end_offset = offset + bytes_len;
15155            _next_ordinal_to_read += 1;
15156            if next_offset >= end_offset {
15157                return Ok(());
15158            }
15159
15160            // Decode unknown envelopes for gaps in ordinals.
15161            while _next_ordinal_to_read < 1 {
15162                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15163                _next_ordinal_to_read += 1;
15164                next_offset += envelope_size;
15165            }
15166
15167            let next_out_of_line = decoder.next_out_of_line();
15168            let handles_before = decoder.remaining_handles();
15169            if let Some((inlined, num_bytes, num_handles)) =
15170                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15171            {
15172                let member_inline_size =
15173                    <CigParameters as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15174                if inlined != (member_inline_size <= 4) {
15175                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15176                }
15177                let inner_offset;
15178                let mut inner_depth = depth.clone();
15179                if inlined {
15180                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15181                    inner_offset = next_offset;
15182                } else {
15183                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15184                    inner_depth.increment()?;
15185                }
15186                let val_ref = self.cig_parameters.get_or_insert_with(|| {
15187                    fidl::new_empty!(CigParameters, fidl::encoding::DefaultFuchsiaResourceDialect)
15188                });
15189                fidl::decode!(
15190                    CigParameters,
15191                    fidl::encoding::DefaultFuchsiaResourceDialect,
15192                    val_ref,
15193                    decoder,
15194                    inner_offset,
15195                    inner_depth
15196                )?;
15197                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15198                {
15199                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15200                }
15201                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15202                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15203                }
15204            }
15205
15206            next_offset += envelope_size;
15207            _next_ordinal_to_read += 1;
15208            if next_offset >= end_offset {
15209                return Ok(());
15210            }
15211
15212            // Decode unknown envelopes for gaps in ordinals.
15213            while _next_ordinal_to_read < 2 {
15214                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15215                _next_ordinal_to_read += 1;
15216                next_offset += envelope_size;
15217            }
15218
15219            let next_out_of_line = decoder.next_out_of_line();
15220            let handles_before = decoder.remaining_handles();
15221            if let Some((inlined, num_bytes, num_handles)) =
15222                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15223            {
15224                let member_inline_size = <fidl::encoding::Vector<CisRequestedParameters, 31> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15225                if inlined != (member_inline_size <= 4) {
15226                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15227                }
15228                let inner_offset;
15229                let mut inner_depth = depth.clone();
15230                if inlined {
15231                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15232                    inner_offset = next_offset;
15233                } else {
15234                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15235                    inner_depth.increment()?;
15236                }
15237                let val_ref =
15238                self.cis_requested_parameters.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<CisRequestedParameters, 31>, fidl::encoding::DefaultFuchsiaResourceDialect));
15239                fidl::decode!(fidl::encoding::Vector<CisRequestedParameters, 31>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
15240                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15241                {
15242                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15243                }
15244                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15245                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15246                }
15247            }
15248
15249            next_offset += envelope_size;
15250            _next_ordinal_to_read += 1;
15251            if next_offset >= end_offset {
15252                return Ok(());
15253            }
15254
15255            // Decode unknown envelopes for gaps in ordinals.
15256            while _next_ordinal_to_read < 3 {
15257                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15258                _next_ordinal_to_read += 1;
15259                next_offset += envelope_size;
15260            }
15261
15262            let next_out_of_line = decoder.next_out_of_line();
15263            let handles_before = decoder.remaining_handles();
15264            if let Some((inlined, num_bytes, num_handles)) =
15265                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15266            {
15267                let member_inline_size = <fidl::encoding::Endpoint<
15268                    fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
15269                > as fidl::encoding::TypeMarker>::inline_size(
15270                    decoder.context
15271                );
15272                if inlined != (member_inline_size <= 4) {
15273                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15274                }
15275                let inner_offset;
15276                let mut inner_depth = depth.clone();
15277                if inlined {
15278                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15279                    inner_offset = next_offset;
15280                } else {
15281                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15282                    inner_depth.increment()?;
15283                }
15284                let val_ref = self.cig.get_or_insert_with(|| {
15285                    fidl::new_empty!(
15286                        fidl::encoding::Endpoint<
15287                            fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
15288                        >,
15289                        fidl::encoding::DefaultFuchsiaResourceDialect
15290                    )
15291                });
15292                fidl::decode!(
15293                    fidl::encoding::Endpoint<
15294                        fidl::endpoints::ServerEnd<ConnectedIsochronousGroupMarker>,
15295                    >,
15296                    fidl::encoding::DefaultFuchsiaResourceDialect,
15297                    val_ref,
15298                    decoder,
15299                    inner_offset,
15300                    inner_depth
15301                )?;
15302                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15303                {
15304                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15305                }
15306                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15307                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15308                }
15309            }
15310
15311            next_offset += envelope_size;
15312
15313            // Decode the remaining unknown envelopes.
15314            while next_offset < end_offset {
15315                _next_ordinal_to_read += 1;
15316                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15317                next_offset += envelope_size;
15318            }
15319
15320            Ok(())
15321        }
15322    }
15323
15324    impl CentralSyncToPeriodicAdvertisingRequest {
15325        #[inline(always)]
15326        fn max_ordinal_present(&self) -> u64 {
15327            if let Some(_) = self.config {
15328                return 4;
15329            }
15330            if let Some(_) = self.sync {
15331                return 3;
15332            }
15333            if let Some(_) = self.advertising_sid {
15334                return 2;
15335            }
15336            if let Some(_) = self.peer_id {
15337                return 1;
15338            }
15339            0
15340        }
15341    }
15342
15343    impl fidl::encoding::ResourceTypeMarker for CentralSyncToPeriodicAdvertisingRequest {
15344        type Borrowed<'a> = &'a mut Self;
15345        fn take_or_borrow<'a>(
15346            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
15347        ) -> Self::Borrowed<'a> {
15348            value
15349        }
15350    }
15351
15352    unsafe impl fidl::encoding::TypeMarker for CentralSyncToPeriodicAdvertisingRequest {
15353        type Owned = Self;
15354
15355        #[inline(always)]
15356        fn inline_align(_context: fidl::encoding::Context) -> usize {
15357            8
15358        }
15359
15360        #[inline(always)]
15361        fn inline_size(_context: fidl::encoding::Context) -> usize {
15362            16
15363        }
15364    }
15365
15366    unsafe impl
15367        fidl::encoding::Encode<
15368            CentralSyncToPeriodicAdvertisingRequest,
15369            fidl::encoding::DefaultFuchsiaResourceDialect,
15370        > for &mut CentralSyncToPeriodicAdvertisingRequest
15371    {
15372        unsafe fn encode(
15373            self,
15374            encoder: &mut fidl::encoding::Encoder<
15375                '_,
15376                fidl::encoding::DefaultFuchsiaResourceDialect,
15377            >,
15378            offset: usize,
15379            mut depth: fidl::encoding::Depth,
15380        ) -> fidl::Result<()> {
15381            encoder.debug_check_bounds::<CentralSyncToPeriodicAdvertisingRequest>(offset);
15382            // Vector header
15383            let max_ordinal: u64 = self.max_ordinal_present();
15384            encoder.write_num(max_ordinal, offset);
15385            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
15386            // Calling encoder.out_of_line_offset(0) is not allowed.
15387            if max_ordinal == 0 {
15388                return Ok(());
15389            }
15390            depth.increment()?;
15391            let envelope_size = 8;
15392            let bytes_len = max_ordinal as usize * envelope_size;
15393            #[allow(unused_variables)]
15394            let offset = encoder.out_of_line_offset(bytes_len);
15395            let mut _prev_end_offset: usize = 0;
15396            if 1 > max_ordinal {
15397                return Ok(());
15398            }
15399
15400            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15401            // are envelope_size bytes.
15402            let cur_offset: usize = (1 - 1) * envelope_size;
15403
15404            // Zero reserved fields.
15405            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15406
15407            // Safety:
15408            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15409            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15410            //   envelope_size bytes, there is always sufficient room.
15411            fidl::encoding::encode_in_envelope_optional::<
15412                fidl_fuchsia_bluetooth::PeerId,
15413                fidl::encoding::DefaultFuchsiaResourceDialect,
15414            >(
15415                self.peer_id.as_ref().map(
15416                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::ValueTypeMarker>::borrow,
15417                ),
15418                encoder,
15419                offset + cur_offset,
15420                depth,
15421            )?;
15422
15423            _prev_end_offset = cur_offset + envelope_size;
15424            if 2 > max_ordinal {
15425                return Ok(());
15426            }
15427
15428            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15429            // are envelope_size bytes.
15430            let cur_offset: usize = (2 - 1) * envelope_size;
15431
15432            // Zero reserved fields.
15433            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15434
15435            // Safety:
15436            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15437            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15438            //   envelope_size bytes, there is always sufficient room.
15439            fidl::encoding::encode_in_envelope_optional::<
15440                u8,
15441                fidl::encoding::DefaultFuchsiaResourceDialect,
15442            >(
15443                self.advertising_sid.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
15444                encoder,
15445                offset + cur_offset,
15446                depth,
15447            )?;
15448
15449            _prev_end_offset = cur_offset + envelope_size;
15450            if 3 > max_ordinal {
15451                return Ok(());
15452            }
15453
15454            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15455            // are envelope_size bytes.
15456            let cur_offset: usize = (3 - 1) * envelope_size;
15457
15458            // Zero reserved fields.
15459            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15460
15461            // Safety:
15462            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15463            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15464            //   envelope_size bytes, there is always sufficient room.
15465            fidl::encoding::encode_in_envelope_optional::<
15466                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>>,
15467                fidl::encoding::DefaultFuchsiaResourceDialect,
15468            >(
15469                self.sync.as_mut().map(
15470                    <fidl::encoding::Endpoint<
15471                        fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
15472                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
15473                ),
15474                encoder,
15475                offset + cur_offset,
15476                depth,
15477            )?;
15478
15479            _prev_end_offset = cur_offset + envelope_size;
15480            if 4 > max_ordinal {
15481                return Ok(());
15482            }
15483
15484            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15485            // are envelope_size bytes.
15486            let cur_offset: usize = (4 - 1) * envelope_size;
15487
15488            // Zero reserved fields.
15489            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15490
15491            // Safety:
15492            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15493            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15494            //   envelope_size bytes, there is always sufficient room.
15495            fidl::encoding::encode_in_envelope_optional::<PeriodicAdvertisingSyncConfiguration, fidl::encoding::DefaultFuchsiaResourceDialect>(
15496            self.config.as_ref().map(<PeriodicAdvertisingSyncConfiguration as fidl::encoding::ValueTypeMarker>::borrow),
15497            encoder, offset + cur_offset, depth
15498        )?;
15499
15500            _prev_end_offset = cur_offset + envelope_size;
15501
15502            Ok(())
15503        }
15504    }
15505
15506    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
15507        for CentralSyncToPeriodicAdvertisingRequest
15508    {
15509        #[inline(always)]
15510        fn new_empty() -> Self {
15511            Self::default()
15512        }
15513
15514        unsafe fn decode(
15515            &mut self,
15516            decoder: &mut fidl::encoding::Decoder<
15517                '_,
15518                fidl::encoding::DefaultFuchsiaResourceDialect,
15519            >,
15520            offset: usize,
15521            mut depth: fidl::encoding::Depth,
15522        ) -> fidl::Result<()> {
15523            decoder.debug_check_bounds::<Self>(offset);
15524            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
15525                None => return Err(fidl::Error::NotNullable),
15526                Some(len) => len,
15527            };
15528            // Calling decoder.out_of_line_offset(0) is not allowed.
15529            if len == 0 {
15530                return Ok(());
15531            };
15532            depth.increment()?;
15533            let envelope_size = 8;
15534            let bytes_len = len * envelope_size;
15535            let offset = decoder.out_of_line_offset(bytes_len)?;
15536            // Decode the envelope for each type.
15537            let mut _next_ordinal_to_read = 0;
15538            let mut next_offset = offset;
15539            let end_offset = offset + bytes_len;
15540            _next_ordinal_to_read += 1;
15541            if next_offset >= end_offset {
15542                return Ok(());
15543            }
15544
15545            // Decode unknown envelopes for gaps in ordinals.
15546            while _next_ordinal_to_read < 1 {
15547                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15548                _next_ordinal_to_read += 1;
15549                next_offset += envelope_size;
15550            }
15551
15552            let next_out_of_line = decoder.next_out_of_line();
15553            let handles_before = decoder.remaining_handles();
15554            if let Some((inlined, num_bytes, num_handles)) =
15555                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15556            {
15557                let member_inline_size =
15558                    <fidl_fuchsia_bluetooth::PeerId as fidl::encoding::TypeMarker>::inline_size(
15559                        decoder.context,
15560                    );
15561                if inlined != (member_inline_size <= 4) {
15562                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15563                }
15564                let inner_offset;
15565                let mut inner_depth = depth.clone();
15566                if inlined {
15567                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15568                    inner_offset = next_offset;
15569                } else {
15570                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15571                    inner_depth.increment()?;
15572                }
15573                let val_ref = self.peer_id.get_or_insert_with(|| {
15574                    fidl::new_empty!(
15575                        fidl_fuchsia_bluetooth::PeerId,
15576                        fidl::encoding::DefaultFuchsiaResourceDialect
15577                    )
15578                });
15579                fidl::decode!(
15580                    fidl_fuchsia_bluetooth::PeerId,
15581                    fidl::encoding::DefaultFuchsiaResourceDialect,
15582                    val_ref,
15583                    decoder,
15584                    inner_offset,
15585                    inner_depth
15586                )?;
15587                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15588                {
15589                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15590                }
15591                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15592                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15593                }
15594            }
15595
15596            next_offset += envelope_size;
15597            _next_ordinal_to_read += 1;
15598            if next_offset >= end_offset {
15599                return Ok(());
15600            }
15601
15602            // Decode unknown envelopes for gaps in ordinals.
15603            while _next_ordinal_to_read < 2 {
15604                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15605                _next_ordinal_to_read += 1;
15606                next_offset += envelope_size;
15607            }
15608
15609            let next_out_of_line = decoder.next_out_of_line();
15610            let handles_before = decoder.remaining_handles();
15611            if let Some((inlined, num_bytes, num_handles)) =
15612                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15613            {
15614                let member_inline_size =
15615                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15616                if inlined != (member_inline_size <= 4) {
15617                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15618                }
15619                let inner_offset;
15620                let mut inner_depth = depth.clone();
15621                if inlined {
15622                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15623                    inner_offset = next_offset;
15624                } else {
15625                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15626                    inner_depth.increment()?;
15627                }
15628                let val_ref = self.advertising_sid.get_or_insert_with(|| {
15629                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
15630                });
15631                fidl::decode!(
15632                    u8,
15633                    fidl::encoding::DefaultFuchsiaResourceDialect,
15634                    val_ref,
15635                    decoder,
15636                    inner_offset,
15637                    inner_depth
15638                )?;
15639                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15640                {
15641                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15642                }
15643                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15644                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15645                }
15646            }
15647
15648            next_offset += envelope_size;
15649            _next_ordinal_to_read += 1;
15650            if next_offset >= end_offset {
15651                return Ok(());
15652            }
15653
15654            // Decode unknown envelopes for gaps in ordinals.
15655            while _next_ordinal_to_read < 3 {
15656                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15657                _next_ordinal_to_read += 1;
15658                next_offset += envelope_size;
15659            }
15660
15661            let next_out_of_line = decoder.next_out_of_line();
15662            let handles_before = decoder.remaining_handles();
15663            if let Some((inlined, num_bytes, num_handles)) =
15664                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15665            {
15666                let member_inline_size = <fidl::encoding::Endpoint<
15667                    fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
15668                > as fidl::encoding::TypeMarker>::inline_size(
15669                    decoder.context
15670                );
15671                if inlined != (member_inline_size <= 4) {
15672                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15673                }
15674                let inner_offset;
15675                let mut inner_depth = depth.clone();
15676                if inlined {
15677                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15678                    inner_offset = next_offset;
15679                } else {
15680                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15681                    inner_depth.increment()?;
15682                }
15683                let val_ref = self.sync.get_or_insert_with(|| {
15684                    fidl::new_empty!(
15685                        fidl::encoding::Endpoint<
15686                            fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
15687                        >,
15688                        fidl::encoding::DefaultFuchsiaResourceDialect
15689                    )
15690                });
15691                fidl::decode!(
15692                    fidl::encoding::Endpoint<
15693                        fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
15694                    >,
15695                    fidl::encoding::DefaultFuchsiaResourceDialect,
15696                    val_ref,
15697                    decoder,
15698                    inner_offset,
15699                    inner_depth
15700                )?;
15701                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15702                {
15703                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15704                }
15705                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15706                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15707                }
15708            }
15709
15710            next_offset += envelope_size;
15711            _next_ordinal_to_read += 1;
15712            if next_offset >= end_offset {
15713                return Ok(());
15714            }
15715
15716            // Decode unknown envelopes for gaps in ordinals.
15717            while _next_ordinal_to_read < 4 {
15718                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15719                _next_ordinal_to_read += 1;
15720                next_offset += envelope_size;
15721            }
15722
15723            let next_out_of_line = decoder.next_out_of_line();
15724            let handles_before = decoder.remaining_handles();
15725            if let Some((inlined, num_bytes, num_handles)) =
15726                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15727            {
15728                let member_inline_size = <PeriodicAdvertisingSyncConfiguration as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15729                if inlined != (member_inline_size <= 4) {
15730                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15731                }
15732                let inner_offset;
15733                let mut inner_depth = depth.clone();
15734                if inlined {
15735                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15736                    inner_offset = next_offset;
15737                } else {
15738                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15739                    inner_depth.increment()?;
15740                }
15741                let val_ref = self.config.get_or_insert_with(|| {
15742                    fidl::new_empty!(
15743                        PeriodicAdvertisingSyncConfiguration,
15744                        fidl::encoding::DefaultFuchsiaResourceDialect
15745                    )
15746                });
15747                fidl::decode!(
15748                    PeriodicAdvertisingSyncConfiguration,
15749                    fidl::encoding::DefaultFuchsiaResourceDialect,
15750                    val_ref,
15751                    decoder,
15752                    inner_offset,
15753                    inner_depth
15754                )?;
15755                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15756                {
15757                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15758                }
15759                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15760                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15761                }
15762            }
15763
15764            next_offset += envelope_size;
15765
15766            // Decode the remaining unknown envelopes.
15767            while next_offset < end_offset {
15768                _next_ordinal_to_read += 1;
15769                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15770                next_offset += envelope_size;
15771            }
15772
15773            Ok(())
15774        }
15775    }
15776
15777    impl ChannelListenerConnectedRequest {
15778        #[inline(always)]
15779        fn max_ordinal_present(&self) -> u64 {
15780            if let Some(_) = self.ext_offload {
15781                return 2;
15782            }
15783            if let Some(_) = self.channel {
15784                return 1;
15785            }
15786            0
15787        }
15788    }
15789
15790    impl fidl::encoding::ResourceTypeMarker for ChannelListenerConnectedRequest {
15791        type Borrowed<'a> = &'a mut Self;
15792        fn take_or_borrow<'a>(
15793            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
15794        ) -> Self::Borrowed<'a> {
15795            value
15796        }
15797    }
15798
15799    unsafe impl fidl::encoding::TypeMarker for ChannelListenerConnectedRequest {
15800        type Owned = Self;
15801
15802        #[inline(always)]
15803        fn inline_align(_context: fidl::encoding::Context) -> usize {
15804            8
15805        }
15806
15807        #[inline(always)]
15808        fn inline_size(_context: fidl::encoding::Context) -> usize {
15809            16
15810        }
15811    }
15812
15813    unsafe impl
15814        fidl::encoding::Encode<
15815            ChannelListenerConnectedRequest,
15816            fidl::encoding::DefaultFuchsiaResourceDialect,
15817        > for &mut ChannelListenerConnectedRequest
15818    {
15819        unsafe fn encode(
15820            self,
15821            encoder: &mut fidl::encoding::Encoder<
15822                '_,
15823                fidl::encoding::DefaultFuchsiaResourceDialect,
15824            >,
15825            offset: usize,
15826            mut depth: fidl::encoding::Depth,
15827        ) -> fidl::Result<()> {
15828            encoder.debug_check_bounds::<ChannelListenerConnectedRequest>(offset);
15829            // Vector header
15830            let max_ordinal: u64 = self.max_ordinal_present();
15831            encoder.write_num(max_ordinal, offset);
15832            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
15833            // Calling encoder.out_of_line_offset(0) is not allowed.
15834            if max_ordinal == 0 {
15835                return Ok(());
15836            }
15837            depth.increment()?;
15838            let envelope_size = 8;
15839            let bytes_len = max_ordinal as usize * envelope_size;
15840            #[allow(unused_variables)]
15841            let offset = encoder.out_of_line_offset(bytes_len);
15842            let mut _prev_end_offset: usize = 0;
15843            if 1 > max_ordinal {
15844                return Ok(());
15845            }
15846
15847            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15848            // are envelope_size bytes.
15849            let cur_offset: usize = (1 - 1) * envelope_size;
15850
15851            // Zero reserved fields.
15852            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15853
15854            // Safety:
15855            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15856            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15857            //   envelope_size bytes, there is always sufficient room.
15858            fidl::encoding::encode_in_envelope_optional::<
15859                fidl::encoding::Endpoint<
15860                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
15861                >,
15862                fidl::encoding::DefaultFuchsiaResourceDialect,
15863            >(
15864                self.channel.as_mut().map(
15865                    <fidl::encoding::Endpoint<
15866                        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
15867                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
15868                ),
15869                encoder,
15870                offset + cur_offset,
15871                depth,
15872            )?;
15873
15874            _prev_end_offset = cur_offset + envelope_size;
15875            if 2 > max_ordinal {
15876                return Ok(());
15877            }
15878
15879            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15880            // are envelope_size bytes.
15881            let cur_offset: usize = (2 - 1) * envelope_size;
15882
15883            // Zero reserved fields.
15884            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15885
15886            // Safety:
15887            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15888            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15889            //   envelope_size bytes, there is always sufficient room.
15890            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelOffloadExtMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
15891            self.ext_offload.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelOffloadExtMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
15892            encoder, offset + cur_offset, depth
15893        )?;
15894
15895            _prev_end_offset = cur_offset + envelope_size;
15896
15897            Ok(())
15898        }
15899    }
15900
15901    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
15902        for ChannelListenerConnectedRequest
15903    {
15904        #[inline(always)]
15905        fn new_empty() -> Self {
15906            Self::default()
15907        }
15908
15909        unsafe fn decode(
15910            &mut self,
15911            decoder: &mut fidl::encoding::Decoder<
15912                '_,
15913                fidl::encoding::DefaultFuchsiaResourceDialect,
15914            >,
15915            offset: usize,
15916            mut depth: fidl::encoding::Depth,
15917        ) -> fidl::Result<()> {
15918            decoder.debug_check_bounds::<Self>(offset);
15919            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
15920                None => return Err(fidl::Error::NotNullable),
15921                Some(len) => len,
15922            };
15923            // Calling decoder.out_of_line_offset(0) is not allowed.
15924            if len == 0 {
15925                return Ok(());
15926            };
15927            depth.increment()?;
15928            let envelope_size = 8;
15929            let bytes_len = len * envelope_size;
15930            let offset = decoder.out_of_line_offset(bytes_len)?;
15931            // Decode the envelope for each type.
15932            let mut _next_ordinal_to_read = 0;
15933            let mut next_offset = offset;
15934            let end_offset = offset + bytes_len;
15935            _next_ordinal_to_read += 1;
15936            if next_offset >= end_offset {
15937                return Ok(());
15938            }
15939
15940            // Decode unknown envelopes for gaps in ordinals.
15941            while _next_ordinal_to_read < 1 {
15942                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15943                _next_ordinal_to_read += 1;
15944                next_offset += envelope_size;
15945            }
15946
15947            let next_out_of_line = decoder.next_out_of_line();
15948            let handles_before = decoder.remaining_handles();
15949            if let Some((inlined, num_bytes, num_handles)) =
15950                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15951            {
15952                let member_inline_size = <fidl::encoding::Endpoint<
15953                    fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
15954                > as fidl::encoding::TypeMarker>::inline_size(
15955                    decoder.context
15956                );
15957                if inlined != (member_inline_size <= 4) {
15958                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15959                }
15960                let inner_offset;
15961                let mut inner_depth = depth.clone();
15962                if inlined {
15963                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15964                    inner_offset = next_offset;
15965                } else {
15966                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15967                    inner_depth.increment()?;
15968                }
15969                let val_ref = self.channel.get_or_insert_with(|| {
15970                    fidl::new_empty!(
15971                        fidl::encoding::Endpoint<
15972                            fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
15973                        >,
15974                        fidl::encoding::DefaultFuchsiaResourceDialect
15975                    )
15976                });
15977                fidl::decode!(
15978                    fidl::encoding::Endpoint<
15979                        fidl::endpoints::ClientEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
15980                    >,
15981                    fidl::encoding::DefaultFuchsiaResourceDialect,
15982                    val_ref,
15983                    decoder,
15984                    inner_offset,
15985                    inner_depth
15986                )?;
15987                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15988                {
15989                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15990                }
15991                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15992                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15993                }
15994            }
15995
15996            next_offset += envelope_size;
15997            _next_ordinal_to_read += 1;
15998            if next_offset >= end_offset {
15999                return Ok(());
16000            }
16001
16002            // Decode unknown envelopes for gaps in ordinals.
16003            while _next_ordinal_to_read < 2 {
16004                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16005                _next_ordinal_to_read += 1;
16006                next_offset += envelope_size;
16007            }
16008
16009            let next_out_of_line = decoder.next_out_of_line();
16010            let handles_before = decoder.remaining_handles();
16011            if let Some((inlined, num_bytes, num_handles)) =
16012                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16013            {
16014                let member_inline_size = <fidl::encoding::Endpoint<
16015                    fidl::endpoints::ClientEnd<ChannelOffloadExtMarker>,
16016                > as fidl::encoding::TypeMarker>::inline_size(
16017                    decoder.context
16018                );
16019                if inlined != (member_inline_size <= 4) {
16020                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16021                }
16022                let inner_offset;
16023                let mut inner_depth = depth.clone();
16024                if inlined {
16025                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16026                    inner_offset = next_offset;
16027                } else {
16028                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16029                    inner_depth.increment()?;
16030                }
16031                let val_ref = self.ext_offload.get_or_insert_with(|| {
16032                    fidl::new_empty!(
16033                        fidl::encoding::Endpoint<
16034                            fidl::endpoints::ClientEnd<ChannelOffloadExtMarker>,
16035                        >,
16036                        fidl::encoding::DefaultFuchsiaResourceDialect
16037                    )
16038                });
16039                fidl::decode!(
16040                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelOffloadExtMarker>>,
16041                    fidl::encoding::DefaultFuchsiaResourceDialect,
16042                    val_ref,
16043                    decoder,
16044                    inner_offset,
16045                    inner_depth
16046                )?;
16047                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16048                {
16049                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16050                }
16051                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16052                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16053                }
16054            }
16055
16056            next_offset += envelope_size;
16057
16058            // Decode the remaining unknown envelopes.
16059            while next_offset < end_offset {
16060                _next_ordinal_to_read += 1;
16061                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16062                next_offset += envelope_size;
16063            }
16064
16065            Ok(())
16066        }
16067    }
16068
16069    impl ChannelListenerRegistryListenL2capRequest {
16070        #[inline(always)]
16071        fn max_ordinal_present(&self) -> u64 {
16072            if let Some(_) = self.listener {
16073                return 2;
16074            }
16075            if let Some(_) = self.parameters {
16076                return 1;
16077            }
16078            0
16079        }
16080    }
16081
16082    impl fidl::encoding::ResourceTypeMarker for ChannelListenerRegistryListenL2capRequest {
16083        type Borrowed<'a> = &'a mut Self;
16084        fn take_or_borrow<'a>(
16085            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16086        ) -> Self::Borrowed<'a> {
16087            value
16088        }
16089    }
16090
16091    unsafe impl fidl::encoding::TypeMarker for ChannelListenerRegistryListenL2capRequest {
16092        type Owned = Self;
16093
16094        #[inline(always)]
16095        fn inline_align(_context: fidl::encoding::Context) -> usize {
16096            8
16097        }
16098
16099        #[inline(always)]
16100        fn inline_size(_context: fidl::encoding::Context) -> usize {
16101            16
16102        }
16103    }
16104
16105    unsafe impl
16106        fidl::encoding::Encode<
16107            ChannelListenerRegistryListenL2capRequest,
16108            fidl::encoding::DefaultFuchsiaResourceDialect,
16109        > for &mut ChannelListenerRegistryListenL2capRequest
16110    {
16111        unsafe fn encode(
16112            self,
16113            encoder: &mut fidl::encoding::Encoder<
16114                '_,
16115                fidl::encoding::DefaultFuchsiaResourceDialect,
16116            >,
16117            offset: usize,
16118            mut depth: fidl::encoding::Depth,
16119        ) -> fidl::Result<()> {
16120            encoder.debug_check_bounds::<ChannelListenerRegistryListenL2capRequest>(offset);
16121            // Vector header
16122            let max_ordinal: u64 = self.max_ordinal_present();
16123            encoder.write_num(max_ordinal, offset);
16124            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16125            // Calling encoder.out_of_line_offset(0) is not allowed.
16126            if max_ordinal == 0 {
16127                return Ok(());
16128            }
16129            depth.increment()?;
16130            let envelope_size = 8;
16131            let bytes_len = max_ordinal as usize * envelope_size;
16132            #[allow(unused_variables)]
16133            let offset = encoder.out_of_line_offset(bytes_len);
16134            let mut _prev_end_offset: usize = 0;
16135            if 1 > max_ordinal {
16136                return Ok(());
16137            }
16138
16139            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16140            // are envelope_size bytes.
16141            let cur_offset: usize = (1 - 1) * envelope_size;
16142
16143            // Zero reserved fields.
16144            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16145
16146            // Safety:
16147            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16148            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16149            //   envelope_size bytes, there is always sufficient room.
16150            fidl::encoding::encode_in_envelope_optional::<
16151                AcceptedChannelParameters,
16152                fidl::encoding::DefaultFuchsiaResourceDialect,
16153            >(
16154                self.parameters
16155                    .as_ref()
16156                    .map(<AcceptedChannelParameters as fidl::encoding::ValueTypeMarker>::borrow),
16157                encoder,
16158                offset + cur_offset,
16159                depth,
16160            )?;
16161
16162            _prev_end_offset = cur_offset + envelope_size;
16163            if 2 > max_ordinal {
16164                return Ok(());
16165            }
16166
16167            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16168            // are envelope_size bytes.
16169            let cur_offset: usize = (2 - 1) * envelope_size;
16170
16171            // Zero reserved fields.
16172            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16173
16174            // Safety:
16175            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16176            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16177            //   envelope_size bytes, there is always sufficient room.
16178            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
16179            self.listener.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
16180            encoder, offset + cur_offset, depth
16181        )?;
16182
16183            _prev_end_offset = cur_offset + envelope_size;
16184
16185            Ok(())
16186        }
16187    }
16188
16189    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
16190        for ChannelListenerRegistryListenL2capRequest
16191    {
16192        #[inline(always)]
16193        fn new_empty() -> Self {
16194            Self::default()
16195        }
16196
16197        unsafe fn decode(
16198            &mut self,
16199            decoder: &mut fidl::encoding::Decoder<
16200                '_,
16201                fidl::encoding::DefaultFuchsiaResourceDialect,
16202            >,
16203            offset: usize,
16204            mut depth: fidl::encoding::Depth,
16205        ) -> fidl::Result<()> {
16206            decoder.debug_check_bounds::<Self>(offset);
16207            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
16208                None => return Err(fidl::Error::NotNullable),
16209                Some(len) => len,
16210            };
16211            // Calling decoder.out_of_line_offset(0) is not allowed.
16212            if len == 0 {
16213                return Ok(());
16214            };
16215            depth.increment()?;
16216            let envelope_size = 8;
16217            let bytes_len = len * envelope_size;
16218            let offset = decoder.out_of_line_offset(bytes_len)?;
16219            // Decode the envelope for each type.
16220            let mut _next_ordinal_to_read = 0;
16221            let mut next_offset = offset;
16222            let end_offset = offset + bytes_len;
16223            _next_ordinal_to_read += 1;
16224            if next_offset >= end_offset {
16225                return Ok(());
16226            }
16227
16228            // Decode unknown envelopes for gaps in ordinals.
16229            while _next_ordinal_to_read < 1 {
16230                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16231                _next_ordinal_to_read += 1;
16232                next_offset += envelope_size;
16233            }
16234
16235            let next_out_of_line = decoder.next_out_of_line();
16236            let handles_before = decoder.remaining_handles();
16237            if let Some((inlined, num_bytes, num_handles)) =
16238                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16239            {
16240                let member_inline_size =
16241                    <AcceptedChannelParameters as fidl::encoding::TypeMarker>::inline_size(
16242                        decoder.context,
16243                    );
16244                if inlined != (member_inline_size <= 4) {
16245                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16246                }
16247                let inner_offset;
16248                let mut inner_depth = depth.clone();
16249                if inlined {
16250                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16251                    inner_offset = next_offset;
16252                } else {
16253                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16254                    inner_depth.increment()?;
16255                }
16256                let val_ref = self.parameters.get_or_insert_with(|| {
16257                    fidl::new_empty!(
16258                        AcceptedChannelParameters,
16259                        fidl::encoding::DefaultFuchsiaResourceDialect
16260                    )
16261                });
16262                fidl::decode!(
16263                    AcceptedChannelParameters,
16264                    fidl::encoding::DefaultFuchsiaResourceDialect,
16265                    val_ref,
16266                    decoder,
16267                    inner_offset,
16268                    inner_depth
16269                )?;
16270                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16271                {
16272                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16273                }
16274                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16275                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16276                }
16277            }
16278
16279            next_offset += envelope_size;
16280            _next_ordinal_to_read += 1;
16281            if next_offset >= end_offset {
16282                return Ok(());
16283            }
16284
16285            // Decode unknown envelopes for gaps in ordinals.
16286            while _next_ordinal_to_read < 2 {
16287                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16288                _next_ordinal_to_read += 1;
16289                next_offset += envelope_size;
16290            }
16291
16292            let next_out_of_line = decoder.next_out_of_line();
16293            let handles_before = decoder.remaining_handles();
16294            if let Some((inlined, num_bytes, num_handles)) =
16295                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16296            {
16297                let member_inline_size = <fidl::encoding::Endpoint<
16298                    fidl::endpoints::ClientEnd<ChannelListenerMarker>,
16299                > as fidl::encoding::TypeMarker>::inline_size(
16300                    decoder.context
16301                );
16302                if inlined != (member_inline_size <= 4) {
16303                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16304                }
16305                let inner_offset;
16306                let mut inner_depth = depth.clone();
16307                if inlined {
16308                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16309                    inner_offset = next_offset;
16310                } else {
16311                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16312                    inner_depth.increment()?;
16313                }
16314                let val_ref = self.listener.get_or_insert_with(|| {
16315                    fidl::new_empty!(
16316                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>>,
16317                        fidl::encoding::DefaultFuchsiaResourceDialect
16318                    )
16319                });
16320                fidl::decode!(
16321                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ChannelListenerMarker>>,
16322                    fidl::encoding::DefaultFuchsiaResourceDialect,
16323                    val_ref,
16324                    decoder,
16325                    inner_offset,
16326                    inner_depth
16327                )?;
16328                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16329                {
16330                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16331                }
16332                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16333                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16334                }
16335            }
16336
16337            next_offset += envelope_size;
16338
16339            // Decode the remaining unknown envelopes.
16340            while next_offset < end_offset {
16341                _next_ordinal_to_read += 1;
16342                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16343                next_offset += envelope_size;
16344            }
16345
16346            Ok(())
16347        }
16348    }
16349
16350    impl CisRequestedParameters {
16351        #[inline(always)]
16352        fn max_ordinal_present(&self) -> u64 {
16353            if let Some(_) = self.max_sdu_size_incoming {
16354                return 4;
16355            }
16356            if let Some(_) = self.max_sdu_size_outgoing {
16357                return 3;
16358            }
16359            if let Some(_) = self.connection_stream {
16360                return 2;
16361            }
16362            if let Some(_) = self.cis_id {
16363                return 1;
16364            }
16365            0
16366        }
16367    }
16368
16369    impl fidl::encoding::ResourceTypeMarker for CisRequestedParameters {
16370        type Borrowed<'a> = &'a mut Self;
16371        fn take_or_borrow<'a>(
16372            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16373        ) -> Self::Borrowed<'a> {
16374            value
16375        }
16376    }
16377
16378    unsafe impl fidl::encoding::TypeMarker for CisRequestedParameters {
16379        type Owned = Self;
16380
16381        #[inline(always)]
16382        fn inline_align(_context: fidl::encoding::Context) -> usize {
16383            8
16384        }
16385
16386        #[inline(always)]
16387        fn inline_size(_context: fidl::encoding::Context) -> usize {
16388            16
16389        }
16390    }
16391
16392    unsafe impl
16393        fidl::encoding::Encode<
16394            CisRequestedParameters,
16395            fidl::encoding::DefaultFuchsiaResourceDialect,
16396        > for &mut CisRequestedParameters
16397    {
16398        unsafe fn encode(
16399            self,
16400            encoder: &mut fidl::encoding::Encoder<
16401                '_,
16402                fidl::encoding::DefaultFuchsiaResourceDialect,
16403            >,
16404            offset: usize,
16405            mut depth: fidl::encoding::Depth,
16406        ) -> fidl::Result<()> {
16407            encoder.debug_check_bounds::<CisRequestedParameters>(offset);
16408            // Vector header
16409            let max_ordinal: u64 = self.max_ordinal_present();
16410            encoder.write_num(max_ordinal, offset);
16411            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16412            // Calling encoder.out_of_line_offset(0) is not allowed.
16413            if max_ordinal == 0 {
16414                return Ok(());
16415            }
16416            depth.increment()?;
16417            let envelope_size = 8;
16418            let bytes_len = max_ordinal as usize * envelope_size;
16419            #[allow(unused_variables)]
16420            let offset = encoder.out_of_line_offset(bytes_len);
16421            let mut _prev_end_offset: usize = 0;
16422            if 1 > max_ordinal {
16423                return Ok(());
16424            }
16425
16426            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16427            // are envelope_size bytes.
16428            let cur_offset: usize = (1 - 1) * envelope_size;
16429
16430            // Zero reserved fields.
16431            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16432
16433            // Safety:
16434            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16435            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16436            //   envelope_size bytes, there is always sufficient room.
16437            fidl::encoding::encode_in_envelope_optional::<
16438                u8,
16439                fidl::encoding::DefaultFuchsiaResourceDialect,
16440            >(
16441                self.cis_id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
16442                encoder,
16443                offset + cur_offset,
16444                depth,
16445            )?;
16446
16447            _prev_end_offset = cur_offset + envelope_size;
16448            if 2 > max_ordinal {
16449                return Ok(());
16450            }
16451
16452            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16453            // are envelope_size bytes.
16454            let cur_offset: usize = (2 - 1) * envelope_size;
16455
16456            // Zero reserved fields.
16457            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16458
16459            // Safety:
16460            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16461            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16462            //   envelope_size bytes, there is always sufficient room.
16463            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
16464            self.connection_stream.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
16465            encoder, offset + cur_offset, depth
16466        )?;
16467
16468            _prev_end_offset = cur_offset + envelope_size;
16469            if 3 > max_ordinal {
16470                return Ok(());
16471            }
16472
16473            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16474            // are envelope_size bytes.
16475            let cur_offset: usize = (3 - 1) * envelope_size;
16476
16477            // Zero reserved fields.
16478            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16479
16480            // Safety:
16481            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16482            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16483            //   envelope_size bytes, there is always sufficient room.
16484            fidl::encoding::encode_in_envelope_optional::<
16485                u16,
16486                fidl::encoding::DefaultFuchsiaResourceDialect,
16487            >(
16488                self.max_sdu_size_outgoing
16489                    .as_ref()
16490                    .map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
16491                encoder,
16492                offset + cur_offset,
16493                depth,
16494            )?;
16495
16496            _prev_end_offset = cur_offset + envelope_size;
16497            if 4 > max_ordinal {
16498                return Ok(());
16499            }
16500
16501            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16502            // are envelope_size bytes.
16503            let cur_offset: usize = (4 - 1) * envelope_size;
16504
16505            // Zero reserved fields.
16506            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16507
16508            // Safety:
16509            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16510            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16511            //   envelope_size bytes, there is always sufficient room.
16512            fidl::encoding::encode_in_envelope_optional::<
16513                u16,
16514                fidl::encoding::DefaultFuchsiaResourceDialect,
16515            >(
16516                self.max_sdu_size_incoming
16517                    .as_ref()
16518                    .map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
16519                encoder,
16520                offset + cur_offset,
16521                depth,
16522            )?;
16523
16524            _prev_end_offset = cur_offset + envelope_size;
16525
16526            Ok(())
16527        }
16528    }
16529
16530    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
16531        for CisRequestedParameters
16532    {
16533        #[inline(always)]
16534        fn new_empty() -> Self {
16535            Self::default()
16536        }
16537
16538        unsafe fn decode(
16539            &mut self,
16540            decoder: &mut fidl::encoding::Decoder<
16541                '_,
16542                fidl::encoding::DefaultFuchsiaResourceDialect,
16543            >,
16544            offset: usize,
16545            mut depth: fidl::encoding::Depth,
16546        ) -> fidl::Result<()> {
16547            decoder.debug_check_bounds::<Self>(offset);
16548            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
16549                None => return Err(fidl::Error::NotNullable),
16550                Some(len) => len,
16551            };
16552            // Calling decoder.out_of_line_offset(0) is not allowed.
16553            if len == 0 {
16554                return Ok(());
16555            };
16556            depth.increment()?;
16557            let envelope_size = 8;
16558            let bytes_len = len * envelope_size;
16559            let offset = decoder.out_of_line_offset(bytes_len)?;
16560            // Decode the envelope for each type.
16561            let mut _next_ordinal_to_read = 0;
16562            let mut next_offset = offset;
16563            let end_offset = offset + bytes_len;
16564            _next_ordinal_to_read += 1;
16565            if next_offset >= end_offset {
16566                return Ok(());
16567            }
16568
16569            // Decode unknown envelopes for gaps in ordinals.
16570            while _next_ordinal_to_read < 1 {
16571                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16572                _next_ordinal_to_read += 1;
16573                next_offset += envelope_size;
16574            }
16575
16576            let next_out_of_line = decoder.next_out_of_line();
16577            let handles_before = decoder.remaining_handles();
16578            if let Some((inlined, num_bytes, num_handles)) =
16579                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16580            {
16581                let member_inline_size =
16582                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
16583                if inlined != (member_inline_size <= 4) {
16584                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16585                }
16586                let inner_offset;
16587                let mut inner_depth = depth.clone();
16588                if inlined {
16589                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16590                    inner_offset = next_offset;
16591                } else {
16592                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16593                    inner_depth.increment()?;
16594                }
16595                let val_ref = self.cis_id.get_or_insert_with(|| {
16596                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
16597                });
16598                fidl::decode!(
16599                    u8,
16600                    fidl::encoding::DefaultFuchsiaResourceDialect,
16601                    val_ref,
16602                    decoder,
16603                    inner_offset,
16604                    inner_depth
16605                )?;
16606                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16607                {
16608                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16609                }
16610                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16611                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16612                }
16613            }
16614
16615            next_offset += envelope_size;
16616            _next_ordinal_to_read += 1;
16617            if next_offset >= end_offset {
16618                return Ok(());
16619            }
16620
16621            // Decode unknown envelopes for gaps in ordinals.
16622            while _next_ordinal_to_read < 2 {
16623                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16624                _next_ordinal_to_read += 1;
16625                next_offset += envelope_size;
16626            }
16627
16628            let next_out_of_line = decoder.next_out_of_line();
16629            let handles_before = decoder.remaining_handles();
16630            if let Some((inlined, num_bytes, num_handles)) =
16631                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16632            {
16633                let member_inline_size = <fidl::encoding::Endpoint<
16634                    fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
16635                > as fidl::encoding::TypeMarker>::inline_size(
16636                    decoder.context
16637                );
16638                if inlined != (member_inline_size <= 4) {
16639                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16640                }
16641                let inner_offset;
16642                let mut inner_depth = depth.clone();
16643                if inlined {
16644                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16645                    inner_offset = next_offset;
16646                } else {
16647                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16648                    inner_depth.increment()?;
16649                }
16650                let val_ref = self.connection_stream.get_or_insert_with(|| {
16651                    fidl::new_empty!(
16652                        fidl::encoding::Endpoint<
16653                            fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
16654                        >,
16655                        fidl::encoding::DefaultFuchsiaResourceDialect
16656                    )
16657                });
16658                fidl::decode!(
16659                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>,
16660                    fidl::encoding::DefaultFuchsiaResourceDialect,
16661                    val_ref,
16662                    decoder,
16663                    inner_offset,
16664                    inner_depth
16665                )?;
16666                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16667                {
16668                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16669                }
16670                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16671                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16672                }
16673            }
16674
16675            next_offset += envelope_size;
16676            _next_ordinal_to_read += 1;
16677            if next_offset >= end_offset {
16678                return Ok(());
16679            }
16680
16681            // Decode unknown envelopes for gaps in ordinals.
16682            while _next_ordinal_to_read < 3 {
16683                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16684                _next_ordinal_to_read += 1;
16685                next_offset += envelope_size;
16686            }
16687
16688            let next_out_of_line = decoder.next_out_of_line();
16689            let handles_before = decoder.remaining_handles();
16690            if let Some((inlined, num_bytes, num_handles)) =
16691                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16692            {
16693                let member_inline_size =
16694                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
16695                if inlined != (member_inline_size <= 4) {
16696                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16697                }
16698                let inner_offset;
16699                let mut inner_depth = depth.clone();
16700                if inlined {
16701                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16702                    inner_offset = next_offset;
16703                } else {
16704                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16705                    inner_depth.increment()?;
16706                }
16707                let val_ref = self.max_sdu_size_outgoing.get_or_insert_with(|| {
16708                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
16709                });
16710                fidl::decode!(
16711                    u16,
16712                    fidl::encoding::DefaultFuchsiaResourceDialect,
16713                    val_ref,
16714                    decoder,
16715                    inner_offset,
16716                    inner_depth
16717                )?;
16718                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16719                {
16720                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16721                }
16722                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16723                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16724                }
16725            }
16726
16727            next_offset += envelope_size;
16728            _next_ordinal_to_read += 1;
16729            if next_offset >= end_offset {
16730                return Ok(());
16731            }
16732
16733            // Decode unknown envelopes for gaps in ordinals.
16734            while _next_ordinal_to_read < 4 {
16735                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16736                _next_ordinal_to_read += 1;
16737                next_offset += envelope_size;
16738            }
16739
16740            let next_out_of_line = decoder.next_out_of_line();
16741            let handles_before = decoder.remaining_handles();
16742            if let Some((inlined, num_bytes, num_handles)) =
16743                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16744            {
16745                let member_inline_size =
16746                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
16747                if inlined != (member_inline_size <= 4) {
16748                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16749                }
16750                let inner_offset;
16751                let mut inner_depth = depth.clone();
16752                if inlined {
16753                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16754                    inner_offset = next_offset;
16755                } else {
16756                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16757                    inner_depth.increment()?;
16758                }
16759                let val_ref = self.max_sdu_size_incoming.get_or_insert_with(|| {
16760                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
16761                });
16762                fidl::decode!(
16763                    u16,
16764                    fidl::encoding::DefaultFuchsiaResourceDialect,
16765                    val_ref,
16766                    decoder,
16767                    inner_offset,
16768                    inner_depth
16769                )?;
16770                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16771                {
16772                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16773                }
16774                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16775                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16776                }
16777            }
16778
16779            next_offset += envelope_size;
16780
16781            // Decode the remaining unknown envelopes.
16782            while next_offset < end_offset {
16783                _next_ordinal_to_read += 1;
16784                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16785                next_offset += envelope_size;
16786            }
16787
16788            Ok(())
16789        }
16790    }
16791
16792    impl ConnectionAcceptCisRequest {
16793        #[inline(always)]
16794        fn max_ordinal_present(&self) -> u64 {
16795            if let Some(_) = self.connection_stream {
16796                return 3;
16797            }
16798            if let Some(_) = self.cis_id {
16799                return 2;
16800            }
16801            if let Some(_) = self.cig_id {
16802                return 1;
16803            }
16804            0
16805        }
16806    }
16807
16808    impl fidl::encoding::ResourceTypeMarker for ConnectionAcceptCisRequest {
16809        type Borrowed<'a> = &'a mut Self;
16810        fn take_or_borrow<'a>(
16811            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16812        ) -> Self::Borrowed<'a> {
16813            value
16814        }
16815    }
16816
16817    unsafe impl fidl::encoding::TypeMarker for ConnectionAcceptCisRequest {
16818        type Owned = Self;
16819
16820        #[inline(always)]
16821        fn inline_align(_context: fidl::encoding::Context) -> usize {
16822            8
16823        }
16824
16825        #[inline(always)]
16826        fn inline_size(_context: fidl::encoding::Context) -> usize {
16827            16
16828        }
16829    }
16830
16831    unsafe impl
16832        fidl::encoding::Encode<
16833            ConnectionAcceptCisRequest,
16834            fidl::encoding::DefaultFuchsiaResourceDialect,
16835        > for &mut ConnectionAcceptCisRequest
16836    {
16837        unsafe fn encode(
16838            self,
16839            encoder: &mut fidl::encoding::Encoder<
16840                '_,
16841                fidl::encoding::DefaultFuchsiaResourceDialect,
16842            >,
16843            offset: usize,
16844            mut depth: fidl::encoding::Depth,
16845        ) -> fidl::Result<()> {
16846            encoder.debug_check_bounds::<ConnectionAcceptCisRequest>(offset);
16847            // Vector header
16848            let max_ordinal: u64 = self.max_ordinal_present();
16849            encoder.write_num(max_ordinal, offset);
16850            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16851            // Calling encoder.out_of_line_offset(0) is not allowed.
16852            if max_ordinal == 0 {
16853                return Ok(());
16854            }
16855            depth.increment()?;
16856            let envelope_size = 8;
16857            let bytes_len = max_ordinal as usize * envelope_size;
16858            #[allow(unused_variables)]
16859            let offset = encoder.out_of_line_offset(bytes_len);
16860            let mut _prev_end_offset: usize = 0;
16861            if 1 > max_ordinal {
16862                return Ok(());
16863            }
16864
16865            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16866            // are envelope_size bytes.
16867            let cur_offset: usize = (1 - 1) * envelope_size;
16868
16869            // Zero reserved fields.
16870            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16871
16872            // Safety:
16873            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16874            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16875            //   envelope_size bytes, there is always sufficient room.
16876            fidl::encoding::encode_in_envelope_optional::<
16877                u8,
16878                fidl::encoding::DefaultFuchsiaResourceDialect,
16879            >(
16880                self.cig_id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
16881                encoder,
16882                offset + cur_offset,
16883                depth,
16884            )?;
16885
16886            _prev_end_offset = cur_offset + envelope_size;
16887            if 2 > max_ordinal {
16888                return Ok(());
16889            }
16890
16891            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16892            // are envelope_size bytes.
16893            let cur_offset: usize = (2 - 1) * envelope_size;
16894
16895            // Zero reserved fields.
16896            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16897
16898            // Safety:
16899            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16900            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16901            //   envelope_size bytes, there is always sufficient room.
16902            fidl::encoding::encode_in_envelope_optional::<
16903                u8,
16904                fidl::encoding::DefaultFuchsiaResourceDialect,
16905            >(
16906                self.cis_id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
16907                encoder,
16908                offset + cur_offset,
16909                depth,
16910            )?;
16911
16912            _prev_end_offset = cur_offset + envelope_size;
16913            if 3 > max_ordinal {
16914                return Ok(());
16915            }
16916
16917            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16918            // are envelope_size bytes.
16919            let cur_offset: usize = (3 - 1) * envelope_size;
16920
16921            // Zero reserved fields.
16922            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16923
16924            // Safety:
16925            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16926            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16927            //   envelope_size bytes, there is always sufficient room.
16928            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
16929            self.connection_stream.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
16930            encoder, offset + cur_offset, depth
16931        )?;
16932
16933            _prev_end_offset = cur_offset + envelope_size;
16934
16935            Ok(())
16936        }
16937    }
16938
16939    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
16940        for ConnectionAcceptCisRequest
16941    {
16942        #[inline(always)]
16943        fn new_empty() -> Self {
16944            Self::default()
16945        }
16946
16947        unsafe fn decode(
16948            &mut self,
16949            decoder: &mut fidl::encoding::Decoder<
16950                '_,
16951                fidl::encoding::DefaultFuchsiaResourceDialect,
16952            >,
16953            offset: usize,
16954            mut depth: fidl::encoding::Depth,
16955        ) -> fidl::Result<()> {
16956            decoder.debug_check_bounds::<Self>(offset);
16957            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
16958                None => return Err(fidl::Error::NotNullable),
16959                Some(len) => len,
16960            };
16961            // Calling decoder.out_of_line_offset(0) is not allowed.
16962            if len == 0 {
16963                return Ok(());
16964            };
16965            depth.increment()?;
16966            let envelope_size = 8;
16967            let bytes_len = len * envelope_size;
16968            let offset = decoder.out_of_line_offset(bytes_len)?;
16969            // Decode the envelope for each type.
16970            let mut _next_ordinal_to_read = 0;
16971            let mut next_offset = offset;
16972            let end_offset = offset + bytes_len;
16973            _next_ordinal_to_read += 1;
16974            if next_offset >= end_offset {
16975                return Ok(());
16976            }
16977
16978            // Decode unknown envelopes for gaps in ordinals.
16979            while _next_ordinal_to_read < 1 {
16980                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16981                _next_ordinal_to_read += 1;
16982                next_offset += envelope_size;
16983            }
16984
16985            let next_out_of_line = decoder.next_out_of_line();
16986            let handles_before = decoder.remaining_handles();
16987            if let Some((inlined, num_bytes, num_handles)) =
16988                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16989            {
16990                let member_inline_size =
16991                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
16992                if inlined != (member_inline_size <= 4) {
16993                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16994                }
16995                let inner_offset;
16996                let mut inner_depth = depth.clone();
16997                if inlined {
16998                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16999                    inner_offset = next_offset;
17000                } else {
17001                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17002                    inner_depth.increment()?;
17003                }
17004                let val_ref = self.cig_id.get_or_insert_with(|| {
17005                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
17006                });
17007                fidl::decode!(
17008                    u8,
17009                    fidl::encoding::DefaultFuchsiaResourceDialect,
17010                    val_ref,
17011                    decoder,
17012                    inner_offset,
17013                    inner_depth
17014                )?;
17015                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17016                {
17017                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17018                }
17019                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17020                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17021                }
17022            }
17023
17024            next_offset += envelope_size;
17025            _next_ordinal_to_read += 1;
17026            if next_offset >= end_offset {
17027                return Ok(());
17028            }
17029
17030            // Decode unknown envelopes for gaps in ordinals.
17031            while _next_ordinal_to_read < 2 {
17032                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17033                _next_ordinal_to_read += 1;
17034                next_offset += envelope_size;
17035            }
17036
17037            let next_out_of_line = decoder.next_out_of_line();
17038            let handles_before = decoder.remaining_handles();
17039            if let Some((inlined, num_bytes, num_handles)) =
17040                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17041            {
17042                let member_inline_size =
17043                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
17044                if inlined != (member_inline_size <= 4) {
17045                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17046                }
17047                let inner_offset;
17048                let mut inner_depth = depth.clone();
17049                if inlined {
17050                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17051                    inner_offset = next_offset;
17052                } else {
17053                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17054                    inner_depth.increment()?;
17055                }
17056                let val_ref = self.cis_id.get_or_insert_with(|| {
17057                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
17058                });
17059                fidl::decode!(
17060                    u8,
17061                    fidl::encoding::DefaultFuchsiaResourceDialect,
17062                    val_ref,
17063                    decoder,
17064                    inner_offset,
17065                    inner_depth
17066                )?;
17067                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17068                {
17069                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17070                }
17071                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17072                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17073                }
17074            }
17075
17076            next_offset += envelope_size;
17077            _next_ordinal_to_read += 1;
17078            if next_offset >= end_offset {
17079                return Ok(());
17080            }
17081
17082            // Decode unknown envelopes for gaps in ordinals.
17083            while _next_ordinal_to_read < 3 {
17084                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17085                _next_ordinal_to_read += 1;
17086                next_offset += envelope_size;
17087            }
17088
17089            let next_out_of_line = decoder.next_out_of_line();
17090            let handles_before = decoder.remaining_handles();
17091            if let Some((inlined, num_bytes, num_handles)) =
17092                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17093            {
17094                let member_inline_size = <fidl::encoding::Endpoint<
17095                    fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
17096                > as fidl::encoding::TypeMarker>::inline_size(
17097                    decoder.context
17098                );
17099                if inlined != (member_inline_size <= 4) {
17100                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17101                }
17102                let inner_offset;
17103                let mut inner_depth = depth.clone();
17104                if inlined {
17105                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17106                    inner_offset = next_offset;
17107                } else {
17108                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17109                    inner_depth.increment()?;
17110                }
17111                let val_ref = self.connection_stream.get_or_insert_with(|| {
17112                    fidl::new_empty!(
17113                        fidl::encoding::Endpoint<
17114                            fidl::endpoints::ServerEnd<IsochronousStreamMarker>,
17115                        >,
17116                        fidl::encoding::DefaultFuchsiaResourceDialect
17117                    )
17118                });
17119                fidl::decode!(
17120                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IsochronousStreamMarker>>,
17121                    fidl::encoding::DefaultFuchsiaResourceDialect,
17122                    val_ref,
17123                    decoder,
17124                    inner_offset,
17125                    inner_depth
17126                )?;
17127                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17128                {
17129                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17130                }
17131                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17132                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17133                }
17134            }
17135
17136            next_offset += envelope_size;
17137
17138            // Decode the remaining unknown envelopes.
17139            while next_offset < end_offset {
17140                _next_ordinal_to_read += 1;
17141                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17142                next_offset += envelope_size;
17143            }
17144
17145            Ok(())
17146        }
17147    }
17148
17149    impl ConnectionAcceptPeriodicAdvertisingSyncTransferRequest {
17150        #[inline(always)]
17151        fn max_ordinal_present(&self) -> u64 {
17152            if let Some(_) = self.config {
17153                return 2;
17154            }
17155            if let Some(_) = self.sync {
17156                return 1;
17157            }
17158            0
17159        }
17160    }
17161
17162    impl fidl::encoding::ResourceTypeMarker for ConnectionAcceptPeriodicAdvertisingSyncTransferRequest {
17163        type Borrowed<'a> = &'a mut Self;
17164        fn take_or_borrow<'a>(
17165            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17166        ) -> Self::Borrowed<'a> {
17167            value
17168        }
17169    }
17170
17171    unsafe impl fidl::encoding::TypeMarker for ConnectionAcceptPeriodicAdvertisingSyncTransferRequest {
17172        type Owned = Self;
17173
17174        #[inline(always)]
17175        fn inline_align(_context: fidl::encoding::Context) -> usize {
17176            8
17177        }
17178
17179        #[inline(always)]
17180        fn inline_size(_context: fidl::encoding::Context) -> usize {
17181            16
17182        }
17183    }
17184
17185    unsafe impl
17186        fidl::encoding::Encode<
17187            ConnectionAcceptPeriodicAdvertisingSyncTransferRequest,
17188            fidl::encoding::DefaultFuchsiaResourceDialect,
17189        > for &mut ConnectionAcceptPeriodicAdvertisingSyncTransferRequest
17190    {
17191        unsafe fn encode(
17192            self,
17193            encoder: &mut fidl::encoding::Encoder<
17194                '_,
17195                fidl::encoding::DefaultFuchsiaResourceDialect,
17196            >,
17197            offset: usize,
17198            mut depth: fidl::encoding::Depth,
17199        ) -> fidl::Result<()> {
17200            encoder.debug_check_bounds::<ConnectionAcceptPeriodicAdvertisingSyncTransferRequest>(
17201                offset,
17202            );
17203            // Vector header
17204            let max_ordinal: u64 = self.max_ordinal_present();
17205            encoder.write_num(max_ordinal, offset);
17206            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
17207            // Calling encoder.out_of_line_offset(0) is not allowed.
17208            if max_ordinal == 0 {
17209                return Ok(());
17210            }
17211            depth.increment()?;
17212            let envelope_size = 8;
17213            let bytes_len = max_ordinal as usize * envelope_size;
17214            #[allow(unused_variables)]
17215            let offset = encoder.out_of_line_offset(bytes_len);
17216            let mut _prev_end_offset: usize = 0;
17217            if 1 > max_ordinal {
17218                return Ok(());
17219            }
17220
17221            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17222            // are envelope_size bytes.
17223            let cur_offset: usize = (1 - 1) * envelope_size;
17224
17225            // Zero reserved fields.
17226            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17227
17228            // Safety:
17229            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17230            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17231            //   envelope_size bytes, there is always sufficient room.
17232            fidl::encoding::encode_in_envelope_optional::<
17233                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>>,
17234                fidl::encoding::DefaultFuchsiaResourceDialect,
17235            >(
17236                self.sync.as_mut().map(
17237                    <fidl::encoding::Endpoint<
17238                        fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
17239                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17240                ),
17241                encoder,
17242                offset + cur_offset,
17243                depth,
17244            )?;
17245
17246            _prev_end_offset = cur_offset + envelope_size;
17247            if 2 > max_ordinal {
17248                return Ok(());
17249            }
17250
17251            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17252            // are envelope_size bytes.
17253            let cur_offset: usize = (2 - 1) * envelope_size;
17254
17255            // Zero reserved fields.
17256            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17257
17258            // Safety:
17259            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17260            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17261            //   envelope_size bytes, there is always sufficient room.
17262            fidl::encoding::encode_in_envelope_optional::<PeriodicAdvertisingSyncConfiguration, fidl::encoding::DefaultFuchsiaResourceDialect>(
17263            self.config.as_ref().map(<PeriodicAdvertisingSyncConfiguration as fidl::encoding::ValueTypeMarker>::borrow),
17264            encoder, offset + cur_offset, depth
17265        )?;
17266
17267            _prev_end_offset = cur_offset + envelope_size;
17268
17269            Ok(())
17270        }
17271    }
17272
17273    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
17274        for ConnectionAcceptPeriodicAdvertisingSyncTransferRequest
17275    {
17276        #[inline(always)]
17277        fn new_empty() -> Self {
17278            Self::default()
17279        }
17280
17281        unsafe fn decode(
17282            &mut self,
17283            decoder: &mut fidl::encoding::Decoder<
17284                '_,
17285                fidl::encoding::DefaultFuchsiaResourceDialect,
17286            >,
17287            offset: usize,
17288            mut depth: fidl::encoding::Depth,
17289        ) -> fidl::Result<()> {
17290            decoder.debug_check_bounds::<Self>(offset);
17291            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17292                None => return Err(fidl::Error::NotNullable),
17293                Some(len) => len,
17294            };
17295            // Calling decoder.out_of_line_offset(0) is not allowed.
17296            if len == 0 {
17297                return Ok(());
17298            };
17299            depth.increment()?;
17300            let envelope_size = 8;
17301            let bytes_len = len * envelope_size;
17302            let offset = decoder.out_of_line_offset(bytes_len)?;
17303            // Decode the envelope for each type.
17304            let mut _next_ordinal_to_read = 0;
17305            let mut next_offset = offset;
17306            let end_offset = offset + bytes_len;
17307            _next_ordinal_to_read += 1;
17308            if next_offset >= end_offset {
17309                return Ok(());
17310            }
17311
17312            // Decode unknown envelopes for gaps in ordinals.
17313            while _next_ordinal_to_read < 1 {
17314                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17315                _next_ordinal_to_read += 1;
17316                next_offset += envelope_size;
17317            }
17318
17319            let next_out_of_line = decoder.next_out_of_line();
17320            let handles_before = decoder.remaining_handles();
17321            if let Some((inlined, num_bytes, num_handles)) =
17322                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17323            {
17324                let member_inline_size = <fidl::encoding::Endpoint<
17325                    fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
17326                > as fidl::encoding::TypeMarker>::inline_size(
17327                    decoder.context
17328                );
17329                if inlined != (member_inline_size <= 4) {
17330                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17331                }
17332                let inner_offset;
17333                let mut inner_depth = depth.clone();
17334                if inlined {
17335                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17336                    inner_offset = next_offset;
17337                } else {
17338                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17339                    inner_depth.increment()?;
17340                }
17341                let val_ref = self.sync.get_or_insert_with(|| {
17342                    fidl::new_empty!(
17343                        fidl::encoding::Endpoint<
17344                            fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
17345                        >,
17346                        fidl::encoding::DefaultFuchsiaResourceDialect
17347                    )
17348                });
17349                fidl::decode!(
17350                    fidl::encoding::Endpoint<
17351                        fidl::endpoints::ServerEnd<PeriodicAdvertisingSyncMarker>,
17352                    >,
17353                    fidl::encoding::DefaultFuchsiaResourceDialect,
17354                    val_ref,
17355                    decoder,
17356                    inner_offset,
17357                    inner_depth
17358                )?;
17359                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17360                {
17361                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17362                }
17363                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17364                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17365                }
17366            }
17367
17368            next_offset += envelope_size;
17369            _next_ordinal_to_read += 1;
17370            if next_offset >= end_offset {
17371                return Ok(());
17372            }
17373
17374            // Decode unknown envelopes for gaps in ordinals.
17375            while _next_ordinal_to_read < 2 {
17376                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17377                _next_ordinal_to_read += 1;
17378                next_offset += envelope_size;
17379            }
17380
17381            let next_out_of_line = decoder.next_out_of_line();
17382            let handles_before = decoder.remaining_handles();
17383            if let Some((inlined, num_bytes, num_handles)) =
17384                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17385            {
17386                let member_inline_size = <PeriodicAdvertisingSyncConfiguration as fidl::encoding::TypeMarker>::inline_size(decoder.context);
17387                if inlined != (member_inline_size <= 4) {
17388                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17389                }
17390                let inner_offset;
17391                let mut inner_depth = depth.clone();
17392                if inlined {
17393                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17394                    inner_offset = next_offset;
17395                } else {
17396                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17397                    inner_depth.increment()?;
17398                }
17399                let val_ref = self.config.get_or_insert_with(|| {
17400                    fidl::new_empty!(
17401                        PeriodicAdvertisingSyncConfiguration,
17402                        fidl::encoding::DefaultFuchsiaResourceDialect
17403                    )
17404                });
17405                fidl::decode!(
17406                    PeriodicAdvertisingSyncConfiguration,
17407                    fidl::encoding::DefaultFuchsiaResourceDialect,
17408                    val_ref,
17409                    decoder,
17410                    inner_offset,
17411                    inner_depth
17412                )?;
17413                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17414                {
17415                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17416                }
17417                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17418                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17419                }
17420            }
17421
17422            next_offset += envelope_size;
17423
17424            // Decode the remaining unknown envelopes.
17425            while next_offset < end_offset {
17426                _next_ordinal_to_read += 1;
17427                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17428                next_offset += envelope_size;
17429            }
17430
17431            Ok(())
17432        }
17433    }
17434
17435    impl ConnectionConnectL2capRequest {
17436        #[inline(always)]
17437        fn max_ordinal_present(&self) -> u64 {
17438            if let Some(_) = self.ext_offload {
17439                return 4;
17440            }
17441            if let Some(_) = self.psm {
17442                return 3;
17443            }
17444            if let Some(_) = self.channel {
17445                return 2;
17446            }
17447            if let Some(_) = self.parameters {
17448                return 1;
17449            }
17450            0
17451        }
17452    }
17453
17454    impl fidl::encoding::ResourceTypeMarker for ConnectionConnectL2capRequest {
17455        type Borrowed<'a> = &'a mut Self;
17456        fn take_or_borrow<'a>(
17457            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17458        ) -> Self::Borrowed<'a> {
17459            value
17460        }
17461    }
17462
17463    unsafe impl fidl::encoding::TypeMarker for ConnectionConnectL2capRequest {
17464        type Owned = Self;
17465
17466        #[inline(always)]
17467        fn inline_align(_context: fidl::encoding::Context) -> usize {
17468            8
17469        }
17470
17471        #[inline(always)]
17472        fn inline_size(_context: fidl::encoding::Context) -> usize {
17473            16
17474        }
17475    }
17476
17477    unsafe impl
17478        fidl::encoding::Encode<
17479            ConnectionConnectL2capRequest,
17480            fidl::encoding::DefaultFuchsiaResourceDialect,
17481        > for &mut ConnectionConnectL2capRequest
17482    {
17483        unsafe fn encode(
17484            self,
17485            encoder: &mut fidl::encoding::Encoder<
17486                '_,
17487                fidl::encoding::DefaultFuchsiaResourceDialect,
17488            >,
17489            offset: usize,
17490            mut depth: fidl::encoding::Depth,
17491        ) -> fidl::Result<()> {
17492            encoder.debug_check_bounds::<ConnectionConnectL2capRequest>(offset);
17493            // Vector header
17494            let max_ordinal: u64 = self.max_ordinal_present();
17495            encoder.write_num(max_ordinal, offset);
17496            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
17497            // Calling encoder.out_of_line_offset(0) is not allowed.
17498            if max_ordinal == 0 {
17499                return Ok(());
17500            }
17501            depth.increment()?;
17502            let envelope_size = 8;
17503            let bytes_len = max_ordinal as usize * envelope_size;
17504            #[allow(unused_variables)]
17505            let offset = encoder.out_of_line_offset(bytes_len);
17506            let mut _prev_end_offset: usize = 0;
17507            if 1 > max_ordinal {
17508                return Ok(());
17509            }
17510
17511            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17512            // are envelope_size bytes.
17513            let cur_offset: usize = (1 - 1) * envelope_size;
17514
17515            // Zero reserved fields.
17516            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17517
17518            // Safety:
17519            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17520            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17521            //   envelope_size bytes, there is always sufficient room.
17522            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth::ChannelParameters, fidl::encoding::DefaultFuchsiaResourceDialect>(
17523            self.parameters.as_ref().map(<fidl_fuchsia_bluetooth::ChannelParameters as fidl::encoding::ValueTypeMarker>::borrow),
17524            encoder, offset + cur_offset, depth
17525        )?;
17526
17527            _prev_end_offset = cur_offset + envelope_size;
17528            if 2 > max_ordinal {
17529                return Ok(());
17530            }
17531
17532            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17533            // are envelope_size bytes.
17534            let cur_offset: usize = (2 - 1) * envelope_size;
17535
17536            // Zero reserved fields.
17537            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17538
17539            // Safety:
17540            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17541            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17542            //   envelope_size bytes, there is always sufficient room.
17543            fidl::encoding::encode_in_envelope_optional::<
17544                fidl::encoding::Endpoint<
17545                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
17546                >,
17547                fidl::encoding::DefaultFuchsiaResourceDialect,
17548            >(
17549                self.channel.as_mut().map(
17550                    <fidl::encoding::Endpoint<
17551                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
17552                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17553                ),
17554                encoder,
17555                offset + cur_offset,
17556                depth,
17557            )?;
17558
17559            _prev_end_offset = cur_offset + envelope_size;
17560            if 3 > max_ordinal {
17561                return Ok(());
17562            }
17563
17564            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17565            // are envelope_size bytes.
17566            let cur_offset: usize = (3 - 1) * envelope_size;
17567
17568            // Zero reserved fields.
17569            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17570
17571            // Safety:
17572            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17573            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17574            //   envelope_size bytes, there is always sufficient room.
17575            fidl::encoding::encode_in_envelope_optional::<
17576                u16,
17577                fidl::encoding::DefaultFuchsiaResourceDialect,
17578            >(
17579                self.psm.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
17580                encoder,
17581                offset + cur_offset,
17582                depth,
17583            )?;
17584
17585            _prev_end_offset = cur_offset + envelope_size;
17586            if 4 > max_ordinal {
17587                return Ok(());
17588            }
17589
17590            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17591            // are envelope_size bytes.
17592            let cur_offset: usize = (4 - 1) * envelope_size;
17593
17594            // Zero reserved fields.
17595            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17596
17597            // Safety:
17598            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17599            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17600            //   envelope_size bytes, there is always sufficient room.
17601            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChannelOffloadExtMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
17602            self.ext_offload.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChannelOffloadExtMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
17603            encoder, offset + cur_offset, depth
17604        )?;
17605
17606            _prev_end_offset = cur_offset + envelope_size;
17607
17608            Ok(())
17609        }
17610    }
17611
17612    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
17613        for ConnectionConnectL2capRequest
17614    {
17615        #[inline(always)]
17616        fn new_empty() -> Self {
17617            Self::default()
17618        }
17619
17620        unsafe fn decode(
17621            &mut self,
17622            decoder: &mut fidl::encoding::Decoder<
17623                '_,
17624                fidl::encoding::DefaultFuchsiaResourceDialect,
17625            >,
17626            offset: usize,
17627            mut depth: fidl::encoding::Depth,
17628        ) -> fidl::Result<()> {
17629            decoder.debug_check_bounds::<Self>(offset);
17630            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17631                None => return Err(fidl::Error::NotNullable),
17632                Some(len) => len,
17633            };
17634            // Calling decoder.out_of_line_offset(0) is not allowed.
17635            if len == 0 {
17636                return Ok(());
17637            };
17638            depth.increment()?;
17639            let envelope_size = 8;
17640            let bytes_len = len * envelope_size;
17641            let offset = decoder.out_of_line_offset(bytes_len)?;
17642            // Decode the envelope for each type.
17643            let mut _next_ordinal_to_read = 0;
17644            let mut next_offset = offset;
17645            let end_offset = offset + bytes_len;
17646            _next_ordinal_to_read += 1;
17647            if next_offset >= end_offset {
17648                return Ok(());
17649            }
17650
17651            // Decode unknown envelopes for gaps in ordinals.
17652            while _next_ordinal_to_read < 1 {
17653                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17654                _next_ordinal_to_read += 1;
17655                next_offset += envelope_size;
17656            }
17657
17658            let next_out_of_line = decoder.next_out_of_line();
17659            let handles_before = decoder.remaining_handles();
17660            if let Some((inlined, num_bytes, num_handles)) =
17661                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17662            {
17663                let member_inline_size = <fidl_fuchsia_bluetooth::ChannelParameters as fidl::encoding::TypeMarker>::inline_size(decoder.context);
17664                if inlined != (member_inline_size <= 4) {
17665                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17666                }
17667                let inner_offset;
17668                let mut inner_depth = depth.clone();
17669                if inlined {
17670                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17671                    inner_offset = next_offset;
17672                } else {
17673                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17674                    inner_depth.increment()?;
17675                }
17676                let val_ref = self.parameters.get_or_insert_with(|| {
17677                    fidl::new_empty!(
17678                        fidl_fuchsia_bluetooth::ChannelParameters,
17679                        fidl::encoding::DefaultFuchsiaResourceDialect
17680                    )
17681                });
17682                fidl::decode!(
17683                    fidl_fuchsia_bluetooth::ChannelParameters,
17684                    fidl::encoding::DefaultFuchsiaResourceDialect,
17685                    val_ref,
17686                    decoder,
17687                    inner_offset,
17688                    inner_depth
17689                )?;
17690                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17691                {
17692                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17693                }
17694                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17695                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17696                }
17697            }
17698
17699            next_offset += envelope_size;
17700            _next_ordinal_to_read += 1;
17701            if next_offset >= end_offset {
17702                return Ok(());
17703            }
17704
17705            // Decode unknown envelopes for gaps in ordinals.
17706            while _next_ordinal_to_read < 2 {
17707                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17708                _next_ordinal_to_read += 1;
17709                next_offset += envelope_size;
17710            }
17711
17712            let next_out_of_line = decoder.next_out_of_line();
17713            let handles_before = decoder.remaining_handles();
17714            if let Some((inlined, num_bytes, num_handles)) =
17715                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17716            {
17717                let member_inline_size = <fidl::encoding::Endpoint<
17718                    fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
17719                > as fidl::encoding::TypeMarker>::inline_size(
17720                    decoder.context
17721                );
17722                if inlined != (member_inline_size <= 4) {
17723                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17724                }
17725                let inner_offset;
17726                let mut inner_depth = depth.clone();
17727                if inlined {
17728                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17729                    inner_offset = next_offset;
17730                } else {
17731                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17732                    inner_depth.increment()?;
17733                }
17734                let val_ref = self.channel.get_or_insert_with(|| {
17735                    fidl::new_empty!(
17736                        fidl::encoding::Endpoint<
17737                            fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
17738                        >,
17739                        fidl::encoding::DefaultFuchsiaResourceDialect
17740                    )
17741                });
17742                fidl::decode!(
17743                    fidl::encoding::Endpoint<
17744                        fidl::endpoints::ServerEnd<fidl_fuchsia_bluetooth::ChannelMarker>,
17745                    >,
17746                    fidl::encoding::DefaultFuchsiaResourceDialect,
17747                    val_ref,
17748                    decoder,
17749                    inner_offset,
17750                    inner_depth
17751                )?;
17752                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17753                {
17754                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17755                }
17756                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17757                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17758                }
17759            }
17760
17761            next_offset += envelope_size;
17762            _next_ordinal_to_read += 1;
17763            if next_offset >= end_offset {
17764                return Ok(());
17765            }
17766
17767            // Decode unknown envelopes for gaps in ordinals.
17768            while _next_ordinal_to_read < 3 {
17769                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17770                _next_ordinal_to_read += 1;
17771                next_offset += envelope_size;
17772            }
17773
17774            let next_out_of_line = decoder.next_out_of_line();
17775            let handles_before = decoder.remaining_handles();
17776            if let Some((inlined, num_bytes, num_handles)) =
17777                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17778            {
17779                let member_inline_size =
17780                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
17781                if inlined != (member_inline_size <= 4) {
17782                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17783                }
17784                let inner_offset;
17785                let mut inner_depth = depth.clone();
17786                if inlined {
17787                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17788                    inner_offset = next_offset;
17789                } else {
17790                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17791                    inner_depth.increment()?;
17792                }
17793                let val_ref = self.psm.get_or_insert_with(|| {
17794                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
17795                });
17796                fidl::decode!(
17797                    u16,
17798                    fidl::encoding::DefaultFuchsiaResourceDialect,
17799                    val_ref,
17800                    decoder,
17801                    inner_offset,
17802                    inner_depth
17803                )?;
17804                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17805                {
17806                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17807                }
17808                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17809                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17810                }
17811            }
17812
17813            next_offset += envelope_size;
17814            _next_ordinal_to_read += 1;
17815            if next_offset >= end_offset {
17816                return Ok(());
17817            }
17818
17819            // Decode unknown envelopes for gaps in ordinals.
17820            while _next_ordinal_to_read < 4 {
17821                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17822                _next_ordinal_to_read += 1;
17823                next_offset += envelope_size;
17824            }
17825
17826            let next_out_of_line = decoder.next_out_of_line();
17827            let handles_before = decoder.remaining_handles();
17828            if let Some((inlined, num_bytes, num_handles)) =
17829                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17830            {
17831                let member_inline_size = <fidl::encoding::Endpoint<
17832                    fidl::endpoints::ServerEnd<ChannelOffloadExtMarker>,
17833                > as fidl::encoding::TypeMarker>::inline_size(
17834                    decoder.context
17835                );
17836                if inlined != (member_inline_size <= 4) {
17837                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17838                }
17839                let inner_offset;
17840                let mut inner_depth = depth.clone();
17841                if inlined {
17842                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17843                    inner_offset = next_offset;
17844                } else {
17845                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17846                    inner_depth.increment()?;
17847                }
17848                let val_ref = self.ext_offload.get_or_insert_with(|| {
17849                    fidl::new_empty!(
17850                        fidl::encoding::Endpoint<
17851                            fidl::endpoints::ServerEnd<ChannelOffloadExtMarker>,
17852                        >,
17853                        fidl::encoding::DefaultFuchsiaResourceDialect
17854                    )
17855                });
17856                fidl::decode!(
17857                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChannelOffloadExtMarker>>,
17858                    fidl::encoding::DefaultFuchsiaResourceDialect,
17859                    val_ref,
17860                    decoder,
17861                    inner_offset,
17862                    inner_depth
17863                )?;
17864                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17865                {
17866                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17867                }
17868                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17869                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17870                }
17871            }
17872
17873            next_offset += envelope_size;
17874
17875            // Decode the remaining unknown envelopes.
17876            while next_offset < end_offset {
17877                _next_ordinal_to_read += 1;
17878                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17879                next_offset += envelope_size;
17880            }
17881
17882            Ok(())
17883        }
17884    }
17885}